コード例 #1
0
 /**
  * Check all pending for uninstallation modules and uninstall them if no pending for deletion files are found
  */
 public static function checkModulesPendingUninstall()
 {
     bx_import('BxDolModuleQuery');
     $a = BxDolModuleQuery::getInstance()->getModules();
     foreach ($a as $aModule) {
         // after we make sure that all pending for deletion files are deleted
         if (!$aModule['pending_uninstall'] || BxDolStorage::isQueuedFilesForDeletion($aModule['name'])) {
             continue;
         }
         // remove pending uninstall flag
         self::setModulePendingUninstall($aModule['uri'], false);
         // perform uninstallation
         bx_import('BxDolStudioInstallerUtils');
         $aResult = BxDolStudioInstallerUtils::getInstance()->perform($aModule['path'], 'uninstall');
         // send email nofitication
         $aTemplateKeys = array('Module' => $aModule['title'], 'Result' => _t('_Success'), 'Message' => '');
         if ($aResult['code'] > 0) {
             $aTemplateKeys['Result'] = _t('_Failed');
             $aTemplateKeys['Message'] = $aResult['message'];
         }
         bx_import('BxDolEmailTemplates');
         $aMessage = BxDolEmailTemplates::getInstance()->parseTemplate('t_DelayedModuleUninstall', $aTemplateKeys);
         sendMail(getParam('site_email'), $aMessage['Subject'], $aMessage['Body'], 0, array(), BX_EMAIL_SYSTEM);
     }
 }
コード例 #2
0
 public function processing()
 {
     if ('on' != getParam('sys_autoupdate_modules')) {
         return;
     }
     BxDolStudioInstallerUtils::getInstance()->performModulesUpgrade();
 }
コード例 #3
0
 function activate($sTemplate)
 {
     $aTemplate = BxDolModuleQuery::getInstance()->getModuleByName($sTemplate);
     if (empty($aTemplate) || !is_array($aTemplate)) {
         return array('code' => 1, 'message' => _t('_adm_err_operation_failed'));
     }
     $aTemplates = array();
     $iTemplates = $this->oDb->getTemplatesBy(array('type' => 'active'), $aTemplates);
     if ($iTemplates == 1 && $aTemplates[0]['name'] == $sTemplate) {
         return array('code' => 1, 'message' => _t('_adm_dsg_err_last_active'));
     }
     $sTemplateDefault = getParam('template');
     if ($aTemplate['uri'] == $sTemplateDefault) {
         return array('code' => 2, 'message' => _t('_adm_dsg_err_deactivate_default'));
     }
     $oInstallerUtils = BxDolStudioInstallerUtils::getInstance();
     $aResult = (int) $aTemplate['enabled'] == 0 ? $oInstallerUtils->perform($aTemplate['path'], 'enable') : $oInstallerUtils->perform($aTemplate['path'], 'disable');
     if ($aResult['code'] != 0) {
         return $aResult;
     }
     $oTemplate = BxDolStudioTemplate::getInstance();
     $aResult = array('code' => 0, 'message' => _t('_adm_scs_operation_done'));
     if ((int) $aTemplate['enabled'] == 0) {
         $aResult['content'] = $oTemplate->parseHtmlByName('page_content_2_col.html', array('page_menu_code' => $this->getPageMenu(), 'page_main_code' => $this->getPageCode()));
     } else {
         $aResult['content'] = "";
     }
     return $aResult;
 }
コード例 #4
0
 function processActions()
 {
     if (($sAction = bx_get($this->sParamPrefix . '_action')) !== false) {
         $sAction = bx_process_input($sAction);
         $aResult = array('code' => 1, 'message' => _t('_adm_' . $this->sLangPrefix . '_err_cannot_process_action'));
         switch ($sAction) {
             case 'uninstall':
                 $sPageName = bx_process_input(bx_get($this->sParamPrefix . '_page_name'));
                 if (empty($sPageName)) {
                     break;
                 }
                 bx_import('BxDolModuleQuery');
                 $aModule = BxDolModuleQuery::getInstance()->getModuleByName($sPageName);
                 if (empty($aModule) || !is_array($aModule)) {
                     break;
                 }
                 if (($iWidgetId = (int) bx_get($this->sParamPrefix . '_widget_id')) != 0 && (int) bx_get($this->sParamPrefix . '_confirmed') != 1) {
                     $aResult['message'] = $this->getPopupConfirm($iWidgetId, $aModule);
                     break;
                 }
                 bx_import('BxDolStudioInstallerUtils');
                 $aResult = BxDolStudioInstallerUtils::getInstance()->perform($aModule['path'], 'uninstall');
                 if (!empty($aResult['message'])) {
                     $aResult['message'] = $this->getPopupResult($aResult['message']);
                 }
                 break;
         }
         if (!empty($aResult['message'])) {
             bx_import('BxTemplStudioFunctions');
             $aResult['message'] = BxTemplStudioFunctions::getInstance()->transBox('', $aResult['message']);
         }
         echo json_encode($aResult);
         exit;
     }
 }
コード例 #5
0
 public function isQueued($sAction, $sName)
 {
     $sJobName = '';
     switch ($sAction) {
         case 'download':
             $sJobName = BxDolStudioInstallerUtils::getNameDownloadFile($sName);
             break;
         case 'action':
             $sJobName = BxDolStudioInstallerUtils::getNamePerformAction($sName);
             break;
     }
     $sSql = $this->prepare("SELECT `id` FROM `sys_cron_jobs` WHERE name=? LIMIT 1", $sJobName);
     return (int) $this->getOne($sSql) > 0;
 }
コード例 #6
0
 public function activate($sModule)
 {
     $aModule = $this->oDb->getModuleByName($sModule);
     if (empty($aModule) || !is_array($aModule)) {
         return array('code' => 1, 'message' => _t('_adm_err_operation_failed'));
     }
     $aResult = BxDolStudioInstallerUtils::getInstance()->perform($aModule['path'], (int) $aModule['enabled'] == 0 ? 'enable' : 'disable', array('html_response' => true));
     if ($aResult['code'] != 0) {
         return $aResult;
     }
     $oTemplate = BxDolStudioTemplate::getInstance();
     $aResult = array('code' => 0, 'message' => _t('_adm_scs_operation_done'));
     if ((int) $aModule['enabled'] == 0) {
         $aResult['content'] = $oTemplate->parseHtmlByName('page_content_2_col.html', array('page_menu_code' => $this->getPageMenu(), 'page_main_code' => $this->getPageCode()));
     } else {
         $aResult['content'] = "";
     }
     return $aResult;
 }
コード例 #7
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;
 }
コード例 #8
0
 public function install($aParams, $bAutoEnable = false)
 {
     $bAutoEnable = $bAutoEnable || isset($aParams['auto_enable']) && (bool) $aParams['auto_enable'];
     $bHtmlResponce = isset($aParams['html_response']) && (bool) $aParams['html_response'];
     //--- Check whether the module was already installed ---//
     if ($this->oDb->isModule($this->_aConfig['home_uri'])) {
         return array('message' => _t('_adm_err_modules_already_installed'), 'result' => false);
     }
     $aResult = array();
     bx_alert('system', 'before_install', 0, false, array('config' => $this->_aConfig, 'result' => &$aResult));
     if ($aResult && !$aResult['result']) {
         return $aResult;
     }
     //--- Check mandatory settings ---//
     if ($this->oDb->isModuleParamsUsed($this->_aConfig['home_uri'], $this->_aConfig['home_dir'], $this->_aConfig['db_prefix'], $this->_aConfig['class_prefix'])) {
         return array('message' => _t('_adm_txt_modules_params_used'), 'result' => false);
     }
     //--- Check version compatibility ---//
     if (!$this->_isCompatibleWith()) {
         return array('message' => $this->_displayResult('check_script_version', false, '_adm_err_modules_wrong_version_script', $bHtmlResponce), 'result' => false);
     }
     //--- Check for available translations ---//
     $oFile = $this->_getFileManager();
     $sModuleUri = $this->_aConfig['home_uri'];
     $aLanguages = $this->oDb->getModulesBy(array('type' => 'languages'));
     foreach ($aLanguages as $aLanguage) {
         if ($aLanguage['uri'] == 'en') {
             continue;
         }
         $aLanguageConfig = self::getModuleConfig(BX_DIRECTORY_PATH_MODULES . $aLanguage['path'] . '/install/config.php');
         if (empty($aLanguageConfig)) {
             continue;
         }
         if (!isset($aLanguageConfig['includes'][$sModuleUri]) || empty($aLanguageConfig['includes'][$sModuleUri])) {
             continue;
         }
         $sSrcPath = 'modules/' . $aLanguage['path'] . 'install/data/' . $aLanguageConfig['includes'][$sModuleUri];
         $sDstPath = $aLanguageConfig['includes'][$sModuleUri];
         $oFile->copy($sSrcPath, $sDstPath);
     }
     //--- Check actions ---//
     $aResult = $this->_perform('install', $aParams);
     if ($aResult['result']) {
         $sDependencies = "";
         if (isset($this->_aConfig['install']['check_dependencies']) && (int) $this->_aConfig['install']['check_dependencies'] == 1 && isset($this->_aConfig['dependencies']) && is_array($this->_aConfig['dependencies'])) {
             $this->_aConfig['dependencies'] = array_keys($this->_aConfig['dependencies']);
         }
         $iModuleId = $this->oDb->insertModule($this->_aConfig);
         $sTitleKey = BxDolModule::getTitleKey($this->_aConfig['home_uri']);
         $oLanguages = BxDolStudioLanguagesUtils::getInstance();
         $oLanguages->addLanguageString($sTitleKey, $this->_aConfig['title']);
         $oLanguages->compileLanguage();
         BxDolStudioInstallerUtils::getInstance()->checkModules();
         $aFiles = array();
         $this->hashFiles($this->_sModulePath, $aFiles);
         foreach ($aFiles as $aFile) {
             $this->oDb->insertModuleTrack($iModuleId, $aFile);
         }
         $this->oDb->cleanMemory('sys_modules_' . $this->_aConfig['home_uri']);
         $this->oDb->cleanMemory('sys_modules_' . $iModuleId);
         $this->oDb->cleanMemory('sys_modules');
         if (!empty($this->_aConfig['install_success'])) {
             $this->_perform('install_success', $aParams);
         }
     } else {
         if (!empty($this->_aConfig['install_failed'])) {
             $this->_perform('install_failed', $aParams);
         }
     }
     bx_alert('system', 'install', 0, false, array('config' => $this->_aConfig, 'result' => &$aResult));
     if ($aResult['result'] && $bAutoEnable) {
         $aResultEnable = $this->enable($aParams);
         $aResult['result'] = $aResult['result'] & $aResultEnable['result'];
         $aResult['message'] = $aResult['message'] . $aResultEnable['message'];
     }
     return $aResult;
 }
コード例 #9
0
 private function getDownloadedModules($bNamesOnly = true)
 {
     bx_import('BxDolStudioInstallerUtils');
     $aModules = BxDolStudioInstallerUtils::getInstance()->getModules(false);
     return $bNamesOnly ? array_keys($aModules) : $aModules;
 }
コード例 #10
0
ファイル: BxDolStudioStore.php プロジェクト: blas-dmx/trident
 protected function loadUpdate($sModuleName, $bAutoUpdate = false)
 {
     return BxDolStudioInstallerUtils::getInstance()->downloadUpdatePublic($sModuleName, $bAutoUpdate);
 }
コード例 #11
0
 protected function processModuleByField($sField, $sModuleUri, $aActions = array('install', 'enable'), $sModuleType = null)
 {
     if (!file_exists(BX_INSTALL_PATH_HEADER)) {
         return _t('_sys_inst_msg_script_isnt_installed');
     }
     require_once BX_INSTALL_PATH_HEADER;
     bx_import('BxDolStudioInstallerUtils');
     bx_import('BxDolLanguages');
     BxDolLanguages::getInstance();
     $oModulesTools = new BxDolInstallModulesTools();
     $aModules = $oModulesTools->getModules($sModuleType);
     foreach ($aModules as $aConfig) {
         if ($sModuleUri != $aConfig[$sField]) {
             continue;
         }
         foreach ($aActions as $sAction) {
             $aResult = BxDolStudioInstallerUtils::getInstance()->perform($aConfig['home_dir'], $sAction);
             if ((!isset($aResult['code']) || $aResult['code']) && !empty($aResult['message'])) {
                 return _t('_sys_inst_msg_module_error', $aConfig['title'], $aResult['message']);
             }
         }
     }
     return '';
 }
コード例 #12
0
 protected function loadUpdate($sModuleName)
 {
     bx_import('BxDolStudioInstallerUtils');
     return BxDolStudioInstallerUtils::getInstance()->downloadUpdatePublic($sModuleName);
 }