mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-13 14:58:52 +00:00
Updated MCP
git-svn-id: file:///svn/phpbb/trunk@4694 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
91467dcd62
commit
068f81b676
1 changed files with 391 additions and 172 deletions
567
phpBB/mcp.php
567
phpBB/mcp.php
|
@ -17,50 +17,35 @@ $phpEx = substr(strrchr(__FILE__, '.'), 1);
|
||||||
include($phpbb_root_path . 'common.'.$phpEx);
|
include($phpbb_root_path . 'common.'.$phpEx);
|
||||||
include($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
|
include($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
|
||||||
|
|
||||||
/*
|
|
||||||
CREATE TABLE phpbb_modules (
|
|
||||||
module_id mediumint(8) NOT NULL auto_increment,
|
|
||||||
module_type char(3) NOT NULL default '',
|
|
||||||
module_title varchar(50) NOT NULL default '',
|
|
||||||
module_filename varchar(50) NOT NULL default '',
|
|
||||||
module_order mediumint(4) NOT NULL default '0',
|
|
||||||
module_enabled tinyint(1) unsigned NOT NULL default '1',
|
|
||||||
module_acl varchar(255) NOT NULL default '',
|
|
||||||
PRIMARY KEY (module_id),
|
|
||||||
KEY module_type (module_type,module_enabled)
|
|
||||||
);
|
|
||||||
|
|
||||||
INSERT INTO phpbb_modules VALUES (6, 'mcp', 'MAIN', 'main', 1, 1, '');
|
|
||||||
*/
|
|
||||||
@define('MODULES_TABLE', $table_prefix . 'modules');
|
|
||||||
|
|
||||||
// ---------
|
// ---------
|
||||||
// FUNCTIONS
|
// FUNCTIONS
|
||||||
//
|
//
|
||||||
class module
|
class module
|
||||||
{
|
{
|
||||||
var $module_id = 0;
|
var $id = 0;
|
||||||
var $module_url;
|
var $type;
|
||||||
var $modules = array();
|
var $name;
|
||||||
var $submodules = array();
|
var $mode;
|
||||||
|
var $modules;
|
||||||
|
|
||||||
function module($module_type, $module_url, $selected)
|
// Private methods, should not be overwritten
|
||||||
|
function create($module_type, $module_url, $selected_mod = false, $selected_submod = false)
|
||||||
{
|
{
|
||||||
global $auth, $db, $phpbb_root_path, $phpEx, $user;
|
global $template, $auth, $db, $user;
|
||||||
|
|
||||||
$sql = 'SELECT module_id, module_title, module_filename, module_acl
|
$sql = 'SELECT module_id, module_title, module_filename, module_subs, module_acl
|
||||||
FROM ' . MODULES_TABLE . "
|
FROM ' . MODULES_TABLE . "
|
||||||
WHERE module_type = '{$module_type}'
|
WHERE module_type = '{$module_type}'
|
||||||
AND module_enabled = 1
|
AND module_enabled = 1
|
||||||
ORDER BY module_order ASC";
|
ORDER BY module_order ASC";
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
|
// Authorisation is required for the basic module
|
||||||
if ($row['module_acl'])
|
if ($row['module_acl'])
|
||||||
{
|
{
|
||||||
// Authorisation is required
|
|
||||||
|
|
||||||
$is_auth = FALSE;
|
$is_auth = FALSE;
|
||||||
foreach (explode(',', $row['module_acl']) as $auth_option)
|
foreach (explode(',', $row['module_acl']) as $auth_option)
|
||||||
{
|
{
|
||||||
|
@ -70,70 +55,157 @@ class module
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The user is not authorised to use this module, skip it
|
||||||
if (!$is_auth)
|
if (!$is_auth)
|
||||||
{
|
{
|
||||||
// The user is not authorised to use this module, skip it
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($row['module_filename'] == $selected || $row['module_id'] == $selected)
|
$selected = ($row['module_filename'] == $selected_mod || $row['module_id'] == $selected_mod || (!$selected_mod && !$i)) ? true : false;
|
||||||
{
|
|
||||||
$module_id = intval($row['module_id']);
|
|
||||||
$module_name = $row['module_filename'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the localised lang string if available, or make up our own otherwise
|
// Get the localised lang string if available, or make up our own otherwise
|
||||||
$title = (isset($user->lang[strtoupper($module_type) . '_' . $row['module_title']])) ? $user->lang[strtoupper($module_type) . '_' . $row['module_title']] : ucfirst(str_replace('_', ' ', strtolower($row['module_title'])));
|
/*
|
||||||
|
$template->assign_block_vars($module_type . '_section', array(
|
||||||
$modules[intval($row['module_id'])] = array(
|
'L_TITLE' => (isset($user->lang[strtoupper($module_type) . '_' . $row['module_title']])) ? $user->lang[strtoupper($module_type) . '_' . $row['module_title']] : ucfirst(str_replace('_', ' ', strtolower($row['module_title']))),
|
||||||
'title' => $title,
|
'S_SELECTED' => $selected,
|
||||||
'name' => $row['module_filename'],
|
'U_TITLE' => $module_url . '&i=' . $row['module_id'])
|
||||||
'link' => '&i=' . $row['module_id']
|
|
||||||
);
|
);
|
||||||
|
*/
|
||||||
|
$this->modules[intval($row['module_id'])] = array(
|
||||||
|
'title' => (isset($user->lang[strtoupper($module_type) . '_' . strtoupper($row['module_title'])])) ? $user->lang[strtoupper($module_type) . '_' . strtoupper($row['module_title'])] : ucfirst(str_replace('_', ' ', strtolower($row['module_title']))),
|
||||||
|
'name' => $row['module_filename'],
|
||||||
|
'link' => '&i=' . $row['module_id'],
|
||||||
|
'selected' => $selected,
|
||||||
|
'subs' => array()
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
if ($selected)
|
||||||
|
{
|
||||||
|
$module_id = $row['module_id'];
|
||||||
|
$module_name = $row['module_filename'];
|
||||||
|
|
||||||
|
if ($row['module_subs'])
|
||||||
|
{
|
||||||
|
$j = 0;
|
||||||
|
$submodules_ary = explode("\n", $row['module_subs']);
|
||||||
|
foreach ($submodules_ary as $submodule)
|
||||||
|
{
|
||||||
|
$submodule = explode(',', trim($submodule));
|
||||||
|
$submodule_title = array_shift($submodule);
|
||||||
|
|
||||||
|
$is_auth = true;
|
||||||
|
foreach ($submodule as $auth_option)
|
||||||
|
{
|
||||||
|
if (!$auth->acl_get($auth_option))
|
||||||
|
{
|
||||||
|
$is_auth = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$is_auth)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$selected = ($submodule_title == $selected_submod || (!$selected_submod && !$j)) ? true : false;
|
||||||
|
|
||||||
|
// Get the localised lang string if available, or make up our own otherwise
|
||||||
|
/*
|
||||||
|
$template->assign_block_vars("{$module_type}_section.{$module_type}_subsection", array(
|
||||||
|
'L_TITLE' => (isset($user->lang[strtoupper($module_type) . '_' . strtoupper($submodule_title)])) ? $user->lang[strtoupper($module_type) . '_' . strtoupper($submodule_title)] : ucfirst(str_replace('_', ' ', strtolower($submodule_title))),
|
||||||
|
'S_SELECTED' => $selected,
|
||||||
|
'U_TITLE' => $module_url . '&i=' . $module_id . '&mode=' . $submodule_title
|
||||||
|
));
|
||||||
|
*/
|
||||||
|
$this->modules[intval($row['module_id'])]['subs'][$submodule_title] = array(
|
||||||
|
'title' => (isset($user->lang[strtoupper($module_type) . '_' . strtoupper($submodule_title)])) ? $user->lang[strtoupper($module_type) . '_' . strtoupper($submodule_title)] : ucfirst(str_replace('_', ' ', strtolower($submodule_title))),
|
||||||
|
'name' => $submodule_title,
|
||||||
|
'link' => '&i=' . $module_id . '&mode=' . $submodule_title,
|
||||||
|
'selected' => $selected
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($selected)
|
||||||
|
{
|
||||||
|
$this->mode = $submodule_title;
|
||||||
|
}
|
||||||
|
|
||||||
|
$j++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$i++;
|
||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
if (empty($module_id))
|
if (!$module_id)
|
||||||
{
|
{
|
||||||
trigger_error('MODULE_NOT_EXIST');
|
trigger_error('MODULE_NOT_EXIST');
|
||||||
}
|
}
|
||||||
|
|
||||||
require($phpbb_root_path . "includes/{$module_type}/{$module_type}_{$module_name}.$phpEx");
|
$this->type = $module_type;
|
||||||
eval("\$this->module = new {$module_type}_{$module_name}(\$module_id);");
|
$this->id = $module_id;
|
||||||
|
$this->name = $module_name;
|
||||||
$this->module->modules = $modules;
|
$this->url = $module_url;
|
||||||
$this->module->module_url = $module_url;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This generates the block template variable for outputting the list
|
function load($type = false, $name = false, $mode = false, $run = true)
|
||||||
// of submodules, should be called with an associative array of modules
|
|
||||||
// in the form 'LANG_STRING' => 'LINK'
|
|
||||||
function menu($selected)
|
|
||||||
{
|
{
|
||||||
global $template, $user;
|
global $template, $phpbb_root_path, $phpEx;
|
||||||
|
|
||||||
foreach ($this->modules as $module_id => $section_data)
|
if ($type)
|
||||||
{
|
{
|
||||||
$template->assign_block_vars($this->module_type . '_section', array(
|
$this->type = $type;
|
||||||
'L_TITLE' => $section_data['title'],
|
|
||||||
'S_SELECTED' => ($module_id == $this->module_id) ? TRUE : FALSE,
|
|
||||||
'U_TITLE' => $this->url . $section_data['link'])
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($module_id == $this->module_id)
|
|
||||||
{
|
|
||||||
foreach ($this->submodules as $title => $module_link)
|
|
||||||
{
|
|
||||||
// Get the localised lang string if available, or make up our own otherwise
|
|
||||||
$section_title = (isset($user->lang[$title])) ? $user->lang[$title] : ucfirst(str_replace('_', ' ', strtolower($title)));
|
|
||||||
|
|
||||||
$template->assign_block_vars("{$this->module_type}_section.{$this->module_type}_subsection", array(
|
|
||||||
'L_TITLE' => $section_title,
|
|
||||||
'S_SELECTED' => ($title == $selected) ? TRUE : FALSE,
|
|
||||||
'U_TITLE' => $this->url . $module_link
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($name)
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$mode && $this->mode)
|
||||||
|
{
|
||||||
|
$mode = $this->mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!class_exists($this->type . '_' . $this->name))
|
||||||
|
{
|
||||||
|
$filename = $phpbb_root_path . "includes/{$this->type}/{$this->type}_{$this->name}.$phpEx";
|
||||||
|
include_once($filename);
|
||||||
|
|
||||||
|
if (!class_exists($this->type . '_' . $this->name) && !file_exists($filename))
|
||||||
|
{
|
||||||
|
trigger_error('MODULE_NOT_EXIST');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($run)
|
||||||
|
{
|
||||||
|
eval("\$this->module = new {$this->type}_{$this->name}(\$this->id, \$mode);");
|
||||||
|
|
||||||
|
$vars = array('modules', 'id', 'name', 'type', 'url', 'mode');
|
||||||
|
foreach ($vars as $var)
|
||||||
|
{
|
||||||
|
$this->module->$var = $this->$var;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Shortcut to submodules
|
||||||
|
$this->module->subs =& $this->module->modules[$this->id]['subs'];
|
||||||
|
|
||||||
|
if (method_exists($this->module, 'init'))
|
||||||
|
{
|
||||||
|
$this->module->init();
|
||||||
|
}
|
||||||
|
if (method_exists($this->module, 'main'))
|
||||||
|
{
|
||||||
|
$this->module->main($mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
// We're not exactly supposed to ever get there
|
||||||
|
$template->assign_var('MESSAGE', 'This mode is currently unavailable');
|
||||||
|
$this->display('An error occured', 'mcp_front.html');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,6 +215,30 @@ class module
|
||||||
{
|
{
|
||||||
global $template;
|
global $template;
|
||||||
|
|
||||||
|
// This method is used to put variables in menu titles
|
||||||
|
if (method_exists($this, 'alter_menu'))
|
||||||
|
{
|
||||||
|
$this->alter_menu();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($this->modules as $id => $section_data)
|
||||||
|
{
|
||||||
|
$template->assign_block_vars($this->type . '_section', array(
|
||||||
|
'L_TITLE' => $section_data['title'],
|
||||||
|
'S_SELECTED' => ($id == $this->id) ? TRUE : FALSE,
|
||||||
|
'U_TITLE' => $this->url . $section_data['link'])
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($section_data['subs'] as $sub)
|
||||||
|
{
|
||||||
|
$template->assign_block_vars("{$this->type}_section.{$this->type}_subsection", array(
|
||||||
|
'L_TITLE' => $sub['title'],
|
||||||
|
'S_SELECTED' => ($sub['name'] == $this->mode) ? TRUE : FALSE,
|
||||||
|
'U_TITLE' => $this->url . $sub['link']
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
page_header($page_title);
|
page_header($page_title);
|
||||||
|
|
||||||
$template->set_filenames(array(
|
$template->set_filenames(array(
|
||||||
|
@ -152,31 +248,95 @@ class module
|
||||||
page_footer();
|
page_footer();
|
||||||
}
|
}
|
||||||
|
|
||||||
function message_die($msg)
|
|
||||||
{
|
|
||||||
global $template, $user;
|
|
||||||
|
|
||||||
if (isset($user->lang[$msg]))
|
// Public methods to be overwritten by modules
|
||||||
|
function module()
|
||||||
{
|
{
|
||||||
$msg = $user->lang[$msg];
|
// Module name
|
||||||
|
// Module filename
|
||||||
|
// Module description
|
||||||
|
// Module version
|
||||||
|
// Module compatibility
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$template->assign_vars(array(
|
function init()
|
||||||
'MESSAGE_TITLE' => $user->lang['MESSAGE'],
|
{
|
||||||
'MESSAGE_TEXT' => $msg
|
return false;
|
||||||
));
|
}
|
||||||
$this->display('MCP', 'mcp_message.html');
|
|
||||||
|
function install()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function uninstall()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class mcp extends module
|
class mcp extends module
|
||||||
{
|
{
|
||||||
var $module_type = 'mcp';
|
|
||||||
var $forum_id = 0;
|
var $forum_id = 0;
|
||||||
var $topic_id = 0;
|
var $topic_id = 0;
|
||||||
var $post_id = 0;
|
var $post_id = 0;
|
||||||
|
var $topic_id_list = array();
|
||||||
|
var $post_id_list = array();
|
||||||
|
|
||||||
function get_forum_data($forum_id, $acl_list = '', $return_on_error = FALSE)
|
function get_topic_ids($acl_list = '')
|
||||||
|
{
|
||||||
|
if (!$this->topic_id_list)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
global $auth, $db;
|
||||||
|
$topic_ids = array();
|
||||||
|
|
||||||
|
$sql = 'SELECT topic_id, forum_id
|
||||||
|
FROM ' . TOPICS_TABLE . '
|
||||||
|
WHERE topic_id IN (' . implode(', ', $this->topic_id_list) . ')';
|
||||||
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
|
while ($row = $db->sql_fetchrow($result))
|
||||||
|
{
|
||||||
|
if (!$acl_list || $auth->acl_get($acl_list, $row['forum_id']))
|
||||||
|
{
|
||||||
|
$topic_ids[] = $row['topic_id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $topic_ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_post_ids($acl_list = '')
|
||||||
|
{
|
||||||
|
if (!$this->post_id_list)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
global $auth, $db;
|
||||||
|
$post_ids = array();
|
||||||
|
|
||||||
|
$sql = 'SELECT post_id, forum_id
|
||||||
|
FROM ' . POSTS_TABLE . '
|
||||||
|
WHERE post_id IN (' . implode(', ', $this->post_id_list) . ')';
|
||||||
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
|
while ($row = $db->sql_fetchrow($result))
|
||||||
|
{
|
||||||
|
if (!$acl_list || $auth->acl_get($acl_list, $row['forum_id']))
|
||||||
|
{
|
||||||
|
$post_ids[] = $row['post_id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $post_ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_forum_data($forum_id, $acl_list = 'f_list')
|
||||||
{
|
{
|
||||||
global $auth, $db;
|
global $auth, $db;
|
||||||
$rowset = array();
|
$rowset = array();
|
||||||
|
@ -200,12 +360,11 @@ class mcp extends module
|
||||||
$rowset[$row['forum_id']] = $row;
|
$rowset[$row['forum_id']] = $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$return_on_error && empty($rowset))
|
if (empty($rowset))
|
||||||
{
|
{
|
||||||
$this->message_die('FORUM_NOT_EXIST');
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
elseif (is_array($forum_id))
|
||||||
if (is_array($forum_id))
|
|
||||||
{
|
{
|
||||||
return $rowset;
|
return $rowset;
|
||||||
}
|
}
|
||||||
|
@ -215,7 +374,7 @@ class mcp extends module
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_topic_data($topic_id, $acl_list = '', $return_on_error = FALSE)
|
function get_topic_data($topic_id, $acl_list = '')
|
||||||
{
|
{
|
||||||
global $auth, $db;
|
global $auth, $db;
|
||||||
$rowset = array();
|
$rowset = array();
|
||||||
|
@ -238,13 +397,23 @@ class mcp extends module
|
||||||
$row['topic_replies'] = $row['topic_replies_real'];
|
$row['topic_replies'] = $row['topic_replies_real'];
|
||||||
$row['forum_topics'] = $row['forum_topics_real'];
|
$row['forum_topics'] = $row['forum_topics_real'];
|
||||||
}
|
}
|
||||||
|
elseif (!$row['topic_approved'])
|
||||||
|
{
|
||||||
|
// TODO: should moderators without m_approve be allowed to perform any action of unapproved items?
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$rowset[$row['topic_id']] = $row;
|
$rowset[$row['topic_id']] = $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$return_on_error && empty($rowset))
|
if (empty($rowset))
|
||||||
{
|
{
|
||||||
$this->message_die('TOPIC_NOT_EXIST');
|
// DEBUG
|
||||||
|
global $template;
|
||||||
|
$template->assign_var('MESSAGE', 'Error while retrieving topic data #' . $topic_id);
|
||||||
|
// -----
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($topic_id))
|
if (is_array($topic_id))
|
||||||
|
@ -257,26 +426,103 @@ class mcp extends module
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_post_data($post_id, $acl_list = '')
|
||||||
|
{
|
||||||
|
global $auth, $db;
|
||||||
|
$rowset = array();
|
||||||
|
|
||||||
|
// DEBUG: won't probably work on global announcements
|
||||||
|
$sql = 'SELECT p.*, u.*, t.*, f.*
|
||||||
|
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u, ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . ' f
|
||||||
|
WHERE p.post_id ' . ((is_array($post_id)) ? 'IN (' . implode(', ', $post_id) . ')' : "= $post_id") . '
|
||||||
|
AND u.user_id = p.poster_id
|
||||||
|
AND t.topic_id = p.topic_id
|
||||||
|
AND f.forum_id = p.forum_id';
|
||||||
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
|
while ($row = $db->sql_fetchrow($result))
|
||||||
|
{
|
||||||
|
if ($acl_list && !$auth->acl_get($acl_list, $row['forum_id']))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!$row['post_approved'] && !$auth->acl_get('m_approve', $row['forum_id']))
|
||||||
|
{
|
||||||
|
// TODO: should moderators without m_approve be allowed to perform any action of unapproved items?
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$rowset[$row['post_id']] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($rowset))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
elseif (is_array($post_id))
|
||||||
|
{
|
||||||
|
return $rowset;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return array_pop($rowset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function mcp_init()
|
function mcp_init()
|
||||||
{
|
{
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
// Obtain initial var settings
|
// Obtain initial var settings
|
||||||
$this->forum_id = (isset($_REQUEST['f'])) ? max(0, intval($_REQUEST['f'])) : 0;
|
$this->forum_id = request_var('f', 0);
|
||||||
$this->topic_id = (!empty($_REQUEST['t'])) ? intval($_REQUEST['t']) : 0;
|
$this->topic_id = request_var('t', 0);
|
||||||
$this->post_id = (!empty($_REQUEST['p'])) ? intval($_REQUEST['p']) : 0;
|
$this->post_id = request_var('p', 0);
|
||||||
|
|
||||||
$this->topic_id_list = ($this->topic_id) ? array($this->topic_id) : array();
|
$this->topic_id_list = ($this->topic_id) ? array($this->topic_id) : array();
|
||||||
$this->post_id_list = ($this->post_id) ? array($this->post_id) : array();
|
$this->post_id_list = ($this->post_id) ? array($this->post_id) : array();
|
||||||
|
|
||||||
$this->to_forum_id = (!empty($_REQUEST['to_forum_id'])) ? intval($_REQUEST['to_forum_id']) : 0;
|
$this->to_forum_id = request_var('to_forum_id', 0);
|
||||||
$this->to_topic_id = (!empty($_REQUEST['to_topic_id'])) ? intval($_REQUEST['to_topic_id']) : 0;
|
$this->to_topic_id = request_var('to_topic_id', 0);
|
||||||
|
|
||||||
$this->confirm = (!empty($_POST['confirm'])) ? TRUE : FALSE;
|
$this->cancel = request_var('cancel', FALSE);
|
||||||
$this->action = (!empty($_REQUEST['action'])) ? $_REQUEST['action'] : '';
|
$this->confirm = ($this->cancel) ? FALSE : request_var('confirm', FALSE);
|
||||||
$this->quickmod = (!empty($_REQUEST['quickmod'])) ? TRUE : FALSE;
|
$this->quickmod = request_var('quickmod', FALSE);
|
||||||
|
|
||||||
|
$this->view = request_var('view', '');
|
||||||
|
$this->start = request_var('start', 0);
|
||||||
|
$this->action = request_var('action', '');
|
||||||
|
if (is_array($this->action))
|
||||||
|
{
|
||||||
|
list($this->action, $void) = each($this->action);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cleanse input
|
||||||
|
if (!empty($_POST['topic_id_list']) && is_array($_POST['topic_id_list']))
|
||||||
|
{
|
||||||
|
foreach ($_POST['topic_id_list'] as $t_id)
|
||||||
|
{
|
||||||
|
if ($t_id = intval($t_id))
|
||||||
|
{
|
||||||
|
$this->topic_id_list[] = $t_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!empty($_POST['post_id_list']) && is_array($_POST['post_id_list']))
|
||||||
|
{
|
||||||
|
foreach ($_POST['post_id_list'] as $p_id)
|
||||||
|
{
|
||||||
|
if ($p_id = intval($p_id))
|
||||||
|
{
|
||||||
|
$this->post_id_list[] = $p_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Put the forum_id and al in the url
|
// Put the forum_id and al in the url
|
||||||
|
if (!$this->post_id && !empty($this->post_id_list))
|
||||||
|
{
|
||||||
|
$this->post_id = $this->post_id_list[0];
|
||||||
|
}
|
||||||
if ($this->post_id)
|
if ($this->post_id)
|
||||||
{
|
{
|
||||||
$this->url .= '&p=' . $this->post_id;
|
$this->url .= '&p=' . $this->post_id;
|
||||||
|
@ -301,6 +547,11 @@ class mcp extends module
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$this->topic_id && !empty($this->topic_id_list))
|
||||||
|
{
|
||||||
|
$this->topic_id = $this->topic_id_list[0];
|
||||||
|
}
|
||||||
if ($this->topic_id)
|
if ($this->topic_id)
|
||||||
{
|
{
|
||||||
$this->url .= '&t=' . $this->topic_id;
|
$this->url .= '&t=' . $this->topic_id;
|
||||||
|
@ -319,28 +570,6 @@ class mcp extends module
|
||||||
$this->url .= '&f=' . $this->forum_id;
|
$this->url .= '&f=' . $this->forum_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanse inputted values
|
|
||||||
if (!empty($_POST['topic_id_list']) && is_array($_POST['topic_id_list']))
|
|
||||||
{
|
|
||||||
foreach ($_POST['topic_id_list'] as $t_id)
|
|
||||||
{
|
|
||||||
if ($t_id = intval($t_id))
|
|
||||||
{
|
|
||||||
$this->topic_id_list[] = $t_id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!empty($_POST['post_id_list']) && is_array($_POST['post_id_list']))
|
|
||||||
{
|
|
||||||
foreach ($_POST['post_id_list'] as $p_id)
|
|
||||||
{
|
|
||||||
if ($p_id = intval($p_id))
|
|
||||||
{
|
|
||||||
$this->post_id_list[] = $p_id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Build short_id_list
|
// Build short_id_list
|
||||||
if (!empty($_GET['selected_ids']))
|
if (!empty($_GET['selected_ids']))
|
||||||
{
|
{
|
||||||
|
@ -361,7 +590,7 @@ class mcp extends module
|
||||||
$sql = 'SELECT forum_id, forum_name, forum_type, left_id, right_id
|
$sql = 'SELECT forum_id, forum_name, forum_type, left_id, right_id
|
||||||
FROM ' . FORUMS_TABLE . '
|
FROM ' . FORUMS_TABLE . '
|
||||||
ORDER BY left_id ASC';
|
ORDER BY left_id ASC';
|
||||||
$result = $db->sql_query($sql, 120);
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
$right = $cat_right = 0;
|
$right = $cat_right = 0;
|
||||||
$padding = $forum_list = $holding = '';
|
$padding = $forum_list = $holding = '';
|
||||||
|
@ -412,7 +641,6 @@ class mcp extends module
|
||||||
|
|
||||||
$template->assign_vars(array(
|
$template->assign_vars(array(
|
||||||
'S_JUMPBOX_ACTION' => $action,
|
'S_JUMPBOX_ACTION' => $action,
|
||||||
'S_MCP_ACTION' => $action,
|
|
||||||
'S_ENABLE_SELECT_ALL' => $enable_select_all,
|
'S_ENABLE_SELECT_ALL' => $enable_select_all,
|
||||||
'S_CURRENT_FORUM' => intval($forum_id)
|
'S_CURRENT_FORUM' => intval($forum_id)
|
||||||
));
|
));
|
||||||
|
@ -443,7 +671,7 @@ class mcp extends module
|
||||||
{
|
{
|
||||||
global $db, $user, $auth, $template;
|
global $db, $user, $auth, $template;
|
||||||
|
|
||||||
$sort_days = (!empty($_REQUEST['st'])) ? max(intval($_REQUEST['st']), 0) : 0;
|
$sort_days = request_var('sort_days', '0');
|
||||||
$min_time = ($sort_days) ? time() - ($sort_days * 86400) : 0;
|
$min_time = ($sort_days) ? time() - ($sort_days * 86400) : 0;
|
||||||
|
|
||||||
switch ($mode)
|
switch ($mode)
|
||||||
|
@ -455,7 +683,7 @@ class mcp extends module
|
||||||
$sql = 'SELECT COUNT(topic_id) AS total
|
$sql = 'SELECT COUNT(topic_id) AS total
|
||||||
FROM ' . TOPICS_TABLE . "
|
FROM ' . TOPICS_TABLE . "
|
||||||
$where_sql forum_id = $forum_id
|
$where_sql forum_id = $forum_id
|
||||||
AND topic_type <> " . POST_ANNOUNCE . "
|
AND topic_type NOT IN (" . POST_ANNOUNCE . ', ' . POST_GLOBAL . ")
|
||||||
AND topic_last_post_time >= $min_time";
|
AND topic_last_post_time >= $min_time";
|
||||||
|
|
||||||
if (!$auth->acl_get('m_approve', $forum_id))
|
if (!$auth->acl_get('m_approve', $forum_id))
|
||||||
|
@ -479,7 +707,7 @@ class mcp extends module
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'unapproved':
|
case 'unapproved_posts':
|
||||||
$type = 'posts';
|
$type = 'posts';
|
||||||
$default_key = 't';
|
$default_key = 't';
|
||||||
$default_dir = 'd';
|
$default_dir = 'd';
|
||||||
|
@ -490,6 +718,17 @@ class mcp extends module
|
||||||
AND post_time >= ' . $min_time;
|
AND post_time >= ' . $min_time;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'unapproved_topics':
|
||||||
|
$type = 'topics';
|
||||||
|
$default_key = 't';
|
||||||
|
$default_dir = 'd';
|
||||||
|
$sql = 'SELECT COUNT(topic_id) AS total
|
||||||
|
FROM ' . TOPICS_TABLE . "
|
||||||
|
$where_sql forum_id IN (" . (($forum_id) ? $forum_id : implode(', ', get_forum_list('m_approve'))) . ')
|
||||||
|
AND topic_approved = 0
|
||||||
|
AND topic_time >= ' . $min_time;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'reports':
|
case 'reports':
|
||||||
$type = 'reports';
|
$type = 'reports';
|
||||||
$default_key = 'p';
|
$default_key = 'p';
|
||||||
|
@ -527,8 +766,8 @@ class mcp extends module
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sort_key = (!empty($_REQUEST['sk'])) ? htmlspecialchars($_REQUEST['sk']) : $default_key;
|
$sort_key = request_var('sk', $default_key);
|
||||||
$sort_dir = (!empty($_REQUEST['sd'])) ? htmlspecialchars($_REQUEST['sd']) : $default_dir;
|
$sort_dir = request_var('sd', $default_dir);
|
||||||
$sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']);
|
$sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']);
|
||||||
|
|
||||||
switch ($type)
|
switch ($type)
|
||||||
|
@ -544,7 +783,7 @@ class mcp extends module
|
||||||
case 'posts':
|
case 'posts':
|
||||||
$limit_days = array(0 => $user->lang['ALL_POSTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 364 => $user->lang['1_YEAR']);
|
$limit_days = array(0 => $user->lang['ALL_POSTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 364 => $user->lang['1_YEAR']);
|
||||||
$sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']);
|
$sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']);
|
||||||
$sort_by_sql = array('a' => 'u.username', 't' => 'p.post_time', 's' => 'p.post_subject');
|
$sort_by_sql = array('a' => 'u.username', 't' => 'p.post_id', 's' => 'p.post_subject');
|
||||||
$limit_time_sql = ($min_time) ? "AND p.post_time >= $min_time" : '';
|
$limit_time_sql = ($min_time) ? "AND p.post_time >= $min_time" : '';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -585,70 +824,50 @@ class mcp extends module
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function return_link($msg, $url)
|
||||||
|
{
|
||||||
|
global $template, $user;
|
||||||
|
|
||||||
|
$template->assign_block_vars('return_links', array(
|
||||||
|
'U_LINK' => $url,
|
||||||
|
'MESSAGE_LINK' => sprintf($user->lang[$msg], '<a href="' . $url . '">', '</a>')
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
// FUNCTIONS
|
// FUNCTIONS
|
||||||
// ---------
|
// ---------
|
||||||
|
|
||||||
|
|
||||||
// Start session management
|
// Start session management
|
||||||
$user->start();
|
$user->start();
|
||||||
$auth->acl($user->data);
|
$auth->acl($user->data);
|
||||||
|
|
||||||
$user->setup();
|
$user->setup();
|
||||||
|
|
||||||
|
$mcp = new module();
|
||||||
|
|
||||||
// Basic parameter data
|
// Basic parameter data
|
||||||
$module = (!empty($_REQUEST['i'])) ? intval($_REQUEST['i']) : 0;
|
$module = request_var('i', 'main');
|
||||||
$start = (!empty($_REQUEST['start'])) ? intval($_REQUEST['start']) : 0;
|
if (isset($_POST['jumpbox']) || isset($_POST['sort']) || isset($_POST['confirm']) || isset($_POST['cancel']))
|
||||||
if (!empty($_REQUEST['mode']))
|
|
||||||
{
|
{
|
||||||
if (is_array($_REQUEST['mode']))
|
// Sometimes we want to ignore input from the dropdown list of modes
|
||||||
{
|
// when the jumpbox is used or when confirming an action for example
|
||||||
list($mode, $void) = each($_REQUEST['mode']);
|
$mode = request_var('mode', '', 'GET');
|
||||||
}
|
}
|
||||||
else
|
elseif (isset($_POST['mode']) && is_array($_POST['mode']))
|
||||||
{
|
{
|
||||||
$mode = $_REQUEST['mode'];
|
list($mode, $void) = each($_POST['mode']);
|
||||||
}
|
$mode = htmlspecialchars($mode);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$mode = 'front';
|
$mode = request_var('mode', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Basic "global" modes
|
// Instantiate module system and generate list of available modules
|
||||||
if (!$module)
|
$mcp->create('mcp', "mcp.$phpEx$SID", $module, $mode);
|
||||||
{
|
|
||||||
switch ($mode)
|
|
||||||
{
|
|
||||||
// NOTE: below are basic modes that must not require a module_id to ne passed
|
|
||||||
case 'topic_view':
|
|
||||||
case 'post_details':
|
|
||||||
case 'approve':
|
|
||||||
// used in viewtopic.php
|
|
||||||
|
|
||||||
case 'split':
|
// Load and execute the relevant module
|
||||||
case 'delete':
|
$mcp->load('mcp', false, $mode, TRUE);
|
||||||
case 'merge':
|
|
||||||
case 'move':
|
|
||||||
case 'fork':
|
|
||||||
case 'make_normal':
|
|
||||||
case 'make_sticky':
|
|
||||||
case 'make_announce':
|
|
||||||
case 'make_global':
|
|
||||||
// quick-mod
|
|
||||||
|
|
||||||
case 'forum_view':
|
|
||||||
case 'front':
|
|
||||||
default:
|
|
||||||
$module = 'main';
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Instantiate a new mcp object
|
|
||||||
// NOTE: if $module is an integer, the module corresponding to this module_id will be loaded
|
|
||||||
// if it's a string, the module of this name will be loaded
|
|
||||||
$mcp = new module('mcp', "mcp.$phpEx$SID", $module);
|
|
||||||
$mcp->module->main($mode);
|
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Add table
Reference in a new issue