Пример #1
0
/**
 * Return current module which we editing
 */
function getCurrMod()
{
    $ModulesManager = new ModulesManager();
    $allow_mods = $ModulesManager->getAllowedModules('categories');
    if (empty($_GET['mod'])) {
        redirect('/admin/category.php?mod=news');
    }
    $mod = trim($_GET['mod']);
    if (!in_array($mod, $allow_mods)) {
        redirect('/admin/category.php?mod=news');
    }
    return $mod;
}
Пример #2
0
 public static function add_filter_fieldset(Menu $menu, Template $tpl)
 {
     $tpl_filter = new FileTemplate('admin/menus/filters.tpl');
     $tpl_filter->assign_block_vars('modules', array('ID' => ''));
     foreach (ModulesManager::get_activated_modules_map_sorted_by_localized_name() as $module) {
         $configuration = $module->get_configuration();
         $home_page = $configuration->get_home_page();
         if (!empty($home_page)) {
             $tpl_filter->assign_block_vars('modules', array('ID' => $module->get_id()));
         }
     }
     //Ajout du menu
     if ($menu->get_id() == '') {
         $menu->set_filters(array(new MenuStringFilter('/')));
     }
     // Installed modules
     foreach ($menu->get_filters() as $key => $filter) {
         $filter_pattern = $filter->get_pattern();
         $filter_infos = explode('/', $filter_pattern);
         $module_name = $filter_infos[0];
         $regex = substr(strstr($filter_pattern, '/'), 1);
         $tpl_filter->assign_block_vars('filters', array('ID' => $key, 'FILTER' => $regex));
         $tpl_filter->assign_block_vars('filters.modules', array('ID' => '', 'SELECTED' => $filter_pattern == '/' ? ' selected="selected"' : ''));
         foreach (ModulesManager::get_activated_modules_map_sorted_by_localized_name() as $module) {
             $configuration = $module->get_configuration();
             $home_page = $configuration->get_home_page();
             if (!empty($home_page)) {
                 $tpl_filter->assign_block_vars('filters.modules', array('ID' => $module->get_id(), 'SELECTED' => $module_name == $module->get_id() ? ' selected="selected"' : ''));
             }
         }
     }
     $tpl_filter->add_lang(LangLoader::get('admin-menus-common'));
     $tpl_filter->put_all(array('NBR_FILTER' => $menu->get_id() == '' ? 0 : count($menu->get_filters()) - 1));
     $tpl->put('filters', $tpl_filter);
 }
Пример #3
0
 /**
  * @desc Load Application Classes
  * @param $checks
  */
 private function load_apps($checks = CHECK_ALL_UPDATES)
 {
     if (ServerConfiguration::get_phpversion() > self::PHP_MIN_VERSION_UPDATES) {
         $user_locale = AppContext::get_current_user()->get_locale();
         if ($checks & CHECK_KERNEL) {
             // Add the kernel to the check list
             $this->apps[] = new Application('kernel', $user_locale, Application::KERNEL_TYPE, Environment::get_phpboost_version(), Updates::PHPBOOST_OFFICIAL_REPOSITORY);
         }
         if ($checks & CHECK_MODULES) {
             $activated_modules = ModulesManager::get_activated_modules_map_sorted_by_localized_name();
             foreach ($activated_modules as $module) {
                 $this->apps[] = new Application($module->get_id(), $user_locale, Application::MODULE_TYPE, $module->get_configuration()->get_version(), $module->get_configuration()->get_repository());
             }
         }
         if ($checks & CHECK_THEMES) {
             // Add Themes
             $activated_themes = ThemesManager::get_activated_themes_map();
             foreach ($activated_themes as $id => $value) {
                 $repository = $value->get_configuration()->get_repository();
                 if (!empty($repository)) {
                     $this->apps[] = new Application($id, $user_locale, Application::TEMPLATE_TYPE, $value->get_configuration()->get_version(), $repository);
                 }
             }
         }
     }
 }
 private static function get_subheader_tpl()
 {
     $subheader_lang = LangLoader::get('admin-links-common');
     $subheader_tpl = new FileTemplate('admin/subheader_menu.tpl');
     $subheader_tpl->add_lang($subheader_lang);
     $modules = ModulesManager::get_activated_modules_map_sorted_by_localized_name();
     $modules_number = 0;
     foreach ($modules as $module) {
         if ($module->get_configuration()->get_admin_menu() == 'modules') {
             $modules_number++;
         }
     }
     $subheader_tpl->put_all(array('L_ADD' => $subheader_lang['add'], 'L_ADMINISTRATION' => $subheader_lang['administration'], 'L_MANAGEMENT' => $subheader_lang['management'], 'L_CONFIGURATION' => $subheader_lang['configuration'], 'L_CONFIG_GENERAL' => $subheader_lang['administration.configuration.general'], 'L_CONFIG_ADVANCED' => $subheader_lang['administration.configuration.advanced'], 'L_MAIL_CONFIG' => $subheader_lang['administration.configuration.mail'], 'L_THEMES' => $subheader_lang['administration.themes'], 'L_LANGS' => $subheader_lang['administration.langs'], 'L_SMILEY' => $subheader_lang['administration.smileys'], 'L_ADMINISTRATOR_ALERTS' => $subheader_lang['administration.alerts'], 'L_TOOLS' => $subheader_lang['tools'], 'L_UPDATES' => $subheader_lang['updates'], 'L_KERNEL' => $subheader_lang['tools.updates.kernel'], 'L_MAINTAIN' => $subheader_lang['tools.maintain'], 'L_CACHE' => $subheader_lang['tools.cache'], 'L_SYNDICATION_CACHE' => $subheader_lang['tools.cache.syndication'], 'L_CSS_CACHE_CONFIG' => $subheader_lang['tools.cache.css'], 'L_ERRORS' => $subheader_lang['tools.errors-archived'], 'L_404_ERRORS' => $subheader_lang['tools.404-errors-archived'], 'L_SERVER' => $subheader_lang['tools.server'], 'L_PHPINFO' => $subheader_lang['tools.server.phpinfo'], 'L_SYSTEM_REPORT' => $subheader_lang['tools.server.system-report'], 'L_USER' => $subheader_lang['users'], 'L_PUNISHEMENT' => $subheader_lang['users.punishement'], 'L_GROUP' => $subheader_lang['users.groups'], 'L_EXTEND_FIELD' => $subheader_lang['users.extended-fields'], 'L_CONTENT' => $subheader_lang['content'], 'L_CONTENT_CONFIG' => $subheader_lang['content'], 'L_MENUS' => $subheader_lang['content.menus'], 'L_ADD_CONTENT_MENU' => $subheader_lang['content.menus.content'], 'L_ADD_LINKS_MENU' => $subheader_lang['content.menus.links'], 'L_ADD_FEED_MENU' => $subheader_lang['content.menus.feed'], 'L_FILES' => $subheader_lang['content.files'], 'L_COMMENTS' => $subheader_lang['content.comments'], 'L_MODULES' => $subheader_lang['modules'], 'U_NBR_MODULES' => ceil(($modules_number + 1) / 7), 'U_INDEX_SITE' => Environment::get_home_page(), 'C_ADMIN_LINKS_1' => false, 'C_ADMIN_LINKS_2' => false, 'C_ADMIN_LINKS_3' => false, 'C_ADMIN_LINKS_4' => false, 'C_ADMIN_LINKS_5' => false, 'C_ADMIN_LINKS_1' => false));
     $array_pos = array(0, 4, 4, 3, 3, 1);
     $menus_numbers = array('index' => 1, 'administration' => 2, 'tools' => 3, 'members' => 4, 'content' => 5, 'modules' => 6);
     foreach ($modules as $module) {
         $module_id = $module->get_id();
         $configuration = $module->get_configuration();
         $menu_pos_name = $configuration->get_admin_menu();
         $menu_pos = 0;
         if (!empty($menu_pos_name) && !empty($menus_numbers[$menu_pos_name])) {
             $menu_pos = $menus_numbers[$menu_pos_name];
         }
         if ($menu_pos > 0) {
             $array_pos[$menu_pos - 1]++;
             $idmenu = $array_pos[$menu_pos - 1];
             $subheader_tpl->put('C_ADMIN_LINKS_' . $menu_pos, true);
             $subheader_tpl->assign_block_vars('admin_links_' . $menu_pos, array('MODULE_MENU' => ModuleTreeLinksService::display_admin_actions_menu($module)));
         }
     }
     return $subheader_tpl;
 }
 private function save(HTTPRequestCustom $request)
 {
     $installed_modules = ModulesManager::get_installed_modules_map();
     foreach ($installed_modules as $module) {
         if ($request->get_string('delete-' . $module->get_id(), '')) {
             AppContext::get_response()->redirect(AdminModulesUrlBuilder::delete_module($module->get_id()));
         }
     }
     if ($request->get_bool('update', false)) {
         $errors = array();
         foreach ($installed_modules as $module) {
             $module_id = $module->get_id();
             $activated = $request->get_bool('activated-' . $module_id, false);
             $error = ModulesManager::update_module($module_id, $activated);
             if (!empty($error)) {
                 $errors[$module->get_configuration()->get_name()] = $error;
             }
         }
         if (empty($errors)) {
             AppContext::get_response()->redirect(AdminModulesUrlBuilder::list_installed_modules());
         } else {
             foreach ($errors as $module_name => $error) {
                 $this->view->assign_block_vars('errors', array('MSG' => MessageHelper::display($module_name . ' : ' . $error, MessageHelper::WARNING, 10)));
             }
         }
     }
 }
Пример #6
0
 public final function get_right_controller_regarding_authorizations()
 {
     if (ModulesManager::is_module_installed(Environment::get_running_module_name())) {
         $module = ModulesManager::get_module(Environment::get_running_module_name());
         if (!$module->is_activated()) {
             return PHPBoostErrors::module_not_activated();
         }
     } else {
         return PHPBoostErrors::module_not_installed();
     }
     return $this;
 }
Пример #7
0
 public function get_formated_title()
 {
     $class_name = get_class($this);
     $module_name = strstr($class_name, 'ModuleMiniMenu', true);
     $module_name = strlen(preg_replace('/[a-z]*/', '', $module_name)) > 1 ? $module_name : strtolower($module_name);
     //Pour les modules qui ont plus de 2 majuscules on les garde, sinon on les enlève
     $module = '';
     try {
         $module = ModulesManager::get_module($module_name);
     } catch (Exception $e) {
     }
     $localized_module_name = !empty($module) ? $module->get_configuration()->get_name() : '';
     return !empty($localized_module_name) ? (!preg_match('/^' . Langloader::get_message('admin.main_menu', 'main') . ' /', $localized_module_name) ? Langloader::get_message('admin.main_menu', 'main') . ' ' : '') . $localized_module_name : $class_name;
 }
 public final function get_right_controller_regarding_authorizations()
 {
     if (!AppContext::get_current_user()->is_admin()) {
         return new UserLoginController(UserLoginController::ADMIN_LOGIN, substr(REWRITED_SCRIPT, strlen(GeneralConfig::load()->get_site_path())));
     } else {
         if (ModulesManager::is_module_installed(Environment::get_running_module_name())) {
             $module = ModulesManager::get_module(Environment::get_running_module_name());
             if (!$module->is_activated()) {
                 return PHPBoostErrors::module_not_activated();
             }
         } else {
             return PHPBoostErrors::module_not_installed();
         }
     }
     return $this;
 }
 public static function display_actions_menu()
 {
     $module_name = Environment::get_running_module_name();
     $tree_links = self::get_tree_links($module_name);
     if ($tree_links !== null) {
         $actions_tree_links = $tree_links->get_actions_tree_links();
         $module = ModulesManager::get_module($module_name);
         $tpl = new FileTemplate('framework/module/module_actions_links_menu.tpl');
         $tpl->put_all(array('C_DISPLAY' => $actions_tree_links->has_visible_links(), 'ID' => $module_name, 'MODULE_NAME' => $module->get_configuration()->get_name()));
         $home_page = $module->get_configuration()->get_home_page();
         if (!empty($home_page)) {
             $module_home = new ModuleLink(LangLoader::get_message('home', 'main'), new Url('/' . $module->get_id() . '/' . $home_page));
             $tpl->assign_block_vars('element', array(), array('ELEMENT' => $module_home->export()));
         }
         return self::display($actions_tree_links, $tpl);
     }
 }
 private function get_module_map($auth_mode)
 {
     $module = ModulesManager::get_module($this->categories_manager->get_module_id());
     $module_configuration = $module->get_configuration();
     $link = new SitemapLink($module_configuration->get_name(), new Url('/' . $module->get_id() . '/'), Sitemap::FREQ_DAILY, Sitemap::PRIORITY_MAX);
     $module_map = new ModuleMap($link, $module->get_id());
     $categories = $this->categories_manager->get_categories_cache()->get_categories();
     foreach ($categories as $id => $category) {
         if ($auth_mode == Sitemap::AUTH_PUBLIC) {
             $this_auth = Authorizations::check_auth(RANK_TYPE, User::VISITOR_LEVEL, $category->get_authorizations(), Category::READ_AUTHORIZATIONS);
         } else {
             $this_auth = AppContext::get_current_user()->check_auth($category->get_authorizations(), Category::READ_AUTHORIZATIONS);
         }
         if ($this_auth && $id != Category::ROOT_CATEGORY && $category->get_id_parent() == Category::ROOT_CATEGORY) {
             $module_map->add($this->create_module_map_sections($categories, $id, $auth_mode));
         }
     }
     return $module_map;
 }
 public function get_menu_content()
 {
     //Create file template
     $tpl = new FileTemplate('shoutbox/ShoutboxModuleMiniMenu.tpl');
     //Assign the lang file to the tpl
     $tpl->add_lang(LangLoader::get('common', 'shoutbox'));
     $config = ShoutboxConfig::load();
     $forbidden_tags = array_flip($config->get_forbidden_formatting_tags());
     if ($config->is_shout_bbcode_enabled()) {
         $smileys_cache = SmileysCache::load();
         $smileys_per_line = 5;
         //Smileys par ligne.
         $smileys_displayed_number = 0;
         foreach ($smileys_cache->get_smileys() as $code_smile => $infos) {
             $smileys_displayed_number++;
             $tpl->assign_block_vars('smileys', array('C_END_LINE' => $smileys_displayed_number % $smileys_per_line == 0, 'URL' => TPL_PATH_TO_ROOT . '/images/smileys/' . $infos['url_smiley'], 'CODE' => addslashes($code_smile)));
         }
     }
     $tpl->put_all(array('C_MEMBER' => AppContext::get_current_user()->check_level(User::MEMBER_LEVEL), 'C_DISPLAY_FORM' => ShoutboxAuthorizationsService::check_authorizations()->write() && !AppContext::get_current_user()->is_readonly(), 'C_VALIDATE_ONKEYPRESS_ENTER' => $config->is_validation_onkeypress_enter_enabled(), 'C_DISPLAY_SHOUT_BBCODE' => ModulesManager::is_module_installed('BBCode') && $config->is_shout_bbcode_enabled(), 'C_BOLD_DISABLED' => isset($forbidden_tags['b']), 'C_ITALIC_DISABLED' => isset($forbidden_tags['i']), 'C_UNDERLINE_DISABLED' => isset($forbidden_tags['u']), 'C_STRIKE_DISABLED' => isset($forbidden_tags['s']), 'C_AUTOMATIC_REFRESH_ENABLED' => $config->is_automatic_refresh_enabled(), 'SHOUTBOX_PSEUDO' => AppContext::get_current_user()->get_display_name(), 'SHOUT_REFRESH_DELAY' => $config->get_refresh_delay(), 'L_ALERT_LINK_FLOOD' => sprintf(LangLoader::get_message('e_l_flood', 'errors'), $config->get_max_links_number_per_message()), 'SHOUTBOX_MESSAGES' => ShoutboxAjaxRefreshMessagesController::get_view()));
     return $tpl->render();
 }
 private function delete_module($drop_files)
 {
     $error = ModulesManager::uninstall_module($this->module_id, $drop_files);
     if (is_int($error)) {
         switch ($error) {
             case ModulesManager::MODULE_FILES_COULD_NOT_BE_DROPPED:
                 $this->tpl->put('MSG', MessageHelper::display(LangLoader::get_message('files_del_failed', 'main'), MessageHelper::WARNING, 10));
                 break;
             case ModulesManager::NOT_INSTALLED_MODULE:
                 $this->tpl->put('MSG', MessageHelper::display($this->lang['modules.not_installed_module'], MessageHelper::WARNING, 10));
                 break;
             case ModulesManager::MODULE_UNINSTALLED:
                 AppContext::get_response()->redirect(AdminModulesUrlBuilder::list_installed_modules());
                 break;
             default:
                 $this->tpl->put('MSG', MessageHelper::display(LangLoader::get_message('process.error', 'status-messages-common'), MessageHelper::WARNING, 10));
         }
     } else {
         $this->tpl->put('MSG', MessageHelper::display($error, MessageHelper::WARNING, 10));
     }
 }
 private function load_modules_providers()
 {
     try {
         // In case that phpboost is not installed and that a command line is invoked,
         // PHPBoostNotInstalledException, DBConnectionException, SQLQuerierException and IOException could be thrown.
         // In that case, it only means that modules extension points providers won't be loaded
         foreach (ModulesManager::get_installed_modules_map() as $provider_id => $module) {
             if ($module->is_activated()) {
                 $this->register_provider($provider_id);
             }
         }
     } catch (PHPBoostNotInstalledException $exception) {
     } catch (DBConnectionException $exception) {
     } catch (SQLQuerierException $exception) {
     } catch (IOException $exception) {
     }
 }
Пример #14
0
 /**
  * @desc Return a menu with links to modules
  * @param int $menu_type the menu type
  * @return LinksMenu the menu with links to modules
  */
 public static function website_modules($menu_type = LinksMenu::AUTOMATIC_MENU)
 {
     $modules_menu = new LinksMenu('PHPBoost', '/', '', $menu_type);
     $modules = ModulesManager::get_activated_modules_map_sorted_by_localized_name();
     foreach ($modules as $module) {
         $configuration = $module->get_configuration();
         $start_page = $configuration->get_home_page();
         if (!empty($start_page)) {
             $img = '';
             $img_url = PATH_TO_ROOT . '/' . $module->get_id() . '/' . $module->get_id();
             foreach (array('_mini.png', '_mini.gif', '_mini.jpg') as $extension) {
                 $file = new File($img_url . $extension);
                 if ($file->exists()) {
                     $img = '/' . $module->get_id() . '/' . $file->get_name();
                     break;
                 }
             }
             $modules_menu->add(new LinksMenuLink($configuration->get_name(), '/' . $module->get_id() . '/', $img));
         }
     }
     return $modules_menu;
 }
 private function upload_module()
 {
     $modules_folder = PATH_TO_ROOT . '/';
     if (!is_writable($modules_folder)) {
         $is_writable = @chmod($dir, 0755);
     } else {
         $is_writable = true;
     }
     if ($is_writable) {
         $file = $this->form->get_value('file');
         if ($file !== null) {
             $modules_id = $file->get_name_without_extension();
             if (ModulesManager::is_module_installed($modules_id)) {
                 $upload = new Upload($modules_folder);
                 $upload->disableContentCheck();
                 if ($upload->file('upload_module_file', '`([A-Za-z0-9-_]+)\\.(gz|zip)+$`i', false, 100000000, false)) {
                     $archive_path = $modules_folder . $upload->get_filename();
                     if ($upload->get_extension() == 'gz') {
                         include_once PATH_TO_ROOT . '/kernel/lib/php/pcl/pcltar.lib.php';
                         PclTarExtract($upload->get_filename(), $modules_folder);
                         $file = new File($archive_path);
                         $file->delete();
                     } else {
                         if ($upload->get_extension() == 'zip') {
                             include_once PATH_TO_ROOT . '/kernel/lib/php/pcl/pclzip.lib.php';
                             $zip = new PclZip($archive_path);
                             $zip->extract(PCLZIP_OPT_PATH, $modules_folder, PCLZIP_OPT_SET_CHMOD, 0755);
                             $file = new File($archive_path);
                             $file->delete();
                         } else {
                             $this->view->put('MSG', MessageHelper::display($this->lang['modules.upload_invalid_format'], MessageHelper::NOTICE, 4));
                         }
                     }
                     $this->upgrade_module($modules_id);
                 } else {
                     $this->view->put('MSG', MessageHelper::display($this->lang['modules.upload_error'], MessageHelper::NOTICE, 4));
                 }
             } else {
                 $this->view->put('MSG', MessageHelper::display($this->lang['modules.not_installed_module'], MessageHelper::NOTICE, 4));
             }
         } else {
             $this->view->put('MSG', MessageHelper::display($this->lang['modules.upload_error'], MessageHelper::NOTICE, 4));
         }
     }
 }
 private function install_modules(array $modules_to_install)
 {
     foreach ($modules_to_install as $module_name) {
         ModulesManager::install_module($module_name, true, false);
     }
     if (ServerEnvironmentConfig::load()->is_url_rewriting_enabled()) {
         HtaccessFileCache::regenerate();
     }
 }
Пример #17
0
 /**
  * @desc Gets the name of the module from which the notification.
  * @return string The module name.
  */
 public function get_module_name()
 {
     if (!empty($this->module_id)) {
         $module = ModulesManager::get_module($this->module_id);
         return $module ? $module->get_configuration()->get_name() : '';
     } else {
         return '';
     }
 }
Пример #18
0
 }
 $pagination = new ModulePagination($page, $num_contributions, CONTRIBUTIONS_PER_PAGE);
 $pagination->set_url(new Url('/user/contribution_panel.php?p=%d&criteria=' . $criteria . '&order=' . $order));
 if ($pagination->current_page_is_empty() && $page > 1) {
     $error_controller = PHPBoostErrors::unexisting_page();
     DispatchManager::redirect($error_controller);
 }
 if ($num_contributions > 1) {
     $template->put_all(array('C_PAGINATION' => $pagination->has_several_pages(), 'PAGINATION' => $pagination->display()));
 } else {
     $template->put_all(array('C_NO_CONTRIBUTION' => true, 'L_NO_CONTRIBUTION_TO_DISPLAY' => LangLoader::get_message('no_item_now', 'common')));
 }
 //Liste des modules proposant de contribuer
 define('NUMBER_OF_MODULES_PER_LINE', 4);
 $i_module = 0;
 $modules = ModulesManager::get_activated_modules_map_sorted_by_localized_name();
 foreach ($modules as $name => $module) {
     $contribution_interface = $module->get_configuration()->get_contribution_interface();
     $authorized = true;
     $authorizations_class = ucfirst($module->get_id()) . 'AuthorizationsService';
     if (class_exists($authorizations_class) && method_exists($authorizations_class, 'check_authorizations') && method_exists($authorizations_class, 'contribution') && !$authorizations_class::check_authorizations()->contribution()) {
         $authorized = false;
     }
     if (!empty($contribution_interface) && $authorized) {
         if ($i_module % NUMBER_OF_MODULES_PER_LINE == 0) {
             $template->assign_block_vars('row', array());
         }
         $template->assign_block_vars('row.module', array('WIDTH' => (int) (100.0 / NUMBER_OF_MODULES_PER_LINE), 'U_MODULE_LINK' => PATH_TO_ROOT . '/' . $module->get_id() . '/' . url($contribution_interface), 'MODULE_ID' => $module->get_id(), 'MODULE_NAME' => $module->get_configuration()->get_name(), 'LINK_TITLE' => sprintf($LANG['contribute_in_module_name'], $module->get_configuration()->get_name())));
         $i_module++;
     }
 }
Пример #19
0
 private static function optimize_database_tables(Date $current_date)
 {
     if (ModulesManager::is_module_installed('database')) {
         $database_config = DatabaseConfig::load();
         if ($database_config->is_database_tables_optimization_enabled()) {
             if ($database_config->get_database_tables_optimization_day() == 7 && $current_date->get_day() == 1 || $database_config->get_database_tables_optimization_day() == $current_date->get_day_of_week()) {
                 $tables_to_optimize = array();
                 foreach (PersistenceContext::get_dbms_utils()->list_and_desc_tables(true) as $key => $table_info) {
                     if (NumberHelper::round($table_info['data_free'] / 1024, 1) != 0) {
                         $tables_to_optimize[] = $key;
                     }
                 }
                 PersistenceContext::get_dbms_utils()->optimize($tables_to_optimize);
             }
         }
     }
 }
Пример #20
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);
     }
 }
 private function list_files($theme_selected)
 {
     $files = array();
     $files[] = new FormFieldSelectChoiceOption('--', '');
     $folder = new Folder(PATH_TO_ROOT . $this->templates_path . $theme_selected . $this->tpl_files_path);
     foreach ($folder->get_files('`\\.tpl$`') as $file) {
         $files[] = new FormFieldSelectChoiceOption($file->get_name(), $file->get_name_without_extension());
     }
     foreach (ModulesManager::get_activated_modules_map_sorted_by_localized_name() as $id => $module) {
         $folder = new Folder(PATH_TO_ROOT . '/' . $module->get_id() . '/templates');
         if ($folder->exists()) {
             foreach ($folder->get_files('`\\.tpl$`') as $file) {
                 $files[] = new FormFieldSelectChoiceOption(LangLoader::get_message('module', 'admin-modules-common') . ' ' . ModulesManager::get_module($module->get_id())->get_configuration()->get_name() . ' : ' . $file->get_name(), $module->get_id() . '/' . $file->get_name_without_extension());
             }
         }
     }
     $folder = new Folder(PATH_TO_ROOT . '/user/templates');
     if ($folder->exists()) {
         foreach ($folder->get_files('`\\.tpl$`') as $file) {
             $files[] = new FormFieldSelectChoiceOption(LangLoader::get_message('users', 'user-common') . ' : ' . $file->get_name(), 'user/' . $file->get_name_without_extension());
         }
     }
     return $files;
 }
 private function save()
 {
     $this->config->set_items_number_per_page($this->form->get_value('items_number_per_page'));
     if ($this->form->get_value('max_messages_number_enabled')) {
         $this->config->enable_max_messages_number();
         $this->config->set_max_messages_number($this->form->get_value('max_messages_number'));
     } else {
         $this->config->disable_max_messages_number();
     }
     $this->config->set_max_messages_number($this->form->get_value('max_messages_number'));
     if ($this->form->get_value('max_links_number_per_message_enabled')) {
         $this->config->enable_max_links_number_per_message();
         $this->config->set_max_links_number_per_message($this->form->get_value('max_links_number_per_message'));
     } else {
         $this->config->disable_max_links_number_per_message();
     }
     $forbidden_formatting_tags = array();
     foreach ($this->form->get_value('forbidden_formatting_tags') as $field => $option) {
         $forbidden_formatting_tags[] = $option->get_raw_value();
     }
     $this->config->set_forbidden_formatting_tags($forbidden_formatting_tags);
     if ($this->form->get_value('automatic_refresh_enabled')) {
         $this->config->enable_automatic_refresh();
         $this->config->set_refresh_delay($this->form->get_value('refresh_delay') * 60000);
     } else {
         $this->config->disable_automatic_refresh();
     }
     if ($this->form->get_value('date_displayed')) {
         $this->config->display_date();
     } else {
         $this->config->hide_date();
     }
     if ($this->form->get_value('shout_max_messages_number_enabled')) {
         $this->config->enable_shout_max_messages_number();
         $this->config->set_shout_max_messages_number($this->form->get_value('shout_max_messages_number'));
     } else {
         $this->config->disable_shout_max_messages_number();
     }
     if (ModulesManager::is_module_installed('BBCode')) {
         if ($this->form->get_value('shout_bbcode_enabled')) {
             $this->config->enable_shout_bbcode();
         } else {
             $this->config->disable_shout_bbcode();
         }
     }
     if ($this->form->get_value('validation_onkeypress_enter_enabled')) {
         $this->config->enable_validation_onkeypress_enter();
     } else {
         $this->config->disable_validation_onkeypress_enter();
     }
     $this->config->set_authorizations($this->form->get_value('authorizations')->build_auth_array());
     ShoutboxConfig::save();
 }
Пример #23
0
 /**
  * @desc Adds to the site map all maps of the installed modules
  * @param int $auth_mode AUTH_GUEST or AUTH_USERS, it depends if you want to display only the public pages or also the private ones.
  */
 private function build_modules_maps($auth_mode = self::AUTH_PUBLIC)
 {
     $providers = AppContext::get_extension_provider_service()->get_providers(SitemapExtensionPoint::EXTENSION_POINT);
     foreach (ModulesManager::get_installed_modules_map_sorted_by_localized_name() as $id => $module) {
         if (array_key_exists($module->get_id(), $providers)) {
             $sitemap_provider = $providers[$module->get_id()]->sitemap();
             if ($auth_mode == self::AUTH_PUBLIC) {
                 $module_map = $sitemap_provider->get_public_sitemap();
             } else {
                 $module_map = $sitemap_provider->get_user_sitemap();
             }
             $this->add($module_map);
         }
     }
 }
 private function upload_module()
 {
     $modules_folder = PATH_TO_ROOT . '/';
     if (!is_writable($modules_folder)) {
         $is_writable = @chmod($dir, 0755);
     } else {
         $is_writable = true;
     }
     if ($is_writable) {
         $uploaded_file = $this->form->get_value('file');
         if ($uploaded_file !== null) {
             $upload = new Upload($modules_folder);
             if ($upload->file('upload_module_file', '`([a-z0-9()_-])+\\.(gz|zip)+$`i')) {
                 $archive = $modules_folder . $upload->get_filename();
                 if ($upload->get_extension() == 'gz') {
                     include_once PATH_TO_ROOT . '/kernel/lib/php/pcl/pcltar.lib.php';
                     $archive_content = PclTarList($upload->get_filename());
                 } else {
                     include_once PATH_TO_ROOT . '/kernel/lib/php/pcl/pclzip.lib.php';
                     $zip = new PclZip($archive);
                     $archive_content = $zip->listContent();
                 }
                 $archive_root_content = array();
                 $required_files = array('/config.ini', '/index.php');
                 foreach ($archive_content as $element) {
                     if (substr($element['filename'], -1) == '/') {
                         $element['filename'] = substr($element['filename'], 0, -1);
                     }
                     if (substr_count($element['filename'], '/') == 0) {
                         $archive_root_content[] = array('filename' => $element['filename'], 'folder' => isset($element['folder']) && $element['folder'] == 1 || isset($element['typeflag']) && $element['typeflag'] == 5);
                     }
                     if (isset($archive_root_content[0])) {
                         $name_in_archive = str_replace($archive_root_content[0]['filename'] . '/', '/', $element['filename']);
                         if (in_array($name_in_archive, $required_files)) {
                             unset($required_files[array_search($name_in_archive, $required_files)]);
                         }
                     }
                 }
                 if (count($archive_root_content) == 1 && $archive_root_content[0]['folder'] && empty($required_files)) {
                     $module_id = $archive_root_content[0]['filename'];
                     if (!ModulesManager::is_module_installed($module_id)) {
                         if ($upload->get_extension() == 'gz') {
                             PclTarExtract($upload->get_filename(), $modules_folder);
                         } else {
                             $zip->extract(PCLZIP_OPT_PATH, $modules_folder, PCLZIP_OPT_SET_CHMOD, 0755);
                         }
                         $this->install_module($module_id, true);
                     } else {
                         $this->view->put('MSG', MessageHelper::display(LangLoader::get_message('element.already_exists', 'status-messages-common'), MessageHelper::NOTICE));
                     }
                 } else {
                     $this->view->put('MSG', MessageHelper::display(LangLoader::get_message('error.invalid_archive_content', 'status-messages-common'), MessageHelper::NOTICE));
                 }
                 $uploaded_file = new File($archive);
                 $uploaded_file->delete();
             } else {
                 $this->view->put('MSG', MessageHelper::display($this->lang['modules.upload_invalid_format'], MessageHelper::NOTICE));
             }
         } else {
             $this->view->put('MSG', MessageHelper::display($this->lang['modules.upload_error'], MessageHelper::NOTICE));
         }
     }
 }
Пример #25
0
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 ###################################################*/
if (defined('PHPBOOST') !== true) {
    exit;
}
$env = new AdminDisplayGraphicalEnvironment();
Environment::set_graphical_environment($env);
if (!defined('TITLE')) {
    define('TITLE', $LANG['unknown']);
}
$module_id = Environment::get_running_module_name();
$section = '';
if (!Environment::home_page_running() && ModulesManager::is_module_installed($module_id)) {
    $section = ModulesManager::get_module($module_id)->get_configuration()->get_name();
}
$env->set_page_title(TITLE, $section);
ob_start();
 private function list_modules_home_page()
 {
     $providers = array_keys(AppContext::get_extension_provider_service()->get_providers(HomePageExtensionPoint::EXTENSION_POINT));
     $options = array(new FormFieldSelectChoiceOption($this->lang['general-config.other_start_page'], 'other'));
     $installed_modules = ModulesManager::get_installed_modules_map_sorted_by_localized_name();
     foreach ($installed_modules as $id => $module) {
         if (in_array($module->get_id(), $providers)) {
             $options[] = new FormFieldSelectChoiceOption($module->get_configuration()->get_name(), $module->get_id());
         }
     }
     if (empty($options)) {
         $options[] = new FormFieldSelectChoiceOption($this->lang['no_module_starteable'], '');
     }
     return $options;
 }
 private function get_array_select_type()
 {
     $select = array();
     $modules = $this->get_extended_fields_class_name();
     foreach ($modules as $module => $files) {
         if (count($modules) > 1) {
             if ($module == 'kernel') {
                 $kernel_select = array();
                 foreach ($files as $field_type) {
                     $kernel_select[] = new FormFieldSelectChoiceOption($field_type->get_name(), get_class($field_type));
                 }
                 $select[] = new FormFieldSelectChoiceGroupOption($this->lang['default-field'], $kernel_select);
             } else {
                 $module_select = array();
                 foreach ($files as $field_type) {
                     $module_select[] = new FormFieldSelectChoiceOption($field_type->get_name(), get_class($field_type));
                 }
                 $module_name = ModulesManager::get_module($module)->get_configuration()->get_name();
                 $select[] = new FormFieldSelectChoiceGroupOption($module_name, $module_select);
             }
         } else {
             foreach ($files as $field_type) {
                 $select[] = new FormFieldSelectChoiceOption($field_type->get_name(), get_class($field_type));
             }
         }
     }
     return $select;
 }
Пример #28
0
    if ($search_in != 'all') {
        if (isset($used_modules[$search_in]) && isset($modules_args[$search_in])) {
            $used_modules = array($search_in => $used_modules[$search_in]);
            $modules_args = array($search_in => $modules_args[$search_in]);
        } else {
            $used_modules = array();
            $modules_args = array();
        }
    } else {
        // We remove modules that we're not searching in
        foreach ($modules_args as $module_id => $module_args) {
            if (!$query_mode && (!in_array($module_id, $selected_modules) || !isset($modules_args[$module_id]))) {
                unset($modules_args[$module_id]);
                unset($used_modules[$module_id]);
            }
        }
    }
    // Génération des résultats et passage aux templates
    $nbResults = get_search_results($search, $used_modules, $modules_args, $results, $idsSearch);
    foreach ($used_modules as $module_id => $extension_point) {
        $tpl->assign_block_vars('results', array('MODULE_NAME' => $module_id, 'L_MODULE_NAME' => ucfirst(ModulesManager::get_module($module_id)->get_configuration()->get_name()), 'ID_SEARCH' => $idsSearch[$module_id]));
    }
    $all_html_result = '';
    if ($nbResults > 0) {
        get_html_results($results, $all_html_result, $search_in);
    }
    $tpl->assign_vars(array('NB_RESULTS_PER_PAGE' => NB_RESULTS_PER_PAGE, 'L_TITLE_ALL_RESULTS' => $LANG['title_all_results'], 'L_RESULTS' => $LANG['results'], 'L_RESULTS_CHOICE' => $LANG['results_choice'], 'L_PRINT' => $LANG['print'], 'L_NB_RESULTS_FOUND' => $nbResults > 1 ? $LANG['nb_results_found'] : ($nbResults == 0 ? $LANG['no_results_found'] : $LANG['one_result_found']), 'L_SEARCH_RESULTS' => $LANG['search_results'], 'NB_RESULTS' => $nbResults, 'ALL_RESULTS' => $all_html_result, 'SEARCH_IN' => $search_in, 'C_SIMPLE_SEARCH' => $search_in == 'all'));
    $tpl->display();
}
//--------------------------------------------------------------------- Footer
require_once '../kernel/footer.php';
Пример #29
0
{
    return get_feeds_children($feed_cat->get_children(), $module_id, $feed_type, $feed_url_edit, $level + 1);
}
function get_feeds_children(array $children, $module_id, $feed_type, $feed_url_edit = '', $level)
{
    if (!empty($children)) {
        foreach ($children as $id => $feed_cat) {
            $url = $feed_cat->get_url($feed_type);
            $urls[] = array('name' => $feed_cat->get_category_name(), 'url' => $url, 'level' => $level, 'feed_name' => $feed_type, 'selected' => $feed_url_edit == $url);
        }
        return array_merge($urls, get_feeds_children($feed_cat->get_children(), $module_id, $feed_type, $feed_url_edit, $level + 1));
    }
    return array();
}
$feeds_modules = AppContext::get_extension_provider_service()->get_providers(FeedProvider::EXTENSION_POINT);
foreach (ModulesManager::get_installed_modules_map_sorted_by_localized_name() as $id => $module) {
    if (array_key_exists($module->get_id(), $feeds_modules)) {
        $list = $feeds_modules[$module->get_id()]->get_extension_point(FeedProvider::EXTENSION_POINT);
        $list = $list->get_feeds_list();
        foreach ($list->get_feeds_list() as $feed_type => $object) {
            $urls = get_feeds($object, $module->get_id(), $feed_type, $feed_url);
            $root[0] = array('name' => $object->get_category_name(), 'url' => $object->get_url($feed_type), 'level' => 0, 'feed_name' => null, 'selected' => $feed_url == $object->get_url($feed_type));
        }
        $urls = array_merge($root, $urls);
        $tpl->assign_block_vars('modules', array('NAME' => ucfirst($module->get_configuration()->get_name())));
        foreach ($urls as $url) {
            $tpl->assign_block_vars('modules.feeds_urls', array('URL' => $url['url'], 'NAME' => $url['name'], 'SPACE' => str_repeat('--', $url['level']), 'FEED_NAME' => $url['feed_name'] != 'master' ? $url['feed_name'] : null, 'SELECTED' => $url['selected'] ? ' selected="selected"' : ''));
        }
    }
}
$locations = '';
Пример #30
0
| @copyright     ©Andrey Brykin 2010-2013        |
\-----------------------------------------------*/
/*-----------------------------------------------\
| 												 |
|  any partial or not partial extension          |
|  CMS AtomX,without the consent of the          |
|  author, is illegal                            |
|------------------------------------------------|
|  Любое распространение                         |
|  CMS AtomX или ее частей,                      |
|  без согласия автора, является не законным     |
\-----------------------------------------------*/
include_once '../sys/boot.php';
include_once ROOT . '/admin/inc/adm_boot.php';
// Know module
$ModulesManager = new ModulesManager();
$allow_modules = $ModulesManager->getAllowedModules('addFields');
if (empty($_GET['m']) || !in_array($_GET['m'], $allow_modules)) {
    $_GET['m'] = 'news';
    $_GET['ac'] = 'index';
}
$pageTitle = __(ucfirst($_GET['m'])) . ' - ' . __('Additional fields');
// Know action
if (!isset($_GET['ac'])) {
    $_GET['ac'] = 'index';
}
$permis = array('add', 'del', 'index', 'edit');
if (!in_array($_GET['ac'], $permis)) {
    $_GET['ac'] = 'index';
}
switch ($_GET['ac']) {