diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 0061a236db..32cb2b383d 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -1869,11 +1869,11 @@ function cache_moderators() */ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_time DESC') { - global $db, $user, $auth, $phpEx, $SID; + global $db, $user, $auth, $phpEx, $SID, $phpbb_root_path; $topic_id_list = $is_auth = $is_mod = array(); - $profile_url = (defined('IN_ADMIN')) ? "index.$phpEx$SID&i=users&mode=overview" : "memberlist.$phpEx$SID&mode=viewprofile"; + $profile_url = (defined('IN_ADMIN')) ? "{$phpbb_root_path}index.$phpEx$SID&i=users&mode=overview" : "{$phpbb_root_path}memberlist.$phpEx$SID&mode=viewprofile"; switch ($mode) { @@ -1937,7 +1937,7 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id $log[$i]['time'] = $row['log_time']; $log[$i]['forum_id'] = $row['forum_id']; $log[$i]['topic_id'] = $row['topic_id']; - $log[$i]['viewforum'] = ($row['forum_id'] && $auth->acl_get('f_read', $row['forum_id'])) ? ((defined('IN_ADMIN')) ? '../' : '') . "viewforum.$phpEx$SID&f=" . $row['forum_id'] : ''; + $log[$i]['viewforum'] = ($row['forum_id'] && $auth->acl_get('f_read', $row['forum_id'])) ? "{$phpbb_root_path}viewforum.$phpEx$SID&f=" . $row['forum_id'] : ''; $log[$i]['action'] = (isset($user->lang[$row['log_operation']])) ? $user->lang[$row['log_operation']] : '{' . ucfirst(str_replace('_', ' ', $row['log_operation'])) . '}'; @@ -1992,8 +1992,8 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id foreach ($log as $key => $row) { - $log[$key]['viewtopic'] = (isset($is_auth[$row['topic_id']])) ? ((defined('IN_ADMIN')) ? '../' : '') . "viewtopic.$phpEx$SID&f=" . $is_auth[$row['topic_id']] . '&t=' . $row['topic_id'] : ''; - $log[$key]['viewlogs'] = (isset($is_mod[$row['topic_id']])) ? ((defined('IN_ADMIN')) ? '../' : '') . "mcp.$phpEx$SID&mode=logs&action=topic_logs&t=" . $row['topic_id'] : ''; + $log[$key]['viewtopic'] = (isset($is_auth[$row['topic_id']])) ? "{$phpbb_root_path}viewtopic.$phpEx$SID&f=" . $is_auth[$row['topic_id']] . '&t=' . $row['topic_id'] : ''; + $log[$key]['viewlogs'] = (isset($is_mod[$row['topic_id']])) ? "{$phpbb_root_path}mcp.$phpEx$SID&i=logs&mode=topic_logs&t=" . $row['topic_id'] : ''; } } diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index 4ced2b77bf..ce99fc05d7 100644 --- a/phpBB/includes/mcp/mcp_forum.php +++ b/phpBB/includes/mcp/mcp_forum.php @@ -11,11 +11,13 @@ /** * MCP Forum View */ -function mcp_forum_view($id, $mode, $action, $url, $forum_info) +function mcp_forum_view($id, $mode, $action, $forum_info) { global $template, $db, $user, $auth, $cache; global $SID, $phpEx, $phpbb_root_path, $config; + $url = "{$phpbb_root_path}mcp.$phpEx$SID" . extra_url(); + if ($action == 'merge_select') { // Fixes a "bug" that makes forum_view use the same ordering as topic_view @@ -33,14 +35,7 @@ function mcp_forum_view($id, $mode, $action, $url, $forum_info) { $topic_ids = request_var('topic_id_list', array(0)); - if (!sizeof($topic_ids)) - { - $template->assign_var('MESSAGE', $user->lang['NO_TOPIC_SELECTED']); - } - else - { - mcp_resync_topics($topic_ids); - } + mcp_resync_topics($topic_ids); } $selected_ids = ''; @@ -52,7 +47,7 @@ function mcp_forum_view($id, $mode, $action, $url, $forum_info) } } - make_jumpbox($url . "&action=$action&mode=$mode", $forum_id . (($action == 'merge_select') ? $selected_ids : ''), false, 'm_'); + make_jumpbox($url . "&i=$id&action=$action&mode=$mode", $forum_id . (($action == 'merge_select') ? $selected_ids : ''), false, 'm_'); $topics_per_page = ($forum_info['forum_topics_per_page']) ? $forum_info['forum_topics_per_page'] : $config['topics_per_page']; @@ -62,6 +57,7 @@ function mcp_forum_view($id, $mode, $action, $url, $forum_info) $template->assign_vars(array( 'FORUM_NAME' => $forum_info['forum_name'], + 'FORUM_DESCRIPTION' => $forum_info['forum_desc'], 'REPORTED_IMG' => $user->img('icon_reported', 'TOPIC_REPORTED'), 'UNAPPROVED_IMG' => $user->img('icon_unapproved', 'TOPIC_UNAPPROVED'), @@ -73,10 +69,12 @@ function mcp_forum_view($id, $mode, $action, $url, $forum_info) 'S_CAN_SYNC' => $auth->acl_get('m_', $forum_id), 'S_CAN_APPROVE' => $auth->acl_get('m_approve', $forum_id), - 'U_VIEW_FORUM' => "viewforum.$phpEx$SID&f=" . $forum_id, - 'S_MCP_ACTION' => $url . "&action=$action&mode=$mode&start=$start" . (($action == 'merge_select') ? $selected_ids : ''), + 'U_VIEW_FORUM' => "{$phpbb_root_path}viewforum.$phpEx$SID&f=" . $forum_id, + 'U_VIEW_FORUM_LOGS' => ($auth->acl_gets('a_', 'm_', $forum_id)) ? "{$phpbb_root_path}mcp.$phpEx$SID&i=logs&mode=forum_logs&f=" . $forum_id : '', - 'PAGINATION' => generate_pagination($url . "&action=$action&mode=$mode" . (($action == 'merge_select') ? $selected_ids : ''), $forum_topics, $topics_per_page, $start), + 'S_MCP_ACTION' => $url . "&i=$id&action=$action&mode=$mode&start=$start" . (($action == 'merge_select') ? $selected_ids : ''), + + 'PAGINATION' => generate_pagination($url . "&i=$id&action=$action&mode=$mode" . (($action == 'merge_select') ? $selected_ids : ''), $forum_topics, $topics_per_page, $start), 'PAGE_NUMBER' => on_page($forum_topics, $topics_per_page, $start), 'TOTAL' => $forum_topics) ); @@ -178,14 +176,14 @@ function mcp_forum_view($id, $mode, $action, $url, $forum_info) } $topic_title = censor_text($row['topic_title']); - + $template->assign_block_vars('topicrow', array( - 'U_VIEW_TOPIC' => "mcp.$phpEx$SID&f=$forum_id&t={$row['topic_id']}&mode=topic_view", + 'U_VIEW_TOPIC' => "{$phpbb_root_path}mcp.$phpEx$SID&i=$id&f=$forum_id&t={$row['topic_id']}&mode=topic_view", 'S_SELECT_TOPIC' => ($action == 'merge_select' && $row['topic_id'] != $topic_id) ? true : false, - 'U_SELECT_TOPIC' => $url . '&mode=topic_view&action=merge&to_topic_id=' . $row['topic_id'] . $selected_ids, + 'U_SELECT_TOPIC' => $url . "&i=$id&mode=topic_view&action=merge&to_topic_id=" . $row['topic_id'] . $selected_ids, 'U_MCP_QUEUE' => $url . '&i=queue&mode=approve_details&t=' . $row['topic_id'], - 'U_MCP_REPORT' => "mcp.$phpEx$SID&i=main&mode=topic_view&t={$row['topic_id']}&action=reports", + 'U_MCP_REPORT' => "{$phpbb_root_path}mcp.$phpEx$SID&i=main&mode=topic_view&t={$row['topic_id']}&action=reports", 'ATTACH_ICON_IMG' => ($auth->acl_gets('f_download', 'u_download', $row['forum_id']) && $row['topic_attachment']) ? $user->img('icon_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), @@ -222,10 +220,10 @@ function mcp_resync_topics($topic_ids) if (!sizeof($topic_ids)) { - $template->assign_var('MESSAGE', $user->lang['NO_TOPIC_SELECTED']); + trigger_error($user->lang['NO_TOPIC_SELECTED']); return; } - + // Sync everything and perform extra checks separately sync('topic_reported', 'topic_id', $topic_ids, false, true); sync('topic_attachment', 'topic_id', $topic_ids, false, true); @@ -243,7 +241,11 @@ function mcp_resync_topics($topic_ids) } $msg = (sizeof($topic_ids) == 1) ? $user->lang['TOPIC_RESYNC_SUCCESS'] : $user->lang['TOPICS_RESYNC_SUCCESS']; - $template->assign_var('MESSAGE', $msg); + + $redirect = request_var('redirect', $user->data['session_page']); + + meta_refresh(2, $redirect); + trigger_error($msg . '

' . sprintf($user->lang['RETURN_PAGE'], '', '')); return; } diff --git a/phpBB/includes/mcp/mcp_front.php b/phpBB/includes/mcp/mcp_front.php index 8659c0b2f1..c0d6ce19d5 100644 --- a/phpBB/includes/mcp/mcp_front.php +++ b/phpBB/includes/mcp/mcp_front.php @@ -11,11 +11,13 @@ /** * MCP Front Panel */ -function mcp_front_view($id, $mode, $action, $url) +function mcp_front_view($id, $mode, $action) { global $SID, $phpEx, $phpbb_root_path, $config; global $template, $db, $user, $auth; + $url = "{$phpbb_root_path}mcp.$phpEx$SID" . extra_url(); + // Latest 5 unapproved $forum_list = get_forum_list('m_approve'); $post_list = array(); @@ -39,8 +41,8 @@ function mcp_front_view($id, $mode, $action, $url) $sql = 'SELECT forum_id, forum_name FROM ' . FORUMS_TABLE . ' WHERE forum_id IN (' . implode(', ', $forum_list) . ')'; - $result = $db->sql_query_limit($sql); - + $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) { $forum_names[$row['forum_id']] = $row['forum_name']; @@ -69,19 +71,19 @@ function mcp_front_view($id, $mode, $action, $url) while ($row = $db->sql_fetchrow($result)) { $template->assign_block_vars('unapproved', array( - 'U_POST_DETAILS'=> $url . '&p=' . $row['post_id'] . '&mode=post_details', - 'U_MCP_FORUM' => ($row['forum_id']) ? $url . '&f=' . $row['forum_id'] . '&mode=forum_view' : '', - 'U_MCP_TOPIC' => $url . '&t=' . $row['topic_id'] . '&mode=topic_view', - 'U_FORUM' => ($row['forum_id']) ? 'viewforum.' . $phpEx . $SID . '&f=' . $row['forum_id'] : '', - 'U_TOPIC' => $phpbb_root_path . 'viewtopic.' . $phpEx . $SID . '&f=' . (($row['forum_id']) ? $row['forum_id'] : $forum_id) . '&t=' . $row['topic_id'], - 'U_AUTHOR' => ($row['poster_id'] == ANONYMOUS) ? '' : 'memberlist.' . $phpEx . $SID . '&mode=viewprofile&u=' . $row['poster_id'], + 'U_POST_DETAILS'=> $url . '&i=main&mode=post_details&p=' . $row['post_id'], + 'U_MCP_FORUM' => ($row['forum_id']) ? $url . '&i=main&mode=forum_view&f=' . $row['forum_id'] : '', + 'U_MCP_TOPIC' => $url . '&i=main&mode=topic_view&t=' . $row['topic_id'], + 'U_FORUM' => ($row['forum_id']) ? "{$phpbb_root_path}viewforum.$phpEx$SID&f=" . $row['forum_id'] : '', + 'U_TOPIC' => $phpbb_root_path . "{$phpbb_root_path}viewtopic.$phpEx$SID&f=" . (($row['forum_id']) ? $row['forum_id'] : $forum_id) . '&t=' . $row['topic_id'], + 'U_AUTHOR' => ($row['poster_id'] == ANONYMOUS) ? '' : "{$phpbb_root_path}memberlist.$phpEx$SID&mode=viewprofile&u=" . $row['poster_id'], 'FORUM_NAME' => ($row['forum_id']) ? $forum_names[$row['forum_id']] : $user->lang['GLOBAL_ANNOUNCEMENT'], 'TOPIC_TITLE' => $row['topic_title'], 'AUTHOR' => ($row['poster_id'] == ANONYMOUS) ? (($row['post_username']) ? $row['post_username'] : $user->lang['GUEST']) : $row['username'], 'SUBJECT' => ($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT'], 'POST_TIME' => $user->format_date($row['post_time'])) - ); + ); } } @@ -103,7 +105,7 @@ function mcp_front_view($id, $mode, $action, $url) // Latest 5 reported $forum_list = get_forum_list('m_'); - + $template->assign_var('S_SHOW_REPORTS', (!empty($forum_list)) ? true : false); if (!empty($forum_list)) { @@ -134,16 +136,16 @@ function mcp_front_view($id, $mode, $action, $url) 'U_POST_DETAILS'=> $url . '&p=' . $row['post_id'] . '&mode=post_details', 'U_MCP_FORUM' => ($row['forum_id']) ? $url . '&f=' . $row['forum_id'] . '&mode=forum_view' : '', 'U_MCP_TOPIC' => $url . '&t=' . $row['topic_id'] . '&mode=topic_view', - 'U_FORUM' => ($row['forum_id']) ? 'viewforum.' . $phpEx . $SID . '&f=' . $row['forum_id'] : '', - 'U_TOPIC' => 'viewtopic.' . $phpEx . $SID . '&f=' . $row['forum_id'] . '&t=' . $row['topic_id'], - 'U_REPORTER' => ($row['user_id'] == ANONYMOUS) ? '' : 'memberlist.' . $phpEx . $SID . '&mode=viewprofile&u=' . $row['user_id'], + 'U_FORUM' => ($row['forum_id']) ? "{$phpbb_root_path}viewforum.$phpEx$SID&f=" . $row['forum_id'] : '', + 'U_TOPIC' => "{$phpbb_root_path}viewtopic.$phpEx$SID&f=" . $row['forum_id'] . '&t=' . $row['topic_id'], + 'U_REPORTER' => ($row['user_id'] == ANONYMOUS) ? '' : "{$phpbb_root_path}memberlist.$phpEx$SID&mode=viewprofile&u=" . $row['user_id'], 'FORUM_NAME' => ($row['forum_id']) ? $row['forum_name'] : $user->lang['POST_GLOBAL'], 'TOPIC_TITLE' => $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'])) - ); + ); } } diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index ef92a41399..8862cf31dd 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -17,7 +17,7 @@ class mcp_main { var $p_master; - + function mcp_main(&$p_master) { $this->p_master = &$p_master; @@ -25,30 +25,24 @@ class mcp_main function main($id, $mode) { - global $auth, $db, $user, $template; + global $auth, $db, $user, $template, $action; global $config, $phpbb_root_path, $phpEx, $SID; - - $action = request_var('action', ''); - $quickmod = request_var('quickmod', ''); - if (is_array($action)) - { - list($action, ) = each($action); - } + $quickmod = ($mode == 'quickmod') ? true : false; - switch ($mode) + switch ($action) { case 'lock': case 'unlock': $topic_ids = (!$quickmod) ? request_var('topic_id_list', array(0)) : array(request_var('t', 0)); - + if (!sizeof($topic_ids)) { trigger_error('NO_TOPIC_SELECTED'); } - lock_unlock($mode, $topic_ids); - break; + lock_unlock($action, $topic_ids); + break; case 'lock_post': case 'unlock_post': @@ -60,65 +54,62 @@ class mcp_main trigger_error('NO_POST_SELECTED'); } - lock_unlock($mode, $post_ids); - break; + lock_unlock($action, $post_ids); + break; case 'make_announce': case 'make_sticky': case 'make_global': case 'make_normal': - + $topic_ids = (!$quickmod) ? request_var('topic_id_list', array(0)) : array(request_var('t', 0)); - + if (!sizeof($topic_ids)) { trigger_error('NO_TOPIC_SELECTED'); } - change_topic_type($mode, $topic_ids); - - break; + change_topic_type($action, $topic_ids); + break; case 'move': $user->add_lang('viewtopic'); $topic_ids = (!$quickmod) ? request_var('topic_id_list', array(0)) : array(request_var('t', 0)); - + if (!sizeof($topic_ids)) { trigger_error('NO_TOPIC_SELECTED'); } mcp_move_topic($topic_ids); - - break; + break; case 'fork': $user->add_lang('viewtopic'); $topic_ids = (!$quickmod) ? request_var('topic_id_list', array(0)) : array(request_var('t', 0)); - + if (!sizeof($topic_ids)) { trigger_error('NO_TOPIC_SELECTED'); } mcp_fork_topic($topic_ids); - - break; + break; case 'delete_topic': $user->add_lang('viewtopic'); $topic_ids = (!$quickmod) ? request_var('topic_id_list', array(0)) : array(request_var('t', 0)); - + if (!sizeof($topic_ids)) { trigger_error('NO_TOPIC_SELECTED'); } mcp_delete_topic($topic_ids); - break; + break; case 'delete_post': $user->add_lang('posting'); @@ -131,19 +122,22 @@ class mcp_main } mcp_delete_post($post_ids); - break; + break; + } + switch ($mode) + { case 'front': include($phpbb_root_path . 'includes/mcp/mcp_front.' . $phpEx); - mcp_front_view($id, $mode, $action, $url); + mcp_front_view($id, $mode, $action); $this->tpl_name = 'mcp_front'; - break; + break; case 'forum_view': include($phpbb_root_path . 'includes/mcp/mcp_forum.' . $phpEx); - + $user->add_lang('viewforum'); $forum_id = request_var('f', 0); @@ -152,32 +146,32 @@ class mcp_main if (!sizeof($forum_info)) { - $this->mcp_main('mcp', 'front', $url); - exit; + $this->main('main', 'front'); + return; } $forum_info = $forum_info[$forum_id]; - mcp_forum_view($id, $mode, $action, $url, $forum_info); - + mcp_forum_view($id, $mode, $action, $forum_info); + $this->tpl_name = 'mcp_forum'; - break; + break; case 'topic_view': include($phpbb_root_path . 'includes/mcp/mcp_topic.' . $phpEx); - - mcp_topic_view($id, $mode, $action, $url); - + + mcp_topic_view($id, $mode, $action); + $this->tpl_name = 'mcp_topic'; - break; - + break; + case 'post_details': include($phpbb_root_path . 'includes/mcp/mcp_post.' . $phpEx); - - mcp_post_details($id, $mode, $action, $url); - + + mcp_post_details($id, $mode, $action); + $this->tpl_name = 'mcp_post'; - break; + break; default: trigger_error("Unknown mode: $mode"); @@ -188,11 +182,11 @@ class mcp_main /** * Lock/Unlock Topic/Post */ -function lock_unlock($mode, $ids) +function lock_unlock($action, $ids) { global $auth, $user, $db, $SID, $phpEx, $phpbb_root_path; - if ($mode == 'lock' || $mode == 'unlock') + if ($action == 'lock' || $action == 'unlock') { $table = TOPICS_TABLE; $sql_id = 'topic_id'; @@ -206,17 +200,17 @@ function lock_unlock($mode, $ids) $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(array( $sql_id . '_list' => $ids, - 'mode' => $mode, + 'action' => $action, 'redirect' => $redirect) ); $success_msg = ''; @@ -224,22 +218,22 @@ function lock_unlock($mode, $ids) if (confirm_box(true)) { $sql = "UPDATE $table - SET $set_id = " . (($mode == 'lock' || $mode == 'lock_post') ? ITEM_LOCKED : ITEM_UNLOCKED) . " + SET $set_id = " . (($action == 'lock' || $action == '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); + $data = ($action == 'lock' || $action == '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']); + add_log('mod', $forum_id, $row['topic_id'], 'LOG_' . strtoupper($action), $row['topic_title']); } - - $success_msg = $l_prefix . ((sizeof($ids) == 1) ? '' : 'S') . '_' . (($mode == 'lock' || $mode == 'lock_post') ? 'LOCKED' : 'UNLOCKED') . '_SUCCESS'; + + $success_msg = $l_prefix . ((sizeof($ids) == 1) ? '' : 'S') . '_' . (($action == 'lock' || $action == 'lock_post') ? 'LOCKED' : 'UNLOCKED') . '_SUCCESS'; } else { - confirm_box(false, strtoupper($mode) . '_' . $l_prefix . ((sizeof($ids) == 1) ? '' : 'S'), $s_hidden_fields); + confirm_box(false, strtoupper($action) . '_' . $l_prefix . ((sizeof($ids) == 1) ? '' : 'S'), $s_hidden_fields); } $redirect = request_var('redirect', "index.$phpEx$SID"); @@ -263,7 +257,7 @@ function lock_unlock($mode, $ids) /** * Change Topic Type */ -function change_topic_type($mode, $topic_ids) +function change_topic_type($action, $topic_ids) { global $auth, $user, $db, $SID, $phpEx, $phpbb_root_path; @@ -272,28 +266,31 @@ function change_topic_type($mode, $topic_ids) return; } - switch ($mode) + switch ($action) { 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; + 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; + 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; + break; + default: $new_topic_type = POST_NORMAL; $check_acl = ''; $l_new_type = (sizeof($topic_ids) == 1) ? 'MCP_MAKE_NORMAL' : 'MCP_MAKE_NORMALS'; - break; + break; } $redirect = request_var('redirect', $user->data['session_page']); @@ -301,7 +298,7 @@ function change_topic_type($mode, $topic_ids) $s_hidden_fields = build_hidden_fields(array( 'topic_id_list' => $topic_ids, 'f' => $forum_id, - 'mode' => $mode, + 'action' => $action, 'redirect' => $redirect) ); $success_msg = ''; @@ -378,7 +375,7 @@ function mcp_move_topic($topic_ids) { return; } - + $to_forum_id = request_var('to_forum_id', 0); $redirect = request_var('redirect', $user->data['session_page']); $additional_msg = $success_msg = ''; @@ -386,7 +383,7 @@ function mcp_move_topic($topic_ids) $s_hidden_fields = build_hidden_fields(array( 'topic_id_list' => $topic_ids, 'f' => $forum_id, - 'mode' => 'move', + 'action' => 'move', 'redirect' => $redirect) ); @@ -401,7 +398,7 @@ function mcp_move_topic($topic_ids) else { $forum_data = $forum_data[$to_forum_id]; - + if ($forum_data['forum_type'] != FORUM_POST) { $additional_msg = $user->lang['FORUM_NOT_POSTABLE']; @@ -421,7 +418,7 @@ function mcp_move_topic($topic_ids) { unset($_POST['confirm']); } - + if (confirm_box(true)) { $topic_data = get_topic_data($topic_ids); @@ -473,7 +470,7 @@ function mcp_move_topic($topic_ids) ); $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); @@ -511,7 +508,7 @@ function mcp_move_topic($topic_ids) else { meta_refresh(3, $redirect); - + $message = $user->lang[$success_msg]; $message .= '

' . sprintf($user->lang['RETURN_PAGE'], '', ''); $message .= '

' . sprintf($user->lang['RETURN_FORUM'], "", ''); @@ -538,7 +535,7 @@ function mcp_delete_topic($topic_ids) $s_hidden_fields = build_hidden_fields(array( 'topic_id_list' => $topic_ids, 'f' => $forum_id, - 'mode' => 'delete_topic', + 'action' => 'delete_topic', 'redirect' => $redirect) ); $success_msg = ''; @@ -598,7 +595,7 @@ function mcp_delete_post($post_ids) $s_hidden_fields = build_hidden_fields(array( 'post_id_list' => $post_ids, 'f' => $forum_id, - 'mode' => 'delete_post', + 'action' => 'delete_post', 'redirect' => $redirect) ); $success_msg = ''; @@ -623,7 +620,7 @@ function mcp_delete_post($post_ids) $db->sql_freeresult($result); $post_data = get_post_data($post_ids); - + foreach ($post_data as $id => $row) { add_log('mod', $row['forum_id'], $row['topic_id'], 'LOG_DELETE_POST', $row['post_subject']); @@ -631,7 +628,7 @@ function mcp_delete_post($post_ids) // 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) . ')'; @@ -711,7 +708,7 @@ function mcp_fork_topic($topic_ids) { return; } - + $to_forum_id = request_var('to_forum_id', 0); $redirect = request_var('redirect', $user->data['session_page']); $additional_msg = $success_msg = ''; @@ -719,7 +716,7 @@ function mcp_fork_topic($topic_ids) $s_hidden_fields = build_hidden_fields(array( 'topic_id_list' => $topic_ids, 'f' => $forum_id, - 'mode' => 'fork', + 'action' => 'fork', 'redirect' => $redirect) ); @@ -738,7 +735,7 @@ function mcp_fork_topic($topic_ids) else { $forum_data = $forum_data[$to_forum_id]; - + if ($forum_data['forum_type'] != FORUM_POST) { $additional_msg = $user->lang['FORUM_NOT_POSTABLE']; @@ -754,11 +751,11 @@ function mcp_fork_topic($topic_ids) { unset($_POST['confirm']); } - + if (confirm_box(true)) { $topic_data = get_topic_data($topic_ids); - + $total_posts = 0; $new_topic_id_list = array(); foreach ($topic_data as $topic_id => $topic_row) @@ -801,8 +798,8 @@ function mcp_fork_topic($topic_ids) { $poll_rows = array(); - $sql = 'SELECT * - FROM ' . POLL_OPTIONS_TABLE . " + $sql = 'SELECT * + FROM ' . POLL_OPTIONS_TABLE . " WHERE topic_id = $topic_id"; $result = $db->sql_query($sql); @@ -819,7 +816,7 @@ function mcp_fork_topic($topic_ids) WHERE topic_id = $topic_id ORDER BY post_id ASC"; $result = $db->sql_query($sql); - + $post_rows = array(); while ($row = $db->sql_fetchrow($result)) { @@ -875,7 +872,7 @@ function mcp_fork_topic($topic_ids) AND topic_id = $topic_id AND in_message = 0"; $result = $db->sql_query($sql); - + while ($attach_row = $db->sql_fetchrow($result)) { $sql_ary = array( @@ -893,7 +890,7 @@ function mcp_fork_topic($topic_ids) 'filetime' => (int) $attach_row['filetime'], 'thumbnail' => (int) $attach_row['thumbnail'] ); - + $db->sql_query('INSERT INTO ' . ATTACHMENTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); } $db->sql_freeresult($result); @@ -962,10 +959,10 @@ class mcp_main_info 'title' => 'MCP_MAIN', 'version' => '1.0.0', 'modes' => array( - 'front' => array('title' => 'MCP_MAIN_FRONT', 'auth' => ''), 'forum_view' => array('title' => 'MCP_MAIN_FORUM_VIEW', 'auth' => 'acl_m_,$id'), - 'topic_view' => array('title' => 'MCP_MAIN_TOPIC_VIEW', 'auth' => 'acl_m_,$id'), + 'front' => array('title' => 'MCP_MAIN_FRONT', 'auth' => ''), 'post_details' => array('title' => 'MCP_MAIN_POST_DETAILS', 'auth' => 'acl_m_,$id'), + 'topic_view' => array('title' => 'MCP_MAIN_TOPIC_VIEW', 'auth' => 'acl_m_,$id'), ), ); } diff --git a/phpBB/includes/mcp/mcp_post.php b/phpBB/includes/mcp/mcp_post.php index 65ef3f7805..cbdf6d4f6a 100644 --- a/phpBB/includes/mcp/mcp_post.php +++ b/phpBB/includes/mcp/mcp_post.php @@ -11,7 +11,7 @@ /** * Handling actions in post details screen */ -function mcp_post_details($id, $mode, $action, $url) +function mcp_post_details($id, $mode, $action) { global $SID, $phpEx, $phpbb_root_path, $config; global $template, $db, $user, $auth; @@ -30,135 +30,55 @@ function mcp_post_details($id, $mode, $action, $url) } $post_info = $post_info[$post_id]; + $url = "{$phpbb_root_path}mcp.$phpEx$SID" . extra_url(); switch ($action) { - case 'chgposter_search': - + case 'chgposter': + $username = request_var('username', ''); - if ($username) + $sql = 'SELECT user_id + FROM ' . USERS_TABLE . ' + WHERE username = \'' . $db->sql_escape($username) . '\''; + $result = $db->sql_query($sql); + + if (!($row = $db->sql_fetchrow($result))) { - $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 NOT IN (" . USER_INACTIVE . ', ' . USER_IGNORE . ') - 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"; - } + trigger_error($user->lang['NO_USER']); } + $new_user = $row['user_id']; - if (!$user_select) + if ($auth->acl_get('m_', $post_info['forum_id'])) { - $template->assign_var('MESSAGE', $user->lang['NO_MATCHES_FOUND']); + change_poster($post_info, $new_user); } + break; - $template->assign_vars(array( - 'S_USER_SELECT' => $user_select, - 'SEARCH_USERNAME' => request_var('username', '')) - ); - break; - - case 'chgposter': + case 'chgposter_ip': $new_user = request_var('u', 0); - if ($new_user && $auth->acl_get('m_', $post_info['forum_id']) && $new_user != $post_info['user_id']) + $sql = 'SELECT user_id + FROM ' . USERS_TABLE . ' + WHERE user_id = ' . $new_user; + $result = $db->sql_query($sql); + + if (!($row = $db->sql_fetchrow($result))) { - $sql = 'UPDATE ' . POSTS_TABLE . " - SET poster_id = $new_user - WHERE post_id = $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); - } - - // Renew post info - $post_info = get_post_data(array($post_id)); - - if (!sizeof($post_info)) - { - trigger_error($user->lang['POST_NOT_EXIST']); - } - - $post_info = $post_info[$post_id]; - } - break; - - case 'del_marked': - case 'del_all': - case 'add_feedback': - - $deletemark = ($action == 'del_marked') ? true : false; - $deleteall = ($action == 'del_all') ? true : false; - $marked = request_var('marknote', 0); - $usernote = request_var('usernote', ''); - - if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs')) - { - $where_sql = ''; - if ($deletemark && $marked) - { - $sql_in = array(); - foreach ($marked as $mark) - { - $sql_in[] = $mark; - } - $where_sql = ' AND log_id IN (' . implode(', ', $sql_in) . ')'; - unset($sql_in); - } - - $sql = 'DELETE FROM ' . LOG_TABLE . ' - WHERE log_type = ' . LOG_USERS . " - $where_sql"; - $db->sql_query($sql); - - add_log('admin', 'LOG_USERS_CLEAR'); - - $msg = ($deletemark) ? 'MARKED_DELETED' : 'ALL_DELETED'; - $redirect = "$url&i=$id&mode=post_details"; - meta_refresh(2, $redirect); - trigger_error($user->lang[$msg] . '

' . sprintf($user->lang['RETURN_PAGE'], '', '')); + trigger_error($user->lang['NO_USER']); } - if ($usernote && $action == 'add_feedback') + if ($auth->acl_get('m_', $post_info['forum_id'])) { - add_log('admin', 'LOG_USER_FEEDBACK', $post_info['username']); - add_log('user', $post_info['user_id'], 'LOG_USER_GENERAL', $usernote); - - $redirect = "$url&i=$id&mode=post_details"; - meta_refresh(2, $redirect); - trigger_error($user->lang['USER_FEEDBACK_ADDED'] . '

' . sprintf($user->lang['RETURN_PAGE'], '', '')); + change_poster($post_info, $new_user); } - break; - - default: + break; } // Set some vars $users_ary = array(); + $post_id = $post_info['post_id']; $poster = ($post_info['user_colour']) ? '' . $post_info['username'] . '' : $post_info['username']; // Process message, leave it uncensored @@ -184,17 +104,17 @@ function mcp_post_details($id, $mode, $action, $url) 'S_POST_REPORTED' => $post_info['post_reported'], 'S_POST_UNAPPROVED' => !$post_info['post_approved'], 'S_POST_LOCKED' => $post_info['post_edit_locked'], - 'S_USER_WARNINGS' => ($post_info['user_warnings']) ? true : false, - 'S_SHOW_USER_NOTES' => true, + 'S_USER_NOTES' => $auth->acl_gets('m_', 'a_') ? true : false, 'S_CLEAR_ALLOWED' => ($auth->acl_get('a_clearlogs')) ? true : false, - 'U_VIEW_PROFILE' => "memberlist.$phpEx$SID&mode=viewprofile&u=" . $post_info['user_id'], -// 'U_MCP_USERNOTES' => "mcp.$phpEx$SID&i=notes&mode=user_notes&u=" . $post_info['user_id'], -// 'U_MCP_WARNINGS' => "mcp.$phpEx$SID&i=warnings&mode=view_user&u=" . $post_info['user_id'], + 'U_FIND_MEMBER' => "{$phpbb_root_path}memberlist.$phpEx$SID&mode=searchuser&form=mcp_chgposter&field=username", + 'U_VIEW_PROFILE' => "{$phpbb_root_path}memberlist.$phpEx$SID&mode=viewprofile&u=" . $post_info['user_id'], + 'U_MCP_USER_NOTES' => $auth->acl_gets('m_', 'a_') ? "{$phpbb_root_path}mcp.$phpEx$SID&i=notes&mode=user_notes&u=" . $post_info['user_id'] : '', + 'U_MCP_WARN_USER' => "{$phpbb_root_path}mcp.$phpEx$SID&i=warn&mode=warn_user&u=" . $post_info['user_id'], 'U_EDIT' => ($auth->acl_get('m_edit', $post_info['forum_id'])) ? "{$phpbb_root_path}posting.$phpEx$SID&mode=edit&f={$post_info['forum_id']}&p={$post_info['post_id']}" : '', - 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], "", ''), - 'RETURN_FORUM' => sprintf($user->lang['RETURN_FORUM'], "", ''), + 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], "", ''), + 'RETURN_FORUM' => sprintf($user->lang['RETURN_FORUM'], "", ''), 'REPORTED_IMG' => $user->img('icon_reported', $user->lang['POST_REPORTED']), 'UNAPPROVED_IMG' => $user->img('icon_unapproved', $user->lang['POST_UNAPPROVED']), 'EDIT_IMG' => $user->img('btn_edit', $user->lang['EDIT_POST']), @@ -231,7 +151,7 @@ function mcp_post_details($id, $mode, $action, $url) // Get Reports if ($auth->acl_get('m_', $post_info['forum_id'])) { - $sql = 'SELECT r.*, re.*, u.user_id, u.username + $sql = 'SELECT r.*, re.*, u.user_id, u.username FROM ' . REPORTS_TABLE . ' r, ' . USERS_TABLE . ' u, ' . REASONS_TABLE . " re WHERE r.post_id = $post_id AND r.reason_id = re.reason_id @@ -250,7 +170,7 @@ function mcp_post_details($id, $mode, $action, $url) 'REASON_TITLE' => $user->lang['report_reasons']['TITLE'][strtoupper($row['reason_name'])], 'REASON_DESC' => $user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_name'])], 'REPORTER' => ($row['user_id'] != ANONYMOUS) ? $row['username'] : $user->lang['GUEST'], - 'U_REPORTER' => ($row['user_id'] != ANONYMOUS) ? "memberlist.$phpEx$SID&mode=viewprofile&u={$row['user_id']}" : '', + 'U_REPORTER' => ($row['user_id'] != ANONYMOUS) ? "{$phpbb_root_path}memberlist.$phpEx$SID&mode=viewprofile&u={$row['user_id']}" : '', 'USER_NOTIFY' => ($row['user_notify']) ? true : false, 'REPORT_TIME' => $user->format_date($row['report_time']), 'REPORT_TEXT' => str_replace("\n", '
', trim($row['report_text']))) @@ -260,7 +180,7 @@ function mcp_post_details($id, $mode, $action, $url) } $db->sql_freeresult($result); } - + // Get IP if ($auth->acl_get('m_ip', $post_info['forum_id'])) { @@ -294,11 +214,11 @@ function mcp_post_details($id, $mode, $action, $url) $template->assign_block_vars('userrow', array( 'USERNAME' => ($row['user_id'] == ANONYMOUS) ? $user->lang['GUEST'] : $row['username'], - 'NUM_POSTS' => $row['postings'], + 'NUM_POSTS' => $row['postings'], 'L_POST_S' => ($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") + 'U_PROFILE' => ($row['user_id'] == ANONYMOUS) ? '' : "{$phpbb_root_path}memberlist.$phpEx$SID&mode=viewprofile&u=" . $row['user_id'], + 'U_SEARCHPOSTS' => "{$phpbb_root_path}search.$phpEx$SID&author=" . urlencode($row['username']) . "&sr=topics") ); } $db->sql_freeresult($result); @@ -318,30 +238,58 @@ function mcp_post_details($id, $mode, $action, $url) $template->assign_block_vars('iprow', array( 'IP' => $row['poster_ip'], 'HOSTNAME' => $hostname, - 'NUM_POSTS' => $row['postings'], + 'NUM_POSTS' => $row['postings'], 'L_POST_S' => ($row['postings'] == 1) ? $user->lang['POST'] : $user->lang['POSTS'], 'U_LOOKUP_IP' => ($rdns_ip_num == $row['poster_ip'] || $rdns_ip_num == 'all') ? '' : "$url&i=$id&mode=post_details&rdns={$row['poster_ip']}#ip", - 'U_WHOIS' => "mcp.$phpEx$SID&i=$id&mode=whois&ip={$row['poster_ip']}") + 'U_WHOIS' => "{$phpbb_root_path}mcp.$phpEx$SID&i=$id&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 ($action != 'chgposter_search') + $user_select = ''; + ksort($users_ary); + foreach ($users_ary as $row) { - $user_select = ''; - ksort($users_ary); - foreach ($users_ary as $row) - { - $user_select .= '\n"; - } - $template->assign_var('S_USER_SELECT', $user_select); + $user_select .= '\n"; } + $template->assign_var('S_USER_SELECT', $user_select); } } +/** +* Changes a post's poster_id +*/ +function change_poster(&$post_info, $new_user) +{ + global $auth, $db; + + if ($new_user && $new_user != $post_info['user_id']) + { + $post_id = $post_info['post_id']; + + $sql = 'UPDATE ' . POSTS_TABLE . " + SET poster_id = $new_user + WHERE post_id = " . $post_id; + $db->sql_query($sql); + + if ($post_info['topic_last_post_id'] == $post_id || $post_info['forum_last_post_id'] == $post_id) + { + sync('topic', 'topic_id', $post_info['topic_id'], false, false); + sync('forum', 'forum_id', $post_info['forum_id'], false, false); + } + + // Renew post info + $post_info = get_post_data(array($post_id)); + + if (!sizeof($post_info)) + { + trigger_error($user->lang['POST_NOT_EXIST']); + } + + $post_info = $post_info[$post_id]; + } +} + ?> \ No newline at end of file diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php index e4879288a7..7109aecab7 100644 --- a/phpBB/includes/mcp/mcp_topic.php +++ b/phpBB/includes/mcp/mcp_topic.php @@ -11,11 +11,13 @@ /** * View topic in MCP */ -function mcp_topic_view($id, $mode, $action, $url) +function mcp_topic_view($id, $mode, $action) { global $SID, $phpEx, $phpbb_root_path, $config; global $template, $db, $user, $auth; + $url = "{$phpbb_root_path}mcp.$phpEx$SID" . extra_url(); + $user->add_lang('viewtopic'); $topic_id = request_var('t', 0); @@ -49,8 +51,6 @@ function mcp_topic_view($id, $mode, $action, $url) merge_posts($topic_id, $to_topic_id); $action = 'merge'; } - - $topics_per_page = ($topic_info['forum_topics_per_page']) ? $topic_info['forum_topics_per_page'] : $config['topics_per_page']; if ($action == 'split' && !$subject) { @@ -58,11 +58,10 @@ function mcp_topic_view($id, $mode, $action, $url) } // Jumpbox, sort selects and that kind of things - make_jumpbox($url . '&mode=forum_view', $topic_info['forum_id'], false, 'm_'); + make_jumpbox($url . "&i=$id&mode=forum_view", $topic_info['forum_id'], false, 'm_'); $where_sql = ($action == 'reports') ? 'WHERE post_reported = 1 AND ' : 'WHERE'; mcp_sorting('viewtopic', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $topic_info['forum_id'], $topic_id, $where_sql); - $forum_topics = ($total == -1) ? $topic_info['forum_topics'] : $total; $limit_time_sql = ($sort_days) ? 'AND t.topic_last_post_time >= ' . (time() - ($sort_days * 86400)) : ''; if ($total == -1) @@ -70,6 +69,10 @@ function mcp_topic_view($id, $mode, $action, $url) $total = $topic_info['topic_replies'] + 1; } $posts_per_page = max(0, request_var('posts_per_page', intval($config['posts_per_page']))); + if ($posts_per_page == 0) + { + $posts_per_page = $total; + } $sql = 'SELECT u.username, u.user_colour, p.* FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u @@ -137,9 +140,9 @@ function mcp_topic_view($id, $mode, $action, $url) 'S_CHECKBOX' => $s_checkbox, 'S_POST_REPORTED' => ($row['post_reported']) ? true : false, 'S_POST_UNAPPROVED' => ($row['post_approved']) ? false : true, - - 'U_POST_DETAILS' => "$url&p={$row['post_id']}&mode=post_details", - 'U_MCP_APPROVE' => "mcp.$phpEx$SID&i=queue&mode=approve&post_id_list[]=" . $row['post_id']) + + 'U_POST_DETAILS' => "$url&i=$id&p={$row['post_id']}&mode=post_details", + 'U_MCP_APPROVE' => "{$phpbb_root_path}mcp.$phpEx$SID&i=queue&mode=approve&post_id_list[]=" . $row['post_id']) ); unset($rowset[$i]); @@ -157,7 +160,7 @@ function mcp_topic_view($id, $mode, $action, $url) if ($to_topic_id) { $to_topic_info = get_topic_data(array($to_topic_id), 'm_merge'); - + if (!sizeof($to_topic_info)) { $to_topic_id = 0; @@ -166,7 +169,6 @@ function mcp_topic_view($id, $mode, $action, $url) { $to_topic_info = $to_topic_info[$to_topic_id]; } - if (!$to_topic_info['enable_icons']) { @@ -177,10 +179,10 @@ function mcp_topic_view($id, $mode, $action, $url) $template->assign_vars(array( 'TOPIC_TITLE' => $topic_info['topic_title'], - 'U_VIEWTOPIC' => "viewtopic.$phpEx$SID&f=" . $topic_info['forum_id'] . '&t=' . $topic_info['topic_id'], + 'U_VIEWTOPIC' => "{$phpbb_root_path}viewtopic.$phpEx$SID&f=" . $topic_info['forum_id'] . '&t=' . $topic_info['topic_id'], 'TO_TOPIC_ID' => $to_topic_id, - 'TO_TOPIC_INFO' => ($to_topic_id) ? sprintf($user->lang['YOU_SELECTED_TOPIC'], $to_topic_id, '' . $to_topic_info['topic_title'] . '') : '', + 'TO_TOPIC_INFO' => ($to_topic_id) ? sprintf($user->lang['YOU_SELECTED_TOPIC'], $to_topic_id, '' . $to_topic_info['topic_title'] . '') : '', 'SPLIT_SUBJECT' => $subject, 'POSTS_PER_PAGE' => $posts_per_page, @@ -189,7 +191,7 @@ function mcp_topic_view($id, $mode, $action, $url) 'REPORTED_IMG' => $user->img('icon_reported', 'POST_REPORTED', false, true), 'UNAPPROVED_IMG' => $user->img('icon_unapproved', 'POST_UNAPPROVED', false, true), - 'S_MCP_ACTION' => "$url&mode=$mode&action=$action&start=$start", + 'S_MCP_ACTION' => "$url&i=$id&mode=$mode&action=$action&start=$start", 'S_FORUM_SELECT' => '', 'S_CAN_SPLIT' => ($auth->acl_get('m_split', $topic_info['forum_id']) && $action != 'merge') ? true : false, 'S_CAN_MERGE' => ($auth->acl_get('m_merge', $topic_info['forum_id']) && $action != 'split') ? true : false, @@ -201,11 +203,13 @@ function mcp_topic_view($id, $mode, $action, $url) 'S_SHOW_TOPIC_ICONS'=> $s_topic_icons, 'S_TOPIC_ICON' => $icon_id, - 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], "", ''), - 'RETURN_FORUM' => sprintf($user->lang['RETURN_FORUM'], "", ''), + 'U_SELECT_TOPIC' => "$url&i=$id&mode=forum_view&action=merge_select", + + 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], "", ''), + 'RETURN_FORUM' => sprintf($user->lang['RETURN_FORUM'], "", ''), 'PAGE_NUMBER' => on_page($total, $posts_per_page, $start), - 'PAGINATION' => (!$posts_per_page) ? '' : generate_pagination("mcp.$phpEx$SID&t=" . $topic_info['topic_id'] . "&mode=$mode&action=$action&to_topic_id=$to_topic_id&posts_per_page=$posts_per_page&st=$sort_days&sk=$sort_key&sd=$sort_dir", $total, $posts_per_page, $start), + 'PAGINATION' => (!$posts_per_page) ? '' : generate_pagination("{$phpbb_root_path}mcp.$phpEx$SID&i=$id&t=" . $topic_info['topic_id'] . "&mode=$mode&action=$action&to_topic_id=$to_topic_id&posts_per_page=$posts_per_page&st=$sort_days&sk=$sort_key&sd=$sort_dir", $total, $posts_per_page, $start), 'TOTAL' => $total) ); } @@ -213,18 +217,18 @@ function mcp_topic_view($id, $mode, $action, $url) /** * Split topic */ -function split_topic($mode, $topic_id, $to_forum_id, $subject) +function split_topic($action, $topic_id, $to_forum_id, $subject) { global $db, $template, $user, $phpEx, $SID, $phpbb_root_path, $auth; $post_id_list = request_var('post_id_list', array(0)); $start = request_var('start', 0); - + if (!sizeof($post_id_list)) { trigger_error('NO_POST_SELECTED'); } - + if (!($forum_id = check_ids($post_id_list, POSTS_TABLE, 'post_id', 'm_split'))) { return; @@ -274,11 +278,12 @@ function split_topic($mode, $topic_id, $to_forum_id, $subject) $redirect = request_var('redirect', $user->data['session_page']); $s_hidden_fields = build_hidden_fields(array( + 'i' => 'main', 'post_id_list' => $post_id_list, 'f' => $forum_id, 'mode' => 'topic_view', 'start' => $start, - 'action' => $mode, + 'action' => $action, 't' => $topic_id, 'redirect' => $redirect, 'subject' => $subject, @@ -289,7 +294,7 @@ function split_topic($mode, $topic_id, $to_forum_id, $subject) if (confirm_box(true)) { - if ($mode == 'split_beyond') + if ($action == 'split_beyond') { mcp_sorting('viewtopic', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id, $topic_id); $limit_time_sql = ($sort_days) ? 'AND t.topic_last_post_time >= ' . (time() - ($sort_days * 86400)) : ''; @@ -349,7 +354,7 @@ function split_topic($mode, $topic_id, $to_forum_id, $subject) 'icon_id' => $icon_id, 'topic_approved'=> 1 ); - + $sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); $db->sql_query($sql); @@ -357,7 +362,7 @@ function split_topic($mode, $topic_id, $to_forum_id, $subject) move_posts($post_id_list, $to_topic_id); // Change topic title of first post - $sql = 'UPDATE ' . POSTS_TABLE . " + $sql = 'UPDATE ' . POSTS_TABLE . " SET post_subject = '" . $db->sql_escape($subject) . "' WHERE post_id = {$post_id_list[0]}"; $db->sql_query($sql); @@ -365,11 +370,11 @@ function split_topic($mode, $topic_id, $to_forum_id, $subject) $success_msg = 'TOPIC_SPLIT_SUCCESS'; // Link back to both topics - $return_link = sprintf($user->lang['RETURN_TOPIC'], '', '') . '

' . sprintf($user->lang['RETURN_NEW_TOPIC'], '', ''); + $return_link = sprintf($user->lang['RETURN_TOPIC'], "', '') . '

' . sprintf($user->lang['RETURN_NEW_TOPIC'], "', ''); } else { - confirm_box(false, ($mode == 'split_all') ? 'SPLIT_TOPIC_ALL' : 'SPLIT_TOPIC_BEYOND', $s_hidden_fields); + confirm_box(false, ($action == 'split_all') ? 'SPLIT_TOPIC_ALL' : 'SPLIT_TOPIC_BEYOND', $s_hidden_fields); } $redirect = request_var('redirect', "index.$phpEx$SID"); @@ -415,13 +420,13 @@ function merge_posts($topic_id, $to_topic_id) $post_id_list = request_var('post_id_list', array(0)); $start = request_var('start', 0); - + if (!sizeof($post_id_list)) { $template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']); return; } - + if (!($forum_id = check_ids($post_id_list, POSTS_TABLE, 'post_id', 'm_merge'))) { return; @@ -430,6 +435,7 @@ function merge_posts($topic_id, $to_topic_id) $redirect = request_var('redirect', $user->data['session_page']); $s_hidden_fields = build_hidden_fields(array( + 'i' => 'main', 'post_id_list' => $post_id_list, 'to_topic_id' => $to_topic_id, 'mode' => 'topic_view', @@ -447,7 +453,7 @@ function merge_posts($topic_id, $to_topic_id) move_posts($post_id_list, $to_topic_id); add_log('mod', $to_forum_id, $to_topic_id, 'LOG_MERGE', $topic_data['topic_title']); - + // Message and return links $success_msg = 'POSTS_MERGED_SUCCESS'; @@ -480,7 +486,7 @@ function merge_posts($topic_id, $to_topic_id) } else { - meta_refresh(3, "viewtopic.$phpEx$SID&f=$to_forum_id&t=$to_topic_id"); + meta_refresh(3, "{$phpbb_root_path}viewtopic.$phpEx$SID&f=$to_forum_id&t=$to_topic_id"); trigger_error($user->lang[$success_msg] . '

' . $return_link); } } diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 4b97375367..7a4c424192 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -441,6 +441,7 @@ $lang = array_merge($lang, array( 'VIEWING_UCP' => 'Viewing user control panel', 'VIEWS' => 'Views', 'VIEW_BOOKMARKS' => 'View bookmarks', + 'VIEW_FORUM_LOGS' => 'View Logs', 'VIEW_LATEST_POST' => 'View latest post', 'VIEW_NEWEST_POST' => 'View newest post', 'VIEW_NOTES' => 'View user notes', diff --git a/phpBB/language/en/mcp.php b/phpBB/language/en/mcp.php index 850dee2c23..23e6099e12 100644 --- a/phpBB/language/en/mcp.php +++ b/phpBB/language/en/mcp.php @@ -18,7 +18,7 @@ if (empty($lang) || !is_array($lang)) $lang = array(); } -// DEVELOPERS PLEASE NOTE +// DEVELOPERS PLEASE NOTE // // Placeholders can now contain order information, e.g. instead of // 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows @@ -30,10 +30,10 @@ if (empty($lang) || !is_array($lang)) $lang = array_merge($lang, array( 'ACTION' => 'Action', - 'ADD_FEEDBACK' => 'Add feedback', - 'ADD_FEEDBACK_EXPLAIN' => 'If you would like to add a report on this please fill out the following form. Only use plain text; HTML, BBCode, etc. are not permitted.', - 'ADD_WARNING' => 'Add warning', - 'ADD_WARNING_EXPLAIN' => 'To send a warning to this user please fill out the following form. Only use plain text; HTML, BBCode, etc. are not permitted.', + 'ADD_FEEDBACK' => 'Add feedback', + 'ADD_FEEDBACK_EXPLAIN' => 'If you would like to add a report on this please fill out the following form. Only use plain text; HTML, BBCode, etc. are not permitted.', + 'ADD_WARNING' => 'Add warning', + 'ADD_WARNING_EXPLAIN' => 'To send a warning to this user please fill out the following form. Only use plain text; HTML, BBCode, etc. are not permitted.', 'ALL_ENTRIES' => 'All entries', 'ALREADY_REPORTED' => 'This post has already been reported', 'ALREADY_WARNED' => 'A warning has already been issued for this post', @@ -75,7 +75,7 @@ $lang = array_merge($lang, array( 'FORUM_STYLE' => 'Forum Style', 'GLOBAL_ANNOUNCEMENT' => 'Global Announcement', - + 'IP_INFO' => 'IP Information', 'LATEST_LOGS' => 'Latest 5 logged actions', @@ -112,6 +112,7 @@ $lang = array_merge($lang, array( 'LOG_USER_LOCK' => 'User locked own topic
» %s', 'LOG_USER_MOVE_POSTS_USER' => 'Moved all posts to forum "%s"', 'LOG_USER_REACTIVATE_USER' => 'Forced user account re-activation', + 'LOGIN_EXPLAIN_MCP' => 'To moderate this forum you must login.', 'LOGVIEW_VIEWTOPIC' => 'View Topic', 'LOGVIEW_VIEWLOGS' => 'View Topic Log', 'LOGVIEW_VIEWFORUM' => 'View Forum', @@ -201,10 +202,10 @@ $lang = array_merge($lang, array( 'POST_APPROVED_SUCCESS' => 'The selected post has been approved', 'POST_DELETED_SUCCESS' => 'The selected post has been successfully removed from the database', 'POST_DETAILS' => 'Post details', - 'POST_LOCKED_SUCCESS' => 'Post locked successsfully', + 'POST_LOCKED_SUCCESS' => 'Post locked successfully', 'POST_NOT_EXIST' => 'The post you requested does not exist', 'POST_REPORTED_SUCCESS' => 'This post has been successfully reported', - 'POST_UNLOCKED_SUCCESS' => 'Post unlocked successsfully', + 'POST_UNLOCKED_SUCCESS' => 'Post unlocked successfully', 'POST_UNRATED_SUCCESS' => 'Post unrated successfully', 'READ_USERNOTES' => 'User notes', @@ -274,7 +275,7 @@ $lang = array_merge($lang, array( '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?', + '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 a89b1c9172..2f00a0ab26 100644 --- a/phpBB/mcp.php +++ b/phpBB/mcp.php @@ -31,7 +31,7 @@ $module = new p_master(); // Basic parameter data $id = request_var('i', ''); -if (is_array($_REQUEST['mode'])) +if (isset($_REQUEST['mode']) && is_array($_REQUEST['mode'])) { list($mode, ) = each(request_var('mode', array(''))); } @@ -40,12 +40,6 @@ else $mode = request_var('mode', ''); } -if (isset($_REQUEST['quick'])) -{ - $mode = request_var('mode2', ''); - $action = ''; -} - // Make sure we are using the correct module if ($mode == 'approve' || $mode == 'disapprove') { @@ -69,161 +63,141 @@ $action_ary = request_var('action', array('' => 0)); if (sizeof($action_ary)) { - list($action, ) = each($action); + list($action, ) = each($action_ary); } unset($action_ary); -if ($action == 'merge_select') -{ - $mode = 'forum_view'; -} - if ($mode == 'topic_logs') { $id = 'logs'; $quickmod = false; } -// Topic view modes -if (in_array($mode, array('split', 'split_all', 'split_beyond', 'merge', 'merge_posts'))) +$post_id = request_var('p', 0); +$topic_id = request_var('t', 0); +$forum_id = request_var('f', 0); +$user_id = request_var('u', 0); +$username = request_var('username', ''); + +if ($post_id) { - $_REQUEST['action'] = $action = $mode; - $mode = 'topic_view'; - $quickmod = false; + // We determine the topic and forum id here, to make sure the moderator really has moderative rights on this post + $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']; } -// Forum view modes -if (in_array($mode, array('resync'))) +if ($topic_id && !$forum_id) { - $_REQUEST['action'] = $action = $mode; - $mode = 'forum_view'; - $quickmod = false; + $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']; } -if (!$quickmod) +// If we do not have a forum id and the user is not a super moderator (global options are set to false, even if the user is able to moderator at least one forum +if (!$forum_id && !$auth->acl_get('m_')) { - $post_id = request_var('p', 0); - $topic_id = request_var('t', 0); - $forum_id = request_var('f', 0); - $user_id = request_var('u', 0); - $username = request_var('username', ''); + $forum_list = get_forum_list('m_'); - - if ($post_id) + if (!sizeof($forum_list)) { - // We determine the topic and forum id here, to make sure the moderator really has moderative rights on this post - $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']; + trigger_error('MODULE_NOT_EXIST'); } - if ($topic_id && !$forum_id) + // We do not check all forums, only the first one should be sufficiant. + $forum_id = $forum_list[0]; +} + +if($forum_id) +{ + $module->acl_forup_id = $forum_id; +} + +// Instantiate module system and generate list of available modules +$module->list_modules('mcp'); + +if ($quickmod) +{ + $mode = 'quickmod'; + + switch ($action) { - $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); + case 'lock': + case 'unlock': + case 'lock_post': + case 'unlock_post': + case 'make_sticky': + case 'make_announce': + case 'make_global': + case 'make_normal': + case 'fork': + case 'move': + case 'delete_post': + case 'delete_topic': + $module->load('mcp', 'main', 'quickmod'); + exit; - $forum_id = (int) $row['forum_id']; + case 'topic_logs': + $module->set_active('logs', 'topic_logs'); + break; + + default: + trigger_error("$action not allowed as quickmod"); } - - // If we do not have a forum id and the user is not a super moderator (global options are set to false, even if the user is able to moderator at least one forum - if (!$forum_id && !$auth->acl_get('m_')) - { - $forum_list = get_forum_list('m_'); - - if (!sizeof($forum_list)) - { - trigger_error('MODULE_NOT_EXIST'); - } - - // We do not check all forums, only the first one should be sufficiant. - $forum_id = $forum_list[0]; - } - - if($forum_id) - { - $module->acl_forup_id = $forum_id; - } - - // Instantiate module system and generate list of available modules - $module->list_modules('mcp'); - +} +else +{ // Select the active module $module->set_active($id, $mode); - - // Hide some of the options if we don't have the relevant information to use them - if (!$post_id) - { - $module->set_display('post_details', false); - $module->set_display('warn_post', false); - } - if (!$topic_id) - { - $module->set_display('topic_view', false); - $module->set_display('topic_logs', false); - } - if (!$forum_id) - { - $module->set_display('forum_view', false); - $module->set_display('forum_logs', false); - } - if (!$user_id && $username == '') - { - $module->set_display('user_notes', false); - $module->set_display('warn_user', false); - } - - // Load and execute the relevant module - $module->load_active(); - - // Assign data to the template engine for the list of modules - $module->assign_tpl_vars("mcp.$phpEx$SID"); - - // Generate the page - page_header($user->lang['MCP_MAIN']); - - $template->set_filenames(array( - 'body' => $module->get_tpl_name()) - ); - - page_footer(); - } -switch ($mode) +// Hide some of the options if we don't have the relevant information to use them +if (!$post_id) { - case 'lock': - case 'unlock': - case 'lock_post': - case 'unlock_post': - $module->load('mcp', 'main', $mode); - break; - case 'make_sticky': - case 'make_announce': - case 'make_global': - case 'make_normal': - $module->load('mcp', 'main', $mode); - break; - case 'fork': - case 'move': - $module->load('mcp', 'main', $mode); - break; - case 'delete_post': - case 'delete_topic': - $module->load('mcp', 'main', $mode); - break; - default: - trigger_error("$mode not allowed as quickmod"); + $module->set_display('post_details', false); + $module->set_display('warn_post', false); } +if (!$topic_id) +{ + $module->set_display('topic_view', false); + $module->set_display('topic_logs', false); +} +if (!$forum_id) +{ + $module->set_display('forum_view', false); + $module->set_display('forum_logs', false); +} +if (!$user_id && $username == '') +{ + $module->set_display('user_notes', false); + $module->set_display('warn_user', false); +} + +// Load and execute the relevant module +$module->load_active(); + +// Assign data to the template engine for the list of modules +$module->assign_tpl_vars("mcp.$phpEx$SID"); + +// Generate the page +page_header($user->lang['MCP_MAIN']); + +$template->set_filenames(array( + 'body' => $module->get_tpl_name()) +); + +page_footer(); /** * Functions used to generate additional URL paramters @@ -573,7 +547,4 @@ function check_ids(&$ids, $table, $sql_id, $acl_list = false) return $forum_id; } -// LITTLE HELPER -// - ?> \ No newline at end of file diff --git a/phpBB/styles/subSilver/template/mcp_forum.html b/phpBB/styles/subSilver/template/mcp_forum.html index cd5e368e79..834e7852e5 100644 --- a/phpBB/styles/subSilver/template/mcp_forum.html +++ b/phpBB/styles/subSilver/template/mcp_forum.html @@ -2,6 +2,8 @@ + {L_VIEW_FORUM_LOGS} +
@@ -43,7 +45,7 @@ - +
{L_DISPLAY_TOPICS}: {S_SELECT_SORT_DAYS} {L_SORT_BY} {S_SELECT_SORT_KEY} {S_SELECT_SORT_DIR} 
- diff --git a/phpBB/styles/subSilver/template/mcp_header.html b/phpBB/styles/subSilver/template/mcp_header.html index 0d85855b54..f07d6121dd 100644 --- a/phpBB/styles/subSilver/template/mcp_header.html +++ b/phpBB/styles/subSilver/template/mcp_header.html @@ -67,7 +67,7 @@ function marklist(form_name, status)
{L_MESSAGE}

{MESSAGE}

{return_links.MESSAGE_LINK}

@@ -76,11 +76,11 @@ function marklist(form_name, status) - +
- +
{L_PLEASE_CONFIRM}

{CONFIRM_MESSAGE}

{S_HIDDEN_FIELDS}  

diff --git a/phpBB/styles/subSilver/template/mcp_post.html b/phpBB/styles/subSilver/template/mcp_post.html index 702e01ad76..6a1d7e8147 100644 --- a/phpBB/styles/subSilver/template/mcp_post.html +++ b/phpBB/styles/subSilver/template/mcp_post.html @@ -1,6 +1,6 @@ - +
@@ -13,7 +13,7 @@ - + @@ -46,47 +46,6 @@ - -
- - - -
{L_POST_DETAILS}
{L_POSTER}: {POSTER_NAME}   [ {L_READ_PROFILE} ]{POSTER_NAME}   [ {L_READ_PROFILE} | {L_VIEW_NOTES} | {L_WARN_USER} ]
- - - - - - colspan="2">Report by: {usernotes.REPORT_BY} on {usernotes.REPORT_AT}
{usernotes.ACTION} -
- - - - - - - -
{L_FEEDBACK}
 
-
- - - - - - - - - - - - - - -
{L_ADD_FEEDBACK}
{L_ADD_FEEDBACK_EXPLAIN}
  
- - - -
@@ -125,15 +84,15 @@ -
+ {L_CHANGE_POSTER} -
+
[ {L_FIND_USERNAME} ]
-
+ {L_MOD_OPTIONS}
diff --git a/phpBB/styles/subSilver/template/mcp_topic.html b/phpBB/styles/subSilver/template/mcp_topic.html index c6642b720f..6669f62985 100644 --- a/phpBB/styles/subSilver/template/mcp_topic.html +++ b/phpBB/styles/subSilver/template/mcp_topic.html @@ -36,7 +36,7 @@ {L_MERGE_TOPIC_ID} - + {L_SELECT_TOPIC} @@ -117,13 +117,13 @@ - -   +   diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 51e29b388f..454dca6d27 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -338,7 +338,7 @@ if ($hilit_words) { if (trim($word)) { - $highlight_match .= (($highlight_match != '') ? '|' : '') . str_replace('\*', '\w*?', preg_quote(urlencode($word), '#')); + $highlight_match .= (($highlight_match != '') ? '|' : '') . str_replace('*', '\w*?', preg_quote($word, '#')); } } @@ -486,7 +486,7 @@ $template->assign_vars(array( 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days, 'S_TOPIC_ACTION' => "{$phpbb_root_path}viewtopic.$phpEx$SID&f=$forum_id&t=$topic_id&start=$start", - 'S_TOPIC_MOD' => ($topic_mod != '') ? '' : '', + 'S_TOPIC_MOD' => ($topic_mod != '') ? '' : '', 'S_MOD_ACTION' => "{$phpbb_root_path}mcp.$phpEx?sid=" . $user->session_id . "&t=$topic_id&f=$forum_id&quickmod=1", 'S_DISPLAY_SEARCHBOX' => ($auth->acl_get('f_search', $forum_id)) ? true : false,