Exemplo n.º 1
0
 /**
  * @param bool $status Module new status. True to install and False to uninstall
  */
 protected function _processModule($status)
 {
     $data = array();
     foreach ($this->tool()->platform()->getModuleKeysForced() as $module => $value) {
         /* @var $module Aitoc_Aitsys_Model_Module */
         $isCurrent = $module === $this->getModule()->getKey();
         $data[$module] = $isCurrent ? $status : $value;
     }
     $aitsysModel = new Aitoc_Aitsys_Model_Aitsys();
     if ($errors = $aitsysModel->saveData($data, array(), true)) {
         $this->addErrors($errors);
     }
     $this->getModule()->reset();
     $this->tool()->clearCache();
 }
 public function manualInstallUploadAction()
 {
     $this->_prepare();
     $turnOnModule = false;
     if (!$this->_getModule()->getValue() && $this->_getLicense()->isUninstalled()) {
         $turnOnModule = true;
     }
     if (isset($_FILES['license_file']['name']) && $_FILES['license_file']['name'] != '') {
         try {
             $path = Mage::getBaseDir('var');
             $fname = $_FILES['license_file']['name'];
             $uploader = new Varien_File_Uploader('license_file');
             $uploader->setAllowedExtensions(array('sql', 'php'));
             $uploader->setAllowCreateFolders(true);
             $uploader->setAllowRenameFiles(false);
             $uploader->setFilesDispersion(false);
             $uploader->save($path, $fname);
             switch (pathinfo($fname, PATHINFO_EXTENSION)) {
                 case 'php':
                     copy($path . DS . $fname, $path . DS . 'ait_install' . DS . $this->_getLicense()->getPlatform()->getPlatformId() . DS . $fname);
                     break;
                 case 'sql':
                 default:
                     $sql = file_get_contents($path . DS . $fname);
                     $writeConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
                     $writeConnection->query($sql);
                     break;
             }
             unlink($path . DS . $fname);
             $this->_getModule()->updateStatuses();
             if (!$this->_getLicense()->isUninstalled()) {
                 if ($turnOnModule) {
                     $data = array();
                     foreach ($this->tool()->platform()->getModuleKeysForced() as $module => $value) {
                         /* @var $module Aitoc_Aitsys_Model_Module */
                         $isCurrent = $module === $this->_getModule()->getKey();
                         $data[$module] = $isCurrent ? true : $value;
                     }
                     $aitsysModel = new Aitoc_Aitsys_Model_Aitsys();
                     $errors = $aitsysModel->saveData($data, array(), true);
                     if ($errors) {
                         foreach ($errors as $error) {
                             Mage::getSingleton('adminhtml/session')->addError($this->__($error));
                         }
                     }
                 }
                 Mage::getSingleton('adminhtml/session')->addSuccess($this->__('License of %s module has been installed.', $this->_getModule()->getLabel()));
             } else {
                 Mage::getSingleton('adminhtml/session')->addError($this->__('Unknown error. Please retry the operation again. If installation fails, contact support department.'));
             }
         } catch (Exception $e) {
             Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
         }
     } else {
         Mage::getSingleton('adminhtml/session')->addError($this->__('No file uploaded.'));
     }
     $this->_redirect('*');
 }
Exemplo n.º 3
0
 /**
  * @return Aitoc_Aitsys_Model_Module_Install
  */
 public function install()
 {
     $data = array();
     foreach ($this->tool()->platform()->getModuleKeysForced() as $module => $value) {
         /* @var $module Aitoc_Aitsys_Model_Module */
         $isCurrent = $module === $this->getModule()->getKey();
         $data[$module] = $isCurrent ? true : $value;
     }
     $aitsysModel = new Aitoc_Aitsys_Model_Aitsys();
     if ($errors = $aitsysModel->saveData($data, array(), true)) {
         $this->addErrors($errors);
     }
     $this->_resetNotificationDate()->getModule()->reset();
     $this->tool()->clearCache();
     return $this;
 }