/** * Email safe mode links to the site administrator * * @return void */ public function doActionEmailLinks() { \Includes\SafeMode::sendNotification(); \XLite\Core\TopMessage::addInfo('Safe mode links were emailed'); $this->setPureAction(true); }
/** * Third step: install downloaded upgrades * * @return void */ protected function doActionInstallUpgrades() { $this->setReturnURL($this->buildURL('upgrade')); if (\XLite\Upgrade\Cell::getInstance()->isUnpacked()) { if (!$this->isForce()) { \Includes\SafeMode::sendNotification(); } $restorePoint = \Includes\Utils\ModulesManager::getEmptyRestorePoint(); //write current state $current = \XLite\Core\Database::getRepo('\\XLite\\Model\\Module')->findBy(array('enabled' => true)); foreach ($current as $module) { $restorePoint['current'][$module->getModuleId()] = $module->getActualName(); } \Includes\Utils\Operator::showMessage('Installing updates, please wait...'); if (\XLite\Core\Request::getInstance()->preUpgradeWarningModules) { \XLite\Upgrade\Cell::getInstance()->setPreUpgradeWarningModules(array_keys(array_filter(\XLite\Core\Request::getInstance()->preUpgradeWarningModules, function ($value) { return 0 == $value; }))); } // Disable selected modules $modules = array(); foreach (\XLite\Upgrade\Cell::getInstance()->getIncompatibleModules(true) as $module) { $module->setEnabled(false); $modules[] = $module; $restorePoint['disabled'][$module->getModuleId()] = $module->getActualName(); } \XLite\Core\Database::getRepo('XLite\\Model\\Module')->updateInBatch($modules); // Do actions according the admin choice for the disabled modules with hooks $modulesToEnable = array(); /** @var \XLite\Model\Module $module */ foreach (\XLite\Upgrade\Cell::getInstance()->getDisabledModulesHooks() as $marketplaceId => $module) { $action = \XLite\Core\Request::getInstance()->disabledModulesHooks[$marketplaceId]; $module = \XLite\Core\Database::getEM()->merge($module); if (1 == $action) { // Enable module $module->setEnabled(true); $modulesToEnable[] = $module; $restorePoint['enabled'][$module->getModuleId()] = $module->getActualName(); } elseif (0 == $action) { // Uninstall module \XLite\Upgrade\Cell::getInstance()->removeModuleEntry($module); $this->uninstallModule($module); $restorePoint['deleted'][] = $module->getActualName(); } } \XLite\Core\Database::getRepo('XLite\\Model\\Module')->updateInBatch($modulesToEnable); if (\XLite\Upgrade\Cell::getInstance()->getEntries()) { foreach (\XLite\Upgrade\Cell::getInstance()->getEntries() as $module) { $restorePoint['installed'][] = $module->getActualName(); } \XLite\Upgrade\Cell::getInstance()->initUpgradeHooks(); $this->setReturnURL($this->buildURL('upgrade', 'pre_upgrade_hooks', $this->getActionParamsCommon())); } else { // All modules for upgrade were set for uninstallation // There are no upgrade procedures to perform \XLite\Core\Marketplace::getInstance()->clearActionCache(); $this->setReturnURL($this->buildURL('addons_list_installed')); } \Includes\Utils\ModulesManager::updateModuleMigrationLog($restorePoint); } else { $this->showWarning(__FUNCTION__, static::t('unable to install: not all archives were unpacked. Please, try again', array('list' => $this->getErrorEntriesHTML()))); } }
/** * Third step: install downloaded upgrades * * @return void */ protected function doActionInstallUpgrades() { $this->setReturnURL($this->buildURL('upgrade')); if (\XLite\Upgrade\Cell::getInstance()->isUnpacked()) { \Includes\SafeMode::sendNotification(); $restorePoint = \Includes\Utils\ModulesManager::getEmptyRestorePoint(); //write current state $current = \XLite\Core\Database::getRepo('\\XLite\\Model\\Module')->findBy(array('enabled' => true)); foreach ($current as $module) { $restorePoint['current'][$module->getModuleId()] = $module->getActualName(); } \Includes\Utils\Operator::showMessage('Installing updates, please wait...'); if (\XLite\Core\Request::getInstance()->preUpgradeWarningModules) { \XLite\Upgrade\Cell::getInstance()->setPreUpgradeWarningModules(array_keys(array_filter(\XLite\Core\Request::getInstance()->preUpgradeWarningModules, function ($value) { return 0 == $value; }))); } // Disable selected modules $modules = array(); foreach (\XLite\Upgrade\Cell::getInstance()->getIncompatibleModules(true) as $module) { $module->setEnabled(false); $modules[] = $module; $restorePoint['disabled'][$module->getModuleId()] = $module->getActualName(); } \XLite\Core\Database::getRepo('XLite\\Model\\Module')->updateInBatch($modules); // Do actions according the admin choice for the disabled modules with hooks $modulesToEnable = array(); /** @var \XLite\Model\Module $module */ foreach (\XLite\Upgrade\Cell::getInstance()->getDisabledModulesHooks() as $marketplaceId => $module) { $action = \XLite\Core\Request::getInstance()->disabledModulesHooks[$marketplaceId]; $module = \XLite\Core\Database::getEM()->merge($module); if (1 == $action) { // Enable module $module->setEnabled(true); $modulesToEnable[] = $module; $restorePoint['enabled'][$module->getModuleId()] = $module->getActualName(); } elseif (0 == $action) { // Uninstall module \XLite\Upgrade\Cell::getInstance()->removeModuleEntry($module); $this->uninstallModule($module); $restorePoint['deleted'][] = $module->getActualName(); } } \XLite\Core\Database::getRepo('XLite\\Model\\Module')->updateInBatch($modulesToEnable); if (\XLite\Upgrade\Cell::getInstance()->getEntries()) { foreach (\XLite\Upgrade\Cell::getInstance()->getEntries() as $module) { $restorePoint['installed'][] = $module->getActualName(); } // Perform upgrade // pre_upgrade / post_upgrade hooks will be proceeded here $this->runStep('upgrade', array(false, $this->getFilesToOverWrite())); if ($this->isForce()) { if ($this->isNextStepAvailable()) { $target = 'installed'; $this->showInfo(null, 1 < count($modules) ? static::t('Modules have been successfully installed') : static::t('Module has been successfully installed')); if ($this->isOnlySkins()) { $target = 'layout'; } elseif ($this->getPaymentMethodToInstall()) { $target = 'payment_settings'; } else { $target = 'addons_list_installed'; } } else { $target = 'addons_list_marketplace'; $this->showError(__FUNCTION__); } $this->setReturnURL($this->buildURL('upgrade', '', $this->getActionParamsCommon() + array('redirect' => $target))); } } else { // All modules for upgrade were set for uninstallation // There are no upgrade procedures to perform \XLite\Core\Marketplace::getInstance()->clearActionCache(); $this->setReturnURL($this->buildURL('addons_list_installed')); } // Set cell status \XLite\Upgrade\Cell::getInstance()->clear(true, false, false); \XLite\Upgrade\Cell::getInstance()->setUpgraded(true); \Includes\Utils\ModulesManager::updateModuleMigrationLog($restorePoint); // Rebuild cache if (!($this->isForce() && $this->isOnlySkins())) { \XLite::setCleanUpCacheFlag(true); } } else { $this->showWarning(__FUNCTION__, static::t('unable to install: not all archives were unpacked. Please, try again', array('list' => $this->getErrorEntriesHTML()))); } }