|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
*
|
|
|
4c79b5 |
* @package phpBB3
|
|
|
4c79b5 |
* @version $Id: functions_module.php 9095 2008-11-23 12:42:34Z acydburn $
|
|
|
4c79b5 |
* @copyright (c) 2005 phpBB Group
|
|
|
4c79b5 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
|
4c79b5 |
*
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* @ignore
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
if (!defined('IN_PHPBB'))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
exit;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Class handling all types of 'plugins' (a future term)
|
|
|
4c79b5 |
* @package phpBB3
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
class p_master
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
var $p_id;
|
|
|
4c79b5 |
var $p_class;
|
|
|
4c79b5 |
var $p_name;
|
|
|
4c79b5 |
var $p_mode;
|
|
|
4c79b5 |
var $p_parent;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
var $include_path = false;
|
|
|
4c79b5 |
var $active_module = false;
|
|
|
4c79b5 |
var $active_module_row_id = false;
|
|
|
4c79b5 |
var $acl_forum_id = false;
|
|
|
4c79b5 |
var $module_ary = array();
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Constuctor
|
|
|
4c79b5 |
* Set module include path
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function p_master($include_path = false)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $phpbb_root_path;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$this->include_path = ($include_path !== false) ? $include_path : $phpbb_root_path . 'includes/';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Make sure the path ends with /
|
|
|
4c79b5 |
if (substr($this->include_path, -1) !== '/')
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$this->include_path .= '/';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Set custom include path for modules
|
|
|
4c79b5 |
* Schema for inclusion is include_path . modulebase
|
|
|
4c79b5 |
*
|
|
|
4c79b5 |
* @param string $include_path include path to be used.
|
|
|
4c79b5 |
* @access public
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function set_custom_include_path($include_path)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$this->include_path = $include_path;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Make sure the path ends with /
|
|
|
4c79b5 |
if (substr($this->include_path, -1) !== '/')
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$this->include_path .= '/';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* List modules
|
|
|
4c79b5 |
*
|
|
|
4c79b5 |
* This creates a list, stored in $this->module_ary of all available
|
|
|
4c79b5 |
* modules for the given class (ucp, mcp and acp). Additionally
|
|
|
4c79b5 |
* $this->module_y_ary is created with indentation information for
|
|
|
4c79b5 |
* displaying the module list appropriately. Only modules for which
|
|
|
4c79b5 |
* the user has access rights are included in these lists.
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function list_modules($p_class)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $auth, $db, $user, $cache;
|
|
|
4c79b5 |
global $config, $phpbb_root_path, $phpEx;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Sanitise for future path use, it's escaped as appropriate for queries
|
|
|
4c79b5 |
$this->p_class = str_replace(array('.', '/', '\\'), '', basename($p_class));
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Get cached modules
|
|
|
4c79b5 |
if (($this->module_cache = $cache->get('_modules_' . $this->p_class)) === false)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// Get modules
|
|
|
4c79b5 |
$sql = 'SELECT *
|
|
|
4c79b5 |
FROM ' . MODULES_TABLE . "
|
|
|
4c79b5 |
WHERE module_class = '" . $db->sql_escape($this->p_class) . "'
|
|
|
4c79b5 |
ORDER BY left_id ASC";
|
|
|
4c79b5 |
$result = $db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$rows = array();
|
|
|
4c79b5 |
while ($row = $db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$rows[$row['module_id']] = $row;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$this->module_cache = array();
|
|
|
4c79b5 |
foreach ($rows as $module_id => $row)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$this->module_cache['modules'][] = $row;
|
|
|
4c79b5 |
$this->module_cache['parents'][$row['module_id']] = $this->get_parents($row['parent_id'], $row['left_id'], $row['right_id'], $rows);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
unset($rows);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$cache->put('_modules_' . $this->p_class, $this->module_cache);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (empty($this->module_cache))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$this->module_cache = array('modules' => array(), 'parents' => array());
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// We "could" build a true tree with this function - maybe mod authors want to use this...
|
|
|
4c79b5 |
// Functions for traversing and manipulating the tree are not available though
|
|
|
4c79b5 |
// We might re-structure the module system to use true trees in 3.2.x...
|
|
|
4c79b5 |
// $tree = $this->build_tree($this->module_cache['modules'], $this->module_cache['parents']);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Clean up module cache array to only let survive modules the user can access
|
|
|
4c79b5 |
$right_id = false;
|
|
|
4c79b5 |
foreach ($this->module_cache['modules'] as $key => $row)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// Not allowed to view module?
|
|
|
4c79b5 |
if (!$this->module_auth($row['module_auth']))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
unset($this->module_cache['modules'][$key]);
|
|
|
4c79b5 |
continue;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Category with no members, ignore
|
|
|
4c79b5 |
if (!$row['module_basename'] && ($row['left_id'] + 1 == $row['right_id']))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
unset($this->module_cache['modules'][$key]);
|
|
|
4c79b5 |
continue;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Skip branch
|
|
|
4c79b5 |
if ($right_id !== false)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if ($row['left_id'] < $right_id)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
unset($this->module_cache['modules'][$key]);
|
|
|
4c79b5 |
continue;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$right_id = false;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Not enabled?
|
|
|
4c79b5 |
if (!$row['module_enabled'])
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// If category is disabled then disable every child too
|
|
|
4c79b5 |
unset($this->module_cache['modules'][$key]);
|
|
|
4c79b5 |
$right_id = $row['right_id'];
|
|
|
4c79b5 |
continue;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Re-index (this is needed, else we are not able to array_slice later)
|
|
|
4c79b5 |
$this->module_cache['modules'] = array_merge($this->module_cache['modules']);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Include MOD _info files for populating language entries within the menus
|
|
|
4c79b5 |
$this->add_mod_info($this->p_class);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Now build the module array, but exclude completely empty categories...
|
|
|
4c79b5 |
$right_id = false;
|
|
|
4c79b5 |
$names = array();
|
|
|
4c79b5 |
|
|
|
4c79b5 |
foreach ($this->module_cache['modules'] as $key => $row)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// Skip branch
|
|
|
4c79b5 |
if ($right_id !== false)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if ($row['left_id'] < $right_id)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
continue;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$right_id = false;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Category with no members on their way down (we have to check every level)
|
|
|
4c79b5 |
if (!$row['module_basename'])
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$empty_category = true;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// We go through the branch and look for an activated module
|
|
|
4c79b5 |
foreach (array_slice($this->module_cache['modules'], $key + 1) as $temp_row)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if ($temp_row['left_id'] > $row['left_id'] && $temp_row['left_id'] < $row['right_id'])
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// Module there
|
|
|
4c79b5 |
if ($temp_row['module_basename'] && $temp_row['module_enabled'])
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$empty_category = false;
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
continue;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Skip the branch
|
|
|
4c79b5 |
if ($empty_category)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$right_id = $row['right_id'];
|
|
|
4c79b5 |
continue;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$depth = sizeof($this->module_cache['parents'][$row['module_id']]);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// We need to prefix the functions to not create a naming conflict
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Function for building 'url_extra'
|
|
|
4c79b5 |
$url_func = '_module_' . $row['module_basename'] . '_url';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Function for building the language name
|
|
|
4c79b5 |
$lang_func = '_module_' . $row['module_basename'] . '_lang';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Custom function for calling parameters on module init (for example assigning template variables)
|
|
|
4c79b5 |
$custom_func = '_module_' . $row['module_basename'];
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$names[$row['module_basename'] . '_' . $row['module_mode']][] = true;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$module_row = array(
|
|
|
4c79b5 |
'depth' => $depth,
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'id' => (int) $row['module_id'],
|
|
|
4c79b5 |
'parent' => (int) $row['parent_id'],
|
|
|
4c79b5 |
'cat' => ($row['right_id'] > $row['left_id'] + 1) ? true : false,
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'is_duplicate' => ($row['module_basename'] && sizeof($names[$row['module_basename'] . '_' . $row['module_mode']]) > 1) ? true : false,
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'name' => (string) $row['module_basename'],
|
|
|
4c79b5 |
'mode' => (string) $row['module_mode'],
|
|
|
4c79b5 |
'display' => (int) $row['module_display'],
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'url_extra' => (function_exists($url_func)) ? $url_func($row['module_mode'], $row) : '',
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'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']),
|
|
|
4c79b5 |
'langname' => $row['module_langname'],
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'left' => $row['left_id'],
|
|
|
4c79b5 |
'right' => $row['right_id'],
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (function_exists($custom_func))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$custom_func($row['module_mode'], $module_row);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$this->module_ary[] = $module_row;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
unset($this->module_cache['modules'], $names);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Check if a certain main module is accessible/loaded
|
|
|
4c79b5 |
* By giving the module mode you are able to additionally check for only one mode within the main module
|
|
|
4c79b5 |
*
|
|
|
4c79b5 |
* @param string $module_basename The module base name, for example logs, reports, main (for the mcp).
|
|
|
4c79b5 |
* @param mixed $module_mode The module mode to check. If provided the mode will be checked in addition for presence.
|
|
|
4c79b5 |
*
|
|
|
4c79b5 |
* @return bool Returns true if module is loaded and accessible, else returns false
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function loaded($module_basename, $module_mode = false)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if (empty($this->loaded_cache))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$this->loaded_cache = array();
|
|
|
4c79b5 |
|
|
|
4c79b5 |
foreach ($this->module_ary as $row)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if (!$row['name'])
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
continue;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (!isset($this->loaded_cache[$row['name']]))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$this->loaded_cache[$row['name']] = array();
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (!$row['mode'])
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
continue;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$this->loaded_cache[$row['name']][$row['mode']] = true;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($module_mode === false)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
return (isset($this->loaded_cache[$module_basename])) ? true : false;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return (!empty($this->loaded_cache[$module_basename][$module_mode])) ? true : false;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Check module authorisation
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function module_auth($module_auth, $forum_id = false)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $auth, $config;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$module_auth = trim($module_auth);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Generally allowed to access module if module_auth is empty
|
|
|
4c79b5 |
if (!$module_auth)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
return true;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// With the code below we make sure only those elements get eval'd we really want to be checked
|
|
|
4c79b5 |
preg_match_all('/(?:
|
|
|
4c79b5 |
"[^"\\\\]*(?:\\\\.[^"\\\\]*)*" |
|
|
|
4c79b5 |
\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\' |
|
|
|
4c79b5 |
[(),] |
|
|
|
4c79b5 |
[^\s(),]+)/x', $module_auth, $match);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$tokens = $match[0];
|
|
|
4c79b5 |
for ($i = 0, $size = sizeof($tokens); $i < $size; $i++)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$token = &$tokens[$i];
|
|
|
4c79b5 |
|
|
|
4c79b5 |
switch ($token)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
case ')':
|
|
|
4c79b5 |
case '(':
|
|
|
4c79b5 |
case '&&':
|
|
|
4c79b5 |
case '||':
|
|
|
4c79b5 |
case ',':
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
default:
|
|
|
4c79b5 |
if (!preg_match('#(?:acl_([a-z0-9_]+)(,\$id)?)|(?:\$id)|(?:aclf_([a-z0-9_]+))|(?:cfg_([a-z0-9_]+))|(?:request_([a-zA-Z0-9_]+))#', $token))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$token = '';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$module_auth = implode(' ', $tokens);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Make sure $id seperation is working fine
|
|
|
4c79b5 |
$module_auth = str_replace(' , ', ',', $module_auth);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$forum_id = ($forum_id === false) ? $this->acl_forum_id : $forum_id;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$is_auth = false;
|
|
|
4c79b5 |
eval('$is_auth = (int) (' . preg_replace(array('#acl_([a-z0-9_]+)(,\$id)?#', '#\$id#', '#aclf_([a-z0-9_]+)#', '#cfg_([a-z0-9_]+)#', '#request_([a-zA-Z0-9_]+)#'), array('(int) $auth->acl_get(\'\\1\'\\2)', '(int) $forum_id', '(int) $auth->acl_getf_global(\'\\1\')', '(int) $config[\'\\1\']', '!empty($_REQUEST[\'\\1\'])'), $module_auth) . ');');
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return $is_auth;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Set active module
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function set_active($id = false, $mode = false)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$icat = false;
|
|
|
4c79b5 |
$this->active_module = false;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (request_var('icat', ''))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$icat = $id;
|
|
|
4c79b5 |
$id = request_var('icat', '');
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$category = false;
|
|
|
4c79b5 |
foreach ($this->module_ary as $row_id => $item_ary)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// If this is a module and it's selected, active
|
|
|
4c79b5 |
// If this is a category and the module is the first within it, active
|
|
|
4c79b5 |
// If this is a module and no mode selected, select first mode
|
|
|
4c79b5 |
// If no category or module selected, go active for first module in first category
|
|
|
4c79b5 |
if (
|
|
|
4c79b5 |
(($item_ary['name'] === $id || $item_ary['id'] === (int) $id) && (($item_ary['mode'] == $mode && !$item_ary['cat']) || ($icat && $item_ary['cat']))) ||
|
|
|
4c79b5 |
($item_ary['parent'] === $category && !$item_ary['cat'] && !$icat && $item_ary['display']) ||
|
|
|
4c79b5 |
(($item_ary['name'] === $id || $item_ary['id'] === (int) $id) && !$mode && !$item_ary['cat']) ||
|
|
|
4c79b5 |
(!$id && !$mode && !$item_ary['cat'] && $item_ary['display'])
|
|
|
4c79b5 |
)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if ($item_ary['cat'])
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$id = $icat;
|
|
|
4c79b5 |
$icat = false;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
continue;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$this->p_id = $item_ary['id'];
|
|
|
4c79b5 |
$this->p_parent = $item_ary['parent'];
|
|
|
4c79b5 |
$this->p_name = $item_ary['name'];
|
|
|
4c79b5 |
$this->p_mode = $item_ary['mode'];
|
|
|
4c79b5 |
$this->p_left = $item_ary['left'];
|
|
|
4c79b5 |
$this->p_right = $item_ary['right'];
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$this->module_cache['parents'] = $this->module_cache['parents'][$this->p_id];
|
|
|
4c79b5 |
$this->active_module = $item_ary['id'];
|
|
|
4c79b5 |
$this->active_module_row_id = $row_id;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else if (($item_ary['cat'] && $item_ary['id'] === (int) $id) || ($item_ary['parent'] === $category && $item_ary['cat']))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$category = $item_ary['id'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Loads currently active module
|
|
|
4c79b5 |
*
|
|
|
4c79b5 |
* This method loads a given module, passing it the relevant id and mode.
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function load_active($mode = false, $module_url = false, $execute_module = true)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $phpbb_root_path, $phpbb_admin_path, $phpEx, $user;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$module_path = $this->include_path . $this->p_class;
|
|
|
4c79b5 |
$icat = request_var('icat', '');
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($this->active_module === false)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
trigger_error('Module not accessible', E_USER_ERROR);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (!class_exists("{$this->p_class}_$this->p_name"))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if (!file_exists("$module_path/{$this->p_class}_$this->p_name.$phpEx"))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
trigger_error("Cannot find module $module_path/{$this->p_class}_$this->p_name.$phpEx", E_USER_ERROR);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
include("$module_path/{$this->p_class}_$this->p_name.$phpEx");
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (!class_exists("{$this->p_class}_$this->p_name"))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
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);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (!empty($mode))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$this->p_mode = $mode;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Create a new instance of the desired module ... if it has a
|
|
|
4c79b5 |
// constructor it will of course be executed
|
|
|
4c79b5 |
$instance = "{$this->p_class}_$this->p_name";
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$this->module = new $instance($this);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// We pre-define the action parameter we are using all over the place
|
|
|
4c79b5 |
if (defined('IN_ADMIN'))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// Is first module automatically enabled a duplicate and the category not passed yet?
|
|
|
4c79b5 |
if (!$icat && $this->module_ary[$this->active_module_row_id]['is_duplicate'])
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$icat = $this->module_ary[$this->active_module_row_id]['parent'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Not being able to overwrite ;)
|
|
|
4c79b5 |
$this->module->u_action = append_sid("{$phpbb_admin_path}index.$phpEx", "i={$this->p_name}") . (($icat) ? '&icat=' . $icat : '') . "&mode={$this->p_mode}";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// If user specified the module url we will use it...
|
|
|
4c79b5 |
if ($module_url !== false)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$this->module->u_action = $module_url;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$this->module->u_action = $phpbb_root_path . (($user->page['page_dir']) ? $user->page['page_dir'] . '/' : '') . $user->page['page_name'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$this->module->u_action = append_sid($this->module->u_action, "i={$this->p_name}") . (($icat) ? '&icat=' . $icat : '') . "&mode={$this->p_mode}";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Add url_extra parameter to u_action url
|
|
|
4c79b5 |
if (!empty($this->module_ary) && $this->active_module !== false && $this->module_ary[$this->active_module_row_id]['url_extra'])
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$this->module->u_action .= $this->module_ary[$this->active_module_row_id]['url_extra'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Assign the module path for re-usage
|
|
|
4c79b5 |
$this->module->module_path = $module_path . '/';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Execute the main method for the new instance, we send the module id and mode as parameters
|
|
|
4c79b5 |
// Users are able to call the main method after this function to be able to assign additional parameters manually
|
|
|
4c79b5 |
if ($execute_module)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$this->module->main($this->p_name, $this->p_mode);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Appending url parameter to the currently active module.
|
|
|
4c79b5 |
*
|
|
|
4c79b5 |
* This function is called for adding specific url parameters while executing the current module.
|
|
|
4c79b5 |
* It is doing the same as the _module_{name}_url() function, apart from being able to be called after
|
|
|
4c79b5 |
* having dynamically parsed specific parameters. This allows more freedom in choosing additional parameters.
|
|
|
4c79b5 |
* One example can be seen in /includes/mcp/mcp_notes.php - $this->p_master->adjust_url() call.
|
|
|
4c79b5 |
*
|
|
|
4c79b5 |
* @param string $url_extra Extra url parameters, e.g.: &u=$user_id
|
|
|
4c79b5 |
*
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function adjust_url($url_extra)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if (empty($this->module_ary[$this->active_module_row_id]))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
return;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$row = &$this->module_ary[$this->active_module_row_id];
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// We check for the same url_extra in $row['url_extra'] to overcome doubled additions...
|
|
|
4c79b5 |
if (strpos($row['url_extra'], $url_extra) === false)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$row['url_extra'] .= $url_extra;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Check if a module is active
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function is_active($id, $mode = false)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// If we find a name by this id and being enabled we have our active one...
|
|
|
4c79b5 |
foreach ($this->module_ary as $row_id => $item_ary)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if (($item_ary['name'] === $id || $item_ary['id'] === (int) $id) && $item_ary['display'])
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if ($mode === false || $mode === $item_ary['mode'])
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
return true;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return false;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Get parents
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function get_parents($parent_id, $left_id, $right_id, &$all_parents)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $db;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$parents = array();
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($parent_id > 0)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
foreach ($all_parents as $module_id => $row)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if ($row['left_id'] < $left_id && $row['right_id'] > $right_id)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$parents[$module_id] = $row['parent_id'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($row['left_id'] > $left_id)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return $parents;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Get tree branch
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function get_branch($left_id, $right_id, $remaining)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$branch = array();
|
|
|
4c79b5 |
|
|
|
4c79b5 |
foreach ($remaining as $key => $row)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if ($row['left_id'] > $left_id && $row['left_id'] < $right_id)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$branch[] = $row;
|
|
|
4c79b5 |
continue;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return $branch;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Build true binary tree from given array
|
|
|
4c79b5 |
* Not in use
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function build_tree(&$modules, &$parents)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$tree = array();
|
|
|
4c79b5 |
|
|
|
4c79b5 |
foreach ($modules as $row)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$branch = &$tree;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($row['parent_id'])
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// Go through the tree to find our branch
|
|
|
4c79b5 |
$parent_tree = $parents[$row['module_id']];
|
|
|
4c79b5 |
|
|
|
4c79b5 |
foreach ($parent_tree as $id => $value)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if (!isset($branch[$id]) && isset($branch['child']))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$branch = &$branch['child'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$branch = &$branch[$id];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$branch = &$branch['child'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$branch[$row['module_id']] = $row;
|
|
|
4c79b5 |
if (!isset($branch[$row['module_id']]['child']))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$branch[$row['module_id']]['child'] = array();
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return $tree;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Build navigation structure
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function assign_tpl_vars($module_url)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $template;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$current_id = $right_id = false;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Make sure the module_url has a question mark set, effectively determining the delimiter to use
|
|
|
4c79b5 |
$delim = (strpos($module_url, '?') === false) ? '?' : '&';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$current_padding = $current_depth = 0;
|
|
|
4c79b5 |
$linear_offset = 'l_block1';
|
|
|
4c79b5 |
$tabular_offset = 't_block2';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Generate the list of modules, we'll do this in two ways ...
|
|
|
4c79b5 |
// 1) In a linear fashion
|
|
|
4c79b5 |
// 2) In a combined tabbed + linear fashion ... tabs for the categories
|
|
|
4c79b5 |
// and a linear list for subcategories/items
|
|
|
4c79b5 |
foreach ($this->module_ary as $row_id => $item_ary)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// Skip hidden modules
|
|
|
4c79b5 |
if (!$item_ary['display'])
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
continue;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Skip branch
|
|
|
4c79b5 |
if ($right_id !== false)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if ($item_ary['left'] < $right_id)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
continue;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$right_id = false;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Category with no members on their way down (we have to check every level)
|
|
|
4c79b5 |
if (!$item_ary['name'])
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$empty_category = true;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// We go through the branch and look for an activated module
|
|
|
4c79b5 |
foreach (array_slice($this->module_ary, $row_id + 1) as $temp_row)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if ($temp_row['left'] > $item_ary['left'] && $temp_row['left'] < $item_ary['right'])
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// Module there and displayed?
|
|
|
4c79b5 |
if ($temp_row['name'] && $temp_row['display'])
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$empty_category = false;
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
continue;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Skip the branch
|
|
|
4c79b5 |
if ($empty_category)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$right_id = $item_ary['right'];
|
|
|
4c79b5 |
continue;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Select first id we can get
|
|
|
4c79b5 |
if (!$current_id && (isset($this->module_cache['parents'][$item_ary['id']]) || $item_ary['id'] == $this->p_id))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$current_id = $item_ary['id'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$depth = $item_ary['depth'];
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($depth > $current_depth)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$linear_offset = $linear_offset . '.l_block' . ($depth + 1);
|
|
|
4c79b5 |
$tabular_offset = ($depth + 1 > 2) ? $tabular_offset . '.t_block' . ($depth + 1) : $tabular_offset;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else if ($depth < $current_depth)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
for ($i = $current_depth - $depth; $i > 0; $i--)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$linear_offset = substr($linear_offset, 0, strrpos($linear_offset, '.'));
|
|
|
4c79b5 |
$tabular_offset = ($i + $depth > 1) ? substr($tabular_offset, 0, strrpos($tabular_offset, '.')) : $tabular_offset;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$u_title = $module_url . $delim . 'i=' . (($item_ary['cat']) ? $item_ary['id'] : $item_ary['name'] . (($item_ary['is_duplicate']) ? '&icat=' . $current_id : '') . '&mode=' . $item_ary['mode']);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Was not allowed in categories before - /*!$item_ary['cat'] && */
|
|
|
4c79b5 |
$u_title .= (isset($item_ary['url_extra'])) ? $item_ary['url_extra'] : '';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Only output a categories items if it's currently selected
|
|
|
4c79b5 |
if (!$depth || ($depth && (in_array($item_ary['parent'], array_values($this->module_cache['parents'])) || $item_ary['parent'] == $this->p_parent)))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$use_tabular_offset = (!$depth) ? 't_block1' : $tabular_offset;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$tpl_ary = array(
|
|
|
4c79b5 |
'L_TITLE' => $item_ary['lang'],
|
|
|
4c79b5 |
'S_SELECTED' => (isset($this->module_cache['parents'][$item_ary['id']]) || $item_ary['id'] == $this->p_id) ? true : false,
|
|
|
4c79b5 |
'U_TITLE' => $u_title
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$template->assign_block_vars($use_tabular_offset, array_merge($tpl_ary, array_change_key_case($item_ary, CASE_UPPER)));
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$tpl_ary = array(
|
|
|
4c79b5 |
'L_TITLE' => $item_ary['lang'],
|
|
|
4c79b5 |
'S_SELECTED' => (isset($this->module_cache['parents'][$item_ary['id']]) || $item_ary['id'] == $this->p_id) ? true : false,
|
|
|
4c79b5 |
'U_TITLE' => $u_title
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$template->assign_block_vars($linear_offset, array_merge($tpl_ary, array_change_key_case($item_ary, CASE_UPPER)));
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$current_depth = $depth;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Returns desired template name
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function get_tpl_name()
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
return $this->module->tpl_name . '.html';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Returns the desired page title
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function get_page_title()
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $user;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (!isset($this->module->page_title))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
return '';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return (isset($user->lang[$this->module->page_title])) ? $user->lang[$this->module->page_title] : $this->module->page_title;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Load module as the current active one without the need for registering it
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function load($class, $name, $mode = false)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$this->p_class = $class;
|
|
|
4c79b5 |
$this->p_name = $name;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Set active module to true instead of using the id
|
|
|
4c79b5 |
$this->active_module = true;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$this->load_active($mode);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Display module
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function display($page_title, $display_online_list = true)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $template, $user;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Generate the page
|
|
|
4c79b5 |
if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin'])
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
adm_page_header($page_title);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
page_header($page_title, $display_online_list);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$template->set_filenames(array(
|
|
|
4c79b5 |
'body' => $this->get_tpl_name())
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin'])
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
adm_page_footer();
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
page_footer();
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Toggle whether this module will be displayed or not
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function set_display($id, $mode = false, $display = true)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
foreach ($this->module_ary as $row_id => $item_ary)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if (($item_ary['name'] === $id || $item_ary['id'] === (int) $id) && (!$mode || $item_ary['mode'] === $mode))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$this->module_ary[$row_id]['display'] = (int) $display;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Add custom MOD info language file
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function add_mod_info($module_class)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $user, $phpEx;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (file_exists($user->lang_path . $user->lang_name . '/mods'))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$add_files = array();
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$dir = @opendir($user->lang_path . $user->lang_name . '/mods');
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($dir)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
while (($entry = readdir($dir)) !== false)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if (strpos($entry, 'info_' . strtolower($module_class) . '_') === 0 && substr(strrchr($entry, '.'), 1) == $phpEx)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$add_files[] = 'mods/' . substr(basename($entry), 0, -(strlen($phpEx) + 1));
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
closedir($dir);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (sizeof($add_files))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$user->add_lang($add_files);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
?>
|