diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php
index f1f20a9006..f5ec4d703b 100644
--- a/phpBB/includes/mcp/mcp_main.php
+++ b/phpBB/includes/mcp/mcp_main.php
@@ -11,1478 +11,153 @@
//
// -------------------------------------------------------------
-class mcp_main extends mcp
+class mcp_main extends module
{
- function init()
- {
- // Validate input
- $this->mcp_init();
- if (!$this->post_id)
- {
- unset($this->modules[$this->id]['subs']['post_details']);
- }
- if (!$this->topic_id)
- {
- unset($this->modules[$this->id]['subs']['topic_view']);
- }
- }
-
- function main($mode)
+ function mcp_main($id, $mode, $url)
{
global $auth, $db, $user, $template;
global $config, $phpbb_root_path, $phpEx, $SID;
+
+ $action = request_var('action', '');
+ $quickmod = request_var('quickmod', '');
- $this->mode = $mode;
+ if (is_array($action))
+ {
+ list($action, ) = each($action);
+ }
switch ($mode)
{
- case 'resync':
- if (!$topic_id_list = $this->get_topic_ids('m_'))
- {
- $template->assign_var('MESSAGE', $user->lang['NO_TOPIC_SELECTED']);
- $this->main('forum_view');
- }
-
- // Sync everything and perform extra checks separately
- sync('topic_reported', 'topic_id', $topic_id_list, FALSE, TRUE);
- sync('topic_attachment', 'topic_id', $topic_id_list, FALSE, TRUE);
- sync('topic', 'topic_id', $topic_id_list, TRUE, FALSE);
-
-
- $sql = 'SELECT topic_id, forum_id, topic_title
- FROM ' . TOPICS_TABLE . '
- WHERE topic_id IN (' . implode(', ', $topic_id_list) . ')';
- $result = $db->sql_query($sql);
-
- // Log this action
- while ($row = $db->sql_fetchrow($result))
- {
- add_log('mod', $row['forum_id'], $row['topic_id'], 'LOG_TOPIC_RESYNC', $row['topic_title']);
- }
-
- $msg = (count($topic_id_list) == 1) ? $user->lang['TOPIC_RESYNC_SUCCESS'] : $user->lang['TOPICS_RESYNC_SUCCESS'];
- $template->assign_var('MESSAGE', $msg);
-
- // Back to the topics list
- $this->main('forum_view');
- break;
-
case 'lock':
case 'unlock':
- if (!$topic_id_list = $this->get_topic_ids('m_lock'))
+ $topic_ids = get_array((!$quickmod) ? 'topic_id_list' : 't', 0);
+
+ if (!$topic_ids)
{
- $template->assign_var('MESSAGE', $user->lang['NO_TOPIC_SELECTED']);
- $this->main('forum_view');
+ trigger_error('NO_TOPIC_SELECTED');
}
- if (count($topic_id_list) == 1)
+ lock_unlock($mode, $topic_ids);
+ break;
+
+ case 'lock_post':
+ case 'unlock_post':
+
+ $post_ids = get_array((!$quickmod) ? 'post_id_list' : 'p', 0);
+
+ if (!$post_ids)
{
- $message = ($mode == 'lock') ? $user->lang['TOPIC_LOCKED_SUCCESS'] : $user->lang['TOPIC_UNLOCKED_SUCCESS'];
- }
- else
- {
- $message = ($mode == 'lock') ? $user->lang['TOPICS_LOCKED_SUCCESS'] : $user->lang['TOPICS_UNLOCKED_SUCCESS'];
+ trigger_error('NO_POST_SELECTED');
}
- $sql = 'UPDATE ' . TOPICS_TABLE . '
- SET topic_status = ' . (($mode == 'lock') ? ITEM_LOCKED : ITEM_UNLOCKED) . '
- WHERE topic_id IN (' . implode(', ', $topic_id_list) . ')';
- $db->sql_query($sql);
+ lock_unlock($mode, $post_ids);
+ break;
- $topic_data = $this->get_topic_data($topic_id_list);
- foreach ($topic_data as $topic_id => $row)
- {
- add_log('mod', $this->forum_id, $topic_id, 'LOG_' . strtoupper($mode), $row['topic_title']);
- }
-
- // Where are we going to be redirected?
- $return_topic = "viewtopic.$phpEx$SID&f={$this->forum_id}&t={$this->topic_id}&start={$this->start}";
- $return_forum = "viewforum.$phpEx$SID&f={$this->forum_id}";
-
- if ($this->quickmod)
- {
- meta_refresh(3, $return_topic);
-
- $message .= '
' . sprintf($user->lang['RETURN_TOPIC'], '', '');
- $message .= '
' . sprintf($user->lang['RETURN_FORUM'], '', '');
-
- trigger_error($message);
- }
- else
- {
- return_link('RETURN_TOPIC', $return_topic);
- return_link('RETURN_FORUM', $return_forum);
-
- $template->assign_var('MESSAGE', $message);
- $this->main('forum_view');
- }
- break;
-
- case 'front':
- // -------------
- // Latest 5 unapproved
- $forum_list = get_forum_list('m_approve');
- $post_list = array();
-
- $template->assign_var('S_SHOW_UNAPPROVED', (!empty($forum_list)) ? TRUE : FALSE);
- if (!empty($forum_list))
- {
- $sql = 'SELECT COUNT(post_id) AS total
- FROM ' . POSTS_TABLE . '
- WHERE forum_id IN (' . implode(', ', $forum_list) . ')
- AND post_approved = 0';
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $total = $row['total'];
-
- if ($total)
- {
- // KNOWN BUG: does not work with global announcements
- $sql = 'SELECT post_id
- FROM ' . POSTS_TABLE . '
- WHERE forum_id IN (' . implode(', ', $forum_list) . ')
- AND post_approved = 0
- ORDER BY post_id DESC';
- $result = $db->sql_query_limit($sql, 5);
- while ($row = $db->sql_fetchrow($result))
- {
- $post_list[] = $row['post_id'];
- }
-
- $sql = 'SELECT p.post_id, p.post_subject, p.post_time, p.poster_id, p.post_username, u.username, t.topic_id, t.topic_title, t.topic_first_post_id, f.forum_id, f.forum_name
- FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . ' f, ' . USERS_TABLE . ' u
- WHERE p.post_id IN (' . implode(', ', $post_list) . ')
- AND t.topic_id = p.topic_id
- AND f.forum_id = p.forum_id
- AND p.poster_id = u.user_id
- ORDER BY p.post_id DESC';
- $result = $db->sql_query($sql);
-
- while ($row = $db->sql_fetchrow($result))
- {
- if ($row['poster_id'] == ANONYMOUS)
- {
- $author = ($row['post_username']) ? $row['post_username'] : $user->lang['GUEST'];
- }
- else
- {
- $author = '' . $row['username'] . '';
- }
-
- $template->assign_block_vars('unapproved', array(
- 'U_POST_DETAILS'=> $this->url . '&mode=post_details',
- 'FORUM' => (!empty($row['forum_id'])) ? '' . $row['forum_name'] . '' : $user->lang['POST_GLOBAL'],
- 'TOPIC' => '' . $row['topic_title'] . '',
- 'AUTHOR' => $author,
- 'SUBJECT' => '' . (($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT']) . '',
- 'POST_TIME' => $user->format_date($row['post_time'])
- ));
- }
- }
-
- if ($total == 0)
- {
- $template->assign_vars(array(
- 'L_UNAPPROVED_TOTAL' => $user->lang['UNAPPROVED_POSTS_ZERO_TOTAL'],
- 'S_HAS_UNAPPROVED_POSTS' => FALSE
- ));
- }
- elseif ($total == 1)
- {
- $template->assign_vars(array(
- 'L_UNAPPROVED_TOTAL' => $user->lang['UNAPPROVED_POST_TOTAL'],
- 'S_HAS_UNAPPROVED_POSTS' => TRUE
- ));
- }
- else
- {
- $template->assign_vars(array(
- 'L_UNAPPROVED_TOTAL' => sprintf($user->lang['UNAPPROVED_POSTS_TOTAL'], $total),
- 'S_HAS_UNAPPROVED_POSTS' => TRUE
- ));
- }
- }
- // -------------
-
- // -------------
- // Latest 5 reported
- $forum_list = get_forum_list('m_');
+ case 'make_announce':
+ case 'make_sticky':
+ case 'make_global':
+ case 'make_normal':
- $template->assign_var('S_SHOW_REPORTS', (!empty($forum_list)) ? TRUE : FALSE);
- if (!empty($forum_list))
+ $topic_ids = get_array((!$quickmod) ? 'topic_id_list' : 't', 0);
+
+ if (!$topic_ids)
{
- $sql = 'SELECT COUNT(r.report_id) AS total
- FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p
- WHERE r.post_id = p.post_id
- AND p.forum_id IN (0, ' . implode(', ', $forum_list) . ')';
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $total = $row['total'];
-
- if ($total)
- {
- $sql = 'SELECT r.*, p.post_id, p.post_subject, u.username, t.topic_id, t.topic_title, f.forum_id, f.forum_name
- FROM ' . REPORTS_TABLE . ' r, ' . REASONS_TABLE . ' rr,' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u
- LEFT JOIN ' . FORUMS_TABLE . ' f ON f.forum_id = p.forum_id
- WHERE r.post_id = p.post_id
- AND r.reason_id = rr.reason_id
- AND p.topic_id = t.topic_id
- AND r.user_id = u.user_id
- AND p.forum_id IN (0, ' . implode(', ', $forum_list) . ')
- ORDER BY p.post_id DESC';
- $result = $db->sql_query_limit($sql, 5);
-
- while ($row = $db->sql_fetchrow($result))
- {
- $template->assign_block_vars('report', array(
- 'U_POST_DETAILS' => $this->url . '&mode=post_details',
- 'FORUM' => (!empty($row['forum_id'])) ? '' . $row['forum_name'] . '' : $user->lang['POST_GLOBAL'],
- 'TOPIC' => '' . $row['topic_title'] . '',
- 'REPORTER' => ($row['user_id'] == ANONYMOUS) ? $user->lang['GUEST'] : '' . $row['username'] . '',
- 'SUBJECT' => '' . (($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT']) . '',
- 'REPORT_TIME' => $user->format_date($row['report_time'])
- ));
- }
- }
-
- if ($total == 0)
- {
- $template->assign_vars(array(
- 'L_REPORTS_TOTAL' => $user->lang['REPORTS_ZERO_TOTAL'],
- 'S_HAS_REPORTS' => FALSE
- ));
- }
- elseif ($total == 1)
- {
- $template->assign_vars(array(
- 'L_REPORTS_TOTAL' => $user->lang['REPORT_TOTAL'],
- 'S_HAS_REPORTS' => TRUE
- ));
- }
- else
- {
- $template->assign_vars(array(
- 'L_REPORTS_TOTAL' => sprintf($user->lang['REPORTS_TOTAL'], total),
- 'S_HAS_REPORTS' => TRUE
- ));
- }
- }
- // -------------
-
- // -------------
- // Latest 5 logs
- $forum_list = get_forum_list(array('m_', 'a_general'));
-
- if (!empty($forum_list))
- {
- // Add forum_id 0 for global announcements
- $forum_list[] = 0;
-
- $log_count = 0;
- $log = array();
- view_log('mod', $log, $log_count, 5, 0, $forum_list);
-
- foreach ($log as $row)
- {
- $template->assign_block_vars('log', array(
- 'USERNAME' => $row['username'],
- 'IP' => $row['ip'],
- 'TIME' => $user->format_date($row['time']),
- 'ACTION' => $row['action'],
- 'U_VIEWTOPIC' => $row['viewtopic'],
- 'U_VIEWLOGS' => $row['viewlogs']
- ));
- }
- }
- $template->assign_vars(array(
- 'S_SHOW_LOGS' => (!empty($forum_list)) ? TRUE : FALSE,
- 'S_HAS_LOGS' => (!empty($log)) ? TRUE : FALSE
- ));
- // -------------
-
- $template->assign_var('S_MCP_ACTION', $this->url);
- $this->mcp_jumpbox($this->url . '&mode=forum_view', 'm_', $this->forum_id);
- $this->display($user->lang['MCP'], 'mcp_front.html');
- break;
-
- case 'merge_select':
- // Change current mode for the menu
- $this->mode = 'forum_view';
-
- // Fixes a "bug" that makes forum_view use the same ordering as topic_view
- unset($_POST['sk'], $_POST['sd'], $_REQUEST['sk'], $_REQUEST['sd']);
-
- // No break; here
-
- case 'forum_view':
- if (!$forum_info = $this->get_forum_data($this->forum_id, 'm_', TRUE))
- {
- $this->main($id, 'front');
+ trigger_error('NO_TOPIC_SELECTED');
}
- $this->mcp_jumpbox($this->url . '&mode=' . $mode . (($mode == 'merge_select') ? $this->selected_ids : ''), 'm_', $this->forum_id);
-
- $topics_per_page = ($forum_info['forum_topics_per_page']) ? $forum_info['forum_topics_per_page'] : $config['topics_per_page'];
-
- $this->mcp_sorting('viewforum', $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)) : '';
-
- $template->assign_vars(array(
- 'FORUM_NAME' => $forum_info['forum_name'],
-
- 'REPORTED_IMG' => $user->img('icon_reported', 'TOPIC_REPORTED'),
- 'UNAPPROVED_IMG' => $user->img('icon_unapproved', 'TOPIC_UNAPPROVED'),
-
- 'S_CAN_DELETE' => $auth->acl_get('m_delete', $this->forum_id),
- 'S_CAN_MOVE' => $auth->acl_get('m_move', $this->forum_id),
- 'S_CAN_FORK' => $auth->acl_get('m_', $this->forum_id),
- 'S_CAN_LOCK' => $auth->acl_get('m_lock', $this->forum_id),
- 'S_CAN_SYNC' => $auth->acl_get('m_', $this->forum_id),
-
- 'U_VIEW_FORUM' => "viewforum.$phpEx$SID&f=" . $this->forum_id,
- 'S_MCP_ACTION' => $this->url . "&mode={$mode}&start={$this->start}" . (($mode == 'merge_select') ? $this->selected_ids : ''),
-
- 'PAGINATION' => generate_pagination($this->url . "&mode={$mode}&f=" . $this->forum_id . (($mode == 'merge_select') ? $this->selected_ids : ''), $forum_topics, $topics_per_page, $this->start),
- 'PAGE_NUMBER' => on_page($forum_topics, $config['topics_per_page'], $this->start)
- ));
-
-
- $topic_rows = array();
-
-// TODO: no global announcements here
- $sql = 'SELECT t.*
- FROM ' . TOPICS_TABLE . " t
- WHERE t.forum_id = {$this->forum_id}
- " . (($auth->acl_get('m_approve', $this->forum_id)) ? '' : 'AND t.topic_approved = 1') . "
- AND t.topic_type = " . POST_ANNOUNCE . "
- $limit_time_sql
- ORDER BY $sort_order_sql";
- $result = $db->sql_query($sql);
-
- while ($row = $db->sql_fetchrow($result))
- {
- $topic_rows[] = $row;
- }
-
- $db->sql_freeresult($result);
-
- $sql = "SELECT t.*
- FROM " . TOPICS_TABLE . " t
- WHERE t.forum_id = {$this->forum_id}
- " . (($auth->acl_get('m_approve', $this->forum_id)) ? '' : 'AND t.topic_approved = 1') . '
- AND t.topic_type IN (' . POST_NORMAL . ', ' . POST_STICKY . ")
- $limit_time_sql
- ORDER BY t.topic_type DESC, $sort_order_sql";
- $result = $db->sql_query_limit($sql, $config['topics_per_page'], $this->start);
-
- while ($row = $db->sql_fetchrow($result))
- {
- $topic_rows[] = $row;
- }
- $db->sql_freeresult($result);
-
- foreach ($topic_rows as $row)
- {
- $topic_title = '';
-
- if ($auth->acl_get('m_approve', $row['forum_id']))
- {
- $row['topic_replies'] = $row['topic_replies_real'];
- }
-
- if ($row['topic_status'] == ITEM_LOCKED)
- {
- $folder_img = $user->img('folder_locked', 'VIEW_TOPIC_LOCKED');
- }
- else
- {
- if ($row['topic_type'] == POST_ANNOUNCE)
- {
- $folder_img = $user->img('folder_announce', 'VIEW_TOPIC_ANNOUNCEMENT');
- }
- else if ($row['topic_type'] == POST_STICKY)
- {
- $folder_img = $user->img('folder_sticky', 'VIEW_TOPIC_STICKY');
- }
- else
- {
- $folder_img = $user->img('folder', 'NO_NEW_POSTS');
- }
- }
-
- if ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL)
- {
- $topic_type = $user->lang['VIEW_TOPIC_ANNOUNCEMENT'] . ' ';
- }
- else if ($row['topic_type'] == POST_STICKY)
- {
- $topic_type = $user->lang['VIEW_TOPIC_STICKY'] . ' ';
- }
- else if ($row['topic_status'] == ITEM_MOVED)
- {
- $topic_type = $user->lang['VIEW_TOPIC_MOVED'] . ' ';
- }
- else
- {
- $topic_type = '';
- }
-
- if (intval($row['poll_start']))
- {
- $topic_type .= $user->lang['VIEW_TOPIC_POLL'] . ' ';
- }
-
- $topic_title = censor_text($row['topic_title']);
+ change_topic_type($mode, $topic_ids);
- $template->assign_block_vars('topicrow', array(
- 'U_VIEW_TOPIC' => "mcp.$phpEx$SID&t=" . $row['topic_id'] . '&mode=topic_view',
-
- 'S_SELECT_TOPIC' => ($mode == 'merge_select' && $row['topic_id'] != $this->topic_id) ? TRUE : FALSE,
- 'U_SELECT_TOPIC' => $this->url . '&mode=merge&to_topic_id=' . $row['topic_id'] . $this->selected_ids,
- 'U_MCP_QUEUE' => $this->url . '&i=queue&mode=approve&t=' . $row['topic_id'],
- 'U_MCP_REPORT' => $this->url . '&mode=reports&t=' . $row['topic_id'],
-
- 'ATTACH_ICON_IMG' => ($auth->acl_gets('f_download', 'u_download', $row['forum_id']) && $row['topic_attachment']) ? $user->img('icon_attach', sprintf($user->lang['TOTAL_ATTACHMENTS'], $row['topic_attachment'])) : '',
- 'TOPIC_FOLDER_IMG' => $folder_img,
- 'TOPIC_TYPE' => $topic_type,
- 'TOPIC_TITLE' => $topic_title,
- 'REPLIES' => $row['topic_replies'],
- 'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']),
- 'TOPIC_ID' => $row['topic_id'],
- 'S_TOPIC_CHECKED' => (in_array($row['topic_id'], $this->topic_id_list)) ? 'checked="checked" ' : '',
-
- 'S_TOPIC_REPORTED' => ($row['topic_reported']) ? TRUE : FALSE,
- 'S_TOPIC_UNAPPROVED'=> ($row['topic_approved']) ? FALSE : TRUE
- ));
- }
- unset($topic_rows);
-
- $this->display($user->lang['MCP'], 'mcp_forum.html');
- break;
+ break;
case 'move':
- if ($this->cancel)
+ $user->add_lang('viewtopic');
+
+ $topic_ids = get_array((!$quickmod) ? 'topic_id_list' : 't', 0);
+
+ if (!$topic_ids)
{
- $this->main('forum_view');
- }
- //
- // KNOWN BUG: won't work with global announcements
- //
- if (!$topic_id_list = $this->get_topic_ids('m_move'))
- {
- $template->assign_var('MESSAGE', $user->lang['NO_TOPIC_SELECTED']);
+ trigger_error('NO_TOPIC_SELECTED');
}
- if (1 > $this->to_forum_id)
- {
- $this->confirm = FALSE;
- }
- elseif (!$forum_data = $this->get_forum_data($this->to_forum_id))
- {
- $template->assign_var('MESSAGE', $user->lang['FORUM_NOT_EXIST']);
- $this->confirm = FALSE;
- }
- elseif ($forum_data['forum_type'] != FORUM_POST)
- {
- $template->assign_var('MESSAGE', $user->lang['FORUM_NOT_POSTABLE']);
- $this->confirm = FALSE;
- }
- elseif (!$auth->acl_get('f_post', $this->to_forum_id))
- {
- $template->assign_var('MESSAGE', $user->lang['USER_CANNOT_POST']);
- $this->confirm = FALSE;
- }
-
- if (!$this->confirm)
- {
- $s_hidden_fields = '';
- foreach ($topic_id_list as $topic_id)
- {
- $s_hidden_fields .= '';
- }
-
- $template->assign_vars(array(
- 'S_MCP_ACTION' => "mcp.$phpEx$SID&mode=move",
- 'S_HIDDEN_FIELDS' => $s_hidden_fields,
- 'S_FORUM_SELECT' => make_forum_select(),
- 'S_CAN_LEAVE_SHADOW' => TRUE,
-
- 'L_MODE_TITLE' => $user->lang['MOVE'],
- 'L_MODE_EXPLAIN' => ''
- ));
-
- $this->display($user->lang['MCP'], 'mcp_move.html');
- }
- else
- {
- // Get topic data
- $topic_data = $this->get_topic_data($topic_id_list);
-
- // Check if any of topics is moved to the same forum
- foreach ($topic_data as $topic_id => $row)
- {
- if ($row['forum_id'] == $this->to_forum_id)
- {
- $template->assign_var('MESSAGE', $user->lang['CANNOT_MOVE_SAME_FORUM']);
-
- // Another convienient way to eliminate redundancy, go back to the move form
- $this->confirm = FALSE;
- $this->main('move');
- }
- }
-
- // Move topics, but do not resync yet
- move_topics($topic_id_list, $this->to_forum_id, FALSE);
-
- $forum_ids = array($this->to_forum_id);
- foreach ($topic_data as $topic_id => $row)
- {
- // Get the list of forums to resync, add a log entry
- $forum_ids[] = $row['forum_id'];
- add_log('mod', $this->to_forum_id, $topic_id, 'LOG_MOVE', $row['forum_name']);
-
- // Leave a redirection if required and only if the topic is visible to users
- if (!empty($_POST['move_leave_shadow']) && $row['topic_approved'])
- {
- $shadow = array(
- 'forum_id' => (int) $row['forum_id'],
- 'icon_id' => (int) $row['icon_id'],
- 'topic_attachment' => (int) $row['topic_attachment'],
- 'topic_approved' => 1,
- 'topic_reported' => (int) $row['topic_reported'],
- 'topic_title' => (string) $row['topic_title'],
- 'topic_poster' => (int) $row['topic_poster'],
- 'topic_time' => (int) $row['topic_time'],
- 'topic_time_limit' => (int) $row['topic_time_limit'],
- 'topic_views' => (int) $row['topic_views'],
- 'topic_replies' => (int) $row['topic_replies'],
- 'topic_replies_real' => (int) $row['topic_replies_real'],
- 'topic_status' => ITEM_MOVED,
- 'topic_type' => (int) $row['topic_type'],
- 'topic_first_post_id' => (int) $row['topic_first_post_id'],
- 'topic_first_poster_name'=> (string) $row['topic_first_poster_name'],
- 'topic_last_post_id' => (int) $row['topic_last_post_id'],
- 'topic_last_poster_id' => (int) $row['topic_last_poster_id'],
- 'topic_last_poster_name'=> (string) $row['topic_last_poster_name'],
- 'topic_last_post_time' => (int) $row['topic_last_post_time'],
- 'topic_last_view_time' => (int) $row['topic_last_view_time'],
- 'topic_moved_id' => (int) $row['topic_id'],
- 'poll_title' => (string) $row['poll_title'],
- 'poll_start' => (int) $row['poll_start'],
- 'poll_length' => (int) $row['poll_length'],
- 'poll_max_options' => (int) $row['poll_max_options'],
- 'poll_last_vote' => (int) $row['poll_last_vote']
- );
-
- $db->sql_query('INSERT INTO ' . TOPICS_TABLE . $db->sql_build_array('INSERT', $shadow));
- }
- }
- unset($topic_data);
-
- // Now sync forums
- sync('forum', 'forum_id', $forum_ids);
-
- $msg = (count($topic_id_list) == 1) ? 'TOPIC_MOVED_SUCCESS' : 'TOPICS_MOVED_SUCCESS';
- $template->assign_var('MESSAGE', $user->lang[$msg]);
-
- // Return to the destination forum
- return_link('RETURN_FORUM', "viewforum.$phpEx$SID&f={$this->forum_id}");
- return_link('RETURN_NEW_FORUM', "viewforum.$phpEx$SID&f={$this->to_forum_id}");
-
- $this->forum_id = $this->to_forum_id;
- $this->main('forum_view');
- }
- break;
-
- case 'fork':
- if (!$topic_id_list = $this->get_topic_ids('m_'))
- {
- $template->assign_var('MESSAGE', $user->lang['NO_TOPIC_SELECTED']);
- }
-
- if (1 > $this->to_forum_id)
- {
- $this->confirm = FALSE;
- }
- elseif (!$forum_data = $this->get_forum_data($this->to_forum_id))
- {
- $template->assign_var('MESSAGE', $user->lang['FORUM_NOT_EXIST']);
- $this->confirm = FALSE;
- }
- elseif ($forum_data['forum_type'] != FORUM_POST)
- {
- $template->assign_var('MESSAGE', $user->lang['FORUM_NOT_POSTABLE']);
- $this->confirm = FALSE;
- }
- elseif (!$auth->acl_get('f_post', $this->to_forum_id))
- {
- $template->assign_var('MESSAGE', $user->lang['USER_CANNOT_POST']);
- $this->confirm = FALSE;
- }
-
- if (!$this->confirm)
- {
- $s_hidden_fields = '';
- foreach ($topic_id_list as $topic_id)
- {
- $s_hidden_fields .= '';
- }
-
- $template->assign_vars(array(
- 'S_MCP_ACTION' => "mcp.$phpEx$SID&mode=fork",
- 'S_HIDDEN_FIELDS' => $s_hidden_fields,
- 'S_FORUM_SELECT' => make_forum_select(),
-
- 'L_MODE_TITLE' => $user->lang['FORK'],
- 'L_MODE_EXPLAIN' => $user->lang['FORK_EXPLAIN']
- ));
-
- $this->display($user->lang['MCP'], 'mcp_move.html');
- }
- else
- {
- $topic_data = $this->get_topic_data($topic_id_list);
-
- $total_posts = 0;
- $new_topic_id_list = $post_rows = array();
- foreach ($topic_data as $topic_id => $topic_row)
- {
- $sql_ary = array(
- 'forum_id' => (int) $this->to_forum_id,
- 'icon_id' => (int) $topic_row['icon_id'],
- 'topic_approved' => 1,
- 'topic_title' => (string) $topic_row['topic_title'],
- 'topic_poster' => (int) $topic_row['topic_poster'],
- 'topic_time' => (int) $topic_row['topic_time'],
- 'topic_replies' => (int) $topic_row['topic_replies_real'],
- 'topic_replies_real' => (int) $topic_row['topic_replies_real'],
- 'topic_status' => (int) $topic_row['topic_status'],
- 'topic_type' => (int) $topic_row['topic_type'],
- 'topic_first_poster_name' => (string) $topic_row['topic_first_poster_name'],
- 'topic_last_poster_id' => (int) $topic_row['topic_last_poster_id'],
- 'topic_last_poster_name' => (string) $topic_row['topic_last_poster_name'],
- 'topic_last_post_time' => (int) $topic_row['topic_last_post_time'],
- 'poll_title' => (string) $topic_row['poll_title'],
- 'poll_start' => (int) $topic_row['poll_start'],
- 'poll_length' => (int) $topic_row['poll_length']
- );
-
- $db->sql_query('INSERT INTO ' . TOPICS_TABLE . $db->sql_build_array('INSERT', $sql_ary));
- $new_topic_id = $db->sql_nextid();
- $new_topic_id_list[$topic_id] = $new_topic_id;
-
- if ($topic_row['poll_start'])
- {
- $poll_rows = array();
-
- $result = $db->sql_query('SELECT * FROM ' . POLL_OPTIONS_TABLE . ' WHERE topic_id = ' . $topic_id);
- while ($row = $db->sql_fetchrow($result))
- {
- $sql = 'INSERT INTO ' . POLL_OPTIONS_TABLE . ' (poll_option_id, topic_id, poll_option_text, poll_option_total)
- VALUES (' . $row['poll_option_id'] . ', ' . $new_topic_id . ", '" . $db->sql_escape($row['poll_option_text']) . "', 0)";
-
- $db->sql_query($sql);
- }
- }
-
- $sql = 'SELECT *
- FROM ' . POSTS_TABLE . "
- WHERE topic_id = $topic_id
- ORDER BY post_id ASC";
- $result = $db->sql_query($sql);
- while ($row = $db->sql_fetchrow($result))
- {
- $post_rows[] = $row;
- }
- $db->sql_freeresult();
-
- if (!count($post_rows))
- {
- continue;
- }
-
- $total_posts += count($post_rows);
- foreach ($post_rows as $row)
- {
- $sql_ary = array(
- 'topic_id' => (int) $new_topic_id,
- 'forum_id' => (int) $this->to_forum_id,
- 'poster_id' => (int) $row['poster_id'],
- 'icon_id' => (int) $row['icon_id'],
- 'poster_ip' => (string) $row['poster_ip'],
- 'post_time' => (int) $row['post_time'],
- 'post_approved' => 1,
- 'enable_bbcode' => (int) $row['enable_bbcode'],
- 'enable_html' => (int) $row['enable_html'],
- 'enable_smilies' => (int) $row['enable_smilies'],
- 'enable_magic_url' => (int) $row['enable_magic_url'],
- 'enable_sig' => (int) $row['enable_sig'],
- 'post_username' => (string) $row['post_username'],
- 'post_subject' => (string) $row['post_subject'],
- 'post_text' => (string) $row['post_text'],
- 'post_checksum' => (string) $row['post_checksum'],
- 'post_encoding' => (string) $row['post_encoding'],
- 'bbcode_bitfield' => (int) $row['bbcode_bitfield'],
- 'bbcode_uid' => (string) $row['bbcode_uid']
- );
-
- $db->sql_query('INSERT INTO ' . POSTS_TABLE . $db->sql_build_array('INSERT', $sql_ary));
- }
- }
-
- // Sync new topics, parent forums and board stats
- sync('topic', 'topic_id', $new_topic_id_list, TRUE);
- sync('forum', 'forum_id', $this->to_forum_id, TRUE);
- set_config('num_topics', $config['num_topics'] + count($topic_id_list));
- set_config('num_posts', $config['num_posts'] + $total_posts);
-
- foreach ($new_topic_id_list as $topic_id => $new_topic_id)
- {
- add_log('mod', $this->to_forum_id, $new_topic_id, 'LOG_FORK', $topic_row['forum_name']);
- }
-
- $msg = (count($topic_id_list) == 1) ? 'TOPIC_FORKED_SUCCESS' : 'TOPICS_FORKED_SUCCESS';
- $template->assign_var('MESSAGE', $user->lang[$msg]);
-
- // Return to the destination forum
- return_link('RETURN_FORUM', "viewforum.$phpEx$SID&f={$this->forum_id}");
-
- if ($this->forum_id != $this->to_forum_id)
- {
- return_link('RETURN_NEW_FORUM', "viewforum.$phpEx$SID&f={$this->to_forum_id}");
- }
-
- $this->forum_id = $this->to_forum_id;
- $this->main('forum_view');
- }
- break;
-
- case 'merge':
- case 'split':
- case 'delete':
- case 'topic_view':
- if (!$topic_info = $this->get_topic_data($this->topic_id, 'm_', TRUE))
- {
- $template->assign_var('MESSAGE', $user->lang['TOPIC_NOT_EXIST']);
-
- $mode = ($this->forum_id) ? 'forum_view' : 'front';
- $this->main($mode);
- }
-
- // Whatever mode was selected, the submode is "topic_view"
- $this->mode = 'topic_view';
-
- // Set up some vars
- $icon_id = request_var('icon', 0);
- $subject = request_var('subject', '');
- $topics_per_page = ($forum_info['forum_topics_per_page']) ? $forum_info['forum_topics_per_page'] : $config['topics_per_page'];
-
- // Jumpbox, sort selects and that kind of things
- $this->mcp_jumpbox($this->url . '&mode=forum_view', 'm_', $this->forum_id);
- $this->mcp_sorting('viewtopic', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $topic_info['forum_id'], $this->topic_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 ($total == -1)
- {
- $total = $topic_info['topic_replies'] + 1;
- }
- $posts_per_page = max(0, request_var('posts_per_page', intval($config['posts_per_page'])));
-
- $sql = 'SELECT u.username, u.user_colour, p.*
- FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u
- WHERE p.topic_id = {$this->topic_id}
- AND p.poster_id = u.user_id
- ORDER BY $sort_order_sql";
- $result = $db->sql_query_limit($sql, $posts_per_page, $this->start);
-
- $rowset = array();
- while ($row = $db->sql_fetchrow($result))
- {
- $rowset[] = $row;
- $bbcode_bitfield |= $row['bbcode_bitfield'];
- }
-
- if ($bbcode_bitfield)
- {
- include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
- $bbcode = new bbcode($bbcode_bitfield);
- }
-
- foreach ($rowset as $i => $row)
- {
- $has_unapproved_posts = FALSE;
- $poster = ($row['poster_id'] != ANONYMOUS) ? $row['username'] : ((!$row['post_username']) ? $user->lang['GUEST'] : $row['post_username']);
- $poster = ($row['user_colour']) ? '' . $poster . '' : $poster;
-
- $message = $row['post_text'];
- $post_subject = ($row['post_subject'] != '') ? $row['post_subject'] : $topic_info['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_bitfield'])
- {
- $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
- }
-
- $message = smilie_text($message);
-
- $message = nl2br($message);
-
- $checked = (in_array(intval($row['post_id']), $this->post_id_list)) ? 'checked="checked" ' : '';
- $s_checkbox = ($row['post_id'] == $topic_info['topic_first_post_id'] && $mode == 'split') ? ' ' : '';
-
- if (!$row['post_approved'])
- {
- $has_unapproved_posts = TRUE;
- }
-
- $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'],
-
- 'POST_ICON_IMG' => ($row['post_time'] > $user->data['user_lastvisit'] && $user->data['user_id'] != ANONYMOUS) ? $user->img('icon_post_new', $user->lang['NEW_POST']) : $user->img('icon_post', $user->lang['POST']),
-
- 'S_CHECKBOX' => $s_checkbox,
- 'S_ROW_COUNT' => $i,
- 'S_POST_REPORTED' => ($row['post_reported']) ? TRUE : FALSE,
- 'S_POST_UNAPPROVED' => ($row['post_approved']) ? FALSE : TRUE,
-
- 'U_POST_DETAILS' => "mcp.$phpEx$SID&f=" . $row['forum_id'] . '&t=' . $row['topic_id'] . '&p=' . $row['post_id'] . '&mode=post_details',
- 'U_APPROVE' => "mcp.$phpEx$SID&i=queue&mode=approve&p=" . $row['post_id']
- ));
-
- unset($rowset[$i]);
- }
-
- // Display topic icons for split topic
- if ($auth->acl_get('m_split', $topic_info['forum_id']))
- {
- $icons = array();
- obtain_icons($icons);
-
- if (count($icons))
- {
- $s_topic_icons = true;
-
- foreach ($icons as $id => $data)
- {
- if ($data['display'])
- {
- $template->assign_block_vars('topic_icon', array(
- 'ICON_ID' => $id,
- 'ICON_IMG' => $config['icons_path'] . '/' . $data['img'],
- 'ICON_WIDTH' => $data['width'],
- 'ICON_HEIGHT' => $data['height'],
-
- 'S_CHECKED' => ($id == $icon_id) ? TRUE : FALSE
- ));
- }
- }
- }
- }
-
- // Has the user selected a topic for merge?
- if ($this->to_topic_id)
- {
- if (!$to_topic_info = $this->get_topic_data($this->to_topic_id, 'm_merge', TRUE))
- {
- $this->to_topic_id = 0;
- }
- }
-
- $template->assign_vars(array(
- 'TOPIC_TITLE' => $topic_info['topic_title'],
- 'U_VIEW_TOPIC' => "viewtopic.$phpEx$SID&f=" . $topic_info['forum_id'] . '&t=' . $topic_info['topic_id'],
-
- 'TO_TOPIC_ID' => ($this->to_topic_id) ? $this->to_topic_id : '',
- 'TO_TOPIC_INFO' => ($this->to_topic_id) ? sprintf($user->lang['YOU_SELECTED_TOPIC'], $this->to_topic_id, '' . $to_topic_info['topic_title'] . '') : '',
-
- 'SPLIT_SUBJECT' => $subject,
- 'POSTS_PER_PAGE' => $posts_per_page,
- 'MODE' => $mode,
-
- 'REPORTED_IMG' => $user->img('icon_reported', 'POST_REPORTED', FALSE, TRUE),
- 'UNAPPROVED_IMG' => $user->img('icon_unapproved', 'POST_UNAPPROVED', FALSE, TRUE),
-
- 'S_MCP_ACTION' => "mcp.$phpEx$SID&mode=$mode&t=" . $topic_info['topic_id'] . '&start=' . $this->start,
- 'S_FORUM_SELECT' => '',
- 'S_CAN_SPLIT' => ($auth->acl_get('m_split', $topic_info['forum_id'])) ? TRUE : FALSE,
- 'S_CAN_MERGE' => ($auth->acl_get('m_merge', $topic_info['forum_id'])) ? TRUE : FALSE,
- 'S_CAN_DELETE' => ($auth->acl_get('m_delete', $topic_info['forum_id'])) ? TRUE : FALSE,
- 'S_CAN_APPROVE' => ($has_unapproved_posts && $auth->acl_get('m_approve', $topic_info['forum_id'])) ? TRUE : FALSE,
-
- 'S_SHOW_TOPIC_ICONS'=> (!empty($s_topic_icons)) ? TRUE : FALSE,
- 'S_TOPIC_ICON' => $icon_id,
-
- 'PAGE_NUMBER' => on_page($total, $posts_per_page, $this->start),
- 'PAGINATION' => (!$posts_per_page) ? '' : generate_pagination("mcp.$phpEx$SID&t=" . $topic_info['topic_id'] . "&mode=$mode&posts_per_page=$posts_per_page&st=$sort_days&sk=$sort_key&sd=$sort_dir", $total, $posts_per_page, $this->start)
- ));
-
- $this->display($user->lang['MCP'], 'mcp_topic.html');
- break;
-
- case 'merge_posts':
- if (!$this->to_topic_id || !$topic_data = $this->get_topic_data($this->to_topic_id, 'm_merge'))
- {
- // No destination topic? Make the user select one
- $this->main('merge_select');
-// redirect(str_replace('&', '&', $this->url . $this->selected_ids) . '&i=' . $this->id . '&mode=merge_select');
- }
-
- if (!$post_id_list = $this->get_post_ids('m_merge'))
- {
- $template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']);
- $this->main('merge');
- }
-
- move_posts($post_id_list, $this->to_topic_id);
- add_log('mod', $this->to_forum_id, $this->to_topic_id, 'LOG_MERGE', $topic_data['topic_title']);
-
- // Message and return links
- $template->assign_var('MESSAGE', $user->lang['POSTS_MERGED_SUCCESS']);
-
- // Does the original topic still exist? If yes, link back to it
- if ($topic_data = $this->get_topic_data($this->topic_id))
- {
- return_link('RETURN_TOPIC', "viewtopic.$phpEx$SID&f={$this->forum_id}&t={$this->topic_id}");
- }
-
- // Link to the new topic
- return_link('RETURN_NEW_TOPIC', "viewtopic.$phpEx$SID&f={$this->to_forum_id}&t={$this->to_topic_id}");
-
- // Back to the topics list
- $this->main('forum_view');
- break;
+ mcp_move_topic($topic_ids);
+
+ break;
case 'delete_topic':
- if ($this->cancel)
+ $user->add_lang('viewtopic');
+
+ $topic_ids = get_array((!$quickmod) ? 'topic_id_list' : 't', 0);
+
+ if (!$topic_ids)
{
- if (!$this->topic_id && $this->topic_id_list)
- {
- $this->topic_id = $this->topic_id_list[0];
- }
- if ($this->quickmod)
- {
- redirect("viewtopic.$phpEx$SID?f={$this->forum_id}&t={$this->topic_id}");
- }
- else
- {
- $this->main('forum_view');
- }
- }
- if (!$topic_id_list = $this->get_topic_ids('m_delete'))
- {
- $template->assign_var('MESSAGE', $user->lang['NO_TOPIC_SELECTED']);
- $this->main('forum_view');
+ trigger_error('NO_TOPIC_SELECTED');
}
- if ($this->confirm)
- {
-// delete_topics('topic_id', $topic_id_list, true);
- return_link('RETURN_FORUM', "viewforum.$phpEx$SID&f={$this->forum_id}");
-
- $template->assign_var('MESSAGE', (count($topic_id_list) == 1) ? $user->lang['TOPIC_DELETED_SUCCESS'] : $user->lang['TOPICS_DELETED_SUCCESS']);
- $this->main('forum_view');
- }
- else
- {
- $s_hidden_fields = '';
- foreach ($topic_id_list as $topic_id)
- {
- $s_hidden_fields .= '';
- }
-
- $template->assign_vars(array(
- 'S_CONFIRM_ACTION' => $this->url . '&mode=' . $mode . '&quickmod=' . intval($this->quickmod),
- 'S_HIDDEN_FIELDS' => $s_hidden_fields,
-
- 'CONFIRM_MODE' => $mode,
- 'CONFIRM_MESSAGE' => (count($topic_id_list) == 1) ? $user->lang['DELETE_TOPIC_CONFIRM'] : $user->lang['DELETE_TOPICS_CONFIRM']
- ));
-
- $this->main('forum_view');
- }
- break;
+ mcp_delete_topic($topic_ids);
+ break;
case 'delete_post':
- if ($this->cancel)
+ $user->add_lang('posting');
+
+ $post_ids = get_array((!$quickmod) ? 'post_id_list' : 'p', 0);
+
+ if (!$post_ids)
{
- $this->main('forum_view');
- }
- if (!$post_id_list = $this->get_post_ids('m_delete'))
- {
- $template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']);
- $this->main('topic_view');
+ trigger_error('NO_TOPIC_SELECTED');
}
- if ($this->confirm)
+ mcp_delete_post($post_ids);
+ break;
+
+ case 'front':
+ include($phpbb_root_path . 'includes/mcp/mcp_front.' . $phpEx);
+
+ mcp_front_view($id, $mode, $action, $url);
+
+ $this->display($user->lang['MCP'], 'mcp_front.html');
+ break;
+
+ case 'forum_view':
+ include($phpbb_root_path . 'includes/mcp/mcp_forum.' . $phpEx);
+
+ $user->add_lang('viewforum');
+
+ $forum_id = request_var('f', 0);
+
+ $forum_info = get_forum_data($forum_id, 'm_');
+
+ if (!sizeof($forum_info))
{
- // Count the number of topics that are affected
- // I did not use COUNT(DISTINCT ...) because I remember having problems
- // with it on older versions of MySQL -- Ashe
-
- $sql = 'SELECT DISTINCT topic_id
- FROM ' . POSTS_TABLE . '
- WHERE post_id IN (' . implode(', ', $post_id_list) . ')';
-
- $result = $db->sql_query_limit($sql);
-
- $topic_id_list = array();
- while ($row = $db->sql_fetchrow($result))
- {
- $topic_id_list[] = $row['topic_id'];
- }
- $affected_topics = count($topic_id_list);
- $db->sql_freeresult($result);
-
- // Now delete the posts, topics and forums are automatically resync'ed
- delete_posts('post_id', $post_id_list);
-
- $sql = 'SELECT COUNT(topic_id) AS topics_left
- FROM ' . TOPICS_TABLE . '
- WHERE topic_id IN (' . implode(', ', $topic_id_list) . ')';
- $result = $db->sql_query_limit($sql);
-
- $deleted_topics = ($row = $db->sql_fetchrow($result)) ? ($affected_topics - $row['topics_left']) : $affected_topics;
- $db->sql_freeresult($result);
-
- // Return links
- if ($affected_topics == 1 && !$deleted_topics)
- {
- return_link('RETURN_TOPIC', "viewtopic.$phpEx$SID&f={$this->forum_id}&t={$this->topic_id}");
- }
- return_link('RETURN_FORUM', "viewforum.$phpEx$SID&f={$this->forum_id}");
-
- if (count($post_id_list) == 1)
- {
- if ($deleted_topics)
- {
- // We deleted the only post of a topic, which in turn has
- // been removed from the database
- $template->assign_var('MESSAGE', $user->lang['TOPIC_DELETED_SUCCESS']);
- }
- else
- {
- $template->assign_var('MESSAGE', $user->lang['POST_DELETED_SUCCESS']);
- }
- }
- else
- {
- if ($deleted_topics)
- {
- // Some of topics disappeared
- $template->assign_var('MESSAGE', $user->lang['POSTS_DELETED_SUCCESS'] . '
' . $user->lang['EMPTY_TOPICS_REMOVED_WARNING']);
- }
- else
- {
- $template->assign_var('MESSAGE', $user->lang['POSTS_DELETED_SUCCESS']);
- }
- }
-
- // Back to the appropriate mode
- $mode = ($affected_topics == 1 && !$deleted_topics) ? 'topic_view' : 'forum_view';
- $this->main($mode);
- }
- else
- {
- $s_hidden_fields = '';
- foreach ($post_id_list as $post_id)
- {
- $s_hidden_fields .= '';
- }
-
- $template->assign_vars(array(
- 'S_CONFIRM_ACTION' => $this->url . '&mode=' . $mode,
- 'S_HIDDEN_FIELDS' => $s_hidden_fields,
-
- 'CONFIRM_MODE' => $mode,
- 'CONFIRM_MESSAGE' => (count($post_id_list) == 1) ? $user->lang['DELETE_POST_CONFIRM'] : $user->lang['DELETE_POSTS_CONFIRM']
- ));
-
- $this->main('topic_view');
- }
- break;
-
- case 'split_all':
- case 'split_beyond':
- if (!$post_id_list = $this->get_post_ids('m_split'))
- {
- // No posts? back to the topic
- $template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']);
- $this->main('split');
+ $this->mcp_main('mcp', 'front', $url);
+ exit;
}
- $post_id = $post_id_list[0];
- if (!$post_info = $this->get_post_data($post_id))
- {
- // No posts? back to the topic
- $template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']);
- $this->main('split');
- }
+ $forum_info = $forum_info[$forum_id];
- if (!$subject = request_var('subject', ''))
- {
- $template->assign_var('MESSAGE', $user->lang['EMPTY_SUBJECT']);
- $this->main('split');
- }
- if ($this->to_forum_id <= 0)
- {
- $template->assign_var('MESSAGE', $user->lang['NO_DESTINATION_FORUM']);
- $this->main('split');
- }
- if (!$forum_info = $this->get_forum_data($this->to_forum_id, 'm_split', TRUE))
- {
- $template->assign_var('MESSAGE', $user->lang['NOT_MODERATOR']);
- $this->main('split');
- }
- if ($forum_info['forum_type'] != FORUM_POST)
- {
- $template->assign_var('MESSAGE', $user->lang['FORUM_NOT_POSTABLE']);
- $this->main('split');
- }
-
- if ($mode == 'split_beyond')
- {
- $this->mcp_sorting('viewtopic', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $this->forum_id, $this->topic_id);
- $limit_time_sql = ($sort_days) ? 'AND t.topic_last_post_time >= ' . (time() - ($sort_days * 86400)) : '';
-
- if ($sort_order_sql{0} == 'u')
- {
- $sql = 'SELECT p.post_id
- FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u
- WHERE p.topic_id = {$this->topic_id}
- AND p.poster_id = u.user_id
- $limit_time_sql
- ORDER BY $sort_order_sql";
- }
- else
- {
- $sql = 'SELECT p.post_id
- FROM ' . POSTS_TABLE . " p
- WHERE p.topic_id = {$this->topic_id}
- $limit_time_sql
- ORDER BY $sort_order_sql";
- }
- $result = $db->sql_query_limit($sql, 0, $this->start);
-
- $store = FALSE;
- $post_id_list = array();
- while ($row = $db->sql_fetchrow($result))
- {
- // TODO: see unapproved items? perform any action?
- if (!$row['post_approved'] && !$auth->acl_get('m_approve', $row['forum_id']))
- {
-// continue;
- }
-
- // Start to store post_ids as soon as we see the first post that was selected
- if ($row['post_id'] == $post_id)
- {
- $store = TRUE;
- }
- if ($store)
- {
- $post_id_list[] = $row['post_id'];
- }
- }
- }
-
- if (!count($post_id_list))
- {
- $template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']);
- $this->main('split');
- }
-
- $icon_id = request_var('icon', 0);
- $sql = 'INSERT INTO ' . TOPICS_TABLE . " (forum_id, topic_title, icon_id, topic_approved)
- VALUES ({$this->to_forum_id}, '" . $db->sql_escape($subject) . "', $icon_id, 1)";
- $db->sql_query($sql);
-
- $to_topic_id = $db->sql_nextid();
- move_posts($post_id_list, $to_topic_id);
-
- // Link back to both topics
- return_link('RETURN_TOPIC', "viewtopic.$phpEx$SID&f=" . $post_info['forum_id'] . '&t=' . $post_info['topic_id']);
- return_link('RETURN_NEW_TOPIC', "viewtopic.$phpEx$SID&f={$this->to_forum_id}&t=$to_topic_id");
-
- $template->assign_var('MESSAGE', $user->lang['TOPIC_SPLIT_SUCCESS']);
- $this->main('forum_view');
- break;
-
- case 'modoptions':
- if ($this->forum_id && !$auth->acl_get('m_', $this->forum_id))
- {
- trigger_error('NOT_MODERATOR');
- }
-
- switch ($this->action)
- {
- case 'unlock_post':
- case 'lock_post':
- $sql = 'UPDATE ' . POSTS_TABLE . '
- SET post_edit_locked = ' . (($this->action == 'lock_post') ? '1' : '0') . '
- WHERE post_id = ' . $this->post_id;
- $db->sql_query($sql);
-
- $msg = ($this->action == 'lock_post') ? $user->lang['POST_LOCKED_SUCCESS'] : $user->lang['POST_UNLOCKED_SUCCESS'];
- $template->assign_var('MESSAGE', $msg);
-
- add_log('mod', $post_info['forum_id'], $post_info['topic_id'], 'LOG_' . strtoupper($this->action), $post_info['post_subject']);
- $this->main('post_details');
- break;
-
- case 'chgposter':
- $post_info = $this->get_post_data($this->post_id);
- $user_id = request_var('u', 0);
-
- if (!empty($post_info) && $user_id)
- {
- $sql = 'UPDATE ' . POSTS_TABLE . "
- SET poster_id = $user_id
- WHERE post_id = {$this->post_id}";
- $db->sql_query($sql);
-
- if ($post_info['topic_last_post_id'] == $post_info['post_id'] || $post_info['forum_last_post_id'] == $post_info['post_id'])
- {
- sync('topic', 'topic_id', $post_info['topic_id'], FALSE, FALSE);
- sync('forum', 'forum_id', $post_info['forum_id'], FALSE, FALSE);
- }
- }
-
- $this->main('post_details');
- break;
-
- case 'chgposter_search':
- $post_info = $this->get_post_data($this->post_id);
- $username = request_var('username', '');
-
- if (!empty($post_info) && $username)
- {
- $users_ary = array();
-
- if (strpos($username, '*') === FALSE)
- {
- $username = "*$username*";
- }
- $username = str_replace('*', '%', str_replace('%', '\%', $username));
-
- $sql = 'SELECT user_id, username
- FROM ' . USERS_TABLE . "
- WHERE username LIKE '" . $db->sql_escape($username) . "'
- AND user_type = " . USER_NORMAL . '
- AND user_id <> ' . $post_info['user_id'];
- $result = $db->sql_query($sql);
-
- while ($row = $db->sql_fetchrow($result))
- {
- $users_ary[strtolower($row['username'])] = $row;
- }
-
- $user_select = '';
- ksort($users_ary);
- foreach ($users_ary as $row)
- {
- $user_select .= '\n";
- }
- }
-
- if (!$user_select)
- {
- $template->assign_var('MESSAGE', $user->lang['NO_MATCHES_FOUND']);
- }
-
- $template->assign_vars(array(
- 'S_USER_SELECT' => $user_select,
- 'SEARCH_USERNAME' => request_var('username', '')
- ));
-
- $this->main('post_details');
- break;
-
- case 'unrate':
- $post_info = $this->get_post_data($this->post_id, 'm_unrate');
-
- if (!empty($post_info))
- {
- $sql = 'DELETE FROM ' . RATINGS_TABLE . '
- WHERE post_id = ' . $this->post_id;
- $db->sql_query($sql);
-
- add_log('mod', $post_info['forum_id'], $post_info['topic_id'], 'LOG_UNRATE', $post_info['post_subject']);
-
- $template->assign_var('MESSAGE', $user->lang['POST_UNRATED_SUCCESS']);
-
- // TODO: recompute user's rating or something?
- }
- else
- {
- $template->assign_var('MESSAGE', $user->lang['NOT_MODERATOR']);
- }
-
- $this->main('post_details');
- }
-
- trigger_error("What the hell is happening here? (action: '$this->action')");
- break;
+ mcp_forum_view($id, $mode, $action, $url, $forum_info);
+
+ $this->display($user->lang['MCP'], 'mcp_forum.html');
+ break;
+ case 'topic_view':
+ include($phpbb_root_path . 'includes/mcp/mcp_topic.' . $phpEx);
+
+ mcp_topic_view($id, $mode, $action, $url);
+
+ $this->display($user->lang['MCP'], 'mcp_topic.html');
+ break;
+
case 'post_details':
-
- // Get post data
- if (!$post_info = $this->get_post_data($this->post_id))
- {
- trigger_error($user->lang['POST_NOT_EXIST']);
- }
-
- // Set some vars
- $users_ary = array();
- $poster = ($post_info['user_colour']) ? '' . $post_info['username'] . '' : $post_info['username'];
-
- // Process message, leave it uncensored
- $message = $post_info['post_text'];
- if ($post_info['bbcode_bitfield'])
- {
- include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
- $bbcode = new bbcode($post_info['bbcode_bitfield']);
- $bbcode->bbcode_second_pass($message, $post_info['bbcode_uid'], $post_info['bbcode_bitfield']);
- }
- $message = smilie_text($message);
-
- $template->assign_vars(array(
- 'S_MCP_ACTION' => $this->url . '&mode=modoptions',
- 'S_CHGPOSTER_ACTION' => $this->url . '&mode=modoptions',
- 'S_APPROVE_ACTION' => $this->url . '&i=queue&mode=approve&quickmod=' . intval($this->quickmod),
-
- 'S_CAN_VIEWIP' => $auth->acl_get('m_ip', $post_info['forum_id']),
- 'S_CAN_CHGPOSTER' => $auth->acl_get('m_', $post_info['forum_id']),
- 'S_CAN_LOCK_POST' => $auth->acl_get('m_', $post_info['forum_id']),
- 'S_CAN_UNRATE' => $auth->acl_get('m_unrate', $post_info['forum_id']),
-
- 'S_POST_REPORTED' => $post_info['post_reported'],
- 'S_POST_UNAPPROVED' => !$post_info['post_approved'],
- 'S_POST_LOCKED' => $post_info['post_edit_locked'],
- 'S_USER_NOTES' => ($post_info['user_notes']) ? TRUE : FALSE,
- 'S_USER_WARNINGS' => ($post_info['user_warnings']) ? TRUE : FALSE,
- 'S_QUICKMOD' => $this->quickmod,
-
- 'U_PROFILE' => "memberlist.$phpEx$SID&mode=viewprofile&u=" . $row['user_id'],
- 'U_MCP_USERNOTES' => $this->url . '&i=notes&mode=user_notes',
- 'U_MCP_WARNINGS' => $this->url . '&i=warnings&mode=view_user&u=' . $post_info['user_id'],
-
- 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], "post_id}#{$this->post_id}\">", ''),
- 'RETURN_FORUM' => sprintf($user->lang['RETURN_FORUM'], "forum_id}&start={$this->start}\">", ''),
- 'REPORTED_IMG' => $user->img('icon_reported', $user->lang['POST_REPORTED']),
- 'UNAPPROVED_IMG' => $user->img('icon_unapproved', $user->lang['POST_UNAPPROVED']),
-
- 'POSTER_NAME' => $poster,
- 'POST_PREVIEW' => $message,
- 'POST_SUBJECT' => $post_info['post_subject'],
- 'POST_DATE' => $user->format_date($post_info['post_time']),
- 'POST_IP' => $post_info['poster_ip'] . ' (' . @gethostbyaddr($post_info['poster_ip']) . ')'
- ));
-
- // --------
- // IP tools
- if ($auth->acl_get('m_ip', $post_info['forum_id']))
- {
- $rdns_ip_num = request_var('rdns', '');
-
- if ($rdns_ip_num != 'all')
- {
- $template->assign_vars(array(
- 'U_LOOKUP_ALL' => $this->url . '&i=main&mode=post_details&rdns=all'
- ));
- }
-
- // Get other users who've posted under this IP
- $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_info['poster_ip'] . "'
- AND p.poster_id <> " . $post_info['user_id'] . '
- GROUP BY u.user_id
- ORDER BY postings DESC';
- $result = $db->sql_query($sql);
-
- $i = 0;
- while ($row = $db->sql_fetchrow($result))
- {
- // Fill the user select list with users who have posted
- // under this IP
- if ($row['user_id'] != $post_info['poster_id'])
- {
- $users_ary[strtolower($row['username'])] = $row;
- }
-
- $template->assign_block_vars('userrow', array(
- 'S_ROW_COUNT' => $i++,
-
- 'USERNAME' => ($row['user_id'] == ANONYMOUS) ? $user->lang['GUEST'] : $row['username'],
- 'POSTS' => $row['postings'] . ' ' . (($row['postings'] == 1) ? $user->lang['POST'] : $user->lang['POSTS']),
-
- 'U_PROFILE' => ($row['user_id'] == ANONYMOUS) ? '' : "memberlist.$phpEx$SID&mode=viewprofile&u=" . $row['user_id'],
- 'U_SEARCHPOSTS' => "search.$phpEx$SID&search_author=" . urlencode($row['username']) . "&showresults=topics"
- ));
- }
- $db->sql_freeresult($result);
-
- // Get other IP's this user has posted under
- $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';
- $result = $db->sql_query($sql);
-
- $i = 0;
- while ($row = $db->sql_fetchrow($result))
- {
- $hostname = ($rdns_ip_num == $row['poster_ip'] || $rdns_ip_num == 'all') ? @gethostbyaddr($row['poster_ip']) : '';
-
- $template->assign_block_vars('iprow', array(
- 'S_ROW_COUNT' => $i++,
- 'IP' => $row['poster_ip'],
- 'HOSTNAME' => $hostname,
- 'POSTS' => $row['postings'] . ' ' . (($row['postings'] == 1) ? $user->lang['POST'] : $user->lang['POSTS']),
-
- 'U_LOOKUP_IP' => ($rdns_ip_num == $row['poster_ip'] || $rdns_ip_num == 'all') ? '' : $this->url . '&mode=post_details&rdns=' . $row['poster_ip'] . '#ip',
- 'U_WHOIS' => $this->url . '&i=iptool&mode=whois&ip=' . $row['poster_ip']
- ));
- }
- $db->sql_freeresult($result);
-
- // If we were not searching for a specific username fill
- // the user_select box with users who have posted under
- // the same IP
- if ($this->action != 'chgposter_search')
- {
- $user_select = '';
- ksort($users_ary);
- foreach ($users_ary as $row)
- {
- $user_select .= '\n";
- }
- $template->assign_var('S_USER_SELECT', $user_select);
- }
- }
- // --------
-
+ include($phpbb_root_path . 'includes/mcp/mcp_post.' . $phpEx);
+
+ mcp_post_details($id, $mode, $action, $url);
+
$this->display($user->lang['MCP'], 'mcp_post.html');
- break;
+ break;
default:
- trigger_error("Unkwnown mode: $mode");
+ trigger_error("Unknown mode: $mode");
}
}
@@ -1506,4 +181,829 @@ class mcp_main extends mcp
return $details;
}
}
+
+// request_var, the array way
+function get_array($var, $default_value)
+{
+ $ids = request_var($var, $default_value);
+
+ if (!is_array($ids))
+ {
+ if (!$ids)
+ {
+ return $default_value;
+ }
+
+ $ids = array($ids);
+ }
+
+ $ids = array_unique($ids);
+
+ if (sizeof($ids) == 1 && !$ids[0])
+ {
+ return $default_value;
+ }
+
+ return $ids;
+}
+
+//
+// LITTLE HELPER
+
+// Build simple hidden fields from array
+function build_hidden_fields($name, $vars)
+{
+ $s_hidden_fields = '';
+
+ foreach ($vars as $key => $value)
+ {
+ $s_hidden_fields .= '';
+ }
+
+ return $s_hidden_fields;
+}
+
+// Get simple topic data
+function get_topic_data($topic_ids, $acl_list = false)
+{
+ global $auth, $db;
+ $rowset = array();
+
+ if (implode(', ', $topic_ids) == '')
+ {
+ return array();
+ }
+
+ $sql = 'SELECT f.*, t.*
+ FROM ' . TOPICS_TABLE . ' t
+ LEFT JOIN ' . FORUMS_TABLE . ' f ON t.forum_id = f.forum_id
+ WHERE t.topic_id IN (' . implode(', ', $topic_ids) . ')';
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ if ($acl_list && !$auth->acl_get($acl_list, $row['forum_id']))
+ {
+ continue;
+ }
+
+ $rowset[$row['topic_id']] = $row;
+ }
+
+ return $rowset;
+}
+
+// Get simple post data
+function get_post_data($post_ids, $acl_list = false)
+{
+ global $db, $auth;
+ $rowset = array();
+
+ $sql = 'SELECT p.*, u.*, t.*, f.*
+ FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u, ' . TOPICS_TABLE . ' t
+ LEFT JOIN ' . FORUMS_TABLE . ' f ON f.forum_id = p.forum_id
+ WHERE p.post_id IN (' . implode(', ', $post_ids) . ')
+ AND u.user_id = p.poster_id
+ AND t.topic_id = p.topic_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']))
+ {
+ // Moderators without the permission to approve post should at least not see them. ;)
+ continue;
+ }
+
+ $rowset[$row['post_id']] = $row;
+ }
+
+ return $rowset;
+}
+
+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;
+ }
+
+ return $rowset;
+}
+
+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;
+ }
+ else if ($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 = $sort_url = '';
+ gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $sort_url);
+
+ $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 check_ids(&$ids, $table, $sql_id, $acl_list = false)
+{
+ global $db, $auth;
+
+ if (!is_array($ids) || !$ids)
+ {
+ return 0;
+ }
+
+ // a small logical error, since global announcement are assigned to forum_id == 0
+ // If the first topic id is a global announcement, we can force the forum. Though only global announcements can be
+ // tricked... i really do not know how to prevent this atm.
+
+ // With those two queries we make sure all ids are within one forum...
+ $sql = "SELECT forum_id FROM $table
+ WHERE $sql_id = {$ids[0]}";
+ $result = $db->sql_query($sql);
+ $forum_id = (int) $db->sql_fetchfield('forum_id', 0, $result);
+ $db->sql_freeresult($result);
+
+ if (!$forum_id)
+ {
+ // Global Announcement?
+ $forum_id = request_var('f', 0);
+ }
+
+ if ($acl_list && !$auth->acl_get($acl_list, $forum_id))
+ {
+ trigger_error('NOT_AUTHORIZED');
+ }
+
+ if (!$forum_id)
+ {
+ trigger_error('Missing forum_id, has to be in url if global announcement...');
+ }
+
+ $sql = "SELECT $sql_id FROM $table
+ WHERE $sql_id IN (" . implode(', ', $ids) . ")
+ AND (forum_id = $forum_id OR forum_id = 0)";
+ $result = $db->sql_query($sql);
+
+ $ids = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $ids[] = $row[$sql_id];
+ }
+ $db->sql_freeresult($result);
+
+ return $forum_id;
+}
+
+// LITTLE HELPER
+//
+
+// Lock/Unlock Topic/Post
+function lock_unlock($mode, $ids)
+{
+ global $auth, $user, $db, $SID, $phpEx, $phpbb_root_path;
+
+ if ($mode == 'lock' || $mode == 'unlock')
+ {
+ $table = TOPICS_TABLE;
+ $sql_id = 'topic_id';
+ $set_id = 'topic_status';
+ $l_prefix = 'TOPIC';
+ }
+ else
+ {
+ $table = POSTS_TABLE;
+ $sql_id = 'post_id';
+ $set_id = 'post_edit_locked';
+ $l_prefix = 'POST';
+ }
+
+ if (!($forum_id = check_ids($ids, $table, $sql_id, 'm_lock')))
+ {
+ return;
+ }
+
+ $redirect = request_var('redirect', $user->data['session_page']);
+
+ $s_hidden_fields = build_hidden_fields($sql_id . '_list', $ids);
+ $s_hidden_fields .= '';
+ $s_hidden_fields .= '';
+ $success_msg = '';
+
+ if (confirm_box(true))
+ {
+ $sql = "UPDATE $table
+ SET $set_id = " . (($mode == 'lock' || $mode == 'lock_post') ? ITEM_LOCKED : ITEM_UNLOCKED) . "
+ WHERE $sql_id IN (" . implode(', ', $ids) . ")";
+ $db->sql_query($sql);
+
+ $data = ($mode == 'lock' || $mode == 'unlock') ? get_topic_data($ids) : get_post_data($ids);
+
+ foreach ($data as $id => $row)
+ {
+ add_log('mod', $forum_id, $row['topic_id'], 'LOG_' . strtoupper($mode), $row['topic_title']);
+ }
+
+ $success_msg = $l_prefix . ((sizeof($ids) == 1) ? '' : 'S') . '_' . (($mode == 'lock' || $mode == 'lock_post') ? 'LOCKED' : 'UNLOCKED') . '_SUCCESS';
+ }
+ else
+ {
+ confirm_box(false, strtoupper($mode) . '_' . $l_prefix . ((sizeof($ids) == 1) ? '' : 'S'), $s_hidden_fields);
+ }
+
+ $redirect = request_var('redirect', "index.$phpEx$SID");
+
+ if (strpos($redirect, '?') === false)
+ {
+ $redirect = substr_replace($redirect, ".$phpEx$SID&", strpos($redirect, '&'), 1);
+ }
+
+ if (!$success_msg)
+ {
+ redirect($redirect);
+ }
+ else
+ {
+ meta_refresh(2, $redirect);
+ trigger_error($user->lang[$success_msg] . '
' . sprintf($user->lang['RETURN_PAGE'], '', ''));
+ }
+}
+
+// Change Topic Type
+function change_topic_type($mode, $topic_ids)
+{
+ global $auth, $user, $db, $SID, $phpEx, $phpbb_root_path;
+
+ if (!($forum_id = check_ids($topic_ids, TOPICS_TABLE, 'topic_id', 'm_')))
+ {
+ return;
+ }
+
+ switch ($mode)
+ {
+ case 'make_announce':
+ $new_topic_type = POST_ANNOUNCE;
+ $check_acl = 'f_announce';
+ $l_new_type = (sizeof($topic_ids) == 1) ? 'MCP_MAKE_ANNOUNCEMENT' : 'MCP_MAKE_ANNOUNCEMENTS';
+ break;
+ case 'make_global':
+ $new_topic_type = POST_GLOBAL;
+ $check_acl = 'f_announce';
+ $l_new_type = (sizeof($topic_ids) == 1) ? 'MCP_MAKE_GLOBAL' : 'MCP_MAKE_GLOBALS';
+ break;
+ case 'make_sticky':
+ $new_topic_type = POST_STICKY;
+ $check_acl = 'f_sticky';
+ $l_new_type = (sizeof($topic_ids) == 1) ? 'MCP_MAKE_STICKY' : 'MCP_MAKE_STICKIES';
+ break;
+ default:
+ $new_topic_type = POST_NORMAL;
+ $check_acl = '';
+ $l_new_type = (sizeof($topic_ids) == 1) ? 'MCP_MAKE_NORMAL' : 'MCP_MAKE_NORMALS';
+ break;
+ }
+
+ $redirect = request_var('redirect', $user->data['session_page']);
+
+ $s_hidden_fields = build_hidden_fields('topic_id_list', $topic_ids);
+ $s_hidden_fields .= '';
+ $s_hidden_fields .= '';
+ $s_hidden_fields .= '';
+ $success_msg = '';
+
+ if (confirm_box(true))
+ {
+ if ($new_topic_type != POST_GLOBAL)
+ {
+ $sql = 'UPDATE ' . TOPICS_TABLE . "
+ SET topic_type = $new_topic_type
+ WHERE topic_id IN (" . implode(', ', $topic_ids) . ')
+ AND forum_id <> 0';
+ $db->sql_query($sql);
+
+ // Reset forum id if a global topic is within the array
+ if ($forum_id)
+ {
+ $sql = 'UPDATE ' . TOPICS_TABLE . "
+ SET topic_type = $new_topic_type, forum_id = $forum_id
+ WHERE topic_id IN (" . implode(', ', $topic_ids) . ')
+ AND forum_id = 0';
+ $db->sql_query($sql);
+ }
+ }
+ else
+ {
+ $sql = 'UPDATE ' . TOPICS_TABLE . "
+ SET topic_type = $new_topic_type, forum_id = 0
+ WHERE topic_id IN (" . implode(', ', $topic_ids) . ")";
+ $db->sql_query($sql);
+ }
+
+ $success_msg = (sizeof($topic_ids) == 1) ? 'TOPIC_TYPE_CHANGED' : 'TOPICS_TYPE_CHANGED';
+
+ $data = get_topic_data($topic_ids);
+
+ foreach ($data as $topic_id => $row)
+ {
+ add_log('mod', $forum_id, $topic_id, 'LOG_TOPIC_TYPE_CHANGED', $row['topic_title']);
+ }
+ }
+ else
+ {
+ confirm_box(false, $l_new_type, $s_hidden_fields);
+ }
+
+ $redirect = request_var('redirect', "index.$phpEx$SID");
+
+ if (strpos($redirect, '?') === false)
+ {
+ $redirect = substr_replace($redirect, ".$phpEx$SID&", strpos($redirect, '&'), 1);
+ }
+
+ if (!$success_msg)
+ {
+ redirect($redirect);
+ }
+ else
+ {
+ meta_refresh(2, $redirect);
+ trigger_error($user->lang[$success_msg] . '
' . sprintf($user->lang['RETURN_PAGE'], '', ''));
+ }
+}
+
+// Move Topic
+function mcp_move_topic($topic_ids)
+{
+ global $auth, $user, $db, $SID, $phpEx, $phpbb_root_path, $template;
+ global $_POST, $_REQUEST;
+
+ if (!($forum_id = check_ids($topic_ids, TOPICS_TABLE, 'topic_id', 'm_move')))
+ {
+ return;
+ }
+
+ $to_forum_id = request_var('to_forum_id', 0);
+ $redirect = request_var('redirect', $user->data['session_page']);
+ $additional_msg = $success_msg = '';
+
+ $s_hidden_fields = build_hidden_fields('topic_id_list', $topic_ids);
+ $s_hidden_fields .= '';
+ $s_hidden_fields .= '';
+ $s_hidden_fields .= '';
+
+ if ($to_forum_id)
+ {
+ $forum_data = get_forum_data($to_forum_id);
+
+ if (!sizeof($forum_data))
+ {
+ $additional_msg = $user->lang['FORUM_NOT_EXIST'];
+ }
+ else
+ {
+ $forum_data = $forum_data[$to_forum_id];
+
+ if ($forum_data['forum_type'] != FORUM_POST)
+ {
+ $additional_msg = $user->lang['FORUM_NOT_POSTABLE'];
+ }
+ else if (!$auth->acl_get('f_post', $to_forum_id))
+ {
+ $additional_msg = $user->lang['USER_CANNOT_POST'];
+ }
+ else if ($forum_id == $to_forum_id)
+ {
+ $additional_msg = $user->lang['CANNOT_MOVE_SAME_FORUM'];
+ }
+ }
+ }
+
+ if (!$to_forum_id || $additional_msg)
+ {
+ unset($_POST['confirm']);
+ }
+
+ if (confirm_box(true))
+ {
+ $topic_data = get_topic_data($topic_ids);
+ $leave_shadow = (isset($_POST['move_leave_shadow'])) ? true : false;
+
+ // Move topics, but do not resync yet
+ move_topics($topic_ids, $to_forum_id, false);
+
+ $forum_ids = array($to_forum_id);
+ foreach ($topic_data as $topic_id => $row)
+ {
+ // Get the list of forums to resync, add a log entry
+ $forum_ids[] = $row['forum_id'];
+ add_log('mod', $to_forum_id, $topic_id, 'LOG_MOVE', $row['forum_name']);
+
+ // Leave a redirection if required and only if the topic is visible to users
+ if ($leave_shadow && $row['topic_approved'])
+ {
+ $shadow = array(
+ 'forum_id' => (int) $row['forum_id'],
+ 'icon_id' => (int) $row['icon_id'],
+ 'topic_attachment' => (int) $row['topic_attachment'],
+ 'topic_approved' => 1,
+ 'topic_reported' => (int) $row['topic_reported'],
+ 'topic_title' => (string) $row['topic_title'],
+ 'topic_poster' => (int) $row['topic_poster'],
+ 'topic_time' => (int) $row['topic_time'],
+ 'topic_time_limit' => (int) $row['topic_time_limit'],
+ 'topic_views' => (int) $row['topic_views'],
+ 'topic_replies' => (int) $row['topic_replies'],
+ 'topic_replies_real' => (int) $row['topic_replies_real'],
+ 'topic_status' => ITEM_MOVED,
+ 'topic_type' => (int) $row['topic_type'],
+ 'topic_first_post_id' => (int) $row['topic_first_post_id'],
+ 'topic_first_poster_name'=> (string) $row['topic_first_poster_name'],
+ 'topic_last_post_id' => (int) $row['topic_last_post_id'],
+ 'topic_last_poster_id' => (int) $row['topic_last_poster_id'],
+ 'topic_last_poster_name'=> (string) $row['topic_last_poster_name'],
+ 'topic_last_post_time' => (int) $row['topic_last_post_time'],
+ 'topic_last_view_time' => (int) $row['topic_last_view_time'],
+ 'topic_moved_id' => (int) $row['topic_id'],
+ 'topic_bumped' => (int) $row['topic_bumped'],
+ 'topic_bumper' => (int) $row['topic_bumper'],
+ 'poll_title' => (string) $row['poll_title'],
+ 'poll_start' => (int) $row['poll_start'],
+ 'poll_length' => (int) $row['poll_length'],
+ 'poll_max_options' => (int) $row['poll_max_options'],
+ 'poll_last_vote' => (int) $row['poll_last_vote']
+ );
+
+ $db->sql_query('INSERT INTO ' . TOPICS_TABLE . $db->sql_build_array('INSERT', $shadow));
+ $next_id = $db->sql_nextid();
+
+ // Mark Shadow topic read
+ markread('topic', $row['forum_id'], $next_id);
+ }
+ }
+ unset($topic_data);
+
+ // Now sync forums
+ sync('forum', 'forum_id', $forum_ids);
+
+ $success_msg = (sizeof($topic_ids) == 1) ? 'TOPIC_MOVED_SUCCESS' : 'TOPICS_MOVED_SUCCESS';
+ }
+ else
+ {
+ $template->assign_vars(array(
+ 'S_FORUM_SELECT' => make_forum_select($to_forum_id, $forum_id, false, true, true),
+ 'S_CAN_LEAVE_SHADOW' => true,
+ 'ADDITIONAL_MSG' => $additional_msg)
+ );
+
+ confirm_box(false, 'MOVE_TOPIC' . ((sizeof($topic_ids) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_move.html');
+ }
+
+ $redirect = request_var('redirect', "index.$phpEx$SID");
+
+ if (strpos($redirect, '?') === false)
+ {
+ $redirect = substr_replace($redirect, ".$phpEx$SID&", strpos($redirect, '&'), 1);
+ }
+
+ if (!$success_msg)
+ {
+ redirect($redirect);
+ }
+ else
+ {
+ meta_refresh(3, $redirect);
+ trigger_error($user->lang[$success_msg] . '
' . sprintf($user->lang['RETURN_PAGE'], '', '') . '
' . sprintf($user->lang['RETURN_NEW_FORUM'], '', ''));
+ }
+}
+
+// Delete Topics
+function mcp_delete_topic($topic_ids)
+{
+ global $auth, $user, $db, $SID, $phpEx, $phpbb_root_path;
+
+ if (!($forum_id = check_ids($topic_ids, TOPICS_TABLE, 'topic_id', 'm_delete')))
+ {
+ return;
+ }
+
+ $redirect = request_var('redirect', $user->data['session_page']);
+
+ $s_hidden_fields = build_hidden_fields('topic_id_list', $topic_ids);
+ $s_hidden_fields .= '';
+ $s_hidden_fields .= '';
+ $s_hidden_fields .= '';
+ $success_msg = '';
+
+ if (confirm_box(true))
+ {
+ $success_msg = (sizeof($topic_ids) == 1) ? 'TOPIC_DELETED_SUCCESS' : 'TOPICS_DELETED_SUCCESS';
+
+ $data = get_topic_data($topic_ids);
+
+ foreach ($data as $topic_id => $row)
+ {
+ add_log('mod', $forum_id, 0, 'LOG_TOPIC_DELETED', $row['topic_title']);
+ }
+
+ $return = delete_topics('topic_id', $topic_ids, true);
+
+ // TODO: Adjust total post count...
+ }
+ else
+ {
+ confirm_box(false, (sizeof($topic_ids) == 1) ? 'DELETE_TOPIC' : 'DELETE_TOPICS', $s_hidden_fields);
+ }
+
+ $redirect = request_var('redirect', "index.$phpEx$SID");
+
+ if (strpos($redirect, '?') === false)
+ {
+ $redirect = substr_replace($redirect, ".$phpEx$SID&", strpos($redirect, '&'), 1);
+ }
+
+ if (!$success_msg)
+ {
+ redirect($redirect);
+ }
+ else
+ {
+ meta_refresh(3, "viewforum.$phpEx$SID&f=$forum_id");
+ trigger_error($user->lang[$success_msg] . '
' . sprintf($user->lang['RETURN_FORUM'], '', ''));
+ }
+}
+
+// Delete Topics
+function mcp_delete_post($post_ids)
+{
+ global $auth, $user, $db, $SID, $phpEx, $phpbb_root_path;
+
+ if (!($forum_id = check_ids($post_ids, POSTS_TABLE, 'post_id', 'm_delete')))
+ {
+ return;
+ }
+
+ $redirect = request_var('redirect', $user->data['session_page']);
+
+ $s_hidden_fields = build_hidden_fields('post_id_list', $post_ids);
+ $s_hidden_fields .= '';
+ $s_hidden_fields .= '';
+ $s_hidden_fields .= '';
+ $success_msg = '';
+
+ if (confirm_box(true))
+ {
+ // Count the number of topics that are affected
+ // I did not use COUNT(DISTINCT ...) because I remember having problems
+ // with it on older versions of MySQL -- Ashe
+
+ $sql = 'SELECT DISTINCT topic_id
+ FROM ' . POSTS_TABLE . '
+ WHERE post_id IN (' . implode(', ', $post_ids) . ')';
+ $result = $db->sql_query($sql);
+
+ $topic_id_list = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $topic_id_list[] = $row['topic_id'];
+ }
+ $affected_topics = sizeof($topic_id_list);
+ $db->sql_freeresult($result);
+
+ // Now delete the posts, topics and forums are automatically resync'ed
+ delete_posts('post_id', $post_ids);
+
+ $sql = 'SELECT COUNT(topic_id) AS topics_left
+ FROM ' . TOPICS_TABLE . '
+ WHERE topic_id IN (' . implode(', ', $topic_id_list) . ')';
+ $result = $db->sql_query_limit($sql, 1);
+
+ $deleted_topics = ($row = $db->sql_fetchrow($result)) ? ($affected_topics - $row['topics_left']) : $affected_topics;
+ $db->sql_freeresult($result);
+
+ $topic_id = request_var('t', 0);
+
+ // Return links
+ $return_link = array();
+ if ($affected_topics == 1 && !$deleted_topics && $topic_id)
+ {
+ $return_link[] = sprintf($user->lang['RETURN_TOPIC'], "", '');
+ }
+ $return_link[] = sprintf($user->lang['RETURN_FORUM'], "", '');
+
+ if (sizeof($post_ids) == 1)
+ {
+ if ($deleted_topics)
+ {
+ // We deleted the only post of a topic, which in turn has
+ // been removed from the database
+ $success_msg = $user->lang['TOPIC_DELETED_SUCCESS'];
+ }
+ else
+ {
+ $success_msg = $user->lang['POST_DELETED_SUCCESS'];
+ }
+ }
+ else
+ {
+ if ($deleted_topics)
+ {
+ // Some of topics disappeared
+ $success_msg = $user->lang['POSTS_DELETED_SUCCESS'] . '
' . $user->lang['EMPTY_TOPICS_REMOVED_WARNING'];
+ }
+ else
+ {
+ $success_msg = $user->lang['POSTS_DELETED_SUCCESS'];
+ }
+ }
+ }
+ else
+ {
+ confirm_box(false, (sizeof($post_ids) == 1) ? 'DELETE_POST' : 'DELETE_POSTS', $s_hidden_fields);
+ }
+
+ $redirect = request_var('redirect', "index.$phpEx$SID");
+
+ if (strpos($redirect, '?') === false)
+ {
+ $redirect = substr_replace($redirect, ".$phpEx$SID&", strpos($redirect, '&'), 1);
+ }
+
+ if (!$success_msg)
+ {
+ redirect($redirect);
+ }
+ else
+ {
+ meta_refresh(3, $redirect);
+ trigger_error($success_msg . '
' . sprintf($user->lang['RETURN_PAGE'], '', '') . '
' . implode('
', $return_link));
+ }
+}
+
?>
\ No newline at end of file
diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php
index a8a4579ae1..15081be62c 100644
--- a/phpBB/includes/mcp/mcp_queue.php
+++ b/phpBB/includes/mcp/mcp_queue.php
@@ -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 = '
' . sprintf($user->lang['RETURN_TOPIC'], '', '');
- }
- else
- {
- if (count($post_id_list) == 1)
- {
- return_link('RETURN_POST', $this->url . '&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&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 . '
' . sprintf($user->lang['RETURN_FORUM'], "forum_id . '">', ''));
- }
- 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 = '' . $row['username'] . '';
- }
-
- $s_checkbox = ($mode == 'unapproved_posts') ? '' : '';
-
- $template->assign_block_vars('postrow', array(
- 'U_VIEWFORUM' => "viewforum.$phpEx$SID&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&f=" . $row['forum_id'] . '&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;
- }
-}
?>
\ No newline at end of file
diff --git a/phpBB/language/en/mcp.php b/phpBB/language/en/mcp.php
index 1365e90075..8d539f3c30 100644
--- a/phpBB/language/en/mcp.php
+++ b/phpBB/language/en/mcp.php
@@ -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' => 'Approved topic
» %s',
'LOG_FORK' => 'Copied topic
» from %s',
@@ -70,21 +80,43 @@ $lang += array(
'LOG_LOCK_POST' => 'Locked post
» %s',
'LOG_MERGE' => 'Merged posts into topic
»%s',
'LOG_MOVE' => 'Moved topic
» from %s',
+ 'LOG_TOPIC_DELETED' => 'Deleted topic
» %s',
'LOG_TOPIC_RESYNC' => 'Resynchronised topic counters
» %s',
+ 'LOG_TOPIC_TYPE_CHANGED'=> 'Changed topic type
» %s',
'LOG_UNLOCK' => 'Unlocked topic
» %s',
'LOG_UNLOCK_POST' => 'Unlocked post
» %s',
'LOG_UNRATE' => 'Unrated post
» %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 %d 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 %d 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',
diff --git a/phpBB/mcp.php b/phpBB/mcp.php
index 6750bde63a..8897c32a23 100644
--- a/phpBB/mcp.php
+++ b/phpBB/mcp.php
@@ -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 . '&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)
{
@@ -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) ? "&p=$post_id" : '';
+ $suffix .= ($topic_id) ? "&t=$topic_id" : '';
+ $suffix .= ($forum_id) ? "&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 . '&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
+ 'U_TITLE' => $module_url . '&i=' . $module_id . '&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) ? "&p=$post_id" : '';
+ $this->url .= ($topic_id) ? "&t=$topic_id" : '';
+ $this->url .= ($forum_id) ? "&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 .= '&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 .= '&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 .= '&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)) ? '&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 .= ' ';
- }
- 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], '', '')
- ));
-}
-
//
// 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&mode=$mode&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");
+}
?>
\ No newline at end of file