Exemplo n.º 1
0
 public static function update_module($module_id, $activated)
 {
     $error = '';
     if (!$activated) {
         MenuService::delete_mini_module($module_id);
         MenuService::delete_module_feeds_menus($module_id);
         $general_config = GeneralConfig::load();
         $module_home_page_selected = $general_config->get_module_home_page();
         if ($module_home_page_selected == $module_id) {
             $general_config->set_module_home_page('');
             $general_config->set_other_home_page('index.php');
         }
         $editors = AppContext::get_content_formatting_service()->get_available_editors();
         if (in_array($module_id, $editors)) {
             if (count($editors) > 1) {
                 $default_editor = ContentFormattingConfig::load()->get_default_editor();
                 if ($default_editor !== $module_id) {
                     PersistenceContext::get_querier()->update(DB_TABLE_MEMBER, array('editor' => $default_editor), 'WHERE editor=:old_editor', array('old_editor' => 'bbcode'));
                 } else {
                     $error = LangLoader::get_message('is_default_editor', 'editor-common');
                 }
             } else {
                 $error = LangLoader::get_message('last_editor_installed', 'editor-common');
             }
         }
     } else {
         $module = self::get_module($module_id);
         if ($module->get_configuration()->get_compatibility() != GeneralConfig::load()->get_phpboost_major_version()) {
             $error = LangLoader::get_message('modules.not_compatible', 'admin-modules-common');
         }
     }
     if (empty($error)) {
         $module = self::get_module($module_id);
         $module->set_activated($activated);
         ModulesConfig::load()->update($module);
         ModulesConfig::save();
         MenuService::generate_cache();
         Feed::clear_cache($module_id);
         if (ServerEnvironmentConfig::load()->is_url_rewriting_enabled()) {
             HtaccessFileCache::regenerate();
         }
     }
     return $error;
 }
Exemplo n.º 2
0
 public function update_modules()
 {
     $modules_config = ModulesConfig::load();
     foreach ($modules_config->get_modules() as $id => $module) {
         if (ModulesManager::module_is_upgradable($id)) {
             ModulesManager::upgrade_module($id);
             $module->set_installed_version($module->get_configuration()->get_version());
         } else {
             if ($module->get_configuration()->get_compatibility() != self::NEW_KERNEL_VERSION) {
                 $module->set_activated(false);
                 $this->add_information_to_file('module ' . $id, 'has been disabled because : incompatible with new version');
             }
         }
         $modules_config->update($module);
     }
     ModulesConfig::save();
     $configs_module_class = $this->get_class(PATH_TO_ROOT . self::$directory . '/modules/config/', self::$configuration_pattern, 'config');
     $update_module_class = $this->get_class(PATH_TO_ROOT . self::$directory . '/modules/', self::$module_pattern, 'module');
     $classes_list = array_merge($configs_module_class, $update_module_class);
     foreach ($classes_list as $class) {
         try {
             $object = new $class['name']();
             $object->execute();
             $success = true;
             $message = '';
         } catch (Exception $e) {
             $success = false;
             $message = $e->getMessage();
         }
         $this->add_error_to_file($class['type'] . ' ' . $object->get_module_id(), $success, $message);
     }
 }