diff --git a/phpBB/language/en/lang_main.php b/phpBB/language/en/lang_main.php
index 6b29376e5a..6090927599 100644
--- a/phpBB/language/en/lang_main.php
+++ b/phpBB/language/en/lang_main.php
@@ -698,12 +698,12 @@ $lang = array_merge($lang, array(
'Viewing_priv_msgs' => 'Viewing Private Messages',
'Viewing_FAQ' => 'Viewing FAQ',
- 'Mod_CP' => 'Moderator Control Panel',
- 'Mod_CP_explain' => 'Using the form below you can perform mass moderation operations on this forum. You can lock, unlock, move or delete any number of topics.',
- 'Select' => 'Select',
- 'Move' => 'Move',
- 'Lock' => 'Lock',
- 'Unlock' => 'Unlock',
+ 'MOD_CP' => 'Moderator Control Panel',
+ 'MOD_CP_EXPLAIN' => 'Using the form below you can perform mass moderation operations on this forum. You can lock, unlock, move or delete any number of topics.',
+ 'SELECT' => 'Select',
+ 'MOVE' => 'Move',
+ 'LOCK' => 'Lock',
+ 'UNLOCK' => 'Unlock',
'Topics_Removed' => 'The selected topics have been successfully removed from the database.',
'Topics_Locked' => 'The selected topics have been locked',
'Topics_Moved' => 'The selected topics have been moved',
diff --git a/phpBB/mcp.php b/phpBB/mcp.php
index 95b700248e..b6cac689c2 100644
--- a/phpBB/mcp.php
+++ b/phpBB/mcp.php
@@ -51,13 +51,23 @@ include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
+// Start session management
+$user->start();
+$user->setup();
+$auth->acl($user->data);
+// End session management
+
+// temp temp temp
+very_temporary_lang_strings();
+// temp temp temp
+
//
// Obtain initial var settings
//
$forum_id = (!empty($_REQUEST['f'])) ? intval($_REQUEST['f']) : '';
$topic_id = (!empty($_REQUEST['t'])) ? intval($_REQUEST['t']) : '';
$post_id = (!empty($_REQUEST['p'])) ? intval($_REQUEST['p']) : '';
-$confirm = (!empty($_POST['confirm'])) ? TRUE : FALSE;
+$start = (!empty($_GET['start'])) ? intval($_GET['start']) : 0;
//
// Check if user did or did not confirm
@@ -67,11 +77,11 @@ if (isset($_POST['cancel']))
{
if ($topic_id)
{
- $redirect = "viewtopic.$phpEx$SID&t=$topic_id";
+ $redirect = "viewtopic.$phpEx$SID&t=$topic_id&start=$start";
}
- else if ($forum_id)
+ elseif ($forum_id)
{
- $redirect = "viewforum.$phpEx$SID&f=$forum_id";
+ $redirect = "viewforum.$phpEx$SID&f=$forum_id&start=$start";
}
else
{
@@ -81,643 +91,470 @@ if (isset($_POST['cancel']))
redirect($redirect);
}
-// Start session management
-$user->start();
-$user->setup();
-$auth->acl($user->data);
-// End session management
-
-
-//
// Continue var definitions
-//
-$start = (isset($_GET['start'])) ? $_GET['start'] : 0;
+$forum_data = $topic_data = $post_data = array();
+$topic_id_list = ($topic_id) ? array($topic_id) : array();
+$post_id_list = ($post_id) ? array($post_id) : array();
+$return_mcp = ' ' . sprintf($user->lang['Click_return_modcp'], '', ' ');
-$delete = (isset($_POST['delete'])) ? TRUE : FALSE;
-$move = (isset($_POST['move'])) ? TRUE : FALSE;
-$lock = (isset($_POST['lock'])) ? TRUE : FALSE;
-$unlock = (isset($_POST['unlock'])) ? TRUE : FALSE;
+$confirm = (!empty($_POST['confirm'])) ? TRUE : FALSE;
+$mode = (!empty($_REQUEST['mode'])) ? $_REQUEST['mode'] : '';
+$submode = (!empty($_REQUEST['submode'])) ? $_REQUEST['submode'] : '';
-if (isset($_POST['mode']) || isset($_GET['mode']))
+$post_modes = array('move', 'delete', 'lock', 'unlock', 'merge_posts', 'delete_posts', 'split_all', 'split_beyond', 'select_topic');
+foreach ($post_modes as $post_mode)
{
- $mode = (isset($_POST['mode'])) ? $_POST['mode'] : $_GET['mode'];
+ if (isset($_POST[$post_mode]))
+ {
+ $mode = $post_mode;
+ }
}
-else
+
+// Check destination forum or topic if applicable
+$to_forum_id = (!empty($_REQUEST['to_forum_id'])) ? intval($_REQUEST['to_forum_id']) : 0;
+$to_topic_id = (!empty($_REQUEST['to_topic_id'])) ? intval($_REQUEST['to_topic_id']) : 0;
+
+if ($to_topic_id)
{
- if ($delete)
+ $result = $db->sql_query('SELECT * FROM ' . TOPICS_TABLE . ' WHERE topic_id = ' . $to_topic_id);
+ $row = $db->sql_fetchrow($result);
+ if (empty($row['forum_id']))
{
- $mode = 'delete';
+ trigger_error($user->lang['Topic_not_exist'] . $return_mcp);
}
- else if ($move)
+ if (!isset($topic_data[$to_topic_id]))
{
- $mode = 'move';
+ $topic_data[$to_topic_id] = $row;
}
- else if ($lock)
+
+ $to_forum_id = $row['forum_id'];
+}
+
+if ($to_forum_id && !$auth->acl_gets('f_post', 'f_reply', 'm_', 'a_', $to_forum_id))
+{
+ if (!$auth->acl_gets('f_list', $to_forum_id))
{
- $mode = 'lock';
- }
- else if ($unlock)
- {
- $mode = 'unlock';
+ trigger_error($user->lang['Forum_not_exist'] . $return_mcp);
}
else
{
- $mode = '';
+ trigger_error('not authorised to perform this action with destination forum');
+ }
+
+ if (!isset($forum_data[$to_forum_id]))
+ {
+ $forum_data[$to_forum_id] = $row;
}
}
-//
-// Obtain relevant data
-//
-if (!empty($topic_id))
+// Cleanse inputted values then get permissions
+foreach ($_POST['topic_id_list'] as $t_id)
{
- $sql = "SELECT f.forum_id, f.forum_name, f.forum_topics
- FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
- WHERE t.topic_id = " . $topic_id . "
- AND f.forum_id = t.forum_id";
- $result = $db->sql_query($sql);
-
- $topic_row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
-
- $forum_topics = ($topic_row['forum_topics'] == 0) ? 1 : $topic_row['forum_topics'];
- $forum_id = $topic_row['forum_id'];
- $forum_name = $topic_row['forum_name'];
+ if ($t_id = intval($t_id))
+ {
+ $topic_id_list[] = $t_id;
+ }
}
-else if (!empty($forum_id))
+foreach ($_POST['post_id_list'] as $p_id)
{
- $sql = "SELECT forum_name, forum_topics
- FROM " . FORUMS_TABLE . "
- WHERE forum_id = " . $forum_id;
+ if ($p_id = intval($p_id))
+ {
+ $post_id_list[] = $p_id;
+ }
+}
+
+$topic_id_sql = implode(', ', $topic_id_list);
+$post_id_sql = implode(', ', $post_id_list);
+
+// Reset id lists then rebuild them
+$forum_id_list = $topic_id_list = $post_id_list = array();
+
+$not_moderator = FALSE;
+if ($forum_id)
+{
+ if ($auth->acl_gets('m_', 'a_', $forum_id))
+ {
+ $forum_id_list[] = $forum_id;
+ }
+ else
+ {
+ $not_moderator = TRUE;
+ }
+}
+
+if ($topic_id_sql)
+{
+ $sql = 'SELECT *
+ FROM ' . TOPICS_TABLE . "
+ WHERE topic_id IN ($topic_id_sql)";
$result = $db->sql_query($sql);
- $topic_row = $db->sql_fetchrow($result);
+ while ($row = $db->sql_fetchrow($result))
+ {
+ if ($auth->acl_gets('m_', 'a_', $row['forum_id']))
+ {
+ $forum_id_list[] = $row['forum_id'];
+ $topic_id_list[] = $row['topic_id'];
+
+ $topic_data[$row['topic_id']] = $row;
+ }
+ else
+ {
+ $not_moderator = TRUE;
+ }
+ }
+
+ $db->sql_freeresult($result);
+}
+
+if ($post_id_sql)
+{
+ $sql = 'SELECT *
+ FROM ' . POSTS_TABLE . "
+ WHERE post_id IN ($post_id_sql)";
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ if ($auth->acl_gets('m_', 'a_', $row['forum_id']))
+ {
+ $forum_id_list[] = $row['forum_id'];
+ $topic_id_list[] = $row['topic_id'];
+ $post_id_list[] = $row['post_id'];
+
+ $post_data[$row['post_id']] = $row;
+ }
+ else
+ {
+ $not_moderator = TRUE;
+ }
+ }
+
+ $db->sql_freeresult($result);
+}
+
+if (count($forum_id_list))
+{
+ $sql = 'SELECT *
+ FROM ' . FORUMS_TABLE . '
+ WHERE forum_id IN (' . implode(', ', $forum_id_list) . ')';
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $forum_data[$row['forum_id']] = $row;
+ }
$db->sql_freeresult($result);
- $forum_topics = ($topic_row['forum_topics'] == 0) ? 1 : $topic_row['forum_topics'];
- $forum_name = $topic_row['forum_name'];
+ $forum_id_list = array_unique($forum_id_list);
+ $topic_id_list = array_unique($topic_id_list);
+ $post_id_list = array_unique($post_id_list);
+
+
+ // Set infos about current forum/topic/post
+ if (count($forum_id_list) == 1)
+ {
+ $forum_id = $forum_id_list[0];
+ }
+ if (count($topic_id_list) == 1)
+ {
+ $topic_id = $topic_id_list[0];
+ }
+ if (count($post_id_list) == 1)
+ {
+ $post_id = $post_id_list[0];
+ }
+
+ $forum_info = @$forum_data[$forum_id];
+ $topic_info = @$topic_data[$topic_id];
+ $post_info = @$post_data[$post_id];
}
else
{
- trigger_error('Forum_not_exist');
+ if ($not_moderator)
+ {
+ // The user has submitted posts or topics but is not allowed to perform mod actions to them
+ trigger_error('Not_Moderator');
+ }
+ else
+ {
+ $forumless_modes = array('', 'front', 'post_reports', 'mod_queue');
+ if (!in_array($mode, $forumless_modes))
+ {
+ // The user has submitted invalid post_ids or topic_ids
+ trigger_error($user->lang['Topic_post_not_exist'] . $return_mcp);
+ }
+ }
}
-//
-// Auth check
-//
-if (!$auth->acl_gets('m_', 'a_', $forum_id))
+// Build links and tabs
+$mcp_url = "mcp.$phpEx$SID";
+$tabs = array(
+ 'front' => $mcp_url,
+ 'mod_queue' => $mcp_url . '&mode=mod_queue',
+ 'post_reports' => $mcp_url . '&mode=post_reports'
+);
+
+$mcp_url .= ($forum_id) ? '&f=' . $forum_id : '';
+$mcp_url .= ($topic_id) ? '&t=' . $topic_id : '';
+$mcp_url .= ($post_id) ? '&p=' . $post_id : '';
+$mcp_url .= ($start) ? '&start=' . $start : '';
+$return_mcp = ' ' . sprintf($user->lang['Click_return_modcp'], '', ' ');
+
+if ($forum_id)
{
- trigger_error($user->lang['Not_Moderator']);
+ $tabs['forum_view'] = $mcp_url . '&mode=forum_view';
+}
+if ($topic_id)
+{
+ $tabs['topic_view'] = $mcp_url . '&mode=topic_view';
+}
+if ($post_id)
+{
+ $tabs['post_view'] = $mcp_url . '&mode=post_view';
+}
+if (!empty($_GET['post_id_list']))
+{
+ $tabs['merge'] = $mcp_url . '&mode=merge&post_id_list=' . htmlspecialchars($_GET['post_id_list']);
+}
+
+if (count($forum_id_list) == 1 && !$forum_info['forum_postable'])
+{
+ trigger_error($user->lang['Forum_not_postable'] . $return_mcp);
+}
+
+if (!$mode)
+{
+ if ($topic_id)
+ {
+ $mode = 'topic_view';
+ }
+ elseif ($forum_id)
+ {
+ $mode = 'forum_view';
+ }
+ else
+ {
+ $mode = 'front';
+ }
+
+}
+
+// Get the current tab from the mode
+$tabs_mode = array(
+ 'mod_queue' => 'mod_queue',
+ 'post_reports' => 'post_reports',
+ 'split' => 'topic_view',
+ 'merge' => (empty($_GET['post_id_list'])) ? 'topic_view' : 'merge',
+ 'ip' => 'post_view',
+ 'forum_view' => 'forum_view',
+ 'topic_view' => 'topic_view',
+ 'post_view' => 'post_view',
+ 'front' => 'front'
+);
+
+foreach ($tabs as $tab_name => $tab_link)
+{
+ $template->assign_block_vars('tab', array(
+ 'S_IS_SELECTED' => ($tab_name == @$tabs_mode[$mode]) ? TRUE : FALSE,
+ 'NAME' => $user->lang['mod_tabs'][$tab_name],
+ 'U_LINK' => $tab_link
+ ));
}
//
// Do major work ...
//
-switch($mode)
+switch ($mode)
{
- case 'delete':
- $page_title = $user->lang['Mod_CP'];
- include($phpbb_root_path . 'includes/page_header.'.$phpEx);
+ case 'select_topic':
+ $max_len = 0;
+ $short_id_list = array();
- if ($confirm)
+ foreach ($post_id_list as $post_id)
{
- $topics = (isset($_POST['topic_id_list'])) ? $_POST['topic_id_list'] : array($topic_id);
-
- $topic_id_sql = '';
- for($i = 0; $i < count($topics); $i++)
- {
- $topic_id_sql .= (($topic_id_sql != '') ? ', ' : '') . intval($topics[$i]);
- }
-
- // Use prune feature?
- prune($forum_id, '', $topic_id_sql);
-
- $sql = "SELECT vote_id
- FROM " . VOTE_DESC_TABLE . "
- WHERE topic_id IN ($topic_id_sql)";
- $result = $db->sql_query($sql);
-
- if ($row = $db->sql_fetchrow($result))
- {
- $vote_id_sql = '';
- do
- {
- $vote_id_sql .= (($vote_id_sql != '') ? ', ' : '') . intval($row['vote_id']);
- }
- while ($row = $db->sql_fetchrow($result));
-
- $db->sql_transaction();
-
- $sql = "DELETE
- FROM " . VOTE_DESC_TABLE . "
- WHERE vote_id IN ($vote_id_sql)";
- $db->sql_query($sql);
-
- $sql = "DELETE
- FROM " . VOTE_RESULTS_TABLE . "
- WHERE vote_id IN ($vote_id_sql)";
- $db->sql_query($sql);
-
- $sql = "DELETE
- FROM " . VOTE_USERS_TABLE . "
- WHERE vote_id IN ($vote_id_sql)";
- $db->sql_query($sql);
-
- $db->sql_transaction('commit');
- }
- $db->sql_freeresult($result);
-
- if (!empty($topic_id))
- {
- $redirect_page = "viewforum.$phpEx$SID&f==$forum_id";
- $l_redirect = sprintf($user->lang['Click_return_forum'], '', ' ');
- }
- else
- {
- $redirect_page = "mcp.$phpEx$SID&f==$forum_id";
- $l_redirect = sprintf($user->lang['Click_return_modcp'], '', ' ');
- }
-
- $template->assign_vars(array(
- 'META' => ' ')
- );
-
- trigger_error($user->lang['Topics_Removed'] . ' ' . $l_redirect);
+ $short = base_convert($post_id, 10, 36);
+ $max_len = max(strlen($short), $max_len);
+ $short_id_list[] = $short;
}
- else
+
+ $post_id_str = $max_len;
+ foreach ($short_id_list as $short)
{
- // Not confirmed, show confirmation message
- if (empty($_POST['topic_id_list']) && empty($topic_id))
- {
- trigger_error($user->lang['None_selected']);
- }
-
- $hidden_fields = ' ';
-
- if (isset($_POST['topic_id_list']))
- {
- $topics = $_POST['topic_id_list'];
- for($i = 0; $i < count($topics); $i++)
- {
- $hidden_fields .= ' ';
- }
- }
- else
- {
- $hidden_fields .= ' ';
- }
-
- // Set template files
- $template->set_filenames(array(
- 'body' => 'confirm_body.html')
- );
-
- $template->assign_vars(array(
- 'MESSAGE_TITLE' => $user->lang['Confirm'],
- 'MESSAGE_TEXT' => $user->lang['Confirm_delete_topic'],
-
- 'L_YES' => $user->lang['Yes'],
- 'L_NO' => $user->lang['No'],
-
- 'S_CONFIRM_ACTION' => "mcp.$phpEx$SID",
- 'S_HIDDEN_FIELDS' => $hidden_fields)
- );
-
- include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
+ $post_id_str .= str_pad($short, $max_len, '0', STR_PAD_LEFT);
}
- break;
+
+ redirect(str_replace('&', '&', $mcp_url) . '&mode=forum_view&post_id_list=' . $post_id_str);
+ break;
+
+ case 'merge':
+ case 'split':
+ case 'massdelete':
+ case 'topic_view':
+ mcp_header('mcp_topic.html');
+
+ $template->assign_vars(array(
+ 'FORUM_NAME' => $forum_info['forum_name'],
+ 'U_VIEW_FORUM' => "viewforum.$phpEx$SID&f=$forum_id",
+
+ 'TO_TOPIC_ID' => ($to_topic_id) ? $to_topic_id : '',
+ 'TO_TOPIC_EXPLAIN' => ($to_topic_id) ? sprintf($user->lang['Topic_number_is'], $to_topic_id, '' . htmlspecialchars($topic_data[$to_topic_id]['topic_title']) . ' ') : '',
+
+ 'S_FORM_ACTION' => "mcp.$phpEx$SID",
+ 'S_FORUM_SELECT' => '' . make_forum_select() . ' ',
+ 'S_ENABLE_SPLIT' => ($mode == 'topic_view' || $mode == 'split') ? TRUE : FALSE,
+ 'S_ENABLE_MERGE' => ($mode == 'topic_view' || $mode == 'merge') ? TRUE : FALSE,
+ 'S_ENABLE_DELETE' => ($mode == 'topic_view' || $mode == 'massdelete') ? TRUE : FALSE
+ ));
+
+ $is_first_post = TRUE;
+ $selected_post_ids = array();
+ if (!empty($_GET['post_id_list']))
+ {
+ $len = $_GET['post_id_list']{0};
+ for ($i = 1; $i < strlen($_GET['post_id_list']); $i += $len)
+ {
+ $short = substr($_GET['post_id_list'], $i, $len);
+ $selected_post_ids[] = (string) base_convert($short, 36, 10);
+ }
+ }
+
+ $sql = "SELECT u.username, p.*, pt.*
+ FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
+ WHERE p.topic_id = $topic_id
+ AND p.poster_id = u.user_id
+ AND p.post_id = pt.post_id
+ ORDER BY p.post_time ASC";
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $poster = (!empty($row['username'])) ? $row['username'] : ((!$row['post_username']) ? $user->lang['Guest'] : $row['post_username']);
+
+ $message = $row['post_text'];
+ $post_subject = ($row['post_subject'] != '') ? $row['post_subject'] : $topic_data['topic_title'];
+
+ // If the board has HTML off but the post has HTML
+ // on then we process it, else leave it alone
+ if (!$config['allow_html'] && $row['enable_html'])
+ {
+ $message = preg_replace('#(<)([\/]?.*?)(>)#is', '<\\2>', $message);
+ }
+
+ if ($row['bbcode_uid'] != '')
+ {
+// $message = ($config['allow_bbcode']) ? bbencode_second_pass($message, $row['bbcode_uid']) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);
+ }
+
+ $message = nl2br($message);
+
+ $checked = ($mode == 'merge' && in_array($row['post_id'], $selected_post_ids)) ? 'checked="checked" ' : '';
+ $s_checkbox = ($is_first_post && $mode == 'split') ? ' ' : ' ';
+
+ $template->assign_block_vars('postrow', array(
+ 'POSTER_NAME' => $poster,
+ 'POST_DATE' => $user->format_date($row['post_time']),
+ 'POST_SUBJECT' => $post_subject,
+ 'MESSAGE' => $message,
+ 'POST_ID' => $row['post_id'],
+
+ 'S_CHECKBOX' => $s_checkbox
+ ));
+
+ $is_first_post = FALSE;
+ }
+ break;
case 'move':
- $page_title = $user->lang['Mod_CP'];
- include($phpbb_root_path . 'includes/page_header.'.$phpEx);
-
- if ($confirm)
+ if (!empty($_POST['confirm']))
{
- $new_forum_id = $_POST['new_forum'];
- $old_forum_id = $forum_id;
-
- if ($new_forum_id != $old_forum_id)
+ if (!$new_forum_id = intval($_POST['new_forum_id']))
{
- $topics = (isset($_POST['topic_id_list'])) ? $_POST['topic_id_list'] : array($topic_id);
-
- $topic_list = '';
- for($i = 0; $i < count($topics); $i++)
- {
- $topic_list .= (($topic_list != '') ? ', ' : '') . intval($topics[$i]);
- }
-
- $sql = "SELECT *
- FROM " . TOPICS_TABLE . "
- WHERE topic_id IN ($topic_list)
- AND topic_status <> " . ITEM_MOVED;
- $result = $db->sql_query($sql);
-
- $row = $db->sql_fetchrowset($result);
- $db->sql_freeresult($result);
-
- $db->sql_transaction();
-
- for($i = 0; $i < count($row); $i++)
- {
- $topic_id = $row[$i]['topic_id'];
-
- if (isset($_POST['move_leave_shadow']))
- {
- $shadow_sql = array(
- 'forum_id' => $old_forum_id,
- 'topic_title' => $db->sql_escape($row[$i]['topic_title']),
- 'topic_poster' => $row[$i]['topic_poster'],
- 'topic_time' => $row[$i]['topic_time'],
- 'topic_status' => ITEM_MOVED,
- 'topic_type' => POST_NORMAL,
- 'topic_vote' => $row[$i]['topic_vote'],
- 'topic_views' => $row[$i]['topic_views'],
- 'topic_replies' => $row[$i]['topic_replies'],
- 'topic_first_post_id' => $row[$i]['topic_first_post_id'],
- 'topic_last_post_id' => $row[$i]['topic_last_post_id'],
- 'topic_moved_id' => $topic_id,
- );
-
- // Insert topic in the old forum that indicates that the forum has moved.
- $sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', $shadow_sql);
- $db->sql_query($sql);
- }
-
- $sql = "UPDATE " . TOPICS_TABLE . "
- SET forum_id = $new_forum_id
- WHERE topic_id = $topic_id";
- $db->sql_query($sql);
-
- $sql = "UPDATE " . POSTS_TABLE . "
- SET forum_id = $new_forum_id
- WHERE topic_id = $topic_id";
- $db->sql_query($sql);
- }
-
- // Sync the forum indexes
- sync('forum', $new_forum_id);
- sync('forum', $old_forum_id);
-
- $db->sql_transaction('commit');
-
- $message = $user->lang['Topics_Moved'] . ' ';
-
+ trigger_error('Forum_not_exist');
}
- else
+ if ($new_forum_id != $forum_id)
{
- $message = $user->lang['No_Topics_Moved'] . ' ';
+ move_topics($topic_id_list, $new_forum_id);
}
-
- if (!empty($topic_id))
- {
- $redirect_page = "viewtopic.$phpEx$SID&t=$topic_id";
- $message .= sprintf($user->lang['Click_return_topic'], '', ' ');
- }
- else
- {
- $redirect_page = "mcp.$phpEx$SID&f=$forum_id";
- $message .= sprintf($user->lang['Click_return_modcp'], '', ' ');
- }
-
- $message = $message . ' ' . sprintf($user->lang['Click_return_forum'], '', ' ');
-
- $template->assign_vars(array(
- 'META' => ' ')
- );
-
- trigger_error($message);
+ trigger_error('done');
}
- else
+
+ foreach ($topic_data as $row)
{
- if (empty($_POST['topic_id_list']) && empty($topic_id))
- {
- trigger_error($user->lang['None_selected']);
- }
-
- $hidden_fields = ' ';
-
- if (isset($_POST['topic_id_list']))
- {
- $topics = $_POST['topic_id_list'];
-
- for($i = 0; $i < count($topics); $i++)
- {
- $hidden_fields .= ' ';
- }
- }
- else
- {
- $hidden_fields .= ' ';
- }
-
- // Set template files
- $template->set_filenames(array(
- 'body' => 'mcp_move.html')
- );
-
- $template->assign_vars(array(
- 'MESSAGE_TITLE' => $user->lang['Confirm'],
- 'MESSAGE_TEXT' => $user->lang['Confirm_move_topic'],
-
- 'L_MOVE_TO_FORUM' => $user->lang['Move_to_forum'],
- 'L_LEAVE_SHADOW' => $user->lang['Leave_shadow_topic'],
-
- 'S_FORUM_SELECT' => '' . make_forum_select(0, $forum_id) . ' ',
- 'S_MODCP_ACTION' => "mcp.$phpEx$SID",
- 'S_HIDDEN_FIELDS' => $hidden_fields)
- );
-
- include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
+ $template->assign_block_vars('topiclist', array(
+ 'TOPIC_TITLE' => $row['topic_title']
+ ));
}
- break;
+
+ $s_hidden_fields = '';
+ foreach ($topic_id_list as $topic_id)
+ {
+ $s_hidden_fields .= ' ';
+ }
+
+ $template->assign_vars(array(
+ 'S_HIDDEN_FIELDS' => $s_hidden_fields,
+ 'S_FORUM_SELECT' => make_forum_select(0, $forum_id)
+ ));
+
+ mcp_header('mcp_move.html');
+ break;
case 'lock':
- $topics = (!empty($_POST['topic_id_list'])) ? $_POST['topic_id_list'] : array($topic_id);
-
- $topic_id_sql = $log_data = '';
- for($i = 0; $i < count($topics); $i++)
- {
- $topic_id_sql .= (($topic_id_sql != '') ? ', ' : '') . intval($topics[$i]);
- $log_data = (($log_data != '') ? ', ' : '') . '' . $topics[$i] . ' ';
- }
-
- $sql = "UPDATE " . TOPICS_TABLE . "
- SET topic_status = " . ITEM_LOCKED . "
- WHERE topic_id IN ($topic_id_sql)
- AND topic_moved_id = 0";
+ case 'unlock':
+ $sql = 'UPDATE ' . TOPICS_TABLE . '
+ SET topic_status = ' . (($mode == 'lock') ? ITEM_LOCKED : ITEM_UNLOCKED) . '
+ WHERE topic_id IN (' . implode(', ', $topic_id_list) . ')
+ AND topic_moved_id = 0';
$db->sql_query($sql);
- add_log('mod', $forum_id, 'logm_lock', $log_data);
-
- if (!empty($topic_id))
+ $message = (($mode == 'lock') ? $user->lang['Topics_Locked'] : $user->lang['Topics_Unlocked']) . ' ';
+ if (isset($_GET['quickmod']))
{
- $redirect_page = "viewtopic.$phpEx$SID&t=$topic_id";
- $message = sprintf($user->lang['Click_return_topic'], '', ' ');
+ $redirect_page = "viewtopic.$phpEx$SID&t=$topic_id&start=$start";
+ $message .= sprintf($user->lang['Click_return_topic'], '', ' ');
}
else
{
- $redirect_page = "mcp.$phpEx$SID&f=$forum_id";
- $message = sprintf($user->lang['Click_return_modcp'], '', ' ');
+ $redirect_page = $mcp_url . '&mode=forum_view';
+ $message .= sprintf($user->lang['Click_return_modcp'], '', ' ');
}
$message .= ' ' . sprintf($user->lang['Click_return_forum'], "", ' ');
$template->assign_vars(array(
- 'META' => ' ')
- );
+ 'META' => ' '
+ ));
- trigger_error($user->lang['Topics_Locked'] . ' ' . $message);
+ trigger_error($message);
+ break;
- break;
+ case 'merge_posts':
+ $return_url = ' ' . sprintf($user->lang['Click_return_topic'], '', ' ');
+ move_posts($post_id_list, $to_topic_id);
- case 'unlock':
- $topics = (isset($_POST['topic_id_list'])) ? $_POST['topic_id_list'] : array($topic_id);
-
- $topic_id_sql = '';
- for($i = 0; $i < count($topics); $i++)
- {
- $topic_id_sql .= (($topic_id_sql != "") ? ', ' : '') . $topics[$i];
- }
-
- $sql = "UPDATE " . TOPICS_TABLE . "
- SET topic_status = " . ITEM_UNLOCKED . "
- WHERE topic_id IN ($topic_id_sql)
- AND topic_moved_id = 0";
- $db->sql_query($sql);
-
- if (!empty($topic_id))
- {
- $redirect_page = "viewtopic.$phpEx$SID&t=$topic_id";
- $message = sprintf($user->lang['Click_return_topic'], '', ' ');
- }
- else
- {
- $redirect_page = "mcp.$phpEx$SID&f=$forum_id";
- $message = sprintf($user->lang['Click_return_modcp'], '', ' ');
- }
-
- $message = $message . ' ' . sprintf($user->lang['Click_return_forum'], '', ' ');
-
- $template->assign_vars(array(
- 'META' => ' ')
- );
-
- trigger_error($user->lang['Topics_Unlocked'] . ' ' . $message);
-
- break;
+ trigger_error($user->lang['Posts_merged'] . $return_url . $return_mcp);
+ break;
case 'split':
- $page_title = $user->lang['Mod_CP'];
- include($phpbb_root_path . 'includes/page_header.'.$phpEx);
+ $return_url = ' ' . sprintf($user->lang['Click_return_topic'], '', ' ');
+ move_posts($post_id_list, $new_topic_id);
- if (isset($_POST['split_type_all']) || isset($_POST['split_type_beyond']))
- {
- $posts = $_POST['post_id_list'];
-
- $sql = "SELECT poster_id, topic_id, post_time
- FROM " . POSTS_TABLE . "
- WHERE post_id = " . $posts[0];
- $result = $db->sql_query($sql);
-
- $post_rowset = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
-
- $first_poster = $post_rowset['poster_id'];
- $topic_id = $post_rowset['topic_id'];
- $post_time = $post_rowset['post_time'];
-
- $post_subject = $db->sql_escape(trim(htmlspecialchars($_POST['subject'])));
- if (empty($post_subject))
- {
- trigger_error($user->lang['Empty_subject']);
- }
-
- $new_forum_id = intval($_POST['new_forum_id']);
- $topic_time = time();
-
- $db->sql_transaction();
-
- $sql = "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type)
- VALUES ('$post_subject', $first_poster, " . $topic_time . ", $new_forum_id, " . ITEM_UNLOCKED . ", " . POST_NORMAL . ")";
- $db->sql_query($sql);
-
- $new_topic_id = $db->sql_nextid();
-
- if(!empty($_POST['split_type_all']))
- {
- $post_id_sql = '';
- for($i = 0; $i < count($posts); $i++)
- {
- $post_id_sql .= (($post_id_sql != '') ? ', ' : '') . $posts[$i];
- }
-
- $sql = "UPDATE " . POSTS_TABLE . "
- SET topic_id = $new_topic_id, forum_id = $new_forum_id
- WHERE post_id IN ($post_id_sql)";
- }
- else if(!empty($_POST['split_type_beyond']))
- {
- $sql = "UPDATE " . POSTS_TABLE . "
- SET topic_id = $new_topic_id, forum_id = $new_forum_id
- WHERE post_time >= $post_time
- AND topic_id = $topic_id";
- }
-
- $db->sql_query($sql);
-
- sync('topic', $new_topic_id);
- sync('topic', $topic_id);
- sync('forum', $new_forum_id);
- sync('forum', $forum_id);
-
- $db->sql_transaction('commit');
-
- $template->assign_vars(array(
- 'META' => ' ')
- );
-
- trigger_error($user->lang['Topic_split'] . ' ' . sprintf($user->lang['Click_return_topic'], '', ' '));
- }
- else
- {
- //
- // Set template files
- //
- $template->set_filenames(array(
- 'body' => 'mcp_split.html')
- );
-
- $sql = "SELECT u.username, p.*, pt.post_text, pt.bbcode_uid, pt.post_subject, p.post_username
- FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
- WHERE p.topic_id = $topic_id
- AND p.poster_id = u.user_id
- AND p.post_id = pt.post_id
- ORDER BY p.post_time ASC";
- $result = $db->sql_query($sql);
-
- $s_hidden_fields = ' ';
-
- if(($total_posts = $db->sql_numrows($result)) > 0)
- {
- $postrow = $db->sql_fetchrowset($result);
-
- $template->assign_vars(array(
- 'L_SPLIT_TOPIC' => $user->lang['Split_Topic'],
- 'L_SPLIT_ITEM_EXPLAIN' => $user->lang['Split_Topic_explain'],
- 'L_AUTHOR' => $user->lang['Author'],
- 'L_MESSAGE' => $user->lang['Message'],
- 'L_SELECT' => $user->lang['Select'],
- 'L_SPLIT_SUBJECT' => $user->lang['Split_title'],
- 'L_SPLIT_FORUM' => $user->lang['Split_forum'],
- 'L_POSTED' => $user->lang['Posted'],
- 'L_SPLIT_POSTS' => $user->lang['Split_posts'],
- 'L_SUBMIT' => $user->lang['Submit'],
- 'L_SPLIT_AFTER' => $user->lang['Split_after'],
- 'L_POST_SUBJECT' => $user->lang['Post_subject'],
- 'L_MARK_ALL' => $user->lang['Mark_all'],
- 'L_UNMARK_ALL' => $user->lang['Unmark_all'],
- 'L_POST' => $user->lang['Post'],
-
- 'FORUM_NAME' => $forum_name,
-
- 'U_VIEW_FORUM' => "viewforum.$phpEx$SID&f=$forum_id",
-
- 'S_SPLIT_ACTION' => "mcp.$phpEx$SID",
- 'S_HIDDEN_FIELDS' => $s_hidden_fields,
- 'S_FORUM_SELECT' => '' . make_forum_select() . ' ')
- );
-
- for($i = 0; $i < $total_posts; $i++)
- {
- $post_id = $postrow[$i]['post_id'];
- $poster_id = $postrow[$i]['user_id'];
- $poster = $postrow[$i]['username'];
-
- $post_date = $user->format_date($postrow[$i]['post_time']);
-
- $bbcode_uid = $postrow[$i]['bbcode_uid'];
- $message = $postrow[$i]['post_text'];
- $post_subject = ($postrow[$i]['post_subject'] != '') ? $postrow[$i]['post_subject'] : $topic_title;
-
- // If the board has HTML off but the post has HTML
- // on then we process it, else leave it alone
- if (!$config['allow_html'])
- {
- if ($postrow[$i]['enable_html'])
- {
- $message = preg_replace('#(<)([\/]?.*?)(>)#is', '<\\2>', $message);
- }
- }
-
- if ($bbcode_uid != '')
- {
-// $message = ($config['allow_bbcode']) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);
- }
-
- // Define censored word matches
- $orig_word = array();
- $replacement_word = array();
- obtain_word_list($orig_word, $replacement_word);
-
- if (count($orig_word))
- {
- $post_subject = preg_replace($orig_word, $replacement_word, $post_subject);
- $message = preg_replace($orig_word, $replacement_word, $message);
- }
-
- if ($config['allow_smilies'] && $postrow[$i]['enable_smilies'])
- {
- }
-
- $message = nl2br($message);
-
- $checkbox = ($i > 0) ? ' ' : ' ';
-
- $template->assign_block_vars('postrow', array(
- 'POSTER_NAME' => $poster,
- 'POST_DATE' => $post_date,
- 'POST_SUBJECT' => $post_subject,
- 'MESSAGE' => $message,
- 'POST_ID' => $post_id,
-
- 'S_SPLIT_CHECKBOX' => $checkbox)
- );
- }
- }
- }
- break;
+ trigger_error($user->lang['Posts_merged'] . $return_url . $return_mcp);
+ break;
case 'ip':
- $page_title = $user->lang['Mod_CP'];
- include($phpbb_root_path . 'includes/page_header.'.$phpEx);
+ mcp_header('mcp_viewip.html');
$rdns_ip_num = (isset($_GET['rdns'])) ? $_GET['rdns'] : '';
if (!$post_id)
{
- trigger_error($user->lang['No_such_post']);
+ trigger_error('No_such_post');
}
- // Set template files
- $template->set_filenames(array(
- 'body' => 'mcp_viewip.html')
- );
-
- // Look up relevent data for this post
- $sql = "SELECT poster_ip, poster_id
- FROM " . POSTS_TABLE . "
- WHERE post_id = $post_id";
- $result = $db->sql_query($sql);
-
- if (!($post_row = $db->sql_fetchrow($result)))
- {
- trigger_error($user->lang['No_such_post']);
- }
-
- $ip_this_post = $post_row['poster_ip'];
- $ip_this_post = ($rdns_ip_num == $ip_this_post) ? gethostbyaddr($ip_this_post) : $ip_this_post;
-
- $poster_id = $post_row['poster_id'];
+ $ip_this_post = $post_info['poster_ip'];
+ $ip_this_post = ($rdns_ip_num == $ip_this_post) ? @gethostbyaddr($ip_this_post) : $ip_this_post;
$template->assign_vars(array(
'L_IP_INFO' => $user->lang['IP_info'],
@@ -731,45 +568,36 @@ switch($mode)
'IP' => $ip_this_post,
- 'U_LOOKUP_IP' => "mcp.$phpEx$SID&mode=ip&p=$post_id&t=$topic_id&rdns=" . $ip_this_post)
- );
+ 'U_LOOKUP_IP' => $mcp_url . '&mode=ip&rdns=' . $ip_this_post
+ ));
- //
// Get other IP's this user has posted under
- //
- $sql = "SELECT poster_ip, COUNT(*) AS postings
- FROM " . POSTS_TABLE . "
- WHERE poster_id = $poster_id
+ $sql = 'SELECT poster_ip, COUNT(*) AS postings
+ FROM ' . POSTS_TABLE . '
+ WHERE poster_id = ' . $post_info['poster_id'] . '
GROUP BY poster_ip
- ORDER BY postings DESC";
+ ORDER BY postings DESC';
$result = $db->sql_query($sql);
- if ($row = $db->sql_fetchrow($result))
+ while ($row = $db->sql_fetchrow($result))
{
- $i = 0;
- do
+ if ($row['poster_ip'] == $post_info['poster_ip'])
{
- if ($row['poster_ip'] == $post_row['poster_ip'])
- {
- $template->assign_vars(array(
- 'POSTS' => $row['postings'] . ' ' . (($row['postings'] == 1) ? $user->lang['Post'] : $user->lang['Posts']))
- );
- continue;
- }
-
- $ip = $row['poster_ip'];
- $ip = ($rdns_ip_num == $row['poster_ip'] || $rdns_ip_num == 'all') ? gethostbyaddr($ip) : $ip;
-
- $template->assign_block_vars('iprow', array(
- 'IP' => $ip,
- 'POSTS' => $row['postings'] . ' ' . (($row['postings'] == 1) ? $user->lang['Post'] : $user->lang['Posts']),
-
- 'U_LOOKUP_IP' => "mcp.$phpEx$SID&mode=ip&p=$post_id&t=$topic_id&rdns=" . $row['poster_ip'])
- );
-
- $i++;
+ $template->assign_vars(array(
+ 'POSTS' => $row['postings'] . ' ' . (($row['postings'] == 1) ? $user->lang['Post'] : $user->lang['Posts'])
+ ));
+ continue;
}
- while ($row = $db->sql_fetchrow($result));
+
+ $ip = $row['poster_ip'];
+ $ip = ($rdns_ip_num == $row['poster_ip'] || $rdns_ip_num == 'all') ? gethostbyaddr($ip) : $ip;
+
+ $template->assign_block_vars('iprow', array(
+ 'IP' => $ip,
+ 'POSTS' => $row['postings'] . ' ' . (($row['postings'] == 1) ? $user->lang['Post'] : $user->lang['Posts']),
+
+ 'U_LOOKUP_IP' => $mcp_url . '&mode=ip&rdns=' . $row['poster_ip'])
+ );
}
$db->sql_freeresult($result);
@@ -777,7 +605,7 @@ switch($mode)
$sql = "SELECT u.user_id, u.username, COUNT(*) as postings
FROM " . USERS_TABLE ." u, " . POSTS_TABLE . " p
WHERE p.poster_id = u.user_id
- AND p.poster_ip = '" . $post_row['poster_ip'] . "'
+ AND p.poster_ip = '" . $post_info['poster_ip'] . "'
GROUP BY u.user_id, u.username
ORDER BY postings DESC";
$result = $db->sql_query($sql);
@@ -804,48 +632,29 @@ switch($mode)
while ($row = $db->sql_fetchrow($result));
}
$db->sql_freeresult($result);
- break;
+ break;
- default:
- $page_title = $user->lang['Mod_CP'];
- include($phpbb_root_path . 'includes/page_header.'.$phpEx);
-
- $template->set_filenames(array(
- 'body' => 'mcp_topics.html')
- );
- make_jumpbox('mcp.'.$phpEx);
+ case 'forum_view':
+ mcp_header('mcp_forum.html');
$template->assign_vars(array(
- 'FORUM_NAME' => $forum_name,
-
- 'L_MOD_CP' => $user->lang['Mod_CP'],
- 'L_MOD_CP_EXPLAIN' => $user->lang['Mod_CP_explain'],
- 'L_SELECT' => $user->lang['Select'],
- 'L_DELETE' => $user->lang['Delete'],
- 'L_MOVE' => $user->lang['Move'],
- 'L_LOCK' => $user->lang['Lock'],
- 'L_UNLOCK' => $user->lang['Unlock'],
- 'L_TOPICS' => $user->lang['Topics'],
- 'L_REPLIES' => $user->lang['Replies'],
- 'L_LASTPOST' => $user->lang['Last_Post'],
- 'L_SELECT' => $user->lang['Select'],
+ 'FORUM_NAME' => $forum_info['forum_name'],
'U_VIEW_FORUM' => "viewforum.$phpEx$SID&f=$forum_id",
'S_HIDDEN_FIELDS' => ' ',
- 'S_MODCP_ACTION' => "mcp.$phpEx$SID")
- );
+ 'S_MCP_ACTION' => $mcp_url
+ ));
// Define censored word matches
$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);
- $sql = "SELECT t.*, u.username, u.user_id, p.post_time
- FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p
+ $sql = "SELECT t.*, u.username, u.user_id
+ FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u
WHERE t.forum_id = $forum_id
AND t.topic_poster = u.user_id
- AND p.post_id = t.topic_last_post_id
- ORDER BY t.topic_type DESC, p.post_time DESC
+ ORDER BY t.topic_type DESC, t.topic_last_post_time DESC
LIMIT $start, " . $config['topics_per_page'];
$result = $db->sql_query($sql);
@@ -855,41 +664,33 @@ switch($mode)
if ($row['topic_status'] == ITEM_LOCKED)
{
- $folder_img = $user->img('folder_locked');
- $folder_alt = $user->lang['Topic_locked'];
+ $folder_img = $user->img('folder_locked', 'Topic_locked');
}
else
{
if ($row['topic_type'] == POST_ANNOUNCE)
{
- $folder_img = $user->img('folder_announce');
- $folder_alt = $user->lang['Announcement'];
+ $folder_img = $user->img('folder_announce', 'Announcement');
}
else if ($row['topic_type'] == POST_STICKY)
{
- $folder_img = $user->img('folder_sticky');
- $folder_alt = $user->lang['Sticky'];
- }
+ $folder_img = $user->img('folder_sticky', 'Sticky');
+ }
else
{
- $folder_img = $user->img('folder');
- $folder_alt = $user->lang['No_new_posts'];
+ $folder_img = $user->img('folder', 'No_new_posts');
}
}
- $topic_id = $row['topic_id'];
- $topic_type = $row['topic_type'];
- $topic_status = $row['topic_status'];
-
- if ($topic_type == POST_ANNOUNCE)
+ if ($row['topic_type'] == POST_ANNOUNCE)
{
$topic_type = $user->lang['Topic_Announcement'] . ' ';
}
- else if ($topic_type == POST_STICKY)
+ else if ($row['topic_type'] == POST_STICKY)
{
$topic_type = $user->lang['Topic_Sticky'] . ' ';
}
- else if ($topic_status == ITEM_MOVED)
+ else if ($row['topic_status'] == ITEM_MOVED)
{
$topic_type = $user->lang['Topic_Moved'] . ' ';
}
@@ -903,41 +704,486 @@ switch($mode)
$topic_type .= $user->lang['Topic_Poll'] . ' ';
}
+ // Shouldn't moderators be allowed to read uncensored title?
$topic_title = $row['topic_title'];
if (count($orig_word))
{
$topic_title = preg_replace($orig_word, $replacement_word, $topic_title);
}
- $u_view_topic = "mcp.$phpEx$SID&mode=split&t=$topic_id";
- $topic_replies = $row['topic_replies'];
-
- $last_post_time = $user->format_date($row['post_time']);
-
$template->assign_block_vars('topicrow', array(
- 'U_VIEW_TOPIC' => $u_view_topic,
+ 'U_VIEW_TOPIC' => $mcp_url . '&t=' . $row['topic_id'] . '&mode=topic_view',
+
+ 'S_MERGE_SELECT' => ($topic_id && !empty($_GET['post_id_list'])) ? sprintf($user->lang['Select_for_merge'], '', ' ') : '',
'TOPIC_FOLDER_IMG' => $folder_img,
'TOPIC_TYPE' => $topic_type,
'TOPIC_TITLE' => $topic_title,
- 'REPLIES' => $topic_replies,
- 'LAST_POST_TIME' => $last_post_time,
- 'TOPIC_ID' => $topic_id,
-
- 'L_TOPIC_FOLDER_ALT' => $folder_alt)
- );
+ 'REPLIES' => $row['topic_replies'],
+ 'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']),
+ 'TOPIC_ID' => $row['topic_id']
+ ));
}
$db->sql_freeresult($result);
$template->assign_vars(array(
- 'PAGINATION' => generate_pagination("mcp.$phpEx$SID&f=$forum_id", $forum_topics, $config['topics_per_page'], $start),
- 'PAGE_NUMBER' => sprintf($user->lang['Page_of'], (floor($start / $config['topics_per_page']) + 1), ceil($forum_topics / $config['topics_per_page'])),
+ 'PAGINATION' => generate_pagination("mcp.$phpEx$SID&f=$forum_id", $forum_info['forum_topics'], $config['topics_per_page'], $start),
+ 'PAGE_NUMBER' => sprintf($user->lang['Page_of'], (floor($start / $config['topics_per_page']) + 1), ceil($forum_info ['forum_topics'] / $config['topics_per_page'])),
'L_GOTO_PAGE' => $user->lang['Goto_page'])
);
+ break;
+
+ case 'front':
+ default:
+ mcp_header('mcp_front.html');
- break;
}
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
+// -----------------------
+// Page specific functions
+//
+function mcp_header($template_name, $jump_mode = 'forum_view')
+{
+ global $phpbb_root_path, $phpEx, $SID, $template, $user, $db, $config, $forum_id;
+
+ $forum_id = (!empty($forum_id)) ? $forum_id : FALSE;
+ $extra_form_fields = array(
+ 'mode' => $jump_mode
+ );
+
+ // NOTE: this will stop working if the jumpbox method is changed to POST
+ if (!empty($_GET['post_id_list']))
+ {
+ $extra_form_fields['post_id_list'] = $_GET['post_id_list'];
+ }
+
+ $page_title = $user->lang['Mod_CP'];
+ include($phpbb_root_path . 'includes/page_header.' . $phpEx);
+ $template->set_filenames(array(
+ 'body' => $template_name
+ ));
+ make_jumpbox('mcp.' . $phpEx, $forum_id, $extra_form_fields);
+}
+
+function move_topics($topic_ids, $forum_id, $auto_sync = TRUE)
+{
+ global $db;
+
+ $forum_ids = array($forum_id);
+ $where_sql = (is_array($topic_ids)) ? 'IN (' . implode(', ', $topic_ids) . ')' : '= ' . $topic_ids;
+
+ if ($auto_sync)
+ {
+ $sql = 'SELECT DISTINCT forum_id
+ FROM ' . TOPICS_TABLE . '
+ WHERE topic_id ' . $where_sql;
+ $result = $db->sql_query($sql);
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $forum_ids[] = $row['forum_id'];
+ }
+ }
+
+ $sql = 'DELETE FROM ' . TOPICS_TABLE . "
+ WHERE topic_moved_id $where_sql
+ AND forum_id = " . $forum_id;
+ $db->sql_query($sql);
+
+ $sql = 'UPDATE ' . TOPICS_TABLE . "
+ SET forum_id = $forum_id
+ WHERE topic_id " . $where_sql;
+ $db->sql_query($sql);
+
+ $sql = 'UPDATE ' . POSTS_TABLE . "
+ SET forum_id = $forum_id
+ WHERE topic_id " . $where_sql;
+ $db->sql_query($sql);
+
+ if ($auto_sync)
+ {
+ resync('forum', 'forum_id', $forum_ids);
+ }
+}
+
+function move_posts($post_ids, $topic_id, $auto_sync = TRUE)
+{
+ global $db;
+ $topic_ids = array($topic_id);
+
+ if ($auto_sync)
+ {
+ $sql = 'SELECT DISTINCT topic_id
+ FROM ' . TOPICS_TABLE . '
+ WHERE topic_id IN (' . implode(', ', $post_ids) . ')';
+ $result = $db->sql_query($sql);
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $topic_ids[] = $row['topic_id'];
+ }
+ }
+
+ $sql = 'SELECT * FROM ' . TOPICS_TABLE . ' WHERE topic_id = ' . $topic_id;
+ $result = $db->sql_query($sql);
+ if (!$row = $db->sql_fetchrow($result))
+ {
+ trigger_error('Topic_post_not_exist');
+ }
+
+ if (!is_array($post_ids))
+ {
+ $post_ids = array($post_ids);
+ }
+ $sql = 'UPDATE ' . POSTS_TABLE . '
+ SET forum_id = ' . $row['forum_id'] . ", topic_id = $topic_id
+ WHERE post_id IN (" . implode(', ', $post_ids) . ')';
+ $db->sql_query($sql);
+
+ if ($auto_sync)
+ {
+ resync('topic', 'topic_id', $topic_ids);
+ resync('forum', 'forum_id', $row['forum_id']);
+ }
+}
+
+function delete_topics($where_type, $where_ids, $auto_sync = TRUE)
+{
+ global $db;
+ if (is_array($where_ids))
+ {
+ $where_ids = array_unique($where_ids);
+ }
+
+ delete_posts($where_type, $where_ids, FALSE);
+
+ if ($where_type == 'topic_id' && is_array($where_ids))
+ {
+ $topic_ids = $where_ids;
+ }
+ else
+ {
+ $topic_ids = array();
+ $where_sql = "WHERE $where_type " . ((!is_array($where_ids)) ? "= $where_ids" : 'IN (' . implode(', ', $where_ids) . ')');
+
+ $sql = 'SELECT topic_id
+ FROM ' . TOPICS_TABLE . "
+ $where_sql";
+
+ $result = $db->sql_query($sql);
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $topic_ids[] = $row['topic_id'];
+ }
+ }
+
+ if (count($topic_ids))
+ {
+ // TODO: clean up topics cache if any, last read marking, probably some other stuff too (polls)
+
+ $db->sql_query('DELETE FROM ' . TOPICS_TABLE . ' WHERE topic_moved_id IN (' . implode(', ', $topic_ids) . ')');
+ $db->sql_query('DELETE FROM ' . TOPICS_WATCH_TABLE . ' WHERE topic_id IN (' . implode(', ', $topic_ids) . ')');
+
+ if ($auto_sync)
+ {
+ $forum_ids = array();
+ $sql = 'SELECT forum_id
+ FROM ' . FORUMS_TABLE . '
+ WHERE topic_id IN (' . implode(', ', $topic_ids) . ')
+ GROUP BY forum_id';
+ $result = $db->sql_query($sql);
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $forum_ids[] = $row['forum_id'];
+ }
+ }
+ }
+
+ $db->sql_query('DELETE FROM ' . TOPICS_TABLE . ' ' . $where_sql);
+
+ if (!empty($forum_ids))
+ {
+ resync('forum', 'forum_id', $forum_ids);
+ }
+}
+
+function delete_posts($where_type, $where_ids, $auto_sync = TRUE)
+{
+ global $db;
+
+ if (is_array($where_ids))
+ {
+ $where_ids = array_unique($where_ids);
+ }
+
+ if ($where_type == 'post_id' && is_array($where_ids))
+ {
+ $post_ids = $where_ids;
+ }
+ else
+ {
+ $post_ids = $topic_ids = $forum_ids = array();
+
+ $sql = 'SELECT post_id, topic_id, forum_id
+ FROM ' . POSTS_TABLE . "
+ WHERE $where_type " . ((!is_array($where_ids)) ? "= $where_ids" : 'IN (' . implode(', ', $where_ids) . ')');
+
+ $result = $db->sql_query($sql);
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $post_ids[] = $row['post_id'];
+ $topic_ids[] = $row['topic_id'];
+ $forum_ids[] = $row['forum_id'];
+ }
+ }
+
+ if (!count($post_ids))
+ {
+ return;
+ }
+
+ $where_sql = ' WHERE post_id IN (' . implode(', ', $post_ids) . ')';
+
+ $db->sql_query('DELETE FROM ' . POSTS_TABLE . $where_sql);
+ $db->sql_query('DELETE FROM ' . POSTS_TEXT_TABLE . $where_sql);
+ $db->sql_query('DELETE FROM ' . RATINGS_TABLE . $where_sql);
+ $db->sql_query('DELETE FROM ' . SEARCH_MATCH_TABLE . $where_sql);
+
+ if ($auto_resync && count($topic_ids))
+ {
+ resync('topic', 'topic_id', $topic_ids);
+ resync('forum', 'forum_id', $forum_ids);
+ }
+}
+
+//
+// Usage:
+// sync('topic', 'topic_id', 123); <= resynch topic #123
+// sync('topic', 'forum_id', array(2, 3)); <= resynch topics from forum #2 and #3
+// sync('topic'); <= resynch all topics
+//
+function resync($type, $where_type = '', $where_ids = '')
+{
+ global $db;
+
+ switch ($where_type)
+ {
+ case 'topic_id':
+ case 'forum_id':
+ if (is_array($where_ids))
+ {
+ $where_ids = array_unique($where_ids);
+ $where_sql = 'WHERE ' . $where_type{0} . ".$where_type IN (" . implode(', ', $where_ids) . ') AND';
+ }
+ else
+ {
+ $where_sql = 'WHERE ' . $where_type{0} . ".$where_type = " . intval($where_ids) . ' AND';
+ }
+ break;
+
+ default:
+ $where_sql = 'WHERE';
+ }
+
+ switch ($type)
+ {
+ case 'forum':
+ $sql = "SELECT f.forum_id, f.forum_posts, f.forum_last_post_id, f.forum_last_poster_id, f.forum_last_poster_name, COUNT(p.post_id) AS posts, MAX(p.post_id) AS last_post_id
+ $where_sql p.forum_id = f.forum_id
+ AND p.post_approved = 1
+ GROUP BY f.forum_id";
+
+ $forum_data = $post_ids = array();
+
+ $result = $db->sql_query($sql);
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $post_ids[] = $row['last_post_id'];
+ $forum_data[$row['forum_id']] = $row;
+ }
+
+ $sql = 'SELECT t.forum_id, COUNT(t.topic_id) AS forum_topics
+ FROM ' . TOPICS_TABLE . " t
+ $where_sql t.topic_type <> " . ITEM_MOVED . '
+ AND t.topic_approved = 1
+ GROUP BY t.forum_id';
+ $result = $db->sql_query($sql);
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $forum_data[$row['forum_id']]['topics'] = $row['forum_topics'];
+ }
+
+ if (count($post_ids))
+ {
+ $sql = 'SELECT p.post_id, p.poster_id, p.post_username, p.post_time, u.username
+ FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
+ WHERE p.post_id IN (' . implode(', ', $post_ids) . ')
+ AND p.post_approved = 1
+ AND u.user_id = p.poster_id';
+ $db->sql_query($sql);
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $forum_data[$row['forum_id']]['last_post_time'] = $row['post_time'];
+ $forum_data[$row['forum_id']]['last_poster_id'] = $row['poster_id'];
+ $forum_data[$row['forum_id']]['last_poster_name'] = ($row['poster_id'] == ANONYMOUS) ? $row['post_username'] : $row['username'];
+ }
+ }
+
+ $fieldnames = array('posts', 'topics', 'last_post_id', 'last_post_time', 'last_poster_id', 'last_poster_name');
+
+ foreach ($forum_data as $forum_id => $row)
+ {
+ $need_update = FALSE;
+
+ foreach ($fieldnames as $fieldname)
+ {
+ verify_data('forum', $fieldname, $need_update, $row);
+ }
+
+ if ($need_update)
+ {
+ $sql = array();
+ foreach ($fieldnames as $fieldname)
+ {
+ $sql[$fieldname] = $row['forum_' . $fieldname];
+ }
+
+ $sql = 'UPDATE ' . FORUMS_TABLE . '
+ SET ' . $db->sql_build_array('UPDATE', $sql) . '
+ WHERE topid_id = ' . $forum_id;
+ $db->sql_query($sql);
+ }
+ }
+ break;
+
+ case 'topic':
+ $sql = 'SELECT t.topic_id, t.topic_replies, t.topic_first_post_id, t.topic_last_post_id, t.topic_last_poster_id, t.topic_last_poster_name, COUNT(p.post_id) AS total_posts, MIN(p.post_id) AS first_post_id, MAX(p.post_id) AS last_post_id
+ FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p
+ $where_sql p.topic_id = t.topic_id
+ GROUP BY t.topic_id";
+
+ $topic_data = $post_ids = $topic_ids = array();
+
+ $result = $db->sql_query($sql);
+ while ($row = $db->sql_fetchrow($result))
+ {
+ if ($row['total_posts'] == 0)
+ {
+ $topic_ids[] = $row['topic_id'];
+ continue;
+ }
+
+ $post_ids[] = $row['last_post_id'];
+ if ($row['first_post_id'] != $row['last_post_id'])
+ {
+ $post_ids[] = $row['first_post_id'];
+ }
+
+ $row['replies'] = $row['total_posts'] - 1;
+ $topic_data[$row['topic_id']] = $row;
+ }
+
+ if (count($topic_ids))
+ {
+ delete_topics($topic_ids);
+ }
+ if (!count($post_ids))
+ {
+ // uh-oh
+ return;
+ }
+
+ $sql = 'SELECT post_id, poster_id, post_username, post_time
+ FROM ' . POSTS_TABLE . '
+ WHERE post_id IN (' . implode(', ', $post_ids) . ')';
+ $db->sql_query($sql);
+ while ($row = $db->sql_fetchrow($result))
+ {
+ if ($row['post_id'] == $topic_data[$topic_id]['last_post_id'])
+ {
+ $topic_data[$row['topic_id']]['last_poster_id'] = $row['poster_id'];
+ $topic_data[$row['topic_id']]['last_post_time'] = $row['post_time'];
+ $topic_data[$row['topic_id']]['last_poster_name'] = ($row['poster_id'] == ANONYMOUS) ? $row['post_username'] : '';
+ }
+ elseif ($row['post_id'] == $topic_data[$row['topic_id']]['first_post_id'])
+ {
+ $topic_data[$row['topic_id']]['first_poster_name'] = ($row['poster_id'] == ANONYMOUS) ? $row['post_username'] : '';
+ }
+ }
+
+ $fieldnames = array('replies', 'first_post_id', 'first_poster_name', 'last_post_id', 'last_post_time', 'last_poster_id', 'last_poster_name');
+
+ foreach ($topic_data as $topic_id => $row)
+ {
+ $need_update = FALSE;
+
+ foreach ($fieldnames as $fieldname)
+ {
+ verify_data('topic', $fieldname, $need_update, $row);
+ }
+
+ if ($need_update)
+ {
+ $sql = array();
+ foreach ($fieldnames as $fieldname)
+ {
+ $sql[$fieldname] = $row['topic_' . $fieldname];
+ }
+
+ $sql = 'UPDATE ' . TOPICS_TABLE . '
+ SET ' . $db->sql_build_array('UPDATE', $sql) . '
+ WHERE topid_id = ' . $topic_id;
+ $db->sql_query($sql);
+ }
+ }
+ }
+
+ $result = $db->sql_query('SELECT SUM(forum_topics) AS total_topics, SUM(forum_posts) AS total_posts FROM ' . FORUMS_TABLE);
+ $row = $db->sql_fetchrow($result);
+ set_config('total_posts', $row['total_posts']);
+ set_config('total_topics', $row['total_topics']);
+}
+
+
+function verify_data($type, $fieldname, &$need_update, &$data)
+{
+ // Check if the corresponding data actually exists. Must not fail when equal to zero.
+ if (!isset($data[$fieldname]) || is_null($data[$fieldname]))
+ {
+ return;
+ }
+ if ($data[$fieldname] != $data[$type . '_' . $fieldname])
+ {
+ $need_update = TRUE;
+ $data[$type . '_' . $fieldname] = $data[$fieldname];
+ }
+}
+//
+// End page specific functions
+// ---------------------------
+
+/*****
+Temp function
+*****/
+function very_temporary_lang_strings()
+{
+ global $user;
+ $user->lang['Forum_not_postable'] = 'This forum is not postable';
+ $user->lang['SELECTED_TOPICS'] = 'You selected the following topic(s)';
+ $user->lang['Topic_not_exist'] = 'The topic you selected does not exist';
+ $user->lang['Posts_merged'] = 'The selected posts have been merged';
+ $user->lang['Select_for_merge'] = '%sSelect%s';
+ $user->lang['Select_topic'] = 'Select topic';
+ $user->lang['Topic_number_is'] = 'Topic #%d is %s';
+
+ $user->lang['mod_tabs'] = array(
+ 'front' => 'Front Page',
+ 'mod_queue' => 'Mod Queue',
+ 'forum_view' => 'Forum View',
+ 'topic_view' => 'Topic View',
+ 'post_view' => 'Post View',
+ 'post_reports' => 'Reported Posts',
+ 'merge' => 'Merge'
+ );
+}
?>
\ No newline at end of file
diff --git a/phpBB/templates/subSilver/mcp_forum.html b/phpBB/templates/subSilver/mcp_forum.html
new file mode 100644
index 0000000000..c740434910
--- /dev/null
+++ b/phpBB/templates/subSilver/mcp_forum.html
@@ -0,0 +1,56 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/phpBB/templates/subSilver/mcp_front.html b/phpBB/templates/subSilver/mcp_front.html
new file mode 100644
index 0000000000..eb606b9c9f
--- /dev/null
+++ b/phpBB/templates/subSilver/mcp_front.html
@@ -0,0 +1,9 @@
+
+
+
+Moderation queue:
+There are xx posts waiting to be approved
+
+Reported posts:
+There are xx reported posts to review
+
diff --git a/phpBB/templates/subSilver/mcp_header.html b/phpBB/templates/subSilver/mcp_header.html
new file mode 100644
index 0000000000..a9ee1ed9b4
--- /dev/null
+++ b/phpBB/templates/subSilver/mcp_header.html
@@ -0,0 +1,41 @@
+
+
+
+
+ {FORUM_NAME}
+
+
+
+
+ {PAGINATION}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/phpBB/templates/subSilver/mcp_move.html b/phpBB/templates/subSilver/mcp_move.html
index 6d3a2bbb25..e2a2fd7f37 100644
--- a/phpBB/templates/subSilver/mcp_move.html
+++ b/phpBB/templates/subSilver/mcp_move.html
@@ -1,6 +1,6 @@
-