<?php
/*
* --------------------------------------------------------------------------
* NuclearBB
* (c) 2007 NuclearBB
* --------------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* --------------------------------------------------------------------------
*/
define('IN_NBB', true);
$root_path = '.';
require("$root_path/inc/global.php");
$session->begin();
$auth->setup();
add_lang('ucp');
if(! $session->logged_in)
{
trigger_error('not_auth');
}
$ucp_module_list = $ucp_modules_ordered = $default_module = $hide_menu = array();
$last_cat_id = -1;
$last_cat_name = $module_content = '';
$current_module = (isset($_GET['m'])) ? htmlspecialchars($_GET['m']) : 'overview';
$mode = (isset($_GET['mode'])) ? htmlspecialchars($_GET['mode']) : '';
$sql = "SELECT *
FROM modules
WHERE module_type = 'ucp'
AND module_enabled = 1
ORDER BY left_id ASC";
$result = $db->query($sql);
while($row = $db->fetch_assoc($result))
{
$ucp_module_list[] = $row;
}
for($i = 0; $i < count($ucp_module_list); $i++)
{
//Categories
if($ucp_module_list[$i]['parent_id'] == 0)
{
$last_cat_id = $ucp_module_list[$i]['module_id'];
$last_cat_name = $ucp_module_list[$i]['module_name'];
}
//Modules
if($ucp_module_list[$i]['parent_id'] == $last_cat_id)
{
$ucp_modules_ordered[$last_cat_name][ $ucp_module_list[$i]['module_name'] ] = $ucp_module_list[$i]['module_file'];
if($current_module == $ucp_module_list[$i]['module_name'])
{
$current_cat = $last_cat_name;
if((! empty($ucp_module_list[$i]['view_perm'])) && (! $auth->check($ucp_module_list[$i]['view_perm'])))
{
trigger_error('not_auth');
}
}
if(! $ucp_module_list[$i]['show_menu'])
{
$hide_menu[] = $ucp_module_list[$i]['module_name'];
}
}
}
foreach($ucp_modules_ordered as $cat_name => $cat_data)
{
$template->assign_block_vars('ucp_category', array(
'LANG' => lang($cat_name)
));
foreach($cat_data as $module_name => $module_file)
{
if(! in_array($module_file, $hide_menu))
{
$template->assign_block_vars('ucp_category.ucp_module', array(
'HREF' => "ucp.php?m=$module_name",
'IS_SELECTED' => ($current_module == $module_name),
'LANG' => lang($module_name)
));
}
if($current_module == $module_name)
{
if(file_exists("$root_path/inc/ucp/$module_file.php"))
{
ob_start();
include("$root_path/inc/ucp/$module_file.php");
$module_content = ob_get_contents();
ob_end_clean();
define('UCP_MODULE_INCLUDED', true);
}
}
}
}
//PAGE_TITLE is define()'ed in each module. If not set, it will default to lang('ucp')
if(! defined('PAGE_TITLE'))
{
define('PAGE_TITLE', 'ucp');
}
forum_header(lang(PAGE_TITLE));
$template->load('ucp_wrapper', 'ucp_wrapper.html');
$template->assign_vars(array(
'CURRENT_MODULE_LANG' => lang($current_module),
'CURRENT_MODULE_NAME' => $current_module,
'MODULE_CONTENT' => $module_content,
'SHOW_MODULE_ERROR' => (! defined('UCP_MODULE_INCLUDED'))
));
$template->display('ucp_wrapper');
forum_footer();
?>