1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-02-13 12:35:06 +01:00

nooooo.... the mcp is gone. Yes, we now rely on the good will of our users, no moderation anymore.

buhahaha buhahaharrrr harrr


git-svn-id: file:///svn/phpbb/trunk@4921 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2004-07-08 22:57:05 +00:00
parent 05f1315ebb
commit 754b1c91f4
4 changed files with 1116 additions and 2388 deletions

File diff suppressed because it is too large Load Diff

View File

@ -11,304 +11,4 @@
//
// -------------------------------------------------------------
/*
TODO
- order items by forum?
- ability to restrict listing to a certain forum?
- pagination missing
*/
class mcp_queue extends mcp
{
function init()
{
global $db;
// Validate input
$this->mcp_init();
}
function main($mode)
{
global $auth, $db, $user, $template;
global $config, $phpbb_root_path, $phpEx, $SID;
$this->mode = $mode;
switch ($mode)
{
case 'approve':
//
// TODO: increment post counts
// warn users watching forums/topics
//
// Get topic data
if ($post_id_list = $this->get_post_ids('m_approve'))
{
$post_mode = 'unapproved_posts';
$sql = 'SELECT topic_id
FROM ' . POSTS_TABLE . '
WHERE post_id IN (' . implode(', ', $post_id_list) . ')';
$result = $db->sql_query($sql);
$topic_id_list = array();
while ($row = $db->sql_fetchrow($result))
{
$topic_id_list[] = $row['topic_id'];
// TODO: log posts being approved? that would be a hell lot of logging
//add_log('mod', $row['forum_id'], $row['topic_id'], 'LOG_APPROVE_POST', $row['post_id']);
}
$msg = (count($post_id_list) == 1) ? $user->lang['POST_APPROVED_SUCCESS'] : $user->lang['POSTS_APPROVED_SUCCESS'];
// Return to topic
$redirect_url = "viewtopic.$phpEx$SID&f={$this->forum_id}&p={$this->post_id}#{$this->post_id}";
if ($this->quickmod)
{
meta_refresh(3, $redirect_url);
$return_topic = '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $redirect_url . '">', '</a>');
}
else
{
if (count($post_id_list) == 1)
{
return_link('RETURN_POST', $this->url . '&amp;mode=post_details');
}
return_link('RETURN_TOPIC', $redirect_url);
}
}
elseif ($topic_id_list = $this->get_topic_ids('m_approve'))
{
$post_mode = 'unapproved_topics';
$sql = 'SELECT forum_id, topic_title, topic_first_post_id
FROM ' . TOPICS_TABLE . '
WHERE topic_id IN (' . implode(', ', $topic_id_list) . ')';
$result = $db->sql_query($sql);
$post_id_list = array();
while ($row = $db->sql_fetchrow($result))
{
$post_id_list[] = $row['topic_first_post_id'];
add_log('mod', $row['forum_id'], $row['topic_id'], 'LOG_APPROVE_TOPIC', $row['topic_title']);
}
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_approved = 1
WHERE topic_id IN (' . implode(', ', $topic_id_list) . ')';
$db->sql_query($sql);
$msg = (count($topic_id_list) == 1) ? $user->lang['TOPIC_APPROVED_SUCCESS'] : $user->lang['TOPICS_APPROVED_SUCCESS'];
// Return to forum
$redirect_url = "viewforum.$phpEx$SID&amp;f=" . $this->forum_id;
if ($this->quickmod)
{
meta_refresh(3, $redirect_url);
$return_topic = '';
}
else
{
return_link('RETURN_FORUM', $redirect_url);
}
}
else
{
trigger_error('NOT_MODERATOR');
}
// Update approved flag
$sql = 'UPDATE ' . POSTS_TABLE . '
SET post_approved = 1
WHERE post_id IN (' . implode(', ', $post_id_list) . ')';
$db->sql_query($sql);
// Now resync everything
sync('topic', 'topic_id', $topic_id_list, true, true);
sync('forum', 'forum_id', $this->forum_id, true, true);
// Back to... whatever
if ($this->quickmod)
{
trigger_error($msg . $return_topic . '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], "<a href=\"viewforum.$phpEx$SID&amp;f=" . $this->forum_id . '">', '</a>'));
}
else
{
$template->assign_var('MESSAGE', $msg);
$this->main($post_mode);
}
break;
case 'unapproved_topics':
case 'unapproved_posts':
if (!$forum_list = implode(', ', get_forum_list('m_approve')))
{
trigger_error('NOT_MODERATOR');
}
$this->mcp_sorting($mode, $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $this->forum_id);
$forum_topics = ($total == -1) ? $forum_info['forum_topics'] : $total;
$limit_time_sql = ($sort_days) ? 'AND t.topic_last_post_time >= ' . (time() - ($sort_days * 86400)) : '';
if ($mode == 'unapproved_posts')
{
$sql = 'SELECT p.post_id
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t' . (($sort_order_sql{0} == 'u') ? ', ' . USERS_TABLE . ' u' : '') . "
WHERE p.forum_id IN ($forum_list)
AND p.post_approved = 0
" . (($sort_order_sql{0} == 'u') ? 'AND u.user_id = p.poster_id' : '') . "
AND t.topic_id = p.topic_id
AND t.topic_first_post_id <> p.post_id
ORDER BY $sort_order_sql";
$result = $db->sql_query_limit($sql, $config['topics_per_page'], $this->start);
$i = 0;
$post_ids = array();
while ($row = $db->sql_fetchrow($result))
{
$post_ids[] = $row['post_id'];
$row_num[$row['post_id']] = $i++;
}
if (sizeof($post_ids))
{
$sql = 'SELECT f.forum_id, f.forum_name, t.topic_id, t.topic_title, p.post_id, p.post_username, p.poster_id, p.post_time, u.username
FROM ' . POSTS_TABLE . ' p, ' . FORUMS_TABLE . ' f, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . " u
WHERE p.post_id IN (" . implode(', ', $post_ids) . ")
AND t.topic_id = p.topic_id
AND f.forum_id = p.forum_id
AND u.user_id = p.poster_id";
$result = $db->sql_query($sql);
$post_data = $rowset = array();
while ($row = $db->sql_fetchrow($result))
{
$post_data[$row['post_id']] = $row;
}
$db->sql_freeresult($result);
foreach ($post_ids as $post_id)
{
$rowset[] = $post_data[$post_id];
}
unset($post_data, $post_ids);
}
else
{
$rowset = array();
}
}
else
{
$sql = 'SELECT f.forum_id, f.forum_name, t.topic_id, t.topic_title, t.topic_time AS post_time, t.topic_poster AS poster_id, t.topic_first_post_id AS post_id, t.topic_first_poster_name AS username
FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f
WHERE t.topic_approved = 0
AND t.forum_id IN ($forum_list)
AND f.forum_id = t.forum_id
ORDER BY $sort_order_sql";
$result = $db->sql_query_limit($sql, $config['topics_per_page'], $this->start);
$rowset = array();
while ($row = $db->sql_fetchrow($result))
{
$rowset[] = $row;
}
$db->sql_freeresult($result);
}
foreach ($rowset as $row)
{
if ($row['poster_id'] == ANONYMOUS)
{
$poster = (!empty($row['post_username'])) ? $row['post_username'] : $user->lang['GUEST'];
}
else
{
$poster = '<a href="memberlist.' . $phpEx . $SID . '&amp;mode=viewprofile&amp;u=' . $row['poster_id'] . '">' . $row['username'] . '</a>';
}
$s_checkbox = ($mode == 'unapproved_posts') ? '<input type="checkbox" name="post_id_list[]" value="' . $row['post_id'] . '" />' : '<input type="checkbox" name="topic_id_list[]" value="' . $row['topic_id'] . '" />';
$template->assign_block_vars('postrow', array(
'U_VIEWFORUM' => "viewforum.$phpEx$SID&amp;f=" . $row['forum_id'],
// Q: Why accessing the topic by a post_id instead of its topic_id?
// A: To prevent the post from being hidden because of low karma or wrong encoding
'U_VIEWTOPIC' => "viewtopic.$phpEx$SID&amp;f=" . $row['forum_id'] . '&amp;p=' . $row['post_id'] . (($mode == 'unapproved_posts') ? '#' . $row['post_id'] : ''),
'FORUM_NAME' => $row['forum_name'],
'TOPIC_TITLE' => $row['topic_title'],
'POSTER' => $poster,
'POST_TIME' => $user->format_date($row['post_time']),
'S_CHECKBOX' => $s_checkbox
));
}
unset($rowset);
// Now display the page
$template->assign_vars(array(
'L_DISPLAY_ITEMS' => ($mode == 'unapproved_posts') ? $user->lang['DISPLAY_POSTS'] : $user->lang['DISPLAY_POSTS']
));
$this->display($user->lang['MCP_QUEUE'], 'mcp_queue.html');
break;
default:
trigger_error('UNKNOWN_MODE');
}
}
// This function simply puts the number of unapproved items in menu titles
function alter_menu()
{
global $db, $user;
$forum_list = get_forum_list('m_approve');
$sql = 'SELECT COUNT(*) AS total
FROM ' . TOPICS_TABLE . '
WHERE forum_id IN (' . implode(', ', $forum_list) . ')
AND topic_approved = 0';
$result = $db->sql_query($sql);
$total_topics = $db->sql_fetchfield('total', 0, $result);
$sql = 'SELECT COUNT(*) AS total
FROM ' . POSTS_TABLE . '
WHERE forum_id IN (' . implode(', ', $forum_list) . ')
AND post_approved = 0';
$result = $db->sql_query($sql);
$total_posts = $db->sql_fetchfield('total', 0, $result) - $total_topics;
$this->subs['unapproved_topics']['title'] = sprintf($this->subs['unapproved_topics']['title'], ($total_topics) ? $total_topics : $user->lang['NONE']);
$this->subs['unapproved_posts']['title'] = sprintf($this->subs['unapproved_posts']['title'], ($total_posts) ? $total_posts : $user->lang['NONE']);
}
function install()
{
}
function uninstall()
{
}
function module()
{
$details = array(
'name' => 'MCP - Queue',
'description' => 'Module for management of items waiting for approval',
'filename' => 'queue',
'version' => '0.1.0',
'phpbbversion' => '2.2.0'
);
return $details;
}
}
?>

View File

@ -32,6 +32,7 @@ $lang += array(
'ALL_ENTRIES' => 'All entries',
'ALREADY_REPORTED' => 'This post has already been reported',
'APPROVE' => 'Approve',
'APPROVE_POSTS' => 'Approve Posts',
'CANNOT_MOVE_SAME_FORUM'=> 'You cannot move a topic to the forum it\'s already in',
'CAN_LEAVE_BLANK' => 'This can be left blank.',
@ -40,6 +41,7 @@ $lang += array(
'DELETE_POSTS' => 'Delete posts',
'DELETE_POSTS_CONFIRM' => 'Are you sure you want to delete these posts?',
'DELETE_POST_CONFIRM' => 'Are you sure you want to delete this post?',
'DELETE_TOPICS' => 'Delete selected topics',
'DELETE_TOPICS_CONFIRM' => 'Are you sure you want to delete these topics?',
'DELETE_TOPIC_CONFIRM' => 'Are you sure you want to delete this topic?',
'DISAPPROVE' => 'Disapprove',
@ -62,7 +64,15 @@ $lang += array(
'LATEST_LOGS' => 'Latest 5 logged actions',
'LATEST_REPORTED' => 'Latest 5 reports',
'LATEST_UNAPPROVED' => 'Latest 5 posts awaiting for approval',
'LEAVE_SHADOW' => 'Leave shadow topic in place',
'LOCK' => 'Lock',
'LOCK_POST_POST' => 'Lock Post',
'LOCK_POST_POST_CONFIRM'=> 'Are you sure you want to prevent editing this post?',
'LOCK_POST_POSTS' => 'Lock selected posts',
'LOCK_POST_POSTS_CONFIRM'=> 'Are you sure you want to prevent editing the selected posts?',
'LOCK_TOPIC_CONFIRM' => 'Are you sure you want to lock this topic?',
'LOCK_TOPICS' => 'Lock selected topics',
'LOCK_TOPICS_CONFIRM' => 'Are you sure you want to lock all selected topics?',
'LOGS_CURRENT_TOPIC' => 'Currently viewing logs of:',
'LOG_APPROVE_TOPIC' => '<b>Approved topic</b><br />&#187; %s',
'LOG_FORK' => '<b>Copied topic</b><br />&#187; from %s',
@ -70,21 +80,43 @@ $lang += array(
'LOG_LOCK_POST' => '<b>Locked post</b><br />&#187; %s',
'LOG_MERGE' => '<b>Merged posts</b> into topic<br />&#187;%s',
'LOG_MOVE' => '<b>Moved topic</b><br />&#187; from %s',
'LOG_TOPIC_DELETED' => '<b>Deleted topic</b><br />&#187; %s',
'LOG_TOPIC_RESYNC' => '<b>Resynchronised topic counters</b><br />&#187; %s',
'LOG_TOPIC_TYPE_CHANGED'=> '<b>Changed topic type</b><br />&#187; %s',
'LOG_UNLOCK' => '<b>Unlocked topic</b><br />&#187; %s',
'LOG_UNLOCK_POST' => '<b>Unlocked post</b><br />&#187; %s',
'LOG_UNRATE' => '<b>Unrated post</b><br />&#187; %s',
'LOGVIEW_VIEWTOPIC' => 'View Topic',
'LOGVIEW_VIEWLOGS' => 'View Topic Log',
'LOGVIEW_VIEWFORUM' => 'View Forum',
'LOOKUP_ALL' => 'Look up all IP',
'LOOKUP_IP' => 'Look up IP',
'MCP_ADD' => 'Add a warning',
'MCP_FORUM_VIEW' => 'View forum',
'MCP_FRONT' => 'Front page',
'MCP_MAIN' => 'Main',
'MCP_POST_DETAILS' => 'Post details',
'MCP_ADD' => 'Add a warning',
'MCP_MAIN' => 'Main',
'MCP_MAIN_FORUM_VIEW' => 'View forum',
'MCP_MAIN_FRONT' => 'Front page',
'MCP_MAIN_POST_DETAILS' => 'Post details',
'MCP_MAIN_TOPIC_VIEW' => 'View topic',
'MCP_MAKE_ANNOUNCEMENT' => 'Make Announcement',
'MCP_MAKE_ANNOUNCEMENT_CONFIRM' => 'Are you sure you want to change this topic to an announcement?',
'MCP_MAKE_ANNOUNCEMENTS' => 'Make Announcements',
'MCP_MAKE_ANNOUNCEMENTS_CONFIRM'=> 'Are you sure you want to change the selected topics to announcements?',
'MCP_MAKE_GLOBAL' => 'Make Global Announcement',
'MCP_MAKE_GLOBAL_CONFIRM' => 'Are you sure you want to change this topic to an global announcement?',
'MCP_MAKE_GLOBALS' => 'Make Global Announcements',
'MCP_MAKE_GLOBALS_CONFIRM' => 'Are you sure you want to change the selected topics to global announcements?',
'MCP_MAKE_STICKY' => 'Make Sticky',
'MCP_MAKE_STICKY_CONFIRM' => 'Are you sure you want to stick this topic?',
'MCP_MAKE_STICKIES' => 'Make Stickies',
'MCP_MAKE_STICKIES_CONFIRM' => 'Are you sure you want to stick the selected topics?',
'MCP_MAKE_NORMAL' => 'Make Standard Topic',
'MCP_MAKE_NORMAL_CONFIRM' => 'Are you sure you want to revert this topic?',
'MCP_MAKE_NORMALS' => 'Make Standard Topics',
'MCP_MAKE_NORMALS_CONFIRM' => 'Are you sure you want to revert the selected topics?',
'MCP_QUEUE' => 'Moderation Queue',
'MCP_REPORTS' => 'Reports',
'MCP_TOPIC_VIEW' => 'View topic',
'MCP_UNAPPROVED_POSTS' => 'Posts awaiting for approval (%s)',
'MCP_UNAPPROVED_TOPICS' => 'Topics awaiting for approval (%s)',
'MCP_VIEW_ALL' => 'View all (%s)',
@ -97,6 +129,8 @@ $lang += array(
'MERGE_TOPIC_ID' => 'Destination topic id',
'MOD_OPTIONS' => 'Moderator Options',
'MORE_INFO' => 'Further information',
'MOVE_TOPIC_CONFIRM' => 'Are you sure you want to move the topic into a new forum?',
'MOVE_TOPICS_CONFIRM' => 'Are you sure you want to move the selected topics into a new forum?',
'NOT_MODERATOR' => 'You are not a moderator of this forum',
'NO_DESTINATION_FORUM' => 'Please select a forum for destination',
@ -111,7 +145,9 @@ $lang += array(
'POSTER' => 'Poster',
'POSTS_APPROVED_SUCCESS'=> 'The selected posts have been approved',
'POSTS_DELETED_SUCCESS' => 'The selected posts have been successfully removed from the database',
'POSTS_LOCKED_SUCCESS' => 'The selected posts have been locked successfully',
'POSTS_MERGED_SUCCESS' => 'The selected posts have been merged',
'POSTS_UNLOCKED_SUCCESS'=> 'The selected posts have been unlocked successfully',
'POSTS_PER_PAGE' => 'Posts per page',
'POSTS_PER_PAGE_EXPLAIN'=> '(Set to 0 to view all posts)',
'POST_APPROVED_SUCCESS' => 'The selected post has been approved',
@ -125,6 +161,8 @@ $lang += array(
'READ_USERNOTES' => 'User notes',
'READ_WARNINGS' => 'User warnings',
'REPORTER' => 'Reporter',
'REPORT_TIME' => 'Report time',
'REPORTS_TOTAL' => 'In total there are <b>%d</b> reports to review',
'REPORTS_ZERO_TOTAL' => 'There are no reports to review',
'REPORT_MESSAGE' => 'Report this message',
@ -138,6 +176,7 @@ $lang += array(
'RETURN_NEW_FORUM' => 'Click %sHere%s to return to the new forum',
'RETURN_NEW_TOPIC' => 'Click %sHere%s to return to the new topic',
'SELECT_ACTION' => 'Select desired action',
'SELECT_TOPIC' => 'Select topic',
'SORT_ACTION' => 'Log action',
'SORT_DATE' => 'Date',
@ -166,6 +205,7 @@ $lang += array(
'TOPIC_RESYNC_SUCCESS' => 'The selected topic has been resynchronised',
'TOPIC_SPLIT_SUCCESS' => 'The selected topic has been split successfully',
'TOPIC_TIME' => 'Topic time',
'TOPIC_TYPE_CHANGED' => 'Topic type changed successfully.',
'TOPIC_UNLOCKED_SUCCESS'=> 'The selected topic has been unlocked',
'UNAPPROVED_POSTS_TOTAL'=> 'In total there are <b>%d</b> posts waiting for approval',
@ -174,6 +214,14 @@ $lang += array(
'UNLOCK' => 'Unlock',
'UNLOCK_POST' => 'Unlock Post',
'UNLOCK_POST_EXPLAIN' => 'Allow editing',
'UNLOCK_POST_POST' => 'Unlock Post',
'UNLOCK_POST_POST_CONFIRM'=> 'Are you sure you want to allow editing this post?',
'UNLOCK_POST_POSTS' => 'Unlock selected posts',
'UNLOCK_POST_POSTS_CONFIRM'=> 'Are you sure you want to allow editing the selected posts?',
'UNLOCK_TOPIC' => 'Unlock Topic',
'UNLOCK_TOPIC_CONFIRM' => 'Are you sure you want to unlock this topic?',
'UNLOCK_TOPICS' => 'Unlock selected topics',
'UNLOCK_TOPICS_CONFIRM' => 'Are you sure you want to unlock all selected topics?',
'UNRATE_POST' => 'Unrate post',
'UNRATE_POST_EXPLAIN' => 'Reset post rating',
'USER_CANNOT_POST' => 'You cannot post in this forum',

View File

@ -26,12 +26,41 @@ class module
var $type;
var $name;
var $mode;
var $modules;
var $url;
// Private methods, should not be overwritten
function create($module_type, $module_url, $selected_mod = false, $selected_submod = false)
function create($module_type, $module_url, $post_id, $topic_id, $forum_id, $selected_mod = false, $selected_submod = false)
{
global $template, $auth, $db, $user;
global $template, $auth, $db, $user, $config;
global $phpbb_root_path, $phpEx;
if ($post_id)
{
if (!$topic_id || !$forum_id)
{
$sql = 'SELECT topic_id, forum_id
FROM ' . POSTS_TABLE . "
WHERE post_id = $post_id";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$topic_id = (int) $row['topic_id'];
$forum_id = (int) $row['forum_id'];
}
}
if ($topic_id && !$forum_id)
{
$sql = 'SELECT forum_id
FROM ' . TOPICS_TABLE . "
WHERE topic_id = $topic_id";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$forum_id = (int) $row['forum_id'];
}
$sql = 'SELECT module_id, module_title, module_filename, module_subs, module_acl
FROM ' . MODULES_TABLE . "
@ -59,21 +88,12 @@ class module
$selected = ($row['module_filename'] == $selected_mod || $row['module_id'] == $selected_mod || (!$selected_mod && !$i)) ? true : false;
// Get the localised lang string if available, or make up our own otherwise
/*
$module_lang = strtoupper($module_type) . '_' . $row['module_title'];
$template->assign_block_vars($module_type . '_section', 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']))),
'L_TITLE' => (isset($user->lang[$module_lang])) ? $user->lang[$module_lang] : ucfirst(str_replace('_', ' ', strtolower($row['module_title']))),
'S_SELECTED' => $selected,
'U_TITLE' => $module_url . '&amp;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' => '&amp;i=' . $row['module_id'],
'selected' => $selected,
'subs' => array()
);
if ($selected)
{
@ -98,26 +118,32 @@ class module
}
}
if (!$is_auth)
if (!$is_auth || empty($submodule_title))
{
continue;
}
// Only show those rows we are able to access
if (($submodule_title == 'post_details' && !$post_id) ||
($submodule_title == 'topic_view' && !$topic_id) ||
($submodule_title == 'forum_view' && !$forum_id))
{
continue;
}
$suffix = ($post_id) ? "&amp;p=$post_id" : '';
$suffix .= ($topic_id) ? "&amp;t=$topic_id" : '';
$suffix .= ($forum_id) ? "&amp;f=$forum_id" : '';
$selected = ($submodule_title == $selected_submod || (!$selected_submod && !$j)) ? true : false;
// Get the localised lang string if available, or make up our own otherwise
/*
$module_lang = strtoupper($module_type . '_' . $module_name . '_' . $submodule_title);
$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))),
'L_TITLE' => (isset($user->lang[$module_lang])) ? $user->lang[$module_lang] : ucfirst(str_replace('_', ' ', strtolower($module_lang))),
'S_SELECTED' => $selected,
'U_TITLE' => $module_url . '&amp;i=' . $module_id . '&amp;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' => '&amp;i=' . $module_id . '&amp;mode=' . $submodule_title,
'selected' => $selected
'U_TITLE' => $module_url . '&amp;i=' . $module_id . '&amp;mode=' . $submodule_title . $suffix)
);
if ($selected)
@ -142,12 +168,15 @@ class module
$this->type = $module_type;
$this->id = $module_id;
$this->name = $module_name;
$this->url = $module_url;
$this->url = "{$phpbb_root_path}mcp.$phpEx?sid={$user->session_id}";
$this->url .= ($post_id) ? "&amp;p=$post_id" : '';
$this->url .= ($topic_id) ? "&amp;t=$topic_id" : '';
$this->url .= ($forum_id) ? "&amp;f=$forum_id" : '';
}
function load($type = false, $name = false, $mode = false, $run = true)
{
global $template, $phpbb_root_path, $phpEx;
global $phpbb_root_path, $phpEx;
if ($type)
{
@ -159,46 +188,22 @@ class module
$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');
}
require_once($phpbb_root_path . "includes/{$this->type}/{$this->type}_{$this->name}.$phpEx");
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)
if (!isset($this->mode))
{
$this->module->$var = $this->$var;
$this->mode = $mode;
}
// Shortcut to submodules
$this->module->subs =& $this->module->modules[$this->id]['subs'];
eval("\$this->module = new {$this->type}_{$this->name}(\$this->id, \$this->mode, \$this->url);");
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');
}
}
}
@ -208,30 +213,6 @@ class module
{
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);
$template->set_filenames(array(
@ -268,570 +249,11 @@ class module
return false;
}
}
class mcp extends module
{
var $forum_id = 0;
var $topic_id = 0;
var $post_id = 0;
var $topic_id_list = array();
var $post_id_list = array();
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;
$rowset = array();
$sql = 'SELECT *
FROM ' . FORUMS_TABLE . '
WHERE forum_id ' . ((is_array($forum_id)) ? 'IN (' . implode(', ', $forum_id) . ')' : "= $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 ($auth->acl_get('m_approve', $row['forum_id']))
{
$row['forum_topics'] = $row['forum_topics_real'];
}
$rowset[$row['forum_id']] = $row;
}
if (empty($rowset))
{
return FALSE;
}
elseif (is_array($forum_id))
{
return $rowset;
}
else
{
return array_pop($rowset);
}
}
function get_topic_data($topic_id, $acl_list = '')
{
global $auth, $db;
$rowset = array();
// TODO: Known Bug: will fail on global announcements because of forum_id = 0
$sql = 'SELECT t.*, f.*
FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . ' f
WHERE t.topic_id ' . ((is_array($topic_id)) ? 'IN (' . implode(', ', $topic_id) . ')' : "= $topic_id") . '
AND t.forum_id = f.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 ($auth->acl_get('m_approve', $row['forum_id']))
{
$row['topic_replies'] = $row['topic_replies_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;
}
if (empty($rowset))
{
// DEBUG
global $template;
$template->assign_var('MESSAGE', 'Error while retrieving topic data #' . $topic_id);
// -----
return FALSE;
}
if (is_array($topic_id))
{
return $rowset;
}
else
{
return array_pop($rowset);
}
}
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()
{
global $db;
// Obtain initial var settings
$this->forum_id = request_var('f', 0);
$this->topic_id = request_var('t', 0);
$this->post_id = request_var('p', 0);
$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->to_forum_id = request_var('to_forum_id', 0);
$this->to_topic_id = request_var('to_topic_id', 0);
$this->cancel = request_var('cancel', FALSE);
$this->confirm = ($this->cancel) ? FALSE : request_var('confirm', 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
if (!$this->post_id && !empty($this->post_id_list))
{
$this->post_id = $this->post_id_list[0];
}
if ($this->post_id)
{
$this->url .= '&amp;p=' . $this->post_id;
if (!$this->forum_id || !$this->topic_id)
{
$sql = 'SELECT forum_id, topic_id
FROM ' . POSTS_TABLE . '
WHERE post_id = ' . $this->post_id;
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
{
if (!$this->forum_id)
{
$this->forum_id = intval($row['forum_id']);
}
if (!$this->topic_id)
{
$this->topic_id = intval($row['topic_id']);
}
}
}
}
if (!$this->topic_id && !empty($this->topic_id_list))
{
$this->topic_id = $this->topic_id_list[0];
}
if ($this->topic_id)
{
$this->url .= '&amp;t=' . $this->topic_id;
if (!$this->forum_id)
{
$sql = 'SELECT forum_id
FROM ' . TOPICS_TABLE . '
WHERE topic_id = ' . $this->topic_id;
$result = $db->sql_query($sql);
$this->forum_id = intval($db->sql_fetchfield('forum_id', 0, $result));
}
}
if ($this->forum_id)
{
$this->url .= '&amp;f=' . $this->forum_id;
}
// Build short_id_list
if (!empty($_GET['selected_ids']))
{
$len = $_GET['selected_ids']{0};
for ($i = 1; $i < strlen($_GET['selected_ids']); $i += $len)
{
$short = substr($_GET['selected_ids'], $i, $len);
$this->post_id_list[] = base_convert($short, 36, 10);
}
}
$this->selected_ids = (!empty($this->post_id_list)) ? '&amp;selected_ids=' . $this->short_id_list($this->post_id_list) : '';
}
function mcp_jumpbox($action, $acl_list = 'f_list', $forum_id = false, $enable_select_all = false)
{
global $auth, $template, $user, $db, $phpEx, $SID;
$sql = 'SELECT forum_id, forum_name, forum_type, left_id, right_id
FROM ' . FORUMS_TABLE . '
ORDER BY left_id ASC';
$result = $db->sql_query($sql);
$right = $cat_right = 0;
$padding = $forum_list = $holding = '';
while ($row = $db->sql_fetchrow($result))
{
if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id']))
{
// Non-postable forum with no subforums, don't display
continue;
}
if (!$auth->acl_get('f_list', $row['forum_id']))
{
// if the user does not have permissions to list this forum skip
continue;
}
if ($row['left_id'] < $right)
{
$padding .= '&nbsp; &nbsp;';
}
else if ($row['left_id'] > $right + 1)
{
$padding = substr($padding, 0, -13 * ($row['left_id'] - $right + 1));
}
$right = $row['right_id'];
$selected = ($row['forum_id'] == $forum_id) ? ' selected="selected"' : '';
if ($row['right_id'] - $row['left_id'] > 1)
{
$cat_right = max($cat_right, $row['right_id']);
$char = '+ ';
}
else
{
$char = '- ';
}
$template->assign_block_vars('options', array(
'VALUE' => ($row['forum_type'] != FORUM_POST || !$auth->acl_gets($acl_list, $row['forum_id'])) ? -1 : $row['forum_id'],
'SELECTED' => $selected,
'TEXT' => $padding . $char . $row['forum_name'])
);
}
$db->sql_freeresult($result);
$template->assign_vars(array(
'S_JUMPBOX_ACTION' => $action,
'S_ENABLE_SELECT_ALL' => $enable_select_all,
'S_CURRENT_FORUM' => intval($forum_id)
));
}
function short_id_list($id_list)
{
$max_len = 0;
$short_id_list = array();
foreach ($id_list as $id)
{
$short = (string) base_convert($id, 10, 36);
$max_len = max(strlen($short), $max_len);
$short_id_list[] = $short;
}
$id_str = (string) $max_len;
foreach ($short_id_list as $short)
{
$id_str .= str_pad($short, $max_len, '0', STR_PAD_LEFT);
}
return $id_str;
}
function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql, &$sort_order_sql, &$total, $forum_id = 0, $topic_id = 0, $where_sql = 'WHERE')
{
global $db, $user, $auth, $template;
$sort_days = request_var('sort_days', '0');
$min_time = ($sort_days) ? time() - ($sort_days * 86400) : 0;
switch ($mode)
{
case 'viewforum':
$type = 'topics';
$default_key = 't';
$default_dir = 'd';
$sql = 'SELECT COUNT(topic_id) AS total
FROM ' . TOPICS_TABLE . "
$where_sql forum_id = $forum_id
AND topic_type NOT IN (" . POST_ANNOUNCE . ', ' . POST_GLOBAL . ")
AND topic_last_post_time >= $min_time";
if (!$auth->acl_get('m_approve', $forum_id))
{
$sql .= 'AND topic_approved = 1';
}
break;
case 'viewtopic':
$type = 'posts';
$default_key = 't';
$default_dir = 'a';
$sql = 'SELECT COUNT(post_id) AS total
FROM ' . POSTS_TABLE . "
$where_sql topic_id = $topic_id
AND post_time >= $min_time";
if (!$auth->acl_get('m_approve', $forum_id))
{
$sql .= 'AND post_approved = 1';
}
break;
case 'unapproved_posts':
$type = 'posts';
$default_key = 't';
$default_dir = 'd';
$sql = 'SELECT COUNT(post_id) AS total
FROM ' . POSTS_TABLE . "
$where_sql forum_id IN (" . (($forum_id) ? $forum_id : implode(', ', get_forum_list('m_approve'))) . ')
AND post_approved = 0
AND post_time >= ' . $min_time;
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':
$type = 'reports';
$default_key = 'p';
$default_dir = 'd';
$limit_time_sql = ($min_time) ? "AND r.report_time >= $min_time" : '';
if ($topic_id)
{
$where_sql .= ' p.topic_id = ' . $topic_id;
}
elseif ($forum_id)
{
$where_sql .= ' p.forum_id = ' . $forum_id;
}
else
{
$where_sql .= ' p.forum_id IN (' . implode(', ', get_forum_list('m_')) . ')';
}
$sql = 'SELECT COUNT(r.report_id) AS total
FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . " p
$where_sql
AND p.post_id = r.post_id
$limit_time_sql";
break;
case 'viewlogs':
$type = 'logs';
$default_key = 't';
$default_dir = 'd';
$sql = 'SELECT COUNT(log_id) AS total
FROM ' . LOG_TABLE . "
$where_sql forum_id IN (" . (($forum_id) ? $forum_id : implode(', ', get_forum_list('m_'))) . ')
AND log_time >= ' . $min_time . '
AND log_type = ' . LOG_MOD;
break;
}
$sort_key = request_var('sk', $default_key);
$sort_dir = request_var('sd', $default_dir);
$sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']);
switch ($type)
{
case 'topics':
$limit_days = array(0 => $user->lang['ALL_TOPICS'], 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'], 'tt' => $user->lang['TOPIC_TIME'], 'r' => $user->lang['REPLIES'], 's' => $user->lang['SUBJECT'], 'v' => $user->lang['VIEWS']);
$sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => 't.topic_last_post_time', 'tt' => 't.topic_time', 'r' => (($auth->acl_get('m_approve', $forum_id)) ? 't.topic_replies_real' : 't.topic_replies'), 's' => 't.topic_title', 'v' => 't.topic_views');
$limit_time_sql = ($min_time) ? "AND t.topic_last_post_time >= $min_time" : '';
break;
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']);
$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_id', 's' => 'p.post_subject');
$limit_time_sql = ($min_time) ? "AND p.post_time >= $min_time" : '';
break;
case 'reports':
$limit_days = array(0 => $user->lang['ALL_REPORTS'], 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('p' => $user->lang['REPORT_PRIORITY'], 'r' => $user->lang['REPORTER'], 't' => $user->lang['REPORT_TIME']);
$sort_by_sql = array('p' => 'rr.reason_priority', 'r' => 'u.username', 't' => 'r.report_time');
break;
case 'logs':
$limit_days = array(0 => $user->lang['ALL_ENTRIES'], 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('u' => $user->lang['SORT_USERNAME'], 't' => $user->lang['SORT_DATE'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']);
$sort_by_sql = array('u' => 'l.user_id', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation');
$limit_time_sql = ($min_time) ? "AND l.log_time >= $min_time" : '';
break;
}
$sort_order_sql = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
$s_limit_days = $s_sort_key = $s_sort_dir = '';
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir);
$template->assign_vars(array(
'S_SELECT_SORT_DIR' => $s_sort_dir,
'S_SELECT_SORT_KEY' => $s_sort_key,
'S_SELECT_SORT_DAYS'=> $s_limit_days
));
if (($sort_days && $mode != 'viewlogs') || $mode == 'reports')
{
$result = $db->sql_query($sql);
$total = ($row = $db->sql_fetchrow($result)) ? $row['total'] : 0;
}
else
{
$total = -1;
}
}
}
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
// ---------
// Start session management
$user->start();
$auth->acl($user->data);
@ -840,27 +262,85 @@ $user->setup('mcp');
$mcp = new module();
// Basic parameter data
$module = request_var('i', 'main');
if (isset($_POST['jumpbox']) || isset($_POST['sort']) || isset($_POST['confirm']) || isset($_POST['cancel']))
$mode = request_var('mode', '');
$mode2 = (isset($_REQUEST['quick'])) ? request_var('mode2', '') : '';
$module = request_var('i', '');
if ($mode2)
{
// Sometimes we want to ignore input from the dropdown list of modes
// when the jumpbox is used or when confirming an action for example
$mode = request_var('mode', '', 'GET');
}
elseif (isset($_POST['mode']) && is_array($_POST['mode']))
{
list($mode, $void) = each($_POST['mode']);
$mode = htmlspecialchars($mode);
}
else
{
$mode = request_var('mode', '');
$mode = $mode2;
$action = '';
unset($mode2);
}
// Instantiate module system and generate list of available modules
$mcp->create('mcp', "mcp.$phpEx$SID", $module, $mode);
// Only Moderators can go beyond this point
if ($user->data['user_id'] == ANONYMOUS || !$auth->acl_get('m_'))
{
if ($user->data['user_id'] != ANONYMOUS)
{
redirect("index.$phpEx$SID");
}
login_box("{$phpbb_root_path}mcp.$phpEx$SID&amp;mode=$mode&amp;i=$module", '', $user->lang['LOGIN_EXPLAIN_MCP']);
}
// Load and execute the relevant module
$mcp->load('mcp', false, $mode, TRUE);
$quickmod = (isset($_REQUEST['quickmod'])) ? true : false;
$action = request_var('action', '');
if (is_array($action))
{
list($action, ) = each($action);
}
if ($action == 'merge_select')
{
$mode = 'forum_view';
}
if (!$quickmod)
{
$post_id = request_var('p', 0);
$topic_id = request_var('t', 0);
$forum_id = request_var('f', 0);
// Instantiate module system and generate list of available modules
$mcp->create('mcp', "mcp.$phpEx$SID", $post_id, $topic_id, $forum_id, $module, $mode);
// Load and execute the relevant module
$mcp->load('mcp', 'main', $mode);
exit;
}
switch ($mode)
{
case 'lock':
case 'unlock':
case 'lock_post':
case 'unlock_post':
$mcp->load('mcp', 'main', $mode);
break;
case 'make_sticky':
case 'make_announce':
case 'make_global':
case 'make_normal':
$mcp->load('mcp', 'main', $mode);
break;
case 'move':
$mcp->load('mcp', 'main', $mode);
break;
case 'delete_topic':
$mcp->load('mcp', 'main', $mode);
break;
case 'delete_post':
$mcp->load('mcp', 'main', $mode);
break;
case 'split':
case 'merge':
case 'fork':
case 'viewlogs':
break;
default:
trigger_error("$mode not allowed as quickmod");
}
?>