예제 #1
0
 /**
  * Install add-ons from marketplace
  *
  * @return void
  */
 protected function doActionInstallAddon()
 {
     \XLite\Upgrade\Cell::getInstance()->clear(true, true, !$this->isForce());
     \XLite\Controller\Admin\AddonsListMarketplace::cleanModulesToInstall();
     foreach (\XLite\Core\Request::getInstance()->moduleIds as $moduleId) {
         $module = \XLite\Core\Database::getRepo('XLite\\Model\\Module')->find($moduleId);
         if (!$module) {
             $this->showError(__FUNCTION__, static::t('invalid module ID passed: X', array('moduleId' => $moduleId)));
         } elseif (!$module->getFromMarketplace()) {
             $this->showError(__FUNCTION__, static::t('trying to install a non-marketplace module: X', array('name' => $module->getActualName())));
         } elseif (!\XLite\Upgrade\Cell::getInstance()->addMarketplaceModule($module, true)) {
             $this->showError(__FUNCTION__, static::t('unable to add module entry to the installation list: X', array('path' => $module->getActualName())));
         } else {
             \XLite\Controller\Admin\Base\AddonsList::storeRecentlyInstalledModules(array($module->getModuleID()));
             if ($this->isForce()) {
                 $this->setHardRedirect(true);
                 $this->setReturnURL($this->buildURL('upgrade', 'download', $this->getActionParamsCommon()));
             } elseif (!$this->isNextStepAvailable() || !$this->isFreeSpaceCheckAvailable()) {
                 $this->setHardRedirect(true);
                 $this->setReturnURL($this->buildURL('upgrade', '', $this->getActionParamsCommon()));
             }
         }
     }
 }
예제 #2
0
 /**
  * Update database records
  *
  * @return array
  */
 protected function updateDBRecords()
 {
     $this->setIsFreshInstall(!$this->isInstalled());
     $module = $this->getModuleInstalled() ?: new \XLite\Model\Module($this->getModuleData());
     $module->setDate(\XLite\Core\Converter::time());
     $module->setRevisionDate($this->getRevisionDate());
     $module->setPackSize($this->getPackSize());
     $module->setModuleName($this->getName());
     $module->setAuthorName($this->getAuthor());
     $module->setDescription($this->getDescription());
     $module->setIconURL($this->getIconURL());
     $module->setDependencies($this->getDependencies());
     $data = $this->getModuleData();
     unset($data['majorVersion']);
     unset($data['minorVersion']);
     $modules = \XLite\Core\Database::getRepo('\\XLite\\Model\\Module')->findBy($data);
     foreach ($modules as $moduleOld) {
         if ($moduleOld) {
             if ($moduleOld->getMajorVersion() != $this->getMajorVersionNew() || $moduleOld->getMinorVersion() != $this->getMinorVersionNew()) {
                 $module->setYamlLoaded($moduleOld->getYamlLoaded());
                 \XLite\Core\Database::getRepo('\\XLite\\Model\\Module')->delete($moduleOld);
             }
         }
     }
     // Save changes in DB
     if ($module->getModuleID()) {
         $module->setMajorVersion($this->getMajorVersionNew());
         $module->setMinorVersion($this->getMinorVersionNew());
         \XLite\Core\Database::getRepo('\\XLite\\Model\\Module')->update($module);
     } else {
         $module->setEnabled(true);
         \XLite\Core\Database::getRepo('\\XLite\\Model\\Module')->insert($module);
     }
     \XLite\Controller\Admin\Base\AddonsList::storeRecentlyInstalledModules(array($module->getModuleID()));
 }