Exemplo n.º 1
0
 public function processing()
 {
     $oController = new BxDolUpgradeController();
     if ($oController->setMaintenanceMode(true)) {
         // if upgrade was successful
         if (($sFolder = $oController->getAvailableUpgrade()) && $oController->runUpgrade($sFolder)) {
             // write upgrade log
             $oController->writeLog();
             // send email notification
             bx_import('BxDolLanguages');
             sendMailTemplateSystem('t_UpgradeSuccess', array('new_version' => bx_get_ver(true), 'conclusion' => $oController->getConclusion() ? _t('_sys_upgrade_conclusion', $oController->getConclusion()) : ''));
             // if next upgrade is available (in case of bulk upgrade) then schedule to run it upon next cron run
             $sUpgradeDir = pathinfo(__FILE__, PATHINFO_DIRNAME);
             if ($oController->getAvailableUpgrade()) {
                 $oUpgrader = bx_instance('BxDolUpgrader');
                 $oUpgrader->setTransientUpgradeCronJob($sUpgradeDir);
             } elseif (0 === strpos($sUpgradeDir, BX_DIRECTORY_PATH_TMP)) {
                 @bx_rrmdir($sUpgradeDir);
             }
         }
         $oController->setMaintenanceMode(false);
     }
     // if something went grong during upgrade
     if ($sErrorMsg = $oController->getErrorMsg()) {
         // write upgrade log
         $oController->writeLog();
         // send email notification
         sendMailTemplateSystem('t_UpgradeFailed', array('error_msg' => $sErrorMsg));
         // disable auto-upgrade if it is failed
         setParam('sys_autoupdate_system', '');
     }
 }
Exemplo n.º 2
0
 public function processing()
 {
     if ('on' != getParam('sys_autoupdate_system')) {
         return;
     }
     $o = bx_instance('BxDolUpgrader');
     if (!$o->prepare()) {
         sendMailTemplateSystem('t_UpgradeFailed', array('error_msg' => $o->getError()));
         setParam('sys_autoupdate_system', '');
         // disable auto-update if it is failed
     }
 }
Exemplo n.º 3
0
 public function prepare()
 {
     $iUmaskSave = umask(0);
     bx_import('BxDolStudioInstallerUtils');
     $oInstallerUtils = BxDolStudioInstallerUtils::getInstance();
     $aUpdated = array();
     while (true) {
         $aUpdates = $oInstallerUtils->checkUpdates();
         foreach ($aUpdates as $aUpdate) {
             $mixedResult = $oInstallerUtils->downloadUpdatePublic($aUpdate['name']);
             if ($mixedResult !== true) {
                 $this->setError($mixedResult);
                 break;
             }
         }
         if ($this->getError()) {
             break;
         }
         $aUpdates = $oInstallerUtils->getUpdates();
         foreach ($aUpdates as $aUpdate) {
             $aResult = BxDolStudioInstallerUtils::getInstance()->perform($aUpdate['dir'], 'update');
             if ((int) $aResult['code'] != 0) {
                 $this->setError($aResult['message']);
                 break;
             } else {
                 $aUpdated[$aUpdate['module_name']] = $aUpdate['version_to'];
             }
         }
         break;
     }
     umask($iUmaskSave);
     if (!empty($aUpdated)) {
         bx_import('BxDolModuleQuery');
         $oModuleQuery = BxDolModuleQuery::getInstance();
         $sUpdated = '';
         foreach ($aUpdated as $sModule => $sVersion) {
             $aModule = $oModuleQuery->getModuleByName($sModule);
             $sUpdated .= _t('_sys_et_txt_body_upgraded_module', $aModule['title'], $sVersion);
         }
         sendMailTemplateSystem('t_UpgradeModulesSuccess', array('conclusion' => $sUpdated));
     }
     return $this->getError() ? false : true;
 }
 private function emailNotify($sMessage)
 {
     sendMailTemplateSystem('t_BgOperationFailed', array('conclusion' => strip_tags($sMessage)));
 }
 private function emailNotifyModulesUpgrade($sResult, $aData)
 {
     $oModuleQuery = BxDolModuleQuery::getInstance();
     $sConclusion = '';
     if (!empty($aData)) {
         foreach ($aData as $sModule => $sMessage) {
             $aModule = $oModuleQuery->getModuleByName($sModule);
             $sConclusion .= _t('_sys_et_txt_body_modules_upgrade_' . $sResult, $aModule['title'], $sMessage);
         }
     }
     sendMailTemplateSystem('t_UpgradeModules' . ucfirst($sResult), array('conclusion' => $sConclusion));
 }