oDb = new BxDolStudioModulesQuery(); $this->sModule = ''; if(is_string($sModule) && !empty($sModule)) $this->sModule = $sModule; $this->sPage = $this->sPageDefault; if(is_string($sPage) && !empty($sPage)) $this->sPage = $sPage; } public function init() { //--- Check Actions ---// if(($sAction = bx_get('mod_action')) !== false) { $sAction = bx_process_input($sAction); $aResult = array('code' => 1, 'message' => _t('_adm_mod_err_cannot_process_action')); switch($sAction) { case 'activate': $sValue = bx_process_input(bx_get('mod_value')); if(empty($sValue)) break; $aResult = $this->activate($sValue); break; } echo json_encode($aResult); exit; } $this->aModule = $this->oDb->getModuleByName($this->sModule); if(empty($this->aModule) || !is_array($this->aModule)) BxDolStudioTemplate::getInstance()->displayPageNotFound(); $this->addMarkers(array( 'module_name' => $this->aModule['name'], 'module_uri' => $this->aModule['uri'], 'module_title' => $this->aModule['title'] )); $this->addAction(array( 'type' => 'switcher', 'name' => 'activate', 'caption' => '_adm_txt_pca_active', 'checked' => (int)$this->aModule['enabled'] == 1, 'onchange' => "javascript:" . $this->getPageJsObject() . ".activate('" . $this->sModule . "', this)" ), false); $this->sPageRssHelpUrl = $this->aModule['help_url']; } 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')); bx_import('BxDolStudioInstallerUtils'); $oInstallerUtils = BxDolStudioInstallerUtils::getInstance(); $aResult = (int)$aModule['enabled'] == 0 ? $oInstallerUtils->perform($aModule['path'], 'enable') : $oInstallerUtils->perform($aModule['path'], 'disable'); if($aResult['code'] != 0) return $aResult; bx_import('BxDolStudioTemplate'); $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; } } /** @} */