Exemplo n.º 1
0
 public function _construct()
 {
     $aitsysModel = new Aitoc_Aitsys_Model_Aitsys();
     if ($this->_aErrorList = $aitsysModel->getAllowInstallErrors()) {
         $this->_bAllowInstall = false;
     }
     $this->setTitle('Aitoc Modules Manager v%s');
 }
Exemplo n.º 2
0
 public function __construct()
 {
     parent::__construct();
     $aitsysModel = new Aitoc_Aitsys_Model_Aitsys();
     if ($this->_aErrorList = $aitsysModel->getAllowInstallErrors()) {
         $this->_bAllowInstall = false;
     }
     $this->setTemplate('aitsys/edit.phtml');
     $this->setTitle('Aitoc Module Manager v%s');
 }
Exemplo n.º 3
0
 /**
  * Inits debuger if debuger turned on and PHPUnit lib is available.
  * Performs reload of all licenses if there was a problem to load licenses because of early modules' init.
  * Corrects modules' status and launches install/uninstall scripts if some module was enabled/disabled through xml.
  */
 public function debugerInit()
 {
     if (!$this->_debugerInited) {
         $this->tool()->debuger();
         $this->tool()->platform()->reload();
         if ($this->tool()->platform()->isNeedCorrection()) {
             $aitsysModel = new Aitoc_Aitsys_Model_Aitsys();
             $aitsysModel->correction();
         }
         $this->_debugerInited = true;
     }
 }
Exemplo n.º 4
0
 /**
  * Corrects modules' status and launches install/uninstall scripts if some module was enabled/disabled through xml.
  */
 public function correction()
 {
     if (!$this->_correctionDone) {
         $this->tool()->platform()->getModules();
         // load modules
         if ($this->tool()->platform()->isNeedCorrection()) {
             $aitsysModel = new Aitoc_Aitsys_Model_Aitsys();
             $aitsysModel->correction();
         }
         $this->_correctionDone = true;
     }
 }
Exemplo n.º 5
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();
 }
Exemplo n.º 6
0
 /**
  * @return Mage_Adminhtml_Block_Widget_Form
  */
 public function initForm()
 {
     $form = new Varien_Data_Form();
     $fieldset = $form->addFieldset('module_list', array('legend' => Mage::helper('aitsys')->__('AITOC Modules')));
     $fieldset->getRenderer()->setTemplate('aitcore/fieldset.phtml');
     $aitsysModel = new Aitoc_Aitsys_Model_Aitsys();
     $modulesList = $aitsysModel->getAitocModuleList();
     $this->_elementRenderer = $this->getLayout()->createBlock('aitsys/form_element_renderer');
     if ($modulesList) {
         foreach ($modulesList as $module) {
             $this->_addModule($module, $fieldset);
         }
     }
     $this->setForm($form);
     return $this;
 }
Exemplo n.º 7
0
 public function initForm()
 {
     $form = new Varien_Data_Form();
     $fieldset = $form->addFieldset('module_list', array('legend' => Mage::helper('adminhtml')->__('Enable/Disable Modules List')));
     $aitsysModel = new Aitoc_Aitsys_Model_Aitsys();
     $aModuleList = $aitsysModel->getAitocModuleList();
     $elementRenderer = $this->getLayout()->createBlock('aitsys/form_element_renderer');
     /* @var $elementRenderer Aitoc_Aitsys_Block_Form_Element_Renderer */
     if ($aModuleList) {
         foreach ($aModuleList as $module) {
             /* @var $module Aitoc_Aitsys_Model_Module */
             $aModule = $module;
             $label = $aModule['label'] . ($module->getVersion() ? ' v' . $module->getVersion() : '');
             if ($aModule['access'] || !$module->isAvailable()) {
                 if (($module->isAvailable() || 1 == $module->getValue()) && !$module->getErrorMessageType()) {
                     $fieldset->addField('hidden_enable_' . $aModule['key'], 'hidden', array('name' => 'enable[' . $aModule['key'] . ']', 'value' => 0));
                     $fieldset->addField('enable_' . $aModule['key'], 'checkbox', array('name' => ($module->isAvailable() ? 'enable' : 'ignore') . '[' . $aModule['key'] . ']', 'label' => $label, 'value' => 1, 'checked' => $aModule['value'], 'module' => $module))->setRenderer($elementRenderer);
                 } else {
                     $sMessage = '';
                     $sNote = null;
                     if ($module->getErrorMessageType()) {
                         $sNote = '<ul class="messages"><li class="notice-msg"><ul><li>' . Mage::helper('aitsys/strings')->getString($module->getErrorMessageType()) . '</li></ul></li></ul>';
                     }
                     $fieldset->addField('ignore_' . $aModule['key'], 'note', array('name' => 'ignore[' . $aModule['key'] . ']', 'label' => $label, 'text' => $sMessage, 'module' => $module, 'note' => $sNote))->setRenderer($elementRenderer);
                 }
             } else {
                 if ($this->tool()->platform()->isDemoMode()) {
                     $sMessage = "The extension is already enabled on this Demo Magento installation and can't be disabled for security reasons. Please proceed to the next step outlined in the extension's <a href='%s' target='_blank'>User Manual</a> to see how it works.";
                     $xml = simplexml_load_file(Mage::getBaseDir() . "/aitmodules.xml");
                     $link = (string) $xml->modules->{$aModule}['key'];
                     if ($link == '') {
                         $link = 'http://www.aitoc.com/';
                     }
                     $fieldset->addField('ignore_' . $aModule['key'], 'note', array('name' => 'ignore[' . $aModule['key'] . ']', 'label' => $label, 'note' => '<ul class="messages"><li class="notice-msg"><ul><li>' . Mage::helper('adminhtml')->__($sMessage, $link) . '</li></ul></li></ul>'));
                 } else {
                     $sMessage = 'File does not have write permissions: %s';
                     $fieldset->addField('ignore_' . $aModule['key'], 'note', array('name' => 'ignore[' . $aModule['key'] . ']', 'label' => $label, 'note' => '<ul class="messages"><li class="error-msg"><ul><li>' . Mage::helper('adminhtml')->__($sMessage, $aModule['file']) . '</li></ul></li></ul>'));
                 }
             }
         }
     }
     $this->setForm($form);
     return $this;
 }
 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.º 9
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;
 }