|
From: <dac...@us...> - 2007-09-27 07:09:22
|
Revision: 66
http://thevr.svn.sourceforge.net/thevr/?rev=66&view=rev
Author: dachebodt
Date: 2007-09-27 00:09:25 -0700 (Thu, 27 Sep 2007)
Log Message:
-----------
+ Major changes to custom style module
+ A few tweaks to forum, search, content and zebra modules
Modified Paths:
--------------
mods/cms/trunk/adm/index.php
mods/cms/trunk/common.php
mods/cms/trunk/includes/functions.php
mods/cms/trunk/includes/functions_display.php
mods/cms/trunk/includes/functions_module.php
mods/cms/trunk/modules/comments/functions_comments.php
mods/cms/trunk/modules/content/cms_content.php
mods/cms/trunk/modules/core/language/en/core.php
mods/cms/trunk/modules/cs/custom_style.php
mods/cms/trunk/modules/cs/custom_style_config.php
mods/cms/trunk/modules/cs/custom_style_grids.php
mods/cms/trunk/modules/cs/functions_blocks_admin.php
mods/cms/trunk/modules/cs/functions_style_generator.php
mods/cms/trunk/modules/cs/gcp_cs.php
mods/cms/trunk/modules/cs/info/acp_cs.php
mods/cms/trunk/modules/cs/info/pro_cs.php
mods/cms/trunk/modules/cs/language/en/common.php
mods/cms/trunk/modules/cs/language/en/style_generator.php
mods/cms/trunk/modules/cs/pro_cs.php
mods/cms/trunk/modules/cs/template/cs.css
mods/cms/trunk/modules/cs/template/stylegenerator.css
mods/cms/trunk/modules/cs/ucp_cs.php
mods/cms/trunk/modules/events/info/grp_events.php
mods/cms/trunk/modules/forums1/info/grp_forums.php
mods/cms/trunk/modules/zebra/pro_zebra.php
mods/cms/trunk/modules/zebra/template/balloons.css
mods/cms/trunk/styles/prosilver/template/cs_generator.html
mods/cms/trunk/styles/prosilver/template/custom_style_view.html
mods/cms/trunk/styles/prosilver/template/overall_header.html
Added Paths:
-----------
mods/cms/trunk/modules/cs/images/color.gif
mods/cms/trunk/modules/cs/info/grp_cs.php
mods/cms/trunk/modules/cs/style.php
mods/cms/trunk/modules/cs/template/stylesheet.css
Modified: mods/cms/trunk/adm/index.php
===================================================================
--- mods/cms/trunk/adm/index.php 2007-09-19 06:04:46 UTC (rev 65)
+++ mods/cms/trunk/adm/index.php 2007-09-27 07:09:25 UTC (rev 66)
@@ -1,519 +1,519 @@
-<?php
-/**
-*
-* @package acp
-* @version $Id: index.php,v 1.70 2007/08/24 14:06:54 acydburn Exp $
-* @copyright (c) 2005 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
-*
-*/
-
-/**
-*/
-define('IN_PHPBB', true);
-define('ADMIN_START', true);
-define('NEED_SID', true);
-
-// Include files
-$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../';
-$phpEx = substr(strrchr(__FILE__, '.'), 1);
-require($phpbb_root_path . 'common.' . $phpEx);
-require($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
-require($phpbb_root_path . 'includes/functions_module.' . $phpEx);
-
-// Start session management
-$user->session_begin();
-$auth->acl($user->data);
-$user->setup('acp/common');
-// End session management
-
-// Have they authenticated (again) as an admin for this session?
-if (!isset($user->data['session_admin']) || !$user->data['session_admin'])
-{
- login_box('', $user->lang['LOGIN_ADMIN_CONFIRM'], $user->lang['LOGIN_ADMIN_SUCCESS'], true, false);
-}
-
-// Is user any type of admin? No, then stop here, each script needs to
-// check specific permissions but this is a catchall
-if (!$auth->acl_get('a_'))
-{
- trigger_error('NO_ADMIN');
-}
-
-// We define the admin variables now, because the user is now able to use the admin related features...
-define('IN_ADMIN', true);
-$phpbb_admin_path = './';
-
-// Some oft used variables
-$safe_mode = (@ini_get('safe_mode') || @strtolower(ini_get('safe_mode')) == 'on') ? true : false;
-$file_uploads = (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on') ? true : false;
-$module_id = request_var('i', '');
-$mode = request_var('mode', '');
-
-// Set custom template for admin area
-$template->set_custom_template($phpbb_admin_path . 'style', 'admin');
-$template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style');
-
-// the acp template is never stored in the database
-$user->theme['template_storedb'] = false;
-
-// Instantiate new module
-$module = new p_master();
-
-// Instantiate module system and generate list of available modules
-$module->list_modules('acp');
-
-// Select the active module
-$module->set_active($module_id, $mode);
-
-// Assign data to the template engine for the list of modules
-// We do this before loading the active module for correct menu display in trigger_error
-$module->assign_tpl_vars(append_sid("{$phpbb_admin_path}index.$phpEx"));
-
-// Set custom template path
-$tpl_path = $phpbb_root_path . "modules/$module->p_dir/template";
-$mtemplate->set_custom_template($tpl_path, $module->p_dir);
-
-// Load and execute the relevant module
-$module->load_active();
-
-// Generate the page
-adm_page_header($module->get_page_title());
-
-$template->set_filenames(array(
- 'body' => $module->get_tpl_name())
-);
-
-adm_page_footer();
-
-/**
-* Header for acp pages
-*/
-function adm_page_header($page_title)
-{
- global $config, $db, $user, $template;
- global $phpbb_root_path, $phpbb_admin_path, $phpEx, $SID, $_SID;
-
- if (defined('HEADER_INC'))
- {
- return;
- }
-
- define('HEADER_INC', true);
-
- // gzip_compression
- if ($config['gzip_compress'])
- {
- if (@extension_loaded('zlib') && !headers_sent())
- {
- ob_start('ob_gzhandler');
- }
- }
-
- $template->assign_vars(array(
- 'PAGE_TITLE' => $page_title,
- 'USERNAME' => $user->data['username'],
-
- 'SID' => $SID,
- '_SID' => $_SID,
- 'SESSION_ID' => $user->session_id,
- 'ROOT_PATH' => $phpbb_admin_path,
-
- 'U_LOGOUT' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=logout'),
- 'U_ADM_INDEX' => append_sid("{$phpbb_admin_path}index.$phpEx"),
- 'U_INDEX' => append_sid("{$phpbb_root_path}index.$phpEx"),
-
- 'T_IMAGES_PATH' => "{$phpbb_root_path}images/",
- 'T_SMILIES_PATH' => "{$phpbb_root_path}{$config['smilies_path']}/",
- 'T_AVATAR_PATH' => "{$phpbb_root_path}{$config['avatar_path']}/",
- 'T_AVATAR_GALLERY_PATH' => "{$phpbb_root_path}{$config['avatar_gallery_path']}/",
- 'T_ICONS_PATH' => "{$phpbb_root_path}{$config['icons_path']}/",
- 'T_RANKS_PATH' => "{$phpbb_root_path}{$config['ranks_path']}/",
- 'T_UPLOAD_PATH' => "{$phpbb_root_path}{$config['upload_path']}/",
-
- 'ICON_MOVE_UP' => '<img src="' . $phpbb_admin_path . 'images/icon_up.gif" alt="' . $user->lang['MOVE_UP'] . '" title="' . $user->lang['MOVE_UP'] . '" />',
- 'ICON_MOVE_UP_DISABLED' => '<img src="' . $phpbb_admin_path . 'images/icon_up_disabled.gif" alt="' . $user->lang['MOVE_UP'] . '" title="' . $user->lang['MOVE_UP'] . '" />',
- 'ICON_MOVE_DOWN' => '<img src="' . $phpbb_admin_path . 'images/icon_down.gif" alt="' . $user->lang['MOVE_DOWN'] . '" title="' . $user->lang['MOVE_DOWN'] . '" />',
- 'ICON_MOVE_DOWN_DISABLED' => '<img src="' . $phpbb_admin_path . 'images/icon_down_disabled.gif" alt="' . $user->lang['MOVE_DOWN'] . '" title="' . $user->lang['MOVE_DOWN'] . '" />',
- 'ICON_EDIT' => '<img src="' . $phpbb_admin_path . 'images/icon_edit.gif" alt="' . $user->lang['EDIT'] . '" title="' . $user->lang['EDIT'] . '" />',
- 'ICON_EDIT_DISABLED' => '<img src="' . $phpbb_admin_path . 'images/icon_edit_disabled.gif" alt="' . $user->lang['EDIT'] . '" title="' . $user->lang['EDIT'] . '" />',
- 'ICON_DELETE' => '<img src="' . $phpbb_admin_path . 'images/icon_delete.gif" alt="' . $user->lang['DELETE'] . '" title="' . $user->lang['DELETE'] . '" />',
- 'ICON_DELETE_DISABLED' => '<img src="' . $phpbb_admin_path . 'images/icon_delete_disabled.gif" alt="' . $user->lang['DELETE'] . '" title="' . $user->lang['DELETE'] . '" />',
- 'ICON_SYNC' => '<img src="' . $phpbb_admin_path . 'images/icon_sync.gif" alt="' . $user->lang['RESYNC'] . '" title="' . $user->lang['RESYNC'] . '" />',
- 'ICON_SYNC_DISABLED' => '<img src="' . $phpbb_admin_path . 'images/icon_sync_disabled.gif" alt="' . $user->lang['RESYNC'] . '" title="' . $user->lang['RESYNC'] . '" />',
-
- 'S_USER_LANG' => $user->lang['USER_LANG'],
- 'S_CONTENT_DIRECTION' => $user->lang['DIRECTION'],
- 'S_CONTENT_ENCODING' => 'UTF-8',
- 'S_CONTENT_FLOW_BEGIN' => ($user->lang['DIRECTION'] == 'ltr') ? 'left' : 'right',
- 'S_CONTENT_FLOW_END' => ($user->lang['DIRECTION'] == 'ltr') ? 'right' : 'left',
- ));
-
- // application/xhtml+xml not used because of IE
- header('Content-type: text/html; charset=UTF-8');
-
- header('Cache-Control: private, no-cache="set-cookie"');
- header('Expires: 0');
- header('Pragma: no-cache');
-
- return;
-}
-
-/**
-* Page footer for acp pages
-*/
-function adm_page_footer($copyright_html = true)
-{
- global $db, $config, $template, $user, $auth, $cache;
- global $starttime, $phpbb_root_path, $phpbb_admin_path, $phpEx;
-
- // Output page creation time
- if (defined('DEBUG'))
- {
- $mtime = explode(' ', microtime());
- $totaltime = $mtime[0] + $mtime[1] - $starttime;
-
- if (!empty($_REQUEST['explain']) && $auth->acl_get('a_') && defined('DEBUG_EXTRA') && method_exists($db, 'sql_report'))
- {
- $db->sql_report('display');
- }
-
- $debug_output = sprintf('Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . (($config['gzip_compress']) ? 'On' : 'Off') . (($user->load) ? ' | Load : ' . $user->load : ''), $totaltime);
-
- if ($auth->acl_get('a_') && defined('DEBUG_EXTRA'))
- {
- if (function_exists('memory_get_usage'))
- {
- if ($memory_usage = memory_get_usage())
- {
- global $base_memory_usage;
- $memory_usage -= $base_memory_usage;
- $memory_usage = ($memory_usage >= 1048576) ? round((round($memory_usage / 1048576 * 100) / 100), 2) . ' ' . $user->lang['MB'] : (($memory_usage >= 1024) ? round((round($memory_usage / 1024 * 100) / 100), 2) . ' ' . $user->lang['KB'] : $memory_usage . ' ' . $user->lang['BYTES']);
-
- $debug_output .= ' | Memory Usage: ' . $memory_usage;
- }
- }
-
- $debug_output .= ' | <a href="' . build_url() . '&explain=1">Explain</a>';
- }
- }
-
- $template->assign_vars(array(
- 'DEBUG_OUTPUT' => (defined('DEBUG')) ? $debug_output : '',
- 'TRANSLATION_INFO' => (!empty($user->lang['TRANSLATION_INFO'])) ? $user->lang['TRANSLATION_INFO'] : '',
- 'S_COPYRIGHT_HTML' => $copyright_html,
- 'VERSION' => $config['version'])
- );
-
- $template->display('body');
-
- garbage_collection();
-
- if (!defined('PHPBB_EMBEDDED'))
- {
- exit;
- }
-}
-
-/**
-* Generate back link for acp pages
-*/
-function adm_back_link($u_action)
-{
- global $user;
- return '<br /><br /><a href="' . $u_action . '">« ' . $user->lang['BACK_TO_PREV'] . '</a>';
-}
-
-/**
-* Build select field options in acp pages
-*/
-function build_select($option_ary, $option_default = false)
-{
- global $user;
-
- $html = '';
- foreach ($option_ary as $value => $title)
- {
- $selected = ($option_default !== false && $value == $option_default) ? ' selected="selected"' : '';
- $html .= '<option value="' . $value . '"' . $selected . '>' . $user->lang[$title] . '</option>';
- }
-
- return $html;
-}
-
-/**
-* Build radio fields in acp pages
-*/
-function h_radio($name, &$input_ary, $input_default = false, $id = false, $key = false)
-{
- global $user;
-
- $html = '';
- $id_assigned = false;
- foreach ($input_ary as $value => $title)
- {
- $selected = ($input_default !== false && $value == $input_default) ? ' checked="checked"' : '';
- $html .= '<label><input type="radio" name="' . $name . '"' . (($id && !$id_assigned) ? ' id="' . $id . '"' : '') . ' value="' . $value . '"' . $selected . (($key) ? ' accesskey="' . $key . '"' : '') . ' class="radio" /> ' . $user->lang[$title] . '</label>';
- $id_assigned = true;
- }
-
- return $html;
-}
-
-/**
-* Build configuration template for acp configuration pages
-*/
-function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars)
-{
- global $user, $module;
-
- $tpl = '';
- $name = 'config[' . $config_key . ']';
-
- switch ($tpl_type[0])
- {
- case 'text':
- case 'password':
- $size = (int) $tpl_type[1];
- $maxlength = (int) $tpl_type[2];
-
- $tpl = '<input id="' . $key . '" type="' . $tpl_type[0] . '"' . (($size) ? ' size="' . $size . '"' : '') . ' maxlength="' . (($maxlength) ? $maxlength : 255) . '" name="' . $name . '" value="' . $new[$config_key] . '" />';
- break;
-
- case 'dimension':
- $size = (int) $tpl_type[1];
- $maxlength = (int) $tpl_type[2];
-
- $tpl = '<input id="' . $key . '" type="text"' . (($size) ? ' size="' . $size . '"' : '') . ' maxlength="' . (($maxlength) ? $maxlength : 255) . '" name="config[' . $config_key . '_height]" value="' . $new[$config_key . '_height'] . '" /> x <input type="text"' . (($size) ? ' size="' . $size . '"' : '') . ' maxlength="' . (($maxlength) ? $maxlength : 255) . '" name="config[' . $config_key . '_width]" value="' . $new[$config_key . '_width'] . '" />';
- break;
-
- case 'textarea':
- $rows = (int) $tpl_type[1];
- $cols = (int) $tpl_type[2];
-
- $tpl = '<textarea id="' . $key . '" name="' . $name . '" rows="' . $rows . '" cols="' . $cols . '">' . $new[$config_key] . '</textarea>';
- break;
-
- case 'radio':
- $key_yes = ($new[$config_key]) ? ' checked="checked"' : '';
- $key_no = (!$new[$config_key]) ? ' checked="checked"' : '';
-
- $tpl_type_cond = explode('_', $tpl_type[1]);
- $type_no = ($tpl_type_cond[0] == 'disabled' || $tpl_type_cond[0] == 'enabled') ? false : true;
-
- $tpl_no = '<label><input type="radio" name="' . $name . '" value="0"' . $key_no . ' class="radio" /> ' . (($type_no) ? $user->lang['NO'] : $user->lang['DISABLED']) . '</label>';
- $tpl_yes = '<label><input type="radio" id="' . $key . '" name="' . $name . '" value="1"' . $key_yes . ' class="radio" /> ' . (($type_no) ? $user->lang['YES'] : $user->lang['ENABLED']) . '</label>';
-
- $tpl = ($tpl_type_cond[0] == 'yes' || $tpl_type_cond[0] == 'enabled') ? $tpl_yes . $tpl_no : $tpl_no . $tpl_yes;
- break;
-
- case 'select':
- case 'custom':
-
- $return = '';
-
- if (isset($vars['method']))
- {
- $call = array($module->module, $vars['method']);
- }
- else if (isset($vars['function']))
- {
- $call = $vars['function'];
- }
- else
- {
- break;
- }
-
- if (isset($vars['params']))
- {
- $args = array();
- foreach ($vars['params'] as $value)
- {
- switch ($value)
- {
- case '{CONFIG_VALUE}':
- $value = $new[$config_key];
- break;
-
- case '{KEY}':
- $value = $key;
- break;
- }
-
- $args[] = $value;
- }
- }
- else
- {
- $args = array($new[$config_key], $key);
- }
-
- $return = call_user_func_array($call, $args);
-
- if ($tpl_type[0] == 'select')
- {
- $tpl = '<select id="' . $key . '" name="' . $name . '">' . $return . '</select>';
- }
- else
- {
- $tpl = $return;
- }
-
- break;
-
- default:
- break;
- }
-
- if (isset($vars['append']))
- {
- $tpl .= $vars['append'];
- }
-
- return $tpl;
-}
-
-/**
-* Going through a config array and validate values, writing errors to $error.
-*/
-function validate_config_vars($config_vars, &$cfg_array, &$error)
-{
- global $phpbb_root_path, $user;
-
- foreach ($config_vars as $config_name => $config_definition)
- {
- if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false)
- {
- continue;
- }
-
- if (!isset($config_definition['validate']))
- {
- continue;
- }
-
- // Validate a bit. ;) String is already checked through request_var(), therefore we do not check this again
- switch ($config_definition['validate'])
- {
- case 'bool':
- $cfg_array[$config_name] = ($cfg_array[$config_name]) ? 1 : 0;
- break;
-
- case 'int':
- $cfg_array[$config_name] = (int) $cfg_array[$config_name];
- break;
-
- // Absolute path
- case 'script_path':
- if (!$cfg_array[$config_name])
- {
- break;
- }
-
- $destination = str_replace('\\', '/', $cfg_array[$config_name]);
-
- if ($destination !== '/')
- {
- // Adjust destination path (no trailing slash)
- if (substr($destination, -1, 1) == '/')
- {
- $destination = substr($destination, 0, -1);
- }
-
- $destination = str_replace(array('../', './'), '', $destination);
-
- if ($destination[0] != '/')
- {
- $destination = '/' . $destination;
- }
- }
-
- $cfg_array[$config_name] = trim($destination);
-
- break;
-
- // Absolute path
- case 'lang':
- if (!$cfg_array[$config_name])
- {
- break;
- }
-
- $cfg_array[$config_name] = basename($cfg_array[$config_name]);
-
- if (!file_exists($phpbb_root_path . 'language/' . $cfg_array[$config_name] . '/'))
- {
- $error[] = $user->lang['WRONG_DATA_LANG'];
- }
- break;
-
- // Relative path (appended $phpbb_root_path)
- case 'rpath':
- case 'rwpath':
- if (!$cfg_array[$config_name])
- {
- break;
- }
-
- $destination = $cfg_array[$config_name];
-
- // Adjust destination path (no trailing slash)
- if (substr($destination, -1, 1) == '/' || substr($destination, -1, 1) == '\\')
- {
- $destination = substr($destination, 0, -1);
- }
-
- $destination = str_replace(array('../', '..\\', './', '.\\'), '', $destination);
- if ($destination && ($destination[0] == '/' || $destination[0] == "\\"))
- {
- $destination = '';
- }
-
- $cfg_array[$config_name] = trim($destination);
-
- // Path being relative (still prefixed by phpbb_root_path), but with the ability to escape the root dir...
- case 'path':
- case 'wpath':
-
- if (!$cfg_array[$config_name])
- {
- break;
- }
-
- $cfg_array[$config_name] = trim($cfg_array[$config_name]);
-
- // Make sure no NUL byte is present...
- if (strpos($cfg_array[$config_name], "\0") !== false || strpos($cfg_array[$config_name], '%00') !== false)
- {
- $cfg_array[$config_name] = '';
- break;
- }
-
- if (!file_exists($phpbb_root_path . $cfg_array[$config_name]))
- {
- $error[] = sprintf($user->lang['DIRECTORY_DOES_NOT_EXIST'], $cfg_array[$config_name]);
- }
-
- if (file_exists($phpbb_root_path . $cfg_array[$config_name]) && !is_dir($phpbb_root_path . $cfg_array[$config_name]))
- {
- $error[] = sprintf($user->lang['DIRECTORY_NOT_DIR'], $cfg_array[$config_name]);
- }
-
- // Check if the path is writable
- if ($config_definition['validate'] == 'wpath' || $config_definition['validate'] == 'rwpath')
- {
- if (file_exists($phpbb_root_path . $cfg_array[$config_name]) && !@is_writable($phpbb_root_path . $cfg_array[$config_name]))
- {
- $error[] = sprintf($user->lang['DIRECTORY_NOT_WRITABLE'], $cfg_array[$config_name]);
- }
- }
-
- break;
- }
- }
-
- return;
-}
-
+<?php
+/**
+*
+* @package acp
+* @version $Id: index.php,v 1.70 2007/08/24 14:06:54 acydburn Exp $
+* @copyright (c) 2005 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+/**
+*/
+define('IN_PHPBB', true);
+define('ADMIN_START', true);
+define('NEED_SID', true);
+
+// Include files
+$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../';
+$phpEx = substr(strrchr(__FILE__, '.'), 1);
+require($phpbb_root_path . 'common.' . $phpEx);
+require($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
+require($phpbb_root_path . 'includes/functions_module.' . $phpEx);
+
+// Start session management
+$user->session_begin();
+$auth->acl($user->data);
+$user->setup('acp/common');
+// End session management
+
+// Have they authenticated (again) as an admin for this session?
+if (!isset($user->data['session_admin']) || !$user->data['session_admin'])
+{
+ login_box('', $user->lang['LOGIN_ADMIN_CONFIRM'], $user->lang['LOGIN_ADMIN_SUCCESS'], true, false);
+}
+
+// Is user any type of admin? No, then stop here, each script needs to
+// check specific permissions but this is a catchall
+if (!$auth->acl_get('a_'))
+{
+ trigger_error('NO_ADMIN');
+}
+
+// We define the admin variables now, because the user is now able to use the admin related features...
+define('IN_ADMIN', true);
+$phpbb_admin_path = './';
+
+// Some oft used variables
+$safe_mode = (@ini_get('safe_mode') || @strtolower(ini_get('safe_mode')) == 'on') ? true : false;
+$file_uploads = (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on') ? true : false;
+$module_id = request_var('i', '');
+$mode = request_var('mode', '');
+
+// Set custom template for admin area
+$template->set_custom_template($phpbb_admin_path . 'style', 'admin');
+$template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style');
+
+// the acp template is never stored in the database
+$user->theme['template_storedb'] = false;
+
+// Instantiate new module
+$module = new p_master();
+
+// Instantiate module system and generate list of available modules
+$module->list_modules('acp');
+
+// Select the active module
+$module->set_active($module_id, $mode);
+
+// Assign data to the template engine for the list of modules
+// We do this before loading the active module for correct menu display in trigger_error
+$module->assign_tpl_vars(append_sid("{$phpbb_admin_path}index.$phpEx"));
+
+// Set custom template path
+$tpl_path = $phpbb_root_path . "modules/$module->p_dir/template";
+$mtemplate->set_custom_template($tpl_path, $module->p_dir);
+
+// Load and execute the relevant module
+$module->load_active();
+
+// Generate the page
+adm_page_header($module->get_page_title());
+
+$template->set_filenames(array(
+ 'body' => $module->get_tpl_name())
+);
+
+adm_page_footer();
+
+/**
+* Header for acp pages
+*/
+function adm_page_header($page_title)
+{
+ global $config, $db, $user, $template;
+ global $phpbb_root_path, $phpbb_admin_path, $phpEx, $SID, $_SID;
+
+ if (defined('HEADER_INC'))
+ {
+ return;
+ }
+
+ define('HEADER_INC', true);
+
+ // gzip_compression
+ if ($config['gzip_compress'])
+ {
+ if (@extension_loaded('zlib') && !headers_sent())
+ {
+ ob_start('ob_gzhandler');
+ }
+ }
+
+ $template->assign_vars(array(
+ 'PAGE_TITLE' => $page_title,
+ 'USERNAME' => $user->data['username'],
+
+ 'SID' => $SID,
+ '_SID' => $_SID,
+ 'SESSION_ID' => $user->session_id,
+ 'ROOT_PATH' => $phpbb_admin_path,
+
+ 'U_LOGOUT' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=logout'),
+ 'U_ADM_INDEX' => append_sid("{$phpbb_admin_path}index.$phpEx"),
+ 'U_INDEX' => append_sid("{$phpbb_root_path}index.$phpEx"),
+
+ 'T_IMAGES_PATH' => "{$phpbb_root_path}images/",
+ 'T_SMILIES_PATH' => "{$phpbb_root_path}{$config['smilies_path']}/",
+ 'T_AVATAR_PATH' => "{$phpbb_root_path}{$config['avatar_path']}/",
+ 'T_AVATAR_GALLERY_PATH' => "{$phpbb_root_path}{$config['avatar_gallery_path']}/",
+ 'T_ICONS_PATH' => "{$phpbb_root_path}{$config['icons_path']}/",
+ 'T_RANKS_PATH' => "{$phpbb_root_path}{$config['ranks_path']}/",
+ 'T_UPLOAD_PATH' => "{$phpbb_root_path}{$config['upload_path']}/",
+
+ 'ICON_MOVE_UP' => '<img src="' . $phpbb_admin_path . 'images/icon_up.gif" alt="' . $user->lang['MOVE_UP'] . '" title="' . $user->lang['MOVE_UP'] . '" />',
+ 'ICON_MOVE_UP_DISABLED' => '<img src="' . $phpbb_admin_path . 'images/icon_up_disabled.gif" alt="' . $user->lang['MOVE_UP'] . '" title="' . $user->lang['MOVE_UP'] . '" />',
+ 'ICON_MOVE_DOWN' => '<img src="' . $phpbb_admin_path . 'images/icon_down.gif" alt="' . $user->lang['MOVE_DOWN'] . '" title="' . $user->lang['MOVE_DOWN'] . '" />',
+ 'ICON_MOVE_DOWN_DISABLED' => '<img src="' . $phpbb_admin_path . 'images/icon_down_disabled.gif" alt="' . $user->lang['MOVE_DOWN'] . '" title="' . $user->lang['MOVE_DOWN'] . '" />',
+ 'ICON_EDIT' => '<img src="' . $phpbb_admin_path . 'images/icon_edit.gif" alt="' . $user->lang['EDIT'] . '" title="' . $user->lang['EDIT'] . '" />',
+ 'ICON_EDIT_DISABLED' => '<img src="' . $phpbb_admin_path . 'images/icon_edit_disabled.gif" alt="' . $user->lang['EDIT'] . '" title="' . $user->lang['EDIT'] . '" />',
+ 'ICON_DELETE' => '<img src="' . $phpbb_admin_path . 'images/icon_delete.gif" alt="' . $user->lang['DELETE'] . '" title="' . $user->lang['DELETE'] . '" />',
+ 'ICON_DELETE_DISABLED' => '<img src="' . $phpbb_admin_path . 'images/icon_delete_disabled.gif" alt="' . $user->lang['DELETE'] . '" title="' . $user->lang['DELETE'] . '" />',
+ 'ICON_SYNC' => '<img src="' . $phpbb_admin_path . 'images/icon_sync.gif" alt="' . $user->lang['RESYNC'] . '" title="' . $user->lang['RESYNC'] . '" />',
+ 'ICON_SYNC_DISABLED' => '<img src="' . $phpbb_admin_path . 'images/icon_sync_disabled.gif" alt="' . $user->lang['RESYNC'] . '" title="' . $user->lang['RESYNC'] . '" />',
+
+ 'S_USER_LANG' => $user->lang['USER_LANG'],
+ 'S_CONTENT_DIRECTION' => $user->lang['DIRECTION'],
+ 'S_CONTENT_ENCODING' => 'UTF-8',
+ 'S_CONTENT_FLOW_BEGIN' => ($user->lang['DIRECTION'] == 'ltr') ? 'left' : 'right',
+ 'S_CONTENT_FLOW_END' => ($user->lang['DIRECTION'] == 'ltr') ? 'right' : 'left',
+ ));
+
+ // application/xhtml+xml not used because of IE
+ header('Content-type: text/html; charset=UTF-8');
+
+ header('Cache-Control: private, no-cache="set-cookie"');
+ header('Expires: 0');
+ header('Pragma: no-cache');
+
+ return;
+}
+
+/**
+* Page footer for acp pages
+*/
+function adm_page_footer($copyright_html = true)
+{
+ global $db, $config, $template, $user, $auth, $cache;
+ global $starttime, $phpbb_root_path, $phpbb_admin_path, $phpEx;
+
+ // Output page creation time
+ if (defined('DEBUG'))
+ {
+ $mtime = explode(' ', microtime());
+ $totaltime = $mtime[0] + $mtime[1] - $starttime;
+
+ if (!empty($_REQUEST['explain']) && $auth->acl_get('a_') && defined('DEBUG_EXTRA') && method_exists($db, 'sql_report'))
+ {
+ $db->sql_report('display');
+ }
+
+ $debug_output = sprintf('Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . (($config['gzip_compress']) ? 'On' : 'Off') . (($user->load) ? ' | Load : ' . $user->load : ''), $totaltime);
+
+ if ($auth->acl_get('a_') && defined('DEBUG_EXTRA'))
+ {
+ if (function_exists('memory_get_usage'))
+ {
+ if ($memory_usage = memory_get_usage())
+ {
+ global $base_memory_usage;
+ $memory_usage -= $base_memory_usage;
+ $memory_usage = ($memory_usage >= 1048576) ? round((round($memory_usage / 1048576 * 100) / 100), 2) . ' ' . $user->lang['MB'] : (($memory_usage >= 1024) ? round((round($memory_usage / 1024 * 100) / 100), 2) . ' ' . $user->lang['KB'] : $memory_usage . ' ' . $user->lang['BYTES']);
+
+ $debug_output .= ' | Memory Usage: ' . $memory_usage;
+ }
+ }
+
+ $debug_output .= ' | <a href="' . build_url() . '&explain=1">Explain</a>';
+ }
+ }
+
+ $template->assign_vars(array(
+ 'DEBUG_OUTPUT' => (defined('DEBUG')) ? $debug_output : '',
+ 'TRANSLATION_INFO' => (!empty($user->lang['TRANSLATION_INFO'])) ? $user->lang['TRANSLATION_INFO'] : '',
+ 'S_COPYRIGHT_HTML' => $copyright_html,
+ 'VERSION' => $config['version'])
+ );
+
+ $template->display('body');
+
+ garbage_collection();
+
+ if (!defined('PHPBB_EMBEDDED'))
+ {
+ exit;
+ }
+}
+
+/**
+* Generate back link for acp pages
+*/
+function adm_back_link($u_action)
+{
+ global $user;
+ return '<br /><br /><a href="' . $u_action . '">« ' . $user->lang['BACK_TO_PREV'] . '</a>';
+}
+
+/**
+* Build select field options in acp pages
+*/
+function build_select($option_ary, $option_default = false)
+{
+ global $user;
+
+ $html = '';
+ foreach ($option_ary as $value => $title)
+ {
+ $selected = ($option_default !== false && $value == $option_default) ? ' selected="selected"' : '';
+ $html .= '<option value="' . $value . '"' . $selected . '>' . $user->lang[$title] . '</option>';
+ }
+
+ return $html;
+}
+
+/**
+* Build radio fields in acp pages
+*/
+function h_radio($name, &$input_ary, $input_default = false, $id = false, $key = false)
+{
+ global $user;
+
+ $html = '';
+ $id_assigned = false;
+ foreach ($input_ary as $value => $title)
+ {
+ $selected = ($input_default !== false && $value == $input_default) ? ' checked="checked"' : '';
+ $html .= '<label><input type="radio" name="' . $name . '"' . (($id && !$id_assigned) ? ' id="' . $id . '"' : '') . ' value="' . $value . '"' . $selected . (($key) ? ' accesskey="' . $key . '"' : '') . ' class="radio" /> ' . $user->lang[$title] . '</label>';
+ $id_assigned = true;
+ }
+
+ return $html;
+}
+
+/**
+* Build configuration template for acp configuration pages
+*/
+function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars)
+{
+ global $user, $module;
+
+ $tpl = '';
+ $name = 'config[' . $config_key . ']';
+
+ switch ($tpl_type[0])
+ {
+ case 'text':
+ case 'password':
+ $size = (int) $tpl_type[1];
+ $maxlength = (int) $tpl_type[2];
+
+ $tpl = '<input id="' . $key . '" type="' . $tpl_type[0] . '"' . (($size) ? ' size="' . $size . '"' : '') . ' maxlength="' . (($maxlength) ? $maxlength : 255) . '" name="' . $name . '" value="' . $new[$config_key] . '" />';
+ break;
+
+ case 'dimension':
+ $size = (int) $tpl_type[1];
+ $maxlength = (int) $tpl_type[2];
+
+ $tpl = '<input id="' . $key . '" type="text"' . (($size) ? ' size="' . $size . '"' : '') . ' maxlength="' . (($maxlength) ? $maxlength : 255) . '" name="config[' . $config_key . '_height]" value="' . $new[$config_key . '_height'] . '" /> x <input type="text"' . (($size) ? ' size="' . $size . '"' : '') . ' maxlength="' . (($maxlength) ? $maxlength : 255) . '" name="config[' . $config_key . '_width]" value="' . $new[$config_key . '_width'] . '" />';
+ break;
+
+ case 'textarea':
+ $rows = (int) $tpl_type[1];
+ $cols = (int) $tpl_type[2];
+
+ $tpl = '<textarea id="' . $key . '" name="' . $name . '" rows="' . $rows . '" cols="' . $cols . '">' . $new[$config_key] . '</textarea>';
+ break;
+
+ case 'radio':
+ $key_yes = ($new[$config_key]) ? ' checked="checked"' : '';
+ $key_no = (!$new[$config_key]) ? ' checked="checked"' : '';
+
+ $tpl_type_cond = explode('_', $tpl_type[1]);
+ $type_no = ($tpl_type_cond[0] == 'disabled' || $tpl_type_cond[0] == 'enabled') ? false : true;
+
+ $tpl_no = '<label><input type="radio" name="' . $name . '" value="0"' . $key_no . ' class="radio" /> ' . (($type_no) ? $user->lang['NO'] : $user->lang['DISABLED']) . '</label>';
+ $tpl_yes = '<label><input type="radio" id="' . $key . '" name="' . $name . '" value="1"' . $key_yes . ' class="radio" /> ' . (($type_no) ? $user->lang['YES'] : $user->lang['ENABLED']) . '</label>';
+
+ $tpl = ($tpl_type_cond[0] == 'yes' || $tpl_type_cond[0] == 'enabled') ? $tpl_yes . $tpl_no : $tpl_no . $tpl_yes;
+ break;
+
+ case 'select':
+ case 'custom':
+
+ $return = '';
+
+ if (isset($vars['method']))
+ {
+ $call = array($module->module, $vars['method']);
+ }
+ else if (isset($vars['function']))
+ {
+ $call = $vars['function'];
+ }
+ else
+ {
+ break;
+ }
+
+ if (isset($vars['params']))
+ {
+ $args = array();
+ foreach ($vars['params'] as $value)
+ {
+ switch ($value)
+ {
+ case '{CONFIG_VALUE}':
+ $value = $new[$config_key];
+ break;
+
+ case '{KEY}':
+ $value = $key;
+ break;
+ }
+
+ $args[] = $value;
+ }
+ }
+ else
+ {
+ $args = array($new[$config_key], $key);
+ }
+
+ $return = call_user_func_array($call, $args);
+
+ if ($tpl_type[0] == 'select')
+ {
+ $tpl = '<select id="' . $key . '" name="' . $name . '">' . $return . '</select>';
+ }
+ else
+ {
+ $tpl = $return;
+ }
+
+ break;
+
+ default:
+ break;
+ }
+
+ if (isset($vars['append']))
+ {
+ $tpl .= $vars['append'];
+ }
+
+ return $tpl;
+}
+
+/**
+* Going through a config array and validate values, writing errors to $error.
+*/
+function validate_config_vars($config_vars, &$cfg_array, &$error)
+{
+ global $phpbb_root_path, $user;
+
+ foreach ($config_vars as $config_name => $config_definition)
+ {
+ if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false)
+ {
+ continue;
+ }
+
+ if (!isset($config_definition['validate']))
+ {
+ continue;
+ }
+
+ // Validate a bit. ;) String is already checked through request_var(), therefore we do not check this again
+ switch ($config_definition['validate'])
+ {
+ case 'bool':
+ $cfg_array[$config_name] = ($cfg_array[$config_name]) ? 1 : 0;
+ break;
+
+ case 'int':
+ $cfg_array[$config_name] = (int) $cfg_array[$config_name];
+ break;
+
+ // Absolute path
+ case 'script_path':
+ if (!$cfg_array[$config_name])
+ {
+ break;
+ }
+
+ $destination = str_replace('\\', '/', $cfg_array[$config_name]);
+
+ if ($destination !== '/')
+ {
+ // Adjust destination path (no trailing slash)
+ if (substr($destination, -1, 1) == '/')
+ {
+ $destination = substr($destination, 0, -1);
+ }
+
+ $destination = str_replace(array('../', './'), '', $destination);
+
+ if ($destination[0] != '/')
+ {
+ $destination = '/' . $destination;
+ }
+ }
+
+ $cfg_array[$config_name] = trim($destination);
+
+ break;
+
+ // Absolute path
+ case 'lang':
+ if (!$cfg_array[$config_name])
+ {
+ break;
+ }
+
+ $cfg_array[$config_name] = basename($cfg_array[$config_name]);
+
+ if (!file_exists($phpbb_root_path . 'language/' . $cfg_array[$config_name] . '/'))
+ {
+ $error[] = $user->lang['WRONG_DATA_LANG'];
+ }
+ break;
+
+ // Relative path (appended $phpbb_root_path)
+ case 'rpath':
+ case 'rwpath':
+ if (!$cfg_array[$config_name])
+ {
+ break;
+ }
+
+ $destination = $cfg_array[$config_name];
+
+ // Adjust destination path (no trailing slash)
+ if (substr($destination, -1, 1) == '/' || substr($destination, -1, 1) == '\\')
+ {
+ $destination = substr($destination, 0, -1);
+ }
+
+ $destination = str_replace(array('../', '..\\', './', '.\\'), '', $destination);
+ if ($destination && ($destination[0] == '/' || $destination[0] == "\\"))
+ {
+ $destination = '';
+ }
+
+ $cfg_array[$config_name] = trim($destination);
+
+ // Path being relative (still prefixed by phpbb_root_path), but with the ability to escape the root dir...
+ case 'path':
+ case 'wpath':
+
+ if (!$cfg_array[$config_name])
+ {
+ break;
+ }
+
+ $cfg_array[$config_name] = trim($cfg_array[$config_name]);
+
+ // Make sure no NUL byte is present...
+ if (strpos($cfg_array[$config_name], "\0") !== false || strpos($cfg_array[$config_name], '%00') !== false)
+ {
+ $cfg_array[$config_name] = '';
+ break;
+ }
+
+ if (!file_exists($phpbb_root_path . $cfg_array[$config_name]))
+ {
+ $error[] = sprintf($user->lang['DIRECTORY_DOES_NOT_EXIST'], $cfg_array[$config_name]);
+ }
+
+ if (file_exists($phpbb_root_path . $cfg_array[$config_name]) && !is_dir($phpbb_root_path . $cfg_array[$config_name]))
+ {
+ $error[] = sprintf($user->lang['DIRECTORY_NOT_DIR'], $cfg_array[$config_name]);
+ }
+
+ // Check if the path is writable
+ if ($config_definition['validate'] == 'wpath' || $config_definition['validate'] == 'rwpath')
+ {
+ if (file_exists($phpbb_root_path . $cfg_array[$config_name]) && !@is_writable($phpbb_root_path . $cfg_array[$config_name]))
+ {
+ $error[] = sprintf($user->lang['DIRECTORY_NOT_WRITABLE'], $cfg_array[$config_name]);
+ }
+ }
+
+ break;
+ }
+ }
+
+ return;
+}
+
?>
\ No newline at end of file
Modified: mods/cms/trunk/common.php
===================================================================
--- mods/cms/trunk/common.php 2007-09-19 06:04:46 UTC (rev 65)
+++ mods/cms/trunk/common.php 2007-09-27 07:09:25 UTC (rev 66)
@@ -197,6 +197,11 @@
require($phpbb_root_path . 'modules/core/functions_core.' . $phpEx);
$cms_modules = get_installed_modules();
+
+ foreach($cms_modules as $i => $module)
+ {
+ $user->add_mod_lang(array($module => 'common'));
+ }
}
?>
\ No newline at end of file
Modified: mods/cms/trunk/includes/functions.php
===================================================================
--- mods/cms/trunk/includes/functions.php 2007-09-19 06:04:46 UTC (rev 65)
+++ mods/cms/trunk/includes/functions.php 2007-09-27 07:09:25 UTC (rev 66)
@@ -4207,8 +4207,13 @@
if($config['cms_enabled'])
{
+ global $cms_modules;
+
+//print_r($cms_modules);
+
$template->assign_vars(array(
'L_INDEX' => $user->lang['HOME'],
+ 'U_MY_PROFILE' => (in_array('cs', $cms_modules)) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $user->data['user_id']) : '',
'U_SEARCH' => append_sid("{$phpbb_root_path}index.$phpEx", 'i=search'),
'U_SEARCH_SELF' => append_sid("{$phpbb_root_path}index.$phpEx", 'i=search&mode=search&search_id=egosearch'),
'U_SEARCH_NEW' => append_sid("{$phpbb_root_path}index.$phpEx", 'i=search&mode=search&search_id=newposts'),
Modified: mods/cms/trunk/includes/functions_display.php
===================================================================
--- mods/cms/trunk/includes/functions_display.php 2007-09-19 06:04:46 UTC (rev 65)
+++ mods/cms/trunk/includes/functions_display.php 2007-09-27 07:09:25 UTC (rev 66)
@@ -1144,8 +1144,8 @@
//return '';
$avatar = 'default_avatar.gif';
$avatar_type = AVATAR_GALLERY;
- $avatar_width = (isset($avatar_width)) ? $avatar_width : $config['avatar_max_width'];
- $avatar_height = (isset($avatar_height)) ? $avatar_height : $config['avatar_max_height'];
+ $avatar_width = 70;
+ $avatar_height = 70;
}
$avatar_img = '';
Modified: mods/cms/trunk/includes/functions_module.php
===================================================================
--- mods/cms/trunk/includes/functions_module.php 2007-09-19 06:04:46 UTC (rev 65)
+++ mods/cms/trunk/includes/functions_module.php 2007-09-27 07:09:25 UTC (rev 66)
@@ -1,851 +1,853 @@
-<?php
-/**
-*
-* @package phpBB3
-* @version $Id: functions_module.php,v 1.58 2007/08/13 12:24:20 acydburn Exp $
-* @copyright (c) 2005 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
-*
-*/
-
-/**
-* Class handling all types of 'plugins' (a future term)
-* @package phpBB3
-*/
-class p_master
-{
- var $p_id;
- var $p_class;
- var $p_name;
- var $p_mode;
- var $p_parent;
-
- var $p_dir = '';
- var $active_module = false;
- var $active_module_row_id = false;
- var $acl_forum_id = false;
- var $module_ary = array();
-
- /**
- * List modules
- *
- * This creates a list, stored in $this->module_ary of all available
- * modules for the given class (ucp, mcp and acp). Additionally
- * $this->module_y_ary is created with indentation information for
- * displaying the module list appropriately. Only modules for which
- * the user has access rights are included in these lists.
- */
- function list_modules($p_class)
- {
- global $auth, $db, $user, $cache;
- global $config, $phpbb_root_path, $phpEx;
-
- // Sanitise for future path use, it's escaped as appropriate for queries
- $this->p_class = str_replace(array('.', '/', '\\'), '', basename($p_class));
- $lang_dir = $user->lang_path;
-
- // Get cached modules
- if (($this->module_cache = $cache->get('_modules_' . $this->p_class)) === false)
- {
- // Get modules
- $sql = 'SELECT *
- FROM ' . MODULES_TABLE . "
- WHERE module_class = '" . $db->sql_escape($this->p_class) . "'
- ORDER BY left_id ASC";
- $result = $db->sql_query($sql);
-
- $rows = array();
- while ($row = $db->sql_fetchrow($result))
- {
- $rows[$row['module_id']] = $row;
- }
- $db->sql_freeresult($result);
-
- $this->module_cache = array();
- foreach ($rows as $module_id => $row)
- {
- $this->module_cache['modules'][] = $row;
- $this->module_cache['parents'][$row['module_id']] = $this->get_parents($row['parent_id'], $row['left_id'], $row['right_id'], $rows);
- }
- unset($rows);
-
- $cache->put('_modules_' . $this->p_class, $this->module_cache);
- }
-
- if (empty($this->module_cache))
- {
- $this->module_cache = array('modules' => array(), 'parents' => array());
- }
-
- // We "could" build a true tree with this function - maybe mod authors want to use this...
- // Functions for traversing and manipulating the tree are not available though
- // We might re-structure the module system to use true trees in 3.2.x...
- // $tree = $this->build_tree($this->module_cache['modules'], $this->module_cache['parents']);
-
- // Clean up module cache array to only let survive modules the user can access
- $right_id = false;
- foreach ($this->module_cache['modules'] as $key => $row)
- {
- // Not allowed to view module?
- if (!$this->module_auth($row['module_auth']))
- {
- unset($this->module_cache['modules'][$key]);
- continue;
- }
-
- // Category with no members, ignore
- if (!$row['module_basename'] && ($row['left_id'] + 1 == $row['right_id']))
- {
- unset($this->module_cache['modules'][$key]);
- continue;
- }
-
- // Skip branch
- if ($right_id !== false)
- {
- if ($row['left_id'] < $right_id)
- {
- unset($this->module_cache['modules'][$key]);
- continue;
- }
-
- $right_id = false;
- }
-
- // Not enabled?
- if (!$row['module_enabled'])
- {
- // If category is disabled then disable every child too
- unset($this->module_cache['modules'][$key]);
- $right_id = $row['right_id'];
- continue;
- }
-
- if($row['module_dir'])
- {
- $user->add_mod_lang(array($row['module_dir'] => 'common'));
- }
- }
-
- // Re-index (this is needed, else we are not able to array_slice later)
- $this->module_cache['modules'] = array_merge($this->module_cache['modules']);
-
- // Include MOD _info files for populating language entries within the menus
- $this->add_mod_info($this->p_class);
-
- // Now build the module array, but exclude completely empty categories...
- $right_id = false;
- $names = array();
-
- foreach ($this->module_cache['modules'] as $key => $row)
- {
- // Skip branch
- if ($right_id !== false)
- {
- if ($row['left_id'] < $right_id)
- {
- continue;
- }
-
- $right_id = false;
- }
-
- // Category with no members on their way down (we have to check every level)
- if (!$row['module_basename'])
- {
- $empty_category = true;
-
- // We go through the branch and look for an activated module
- foreach (array_slice($this->module_cache['modules'], $key + 1) as $temp_row)
- {
- if ($temp_row['left_id'] > $row['left_id'] && $temp_row['left_id'] < $row['right_id'])
- {
- // Module there
- if ($temp_row['module_basename'] && $temp_row['module_enabled'])
- {
- $empty_category = false;
- break;
- }
- continue;
- }
- break;
- }
-
- // Skip the branch
- if ($empty_category)
- {
- $right_id = $row['right_id'];
- continue;
- }
- }
-
- $depth = sizeof($this->module_cache['parents'][$row['module_id']]);
-
- // We need to prefix the functions to not create a naming conflict
-
- // Function for building 'url_extra'
- $url_func = '_module_' . $row['module_basename'] . '_url';
-
- // Function for building the language name
- $lang_func = '_module_' . $row['module_basename'] . '_lang';
-
- // Custom function for calling parameters on module init (for example assigning template variables)
- $custom_func = '_module_' . $row['module_basename'];
-
- $names[$row['module_basename'] . '_' . $row['module_mode']][] = true;
-
- $module_row = array(
- 'depth' => $depth,
-
- 'id' => (int) $row['module_id'],
- 'parent' => (int) $row['parent_id'],
- 'cat' => ($row['right_id'] > $row['left_id'] + 1) ? true : false,
-
- 'is_duplicate' => ($row['module_basename'] && sizeof($names[$row['module_basename'] . '_' . $row['module_mode']]) > 1) ? true : false,
-
- 'name' => (string) $row['module_basename'],
- 'mode' => (string) $row['module_mode'],
- 'display' => (int) $row['module_display'],
-
- 'url_extra' => (function_exists($url_func)) ? $url_func($row['module_mode'], $row) : '',
-
- 'lang' => ($row['module_basename'] && function_exists($lang_func)) ? $lang_func($row['module_mode'], $row['module_langname']) : ((!empty($user->lang[$row['module_langname']])) ? $user->lang[$row['module_langname']] : $row['module_langname']),
- 'langname' => $row['module_langname'],
-
- 'left' => $row['left_id'],
- 'right' => $row['right_id'],
- 'module_dir' => $row['module_dir'],
- );
-
- if (function_exists($custom_func))
- {
- $custom_func($row['module_mode'], $module_row);
- }
-
- $this->module_ary[] = $module_row;
- }
-
- $user->lang_path = $lang_dir;
- unset($this->module_cache['modules'], $names);
- }
-
- /**
- * Check if a certain main module is accessible/loaded
- * By giving the module mode you are able to additionally check for only one mode within the main module
- *
- * @param string $module_basename The module base name, for example logs, reports, main (for the mcp).
- * @param mixed $module_mode The module mode to check. If provided the mode will be checked in addition for presence.
- *
- * @return bool Returns true if module is loaded and accessible, else returns false
- */
- function loaded($module_basename, $module_mode = false)
- {
- if (empty($this->loaded_cache))
- {
- $this->loaded_cache = array();
-
- foreach ($this->module_ary as $row)
- {
- if (!$row['name'])
- {
- continue;
- }
-
- if (!isset($this->loaded_cache[$row['name']]))
- {
- $this->loaded_cache[$row['name']] = array();
- }
-
- if (!$row['mode'])
- {
- continue;
- }
-
- $this->loaded_cache[$row['name']][$row['mode']] = true;
- }
- }
-
- if ($module_mode === false)
- {
- return (isset($this->loaded_cache[$module_basename])) ? true : false;
- }
-
- return (!empty($this->loaded_cache[$module_basename][$module_mode])) ? true : false;
- }
-
- /**
- * Check module authorisation
- */
- function module_auth($module_auth, $forum_id = false)
- {
- global $auth, $config;
-
- $module_auth = trim($module_auth);
-
- // Generally allowed to access module if module_auth is empty
- if (!$module_auth)
- {
- return true;
- }
-
- // With the code below we make sure only those elements get eval'd we really want to be checked
- preg_match_all('/(?:
- "[^"\\\\]*(?:\\\\.[^"\\\\]*)*" |
- \'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\' |
- [(),] |
- [^\s(),]+)/x', $module_auth, $match);
-
- $tokens = $match[0];
- for ($i = 0, $size = sizeof($tokens); $i < $size; $i++)
- {
- $token = &$tokens[$i];
-
- switch ($token)
- {
- case ')':
- case '(':
- case '&&':
- case '||':
- case ',':
- break;
-
- default:
- if (!preg_match('#(?:acl_([a-z_]+)(,\$id)?)|(?:\$id)|(?:aclf_([a-z_]+))|(?:cfg_([a-z_]+))|(?:request_([a-z_]+))#', $token))
- {
- $token = '';
- }
- break;
- }
- }
-
- $module_auth = implode(' ', $tokens);
-
- // Make sure $id seperation is working fine
- $module_auth = str_replace(' , ', ',', $module_auth);
-
- $forum_id = ($forum_id === false) ? $this->acl_forum_id : $forum_id;
-
- $is_auth = false;
- eval('$is_auth = (int) (' . preg_replace(array('#acl_([a-z_]+)(,\$id)?#', '#\$id#', '#aclf_([a-z_]+)#', '#cfg_([a-z_]+)#', '#request_([a-z_]+)#'), array('(int) $auth->acl_get(\'\\1\'\\2)', '(int) $forum_id', '(int) $auth->acl_getf_global(\'\\1\')', '(int) $config[\'\\1\']', '!empty($_REQUEST[\'\\1\'])'), $module_auth) . ');');
-
- return $is_auth;
- }
-
- /**
- * Set active module
- */
- function set_active($id = false, $mode = false)
- {
- $icat = false;
- $this->active_module = false;
-
- if (request_var('icat', ''))
- {
- $icat = $id;
- $id = request_var('icat', '');
- }
-
- $category = false;
- foreach ($this->module_ary as $row_id => $item_ary)
- {
- // If this is a module and it's selected, active
- // If this is a category and the module is the first within it, active
- // If this is a module and no mode selected, select first mode
- // If no category or module selected, go active for first module in first category
- if (
- (($item_ary['name'] === $id || $item_ary['id'] === (int) $id) && (($item_ary['mode'] == $mode && !$item_ary['cat']) || ($icat && $item_ary['cat']))) ||
- ($item_ary['parent'] === $category && !$item_ary['cat'] && !$icat && $item_ary['display']) ||
- (($item_ary['name'] === $id || $item_ary['id'] === (int) $id) && !$mode && !$item_ary['cat']) ||
- (!$id && !$mode && !$item_ary['cat'] && $item_ary['display'])
- )
- {
- if ($item_ary['cat'])
- {
- $id = $icat;
- $icat = false;
-
- continue;
- }
-
- $this->p_id = $item_ary['id'];
- $this->p_parent = $item_ary['parent'];
- $this->p_name = $item_ary['name'];
- $this->p_mode = $item_ary['mode'];
- $this->p_left = $item_ary['left'];
- $this->p_right = $item_ary['right'];
- $this->p_dir = $item_ary['module_dir'];
-
- $this->module_cache['parents'] = $this->module_cache['parents'][$this->p_id];
- $this->active_module = $item_ary['id'];
- $this->active_module_row_id = $row_id;
-
- break;
- }
- else if (($item_ary['cat'] && $item_ary['id'] === (int) $id) || ($item_ary['parent'] === $category && $item_ary['cat']))
- {
- $category = $item_ary['id'];
- }
- }
- }
-
- /**
- * Loads currently active module
- *
- * This method loads a given module, passing it the relevant id and mode.
- */
- function load_active($mode = false, $module_url = false, $execute_module = true)
- {
- global $phpbb_root_path, $phpbb_admin_path, $phpEx, $user;
-
- //$module_path = $phpbb_root_path . 'includes/' . $this->p_class;
- $module_path = $phpbb_root_path . (($this->p_dir) ? 'modules/' . $this->p_dir : 'includes/' . $this->p_class);
-
- $icat = request_var('icat', '');
-
- if ($this->active_module === false)
- {
- trigger_error('Module not accessible', E_USER_ERROR);
- }
-
- if (!class_exists("{$this->p_class}_$this->p_name"))
- {
- if (!file_exists("$module_path/{$this->p_class}_$this->p_name.$phpEx"))
- {
- trigger_error("Cannot find module $module_path/{$this->p_class}_$this->p_name.$phpEx", E_USER_ERROR);
- }
-
- include("$module_path/{$this->p_class}_$this->p_name.$phpEx");
-
- if (!class_exists("{$this->p_class}_$this->p_name"))
- {
- trigger_error("Module file $module_path/{$this->p_class}_$this->p_name.$phpEx does not contain correct class [{$this->p_class}_$this->p_name]", E_USER_ERROR);
- }
-
- if (!empty($mode))
- {
- $this->p_mode = $mode;
- }
-
- // Create a new instance of the desired module ... if it has a
- // constructor it will of course be executed
- $instance = "{$this->p_class}_$this->p_name";
-
- $this->module = new $instance($this);
-
- // We pre-define the action parameter we are using all over the place
- if (defined('IN_ADMIN'))
- {
- // Is first module automatically enabled a duplicate and the category not passed yet?
- if (!$icat && $this->module_ary[$this->active_module_row_id]['is_duplicate'])
- {
- $icat = $this->module_ary[$this->active_module_row_id]['parent'];
- }
-
- // Not being able to overwrite ;)
- $this->module->u_action = append_sid("{$phpbb_admin_path}index.$phpEx", "i={$this->p_name}") . (($icat) ? '&icat=' . $icat : '') . "&mode={$this->p_mode}";
- }
- else
- {
- // If user specified the module url we will use it...
- if ($module_url !== false)
- {
- $this->module->u_action = $module_url;
- }
- else
- {
- $this->module->u_action = $phpbb_root_path . (($user->page['page_dir']) ? $user->page['page_dir'] . '/' : '') . $user->page['page_name'];
- }
-
- $this->module->u_action = append_sid($this->module->u_action, "i={$this->p_name}") . (($icat) ? '&icat=' . $icat : '') . "&mode={$this->p_mode}";
- }
-
- // Add url_extra parameter to u_action url
- if (!empty($this->module_ary) && $this->active_module !== false && $this->module_ary[$this->active_module_row_id]['url_extra'])
- {
- $this->module->u_action .= $this->module_ary[$this->active_module_row_id]['url_extra'];
- }
-
- // Assign the module path for re-usage
- $this->module->module_path = $module_path . '/';
-
- // Execute the main method for the new instance, we send the module id and mode as parameters
- // Users are able to call the main method after this function to be able to assign additional parameters manually
- if ($execute_module)
- {
- $this->module->main($this->p_name, $this->p_mode);
- }
-
- return;
- }
- }
-
- /**
- * Appending url parameter to the currently active module.
- *
- * This function is called for adding specific url parameters while executing the current module.
- * It is doing the same as the _module_{name}_url() function, apart from being able to be called after
- * having dynamically parsed specific parameters. This allows more freedom in choosing additional parameters.
- * One example can be seen in /includes/mcp/mcp_notes.php - $this->p_master->adjust_url() call.
- *
- * @param string $url_extra Extra url parameters, e.g.: &u=$user_id
- *
- */
- function adjust_url($url_extra)
- {
- if (empty($this->module_ary[$this->active_module_row_id]))
- {
- return;
- }
-
- $row = &$this->module_ary[$this->active_module_row_id];
-
- // We check for the same url_extra in $row['url_extra'] to overcome doubled additions...
- if (strpos($row['url_extra'], $url_extra) === false)
- {
- $row['url_extra'] .= $url_extra;
- }
- }
-
- /**
- * Check if a module is active
- */
- function is_active($id, $mode = false)
- {
- // If we find a name by this id and being enabled we have our active one...
- foreach ($this->module_ary as $row_id => $item_ary)
- {
- if (($item_ary['name'] === $id || $item_ary['id'] === (int) $id) && $item_ary['display'])
- {
- if ($mode === false || $mode === $item_ary['mode'])
- {
- return true;
- }
- }
- }
-
- return false;
- }
-
- /**
- * Get parents
- */
- function get_parents($parent_id, $left_id, $right_id, &$all_parents)
- {
- global $db;
-
- $parents = array();
-
- if ($parent_id > 0)
- {
- foreach ($all_parents as $module_id => $row)
- {
- if ($row['left_id'] < $left_id && $row['right_id'] > $right_id)
- {
- $parents[$module_id] = $row['parent_id'];
- }
-
- if ($row['left_id'] > $left_id)
- {
- break;
- }
- }
- }
-
- return $parents;
- }
-
- /**
- * Get tree branch
- */
- function get_branch($left_id, $right_id, $remaining)
- {
- $branch = array();
-
- foreach ($remaining as $key => $row)
- {
- if ($row['left_id'] > $left_id && $row['left_id'] < $right_id)
- {
- $branch[] = $row;
- continue;
- }
- break;
- }
-
- return $branch;
- }
-
- /**
- * Build true binary tree from given array
- * Not in use
- */
- function build_tree(&$modules, &$parents)
- {
- $tree = array();
-
- foreach ($modules as $row)
- {
- $branch = &$tree;
-
- if ($row['parent_id'])
- {
- // Go through the tree to find our branch
- $parent_tree = $parents[$row['module_id']];
-
- foreach ($parent_tree as $id => $value)
- {
- if (!isset($branch[$id]) && isset($branch['child']))
- {
- $branch = &$branch['child'];
- }
- $branch = &$branch[$id];
- }
- $branch = &$branch['child'];
- }
-
- $branch[$row['module_id']] = $row;
- if (!isset($branch[$row['module_id']]['child']))
- {
- $branch[$row['module_id']]['child'] = array();
- }
- }
-
- return $tree;
- }
-
- /**
- * Build navigation structure
- */
- function assign_tpl_vars($module_url, $cat_var = 'i', $mode_var = 'mode', $offset_prefix = '')
- {
- global $template;
-
- $current_id = $right_id = false;
-
- // Make sure the module_url has a question mark set, effectively determining the delimiter to use
- $delim = (strpos($module_url, '?') === false) ? '?' : '&';
-
- $current_padding = $current_depth = 0;
- $linear_offset = $offset_prefix . 'l_block1';
- $tabular_offset = $offset_prefix . 't_block2';
-
- // Generate the list of modules, we'll do this in two ways ...
- // 1) In a linear fashion
- // 2) In a combined tabbed + linear fashion ... tabs for the categories
- // and a linear list for subcategories/items
- foreach ($this->module_ary as $row_id => $item_ary)
- {
- // Skip hidden modules
- if (!$item_ary['display'])
- {
- continue;
- }
-
- // Skip branch
- if ($right_id !== false)
- {
- if ($item_ary['left'] < $right_id)
- {
- continue;
- }
-
- $right_id = false;
- }
-
- // Category with no members on their way down (we have to check every level)
- if (!$item_ary['name'])
- {
- $empty_category = true;
-
- // We go through the branch and look for an activated module
- foreach (array_slice($this->module_ary, $row_id + 1) as $temp_row)
- {
- if ($temp_row['left'] > $item_ary['left'] && $temp_row['left'] < $item_ary['right'])
- {
- // Module there and displayed?
- if ($temp_row['name'] && $temp_row['display'])
- {
- $empty_category = false;
- break;
- }
- continue;
- }
- break;
- }
-
- // Skip the branch
- if ($empty_category)
- {
- $right_id = $item_ary['right'];
- continue;
- }
- }
-
- // Select first id we can get
- if (!$current_id && (in_array($item_ary['id'], array_keys($this->module_cache['parents'])) || $item_ary['id'] == $this->p_id))
- {
- $current_id = $item_ary['id'];
- }
-
- $depth = $item_ary['depth'];
-
- if ($depth > $current_depth)
- {
- $linear_offset = $linear_offset . '.l_block' . ($depth + 1);
- $tabular_offset = ($depth + 1 > 2) ? $tabular_offset . '.t_block' . ($depth + 1) : $tabular_offset;
- }
- else if ($depth < $current_depth)
- {
- for ($i = $current_depth - $depth; $i > 0; $i--)
- {
- $linear_offset = substr($linear_offset, 0, strrpos($linear_offset, '.'));
- $tabular_offset = ($i + $depth > 1) ? substr($tabular_offset, 0, strrpos($tabular_offset, '.')) : $tabular_offset;
- }
- }
-
- $u_title = $module_url . $delim . $cat_var . '=' . (($item_ary['cat']) ? $item_ary['id'] : $item_ary['name'] . (($item_ary['is_duplicate']) ? '&icat=' . $current_id : '') . '&' . $mode_var . '=' . $item_ary['mode']);
-
- // Was not allowed in categories before - /*!$item_ary['cat'] && */
- $u_title .= (isset($item_ary['url_extra'])) ? $item_ary['url_extra'] : '';
-
- // Only output a categories items if it's currently selected
- if ($this->p_class == 'CMS' || !$depth || ($depth && (in_array($item_ary['parent'], array_values($this->module_cache['parents'])) || $item_ary['parent'] == $this->p_parent)))
- {
- $use_tabular_offset = (!$depth) ? $offset_prefix . 't_block1' : $tabular_offset;
-
- $tpl_ary = array(
- 'L_TITLE' => $item_ary['lang'],
- 'S_SELECTED' => (in_array($item_ary['id'], array_keys($this->module_cache['parents'])) || $item_ary['id'] == $this->p_id) ? true : false,
- 'U_TITLE' => $u_title
- );
-
- $template->assign_block_vars($use_tabular_offset, array_merge($tpl_ary, array_change_key_case($item_ary, CASE_UPPER)));
- }
-
- $tpl_ary = array(
- 'L_TITLE' => $item_ary['lang'],
- 'S_SELECTED' => (in_array($item_ary['id'], array_keys($this->module_cache['parents'])) || $item_ary['id'] == $this->p_id) ? true : false,
- 'U_TITLE' => $u_title
- );
-
- $template->assign_block_vars($linear_offset, array_merge($tpl_ary, array_change_key_case($item_ary, CASE_UPPER)));
-
- $current_depth = $depth;
- }
- }
-
- /**
- * Returns desired template name
- */
- function get_tpl_name()
- {
- return $this->module->tpl_name . '.html';
- }
-
- /**
- * Returns the desired page title
- */
- function get_page_title()
- {
- global $user;
-
- if (!isset($this->module->page_title))
- {
- return '';
- }
-
- return (isset($user->lang[$this->module->page_title])) ? $user->lang[$this->module->page_title] : $this->module->page_title;
- }
-
- /**
- * Load module as the current active one without the need for registering it
- */
- function load($class, $name, $mode = false)
- {
- $this->p_class = $class;
- $this->p_name = $name;
-
- // Set active module to true instead of using the id
- $this->active_module = true;
-
- $this->load_active($mode);
- }
-
- /**
- * Display module
- */
- function display($page_title, $display_online_list = true)
- {
- global $template, $user;
-
- // Generate the page
- if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin'])
- {
- adm_page_header($page_title);
- }
- else
- {
- page_header($page_title, $display_online_list);
- }
-
- $template->set_filenames(array(
...
[truncated message content] |