Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_Install_Block_Abstract
  • Mage_Install_Block_Admin
  • Mage_Install_Block_Begin
  • Mage_Install_Block_Config
  • Mage_Install_Block_Db_Main
  • Mage_Install_Block_Db_Type
  • Mage_Install_Block_Db_Type_Mysql4
  • Mage_Install_Block_Download
  • Mage_Install_Block_End
  • Mage_Install_Block_Locale
  • Mage_Install_Block_State
  • Mage_Install_Controller_Action
  • Mage_Install_Helper_Data
  • Mage_Install_IndexController
  • Mage_Install_Model_Config
  • Mage_Install_Model_Installer
  • Mage_Install_Model_Installer_Abstract
  • Mage_Install_Model_Installer_Config
  • Mage_Install_Model_Installer_Console
  • Mage_Install_Model_Installer_Data
  • Mage_Install_Model_Installer_Db
  • Mage_Install_Model_Installer_Db_Abstract
  • Mage_Install_Model_Installer_Db_Mysql4
  • Mage_Install_Model_Installer_Env
  • Mage_Install_Model_Installer_Filesystem
  • Mage_Install_Model_Installer_Pear
  • Mage_Install_Model_Observer
  • Mage_Install_Model_Session
  • Mage_Install_Model_Wizard
  • Mage_Install_WizardController
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_Install
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: 
 28: /**
 29:  * Installer model
 30:  *
 31:  * @category   Mage
 32:  * @package    Mage_Install
 33:  * @author      Magento Core Team <core@magentocommerce.com>
 34:  */
 35: class Mage_Install_Model_Installer extends Varien_Object
 36: {
 37: 
 38:     /**
 39:      * Installer host response used to check urls
 40:      *
 41:      */
 42:     const INSTALLER_HOST_RESPONSE   = 'MAGENTO';
 43: 
 44:     /**
 45:      * Installer data model used to store data between installation steps
 46:      *
 47:      * @var Varien_Object
 48:      */
 49:     protected $_dataModel;
 50: 
 51:     /**
 52:      * Checking install status of application
 53:      *
 54:      * @return bool
 55:      */
 56:     public function isApplicationInstalled()
 57:     {
 58:         return Mage::isInstalled();
 59:     }
 60: 
 61:     /**
 62:      * Get data model
 63:      *
 64:      * @return Varien_Object
 65:      */
 66:     public function getDataModel()
 67:     {
 68:         if (is_null($this->_dataModel)) {
 69:             $this->setDataModel(Mage::getSingleton('install/session'));
 70:         }
 71:         return $this->_dataModel;
 72:     }
 73: 
 74:     /**
 75:      * Set data model to store data between installation steps
 76:      *
 77:      * @param Varien_Object $model
 78:      * @return Mage_Install_Model_Installer
 79:      */
 80:     public function setDataModel(Varien_Object $model)
 81:     {
 82:         $this->_dataModel = $model;
 83:         return $this;
 84:     }
 85: 
 86:     /**
 87:      * Check packages (pear) downloads
 88:      *
 89:      * @return boolean
 90:      */
 91:     public function checkDownloads()
 92:     {
 93:         try {
 94:             $result = Mage::getModel('install/installer_pear')->checkDownloads();
 95:             $result = true;
 96:         } catch (Exception $e) {
 97:             $result = false;
 98:         }
 99:         $this->setDownloadCheckStatus($result);
100:         return $result;
101:     }
102: 
103:     /**
104:      * Check server settings
105:      *
106:      * @return bool
107:      */
108:     public function checkServer()
109:     {
110:         try {
111:             Mage::getModel('install/installer_filesystem')->install();
112: 
113:             Mage::getModel('install/installer_env')->install();
114:             $result = true;
115:         } catch (Exception $e) {
116:             $result = false;
117:         }
118:         $this->setData('server_check_status', $result);
119:         return $result;
120:     }
121: 
122:     /**
123:      * Retrieve server checking result status
124:      *
125:      * @return unknown
126:      */
127:     public function getServerCheckStatus()
128:     {
129:         $status = $this->getData('server_check_status');
130:         if (is_null($status)) {
131:             $status = $this->checkServer();
132:         }
133:         return $status;
134:     }
135: 
136:     /**
137:      * Installation config data
138:      *
139:      * @param   array $data
140:      * @return  Mage_Install_Model_Installer
141:      */
142:     public function installConfig($data)
143:     {
144:         $data['db_active'] = true;
145: 
146:         $data = Mage::getSingleton('install/installer_db')->checkDbConnectionData($data);
147: 
148:         Mage::getSingleton('install/installer_config')
149:             ->setConfigData($data)
150:             ->install();
151:         return $this;
152:     }
153: 
154:     /**
155:      * Database installation
156:      *
157:      * @return Mage_Install_Model_Installer
158:      */
159:     public function installDb()
160:     {
161:         Mage_Core_Model_Resource_Setup::applyAllUpdates();
162:         $data = $this->getDataModel()->getConfigData();
163: 
164:         /**
165:          * Saving host information into DB
166:          */
167:         $setupModel = new Mage_Core_Model_Resource_Setup('core_setup');
168: 
169:         if (!empty($data['use_rewrites'])) {
170:             $setupModel->setConfigData(Mage_Core_Model_Store::XML_PATH_USE_REWRITES, 1);
171:         }
172: 
173:         if (!empty($data['enable_charts'])) {
174:             $setupModel->setConfigData(Mage_Adminhtml_Block_Dashboard::XML_PATH_ENABLE_CHARTS, 1);
175:         } else {
176:             $setupModel->setConfigData(Mage_Adminhtml_Block_Dashboard::XML_PATH_ENABLE_CHARTS, 0);
177:         }
178: 
179: 
180:         $unsecureBaseUrl = Mage::getBaseUrl('web');
181:         if (!empty($data['unsecure_base_url'])) {
182:             $unsecureBaseUrl = $data['unsecure_base_url'];
183:             $setupModel->setConfigData(Mage_Core_Model_Store::XML_PATH_UNSECURE_BASE_URL, $unsecureBaseUrl);
184:         }
185: 
186:         if (!empty($data['use_secure'])) {
187:             $setupModel->setConfigData(Mage_Core_Model_Store::XML_PATH_SECURE_IN_FRONTEND, 1);
188:             $setupModel->setConfigData(Mage_Core_Model_Store::XML_PATH_SECURE_BASE_URL, $data['secure_base_url']);
189:             if (!empty($data['use_secure_admin'])) {
190:                 $setupModel->setConfigData(Mage_Core_Model_Store::XML_PATH_SECURE_IN_ADMINHTML, 1);
191:             }
192:         }
193:         elseif (!empty($data['unsecure_base_url'])) {
194:             $setupModel->setConfigData(Mage_Core_Model_Store::XML_PATH_SECURE_BASE_URL, $unsecureBaseUrl);
195:         }
196: 
197:         /**
198:          * Saving locale information into DB
199:          */
200:         $locale = $this->getDataModel()->getLocaleData();
201:         if (!empty($locale['locale'])) {
202:             $setupModel->setConfigData(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE, $locale['locale']);
203:         }
204:         if (!empty($locale['timezone'])) {
205:             $setupModel->setConfigData(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE, $locale['timezone']);
206:         }
207:         if (!empty($locale['currency'])) {
208:             $setupModel->setConfigData(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE, $locale['currency']);
209:             $setupModel->setConfigData(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_DEFAULT, $locale['currency']);
210:             $setupModel->setConfigData(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_ALLOW, $locale['currency']);
211:         }
212: 
213:         return $this;
214:     }
215: 
216:     /**
217:      * Prepare admin user data in model and validate it.
218:      * Returns TRUE or array of error messages.
219:      *
220:      * @param array $data
221:      * @return mixed
222:      */
223:     public function validateAndPrepareAdministrator($data)
224:     {
225:         $user = Mage::getModel('admin/user')
226:             ->load($data['username'], 'username');
227:         $user->addData($data);
228: 
229:         $result = $user->validate();
230:         if (is_array($result)) {
231:             foreach ($result as $error) {
232:                 $this->getDataModel()->addError($error);
233:             }
234:             return $result;
235:         }
236:         return $user;
237:     }
238: 
239:     /**
240:      * Create admin user.
241:      * Paramater can be prepared user model or array of data.
242:      * Returns TRUE or throws exception.
243:      *
244:      * @param mixed $data
245:      * @return bool
246:      */
247:     public function createAdministrator($data)
248:     {
249:         $user = Mage::getModel('admin/user')
250:             ->load('admin', 'username');
251:         if ($user && $user->getPassword() == '4297f44b13955235245b2497399d7a93') {
252:             $user->delete();
253:         }
254: 
255:         //to support old logic checking if real data was passed
256:         if (is_array($data)) {
257:             $data = $this->validateAndPrepareAdministrator($data);
258:             if (is_array(data)) {
259:                 throw new Exception(Mage::helper('install')->__('Please correct the user data and try again.'));
260:             }
261:         }
262: 
263:         //run time flag to force saving entered password
264:         $data->setForceNewPassword(true);
265: 
266:         $data->save();
267:         $data->setRoleIds(array(1))->saveRelations();
268: 
269:         /*Mage::getModel("permissions/user")->setRoleId(1)
270:             ->setUserId($user->getId())
271:             ->setFirstname($user->getFirstname())
272:             ->add();*/
273: 
274:         return true;
275:     }
276: 
277:     /**
278:      * Validating encryption key.
279:      * Returns TRUE or array of error messages.
280:      *
281:      * @param $key
282:      * @return unknown_type
283:      */
284:     public function validateEncryptionKey($key)
285:     {
286:         $errors = array();
287: 
288:         try {
289:             if ($key) {
290:                 Mage::helper('core')->validateKey($key);
291:             }
292:         } catch (Exception $e) {
293:             $errors[] = $e->getMessage();
294:             $this->getDataModel()->addError($e->getMessage());
295:         }
296: 
297:         if (!empty($errors)) {
298:             return $errors;
299:         }
300: 
301:         return true;
302:     }
303: 
304:     /**
305:      * Set encryption key
306:      *
307:      * @param string $key
308:      * @return Mage_Install_Model_Installer
309:      */
310:     public function installEnryptionKey($key)
311:     {
312:         if ($key) {
313:             Mage::helper('core')->validateKey($key);
314:         }
315:         Mage::getSingleton('install/installer_config')->replaceTmpEncryptKey($key);
316:         return $this;
317:     }
318: 
319:     public function finish()
320:     {
321:         Mage::getSingleton('install/installer_config')->replaceTmpInstallDate();
322:         Mage::app()->cleanCache();
323: 
324:         $cacheData = array();
325:         foreach (Mage::helper('core')->getCacheTypes() as $type => $label) {
326:             $cacheData[$type] = 1;
327:         }
328:         Mage::app()->saveUseCache($cacheData);
329:         return $this;
330:     }
331: 
332: }
333: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0