MCP View topic quick mod tools do not work
Posted October 15th 2013, 11:32pm
I posted this on phpBB.com (https://www.phpbb.com/community/viewtop ... &t=2205021), but I don't think I will get much help there because they'll insist it's a mod and get support from the mod's author when I don't even know IF it's a mod and WHAT mod it is if it is.

I discovered today that several of my quick-mod tools no longer function, the ones when you go to a topic --> MCP, I mean. I tried splitting a post to a new topic, but nothing happens when I click "submit" (I go to the topic, choose Split topic. I get taken to the MCP. I choose the post then choose Split selected posts and click submit.). When splitting the topic I made sure I filled in the new topic title, but that didn't help.

What could be the reason this quick-mod tool no longer work? I have not installed any mods that had anything to do with the quick-mod tools recently. I don't really think it's mods and I have too many to waddle through to figure out if one is the culprit. This problem might have been there for weeks or months...and I've only now just discovered it.

It's all the tools that appear in the MCP View Topic (at the bottom, with the dropdown "Select desired action". When viewing a topic outside of the MCP, I can use some of the tools, like move topic, merge topics, change to sticky.


I really don't know where the issue is. I checked mcp_topic.html, includes/mcp/mcp_topic.php and mcp.php but couldn't find anything out of the ordinary. I was hoping someone here could suggest what the problem might be (and help in general), why nothing happens when I click "submit" :/

One of the biggest issues is that I just discovered this recently and it might have been there for weeks or even months...
φ
Posts: 103
Joined: July 19th 2012, 8:17pm
Location: Pennsylvania
Likes Given: 9
Likes Received: 8
MCP View topic quick mod tools do not work
Posted October 16th 2013, 8:34am
Have you checked your browser's error log? This sounds like some sort of javascript error, particularly since the template and PHP files seem fine.
φ
Posts: 1599
Joined: March 12th 2009, 11:00pm
Location: Uncertain due to momentum
Likes Given: 26
Likes Received: 357
MCP View topic quick mod tools do not work
Posted October 16th 2013, 9:28am
Oh, not yet. Gonna look at it now
φ
Posts: 103
Joined: July 19th 2012, 8:17pm
Location: Pennsylvania
Likes Given: 9
Likes Received: 8
MCP View topic quick mod tools do not work
Posted October 17th 2013, 12:56am
Okay I checked the browser error log. There's nothing. Doesn't seem to be a javascript error?

here's mcp.php
<?php
/**
*
* @package mcp
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
require($phpbb_root_path . 'includes/functions_module.' . $phpEx);



// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('mcp');

$module = new p_master();

// Setting a variable to let the style designer know where he is...
$template->assign_var('S_IN_MCP', true);

// Basic parameter data
$id = request_var('i', '');

if (isset($_REQUEST['mode']) && is_array($_REQUEST['mode']))
{
$mode = request_var('mode', array(''));
list($mode, ) = each($mode);
}
else
{
$mode = request_var('mode', '');
}

// Only Moderators can go beyond this point
if (!$user->data['is_registered'])
{
if ($user->data['is_bot'])
{
redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
}

login_box('', $user->lang['LOGIN_EXPLAIN_MCP']);
}

$quickmod = (isset($_REQUEST['quickmod'])) ? true : false;
$action = request_var('action', '');
$action_ary = request_var('action', array('' => 0));

$forum_action = request_var('forum_action', '');
if ($forum_action !== '' && !empty($_POST['sort']))
{
$action = $forum_action;
}

if (sizeof($action_ary))
{
list($action, ) = each($action_ary);
}
unset($action_ary);

if ($mode == 'topic_logs')
{
$id = 'logs';
$quickmod = false;
}

$post_id = request_var('p', 0);
$topic_id = request_var('t', 0);
$forum_id = request_var('f', 0);
$report_id = request_var('r', 0);
$user_id = request_var('u', 0);
$username = utf8_normalize_nfc(request_var('username', '', true));

if ($post_id)
{
// 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']) ? $row['forum_id'] : $forum_id;
}
else if ($topic_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'];
}

// If the user doesn't have any moderator powers (globally or locally) he can't access the mcp
if (!$auth->acl_getf_global('m_'))
{
// Except he is using one of the quickmod tools for users
$user_quickmod_actions = array(
'lock' => 'f_user_lock',
'make_sticky' => 'f_sticky',
'make_announce' => 'f_announce',
'make_global' => 'f_announce',
'make_normal' => array('f_announce', 'f_sticky')
,
'masspm' => 'u_masspm'
);

$allow_user = false;
if ($quickmod && isset($user_quickmod_actions[$action]) && $user->data['is_registered'] && $auth->acl_gets($user_quickmod_actions[$action], $forum_id))
{
$topic_info = get_topic_data(array($topic_id));
if ($topic_info[$topic_id]['topic_poster'] == $user->data['user_id'])
{
$allow_user = true;
}
else if($action == 'masspm')
{
$allow_user = true;
}
}

if (!$allow_user)
{
trigger_error('NOT_AUTHORISED');
}
}

// if the user cannot read the forum he tries to access then we won't allow mcp access either
if ($forum_id && !$auth->acl_get('f_read', $forum_id))
{
trigger_error('NOT_AUTHORISED');
}

if ($forum_id)
{
$module->acl_forum_id = $forum_id;
}

// Instantiate module system and generate list of available modules
$module->list_modules('mcp');

if ($quickmod)
{
$mode = 'quickmod';

switch ($action)
{
case 'masspm':
// We're switching locations, let the style designer know where they are...
$template->assign_var('S_IN_MCP', false);
$template->assign_var('S_IN_UCP', true);

// Make sure the proper lang is available to "$module->list_modules()"
$user->setup('ucp');

// Fresh $module with proper nav
$module = new p_master();
$module->list_modules('ucp');

// Set these manually for for the "request_var()" calls in "compose_pm()" to work with
$_REQUEST['action'] = 'post';
$_REQUEST['address_list'] = array('u' => array());

// Gather poster_id list for the topic
$sql = 'SELECT DISTINCT poster_id
FROM ' . POSTS_TABLE . '
WHERE forum_id = ' . $forum_id . '
AND topic_id = ' . $topic_id;
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$_REQUEST['address_list']['u'][$row['poster_id']] = 'to';
}
$db->sql_freeresult($result);

// Remove author from the recipients
if(isset($_REQUEST['address_list']['u'][$user->data['user_id']]))
{
unset($_REQUEST['address_list']['u'][$user->data['user_id']]);
}

// Fetch topic title for subject and message
$sql = 'SELECT topic_title
FROM ' . TOPICS_TABLE . '
WHERE forum_id = ' . $forum_id . '
AND topic_id = ' . $topic_id;
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$row['topic_title'] = censor_text($row['topic_title']);

if ($config['allow_post_links'])
{
$_REQUEST['message'] = $user->lang['TOPIC'] . ": [url=" . generate_board_url() . "/viewtopic.$phpEx?f={$forum_id}&t={$topic_id}]{$row['topic_title']}[/url]\n\n";
}
else
{
$_REQUEST['message'] = $user->lang['TOPIC'] . ': ' . $row['topic_title'] . " (" . generate_board_url() . "/viewtopic.$phpEx?f={$forum_id}&t={$topic_id})\n\n";
}
$_REQUEST['subject'] = 'Re: ' . $row['topic_title'];
$_POST['preview'] = true;

// Setup a form token good for this request only
// ANONYMOUS is already screened by the MCP itself so that portion of generation has been omited
$now = $_REQUEST['creation_time'] = $_POST['creation_time'] = time();
$_REQUEST['form_token'] = $_POST['form_token'] = sha1($now . $user->data['user_form_salt'] . 'ucp_pm_compose');
}
$db->sql_freeresult($result);

// Continue as if in UCP
$module->set_active('pm', 'compose');
$module->load_active();
$module->assign_tpl_vars(append_sid("{$phpbb_root_path}ucp.$phpEx"));
$module->display($module->get_page_title(), false);
break;
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');
return;
break;

case 'topic_logs':
// Reset start parameter if we jumped from the quickmod dropdown
if (request_var('start', 0))
{
$_REQUEST['start'] = 0;
}

$module->set_active('logs', 'topic_logs');
break;

case 'merge_topic':
$module->set_active('main', 'forum_view');
break;

case 'split':
case 'merge':
$module->set_active('main', 'topic_view');
break;

default:
trigger_error("$action not allowed as quickmod", E_USER_ERROR);
break;
}
}
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('main', 'post_details', false);
$module->set_display('warn', 'warn_post', false);
}

if ($mode == '' || $mode == 'unapproved_topics' || $mode == 'unapproved_posts')
{
$module->set_display('queue', 'approve_details', false);
}

if ($mode == '' || $mode == 'reports' || $mode == 'reports_closed' || $mode == 'pm_reports' || $mode == 'pm_reports_closed' || $mode == 'pm_report_details')
{
$module->set_display('reports', 'report_details', false);
}

if ($mode == '' || $mode == 'reports' || $mode == 'reports_closed' || $mode == 'pm_reports' || $mode == 'pm_reports_closed' || $mode == 'report_details')
{
$module->set_display('pm_reports', 'pm_report_details', false);
}

if (!$topic_id)
{
$module->set_display('main', 'topic_view', false);
$module->set_display('logs', 'topic_logs', false);
}

if (!$forum_id)
{
$module->set_display('main', 'forum_view', false);
$module->set_display('logs', 'forum_logs', false);
}

if (!$user_id && $username == '')
{
$module->set_display('notes', 'user_notes', false);
$module->set_display('warn', '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(append_sid("{$phpbb_root_path}mcp.$phpEx"));

// Generate urls for letting the moderation control panel being accessed in different modes
$template->assign_vars(array(
'U_MCP' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main'),
'U_MCP_FORUM' => ($forum_id) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&mode=forum_view&f=$forum_id") : '',
'U_MCP_TOPIC' => ($forum_id && $topic_id) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&mode=topic_view&t=$topic_id") : '',
'U_MCP_POST' => ($forum_id && $topic_id && $post_id) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&mode=post_details&t=$topic_id&p=$post_id") : '',
));

// Generate the page, do not display/query online list
$module->display($module->get_page_title(), false);

/**
* Functions used to generate additional URL paramters
*/
function _module__url($mode, &$module_row)
{
return extra_url();
}

function _module_notes_url($mode, &$module_row)
{
if ($mode == 'front')
{
return '';
}

global $user_id;
return ($user_id) ? "&u=$user_id" : '';
}

function _module_warn_url($mode, &$module_row)
{
if ($mode == 'front' || $mode == 'list')
{
global $forum_id;

return ($forum_id) ? "&f=$forum_id" : '';
}

if ($mode == 'warn_post')
{
global $forum_id, $post_id;

$url_extra = ($forum_id) ? "&f=$forum_id" : '';
$url_extra .= ($post_id) ? "&p=$post_id" : '';

return $url_extra;
}
else
{
global $user_id;

return ($user_id) ? "&u=$user_id" : '';
}
}

function _module_main_url($mode, &$module_row)
{
return extra_url();
}

function _module_logs_url($mode, &$module_row)
{
return extra_url();
}

function _module_ban_url($mode, &$module_row)
{
return extra_url();
}

function _module_queue_url($mode, &$module_row)
{
return extra_url();
}

function _module_reports_url($mode, &$module_row)
{
return extra_url();
}

function extra_url()
{
global $forum_id, $topic_id, $post_id, $report_id, $user_id;

$url_extra = '';
$url_extra .= ($forum_id) ? "&f=$forum_id" : '';
$url_extra .= ($topic_id) ? "&t=$topic_id" : '';
$url_extra .= ($post_id) ? "&p=$post_id" : '';
$url_extra .= ($user_id) ? "&u=$user_id" : '';
$url_extra .= ($report_id) ? "&r=$report_id" : '';

return $url_extra;
}

/**
* Get simple topic data
*/
function get_topic_data($topic_ids, $acl_list = false, $read_tracking = false)
{
global $auth, $db, $config, $user;
static $rowset = array();

$topics = array();

if (!sizeof($topic_ids))
{
return array();
}

// cache might not contain read tracking info, so we can't use it if read
// tracking information is requested
if (!$read_tracking)
{
$cache_topic_ids = array_intersect($topic_ids, array_keys($rowset));
$topic_ids = array_diff($topic_ids, array_keys($rowset));
}
else
{
$cache_topic_ids = array();
}

if (sizeof($topic_ids))
{
$sql_array = array(
'SELECT' => 't.*, f.*',

'FROM' => array(
TOPICS_TABLE => 't',
),

'LEFT_JOIN' => array(
array(
'FROM' => array(FORUMS_TABLE => 'f'),
'ON' => 'f.forum_id = t.forum_id'
)
),

'WHERE' => $db->sql_in_set('t.topic_id', $topic_ids)
);

if ($read_tracking && $config['load_db_lastread'])
{
$sql_array['SELECT'] .= ', tt.mark_time, ft.mark_time as forum_mark_time';

$sql_array['LEFT_JOIN'][] = array(
'FROM' => array(TOPICS_TRACK_TABLE => 'tt'),
'ON' => 'tt.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = tt.topic_id'
);

$sql_array['LEFT_JOIN'][] = array(
'FROM' => array(FORUMS_TRACK_TABLE => 'ft'),
'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND t.forum_id = ft.forum_id'
);
}

$sql = $db->sql_build_query('SELECT', $sql_array);
$result = $db->sql_query($sql);

while ($row = $db->sql_fetchrow($result))
{
if (!$row['forum_id'])
{
// Global Announcement?
$row['forum_id'] = request_var('f', 0);
}

$rowset[$row['topic_id']] = $row;

if ($acl_list && !$auth->acl_gets($acl_list, $row['forum_id']))
{
continue;
}

$topics[$row['topic_id']] = $row;
}
$db->sql_freeresult($result);
}

foreach ($cache_topic_ids as $id)
{
if (!$acl_list || $auth->acl_gets($acl_list, $rowset[$id]['forum_id']))
{
$topics[$id] = $rowset[$id];
}
}

return $topics;
}

/**
* Get simple post data
*/
function get_post_data($post_ids, $acl_list = false, $read_tracking = false)
{
global $db, $auth, $config, $user;

$rowset = array();

if (!sizeof($post_ids))
{
return array();
}

$sql_array = array(
'SELECT' => 'p.*, u.*, t.*, f.*',

'FROM' => array(
USERS_TABLE => 'u',
POSTS_TABLE => 'p',
TOPICS_TABLE => 't',
),

'LEFT_JOIN' => array(
array(
'FROM' => array(FORUMS_TABLE => 'f'),
'ON' => 'f.forum_id = t.forum_id'
)
),

'WHERE' => $db->sql_in_set('p.post_id', $post_ids) . '
AND u.user_id = p.poster_id
AND t.topic_id = p.topic_id',
);

if ($read_tracking && $config['load_db_lastread'])
{
$sql_array['SELECT'] .= ', tt.mark_time, ft.mark_time as forum_mark_time';

$sql_array['LEFT_JOIN'][] = array(
'FROM' => array(TOPICS_TRACK_TABLE => 'tt'),
'ON' => 'tt.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = tt.topic_id'
);

$sql_array['LEFT_JOIN'][] = array(
'FROM' => array(FORUMS_TRACK_TABLE => 'ft'),
'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND t.forum_id = ft.forum_id'
);
}

$sql = $db->sql_build_query('SELECT', $sql_array);
$result = $db->sql_query($sql);
unset($sql_array);

while ($row = $db->sql_fetchrow($result))
{
if (!$row['forum_id'])
{
// Global Announcement?
$row['forum_id'] = request_var('f', 0);
}

if ($acl_list && !$auth->acl_gets($acl_list, $row['forum_id']))
{
continue;
}

// start mod save full drafts (and end mod too)...added test in next line to exclude drafts
if ((!$row['post_approved'] && !$auth->acl_get('m_approve', $row['forum_id'])) || $row['post_approved'] == POST_DRAFT)
{
// Moderators without the permission to approve post should at least not see them. ;)
continue;
}

$rowset[$row['post_id']] = $row;
}
$db->sql_freeresult($result);

return $rowset;
}

/**
* Get simple forum data
*/
function get_forum_data($forum_id, $acl_list = 'f_list', $read_tracking = false)
{
global $auth, $db, $user, $config;

$rowset = array();

if (!is_array($forum_id))
{
$forum_id = array($forum_id);
}

if (!sizeof($forum_id))
{
return array();
}

if ($read_tracking && $config['load_db_lastread'])
{
$read_tracking_join = ' LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.user_id = ' . $user->data['user_id'] . '
AND ft.forum_id = f.forum_id)';
$read_tracking_select = ', ft.mark_time';
}
else
{
$read_tracking_join = $read_tracking_select = '';
}

$sql = "SELECT f.* $read_tracking_select
FROM " . FORUMS_TABLE . " f$read_tracking_join
WHERE " . $db->sql_in_set('f.forum_id', $forum_id);
$result = $db->sql_query($sql);

while ($row = $db->sql_fetchrow($result))
{
if ($acl_list && !$auth->acl_gets($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;
}
$db->sql_freeresult($result);

return $rowset;
}

/**
* Get simple pm data
*/
function get_pm_data($pm_ids)
{
global $db, $auth, $config, $user;

$rowset = array();

if (!sizeof($pm_ids))
{
return array();
}

$sql_array = array(
'SELECT' => 'p.*, u.*',

'FROM' => array(
USERS_TABLE => 'u',
PRIVMSGS_TABLE => 'p',
),

'WHERE' => $db->sql_in_set('p.msg_id', $pm_ids) . '
AND u.user_id = p.author_id',
);

$sql = $db->sql_build_query('SELECT', $sql_array);
$result = $db->sql_query($sql);
unset($sql_array);

while ($row = $db->sql_fetchrow($result))
{
$rowset[$row['msg_id']] = $row;
}
$db->sql_freeresult($result);

return $rowset;
}

/**
* sorting in mcp
*
* @param string $where_sql should either be WHERE (default if ommited) or end with AND or OR
*
* $mode reports and reports_closed: the $where parameters uses aliases p for posts table and r for report table
* $mode unapproved_posts: the $where parameters uses aliases p for posts table and t for topic table
*/
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('st', 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';
}
// start mod save full drafts (and end mod too)...added the following if clause to exclude drafts
else
{
$sql .= 'AND topic_approved <> ' . POST_DRAFT;
}
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';
}
// start mod save full drafts (and end mod too)...added the following if clause to exclude drafts
else
{
$sql .= 'AND post_approved <> ' . POST_DRAFT;
}
break;

case 'unapproved_posts':
$type = 'posts';
$default_key = 't';
$default_dir = 'd';
$where_sql .= ($topic_id) ? ' p.topic_id = ' . $topic_id . ' AND' : '';

$sql = 'SELECT COUNT(p.post_id) AS total
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t
$where_sql " . $db->sql_in_set('p.forum_id', ($forum_id) ? array($forum_id) : array_intersect(get_forum_list('f_read'), get_forum_list('m_approve'))) . '
AND p.post_approved = 0
AND t.topic_id = p.topic_id
AND t.topic_first_post_id <> p.post_id';

if ($min_time)
{
$sql .= ' 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 " . $db->sql_in_set('forum_id', ($forum_id) ? array($forum_id) : array_intersect(get_forum_list('f_read'), get_forum_list('m_approve'))) . '
AND topic_approved = 0';

if ($min_time)
{
$sql .= ' AND topic_time >= ' . $min_time;
}
break;

case 'pm_reports':
case 'pm_reports_closed':
case 'reports':
case 'reports_closed':
$pm = (strpos($mode, 'pm_') === 0) ? true : false;

$type = ($pm) ? 'pm_reports' : 'reports';
$default_key = 't';
$default_dir = 'd';
$limit_time_sql = ($min_time) ? "AND r.report_time >= $min_time" : '';

if ($topic_id)
{
$where_sql .= ' p.topic_id = ' . $topic_id . ' AND ';
}
else if ($forum_id)
{
$where_sql .= ' p.forum_id = ' . $forum_id . ' AND ';
}
else if (!$pm)
{
$where_sql .= ' ' . $db->sql_in_set('p.forum_id', get_forum_list(array('!f_read', '!m_report')), true, true) . ' AND ';
}

if ($mode == 'reports' || $mode == 'pm_reports')
{
$where_sql .= ' r.report_closed = 0 AND ';
}
else
{
$where_sql .= ' r.report_closed = 1 AND ';
}

if ($pm)
{
$sql = 'SELECT COUNT(r.report_id) AS total
FROM ' . REPORTS_TABLE . ' r, ' . PRIVMSGS_TABLE . " p
$where_sql r.post_id = 0
AND p.msg_id = r.pm_id
$limit_time_sql";
}
else
{
$sql = 'SELECT COUNT(r.report_id) AS total
FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . " p
$where_sql r.pm_id = 0
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 " . $db->sql_in_set('forum_id', ($forum_id) ? array($forum_id) : array_intersect(get_forum_list('f_read'), 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'], 365 => $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'], 365 => $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_clean', 't' => 'p.post_time', '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'], 365 => $user->lang['1_YEAR']);
$sort_by_text = array('a' => $user->lang['AUTHOR'], 'r' => $user->lang['REPORTER'], 'p' => $user->lang['POST_TIME'], 't' => $user->lang['REPORT_TIME'], 's' => $user->lang['SUBJECT']);
$sort_by_sql = array('a' => 'u.username_clean', 'r' => 'ru.username', 'p' => 'p.post_time', 't' => 'r.report_time', 's' => 'p.post_subject');
break;

case 'pm_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'], 365 => $user->lang['1_YEAR']);
$sort_by_text = array('a' => $user->lang['AUTHOR'], 'r' => $user->lang['REPORTER'], 'p' => $user->lang['POST_TIME'], 't' => $user->lang['REPORT_TIME'], 's' => $user->lang['SUBJECT']);
$sort_by_sql = array('a' => 'u.username_clean', 'r' => 'ru.username', 'p' => 'p.message_time', 't' => 'r.report_time', 's' => 'p.message_subject');
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'], 365 => $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' => 'u.username_clean', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation');
$limit_time_sql = ($min_time) ? "AND l.log_time >= $min_time" : '';
break;
}

if (!isset($sort_by_sql[$sort_key]))
{
$sort_key = $default_key;
}

$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') || in_array($mode, array('reports', 'unapproved_topics', 'unapproved_posts')) || $where_sql != 'WHERE')
{
$result = $db->sql_query($sql);
$total = (int) $db->sql_fetchfield('total');
$db->sql_freeresult($result);
}
else
{
$total = -1;
}
}

/**
* Validate ids
*
* @param array &$ids The relevant ids to check
* @param string $table The table to find the ids in
* @param string $sql_id The ids relevant column name
* @param array $acl_list A list of permissions the user need to have
* @param mixed $singe_forum Limit to one forum id (int) or the first forum found (true)
*
* @return mixed False if no ids were able to be retrieved, true if at least one id left.
* Additionally, this value can be the forum_id assigned if $single_forum was set.
* Therefore checking the result for with !== false is the best method.
*/
function check_ids(&$ids, $table, $sql_id, $acl_list = false, $single_forum = false)
{
global $db, $auth;

if (!is_array($ids) || empty($ids))
{
return false;
}

$sql = "SELECT $sql_id, forum_id FROM $table
WHERE " . $db->sql_in_set($sql_id, $ids);
$result = $db->sql_query($sql);

$ids = array();
$forum_id = false;

while ($row = $db->sql_fetchrow($result))
{
if ($acl_list && $row['forum_id'] && !$auth->acl_gets($acl_list, $row['forum_id']))
{
continue;
}

if ($acl_list && !$row['forum_id'] && !$auth->acl_getf_global($acl_list))
{
continue;
}

// Limit forum? If not, just assign the id.
if ($single_forum === false)
{
$ids[] = $row[$sql_id];
continue;
}

// Limit forum to a specific forum id?
// This can get really tricky, because we do not want to create a failure on global topics. :)
if ($row['forum_id'])
{
if ($single_forum !== true && $row['forum_id'] == (int) $single_forum)
{
$forum_id = (int) $single_forum;
}
else if ($forum_id === false)
{
$forum_id = $row['forum_id'];
}

if ($row['forum_id'] == $forum_id)
{
$ids[] = $row[$sql_id];
}
}
else
{
// Always add a global topic
$ids[] = $row[$sql_id];
}
}
$db->sql_freeresult($result);

if (!sizeof($ids))
{
return false;
}

// If forum id is false and ids populated we may have only global announcements selected (returning 0 because of (int) $forum_id)

return ($single_forum === false) ? true : (int) $forum_id;
}

?>
φ
Posts: 103
Joined: July 19th 2012, 8:17pm
Location: Pennsylvania
Likes Given: 9
Likes Received: 8
MCP View topic quick mod tools do not work
Posted October 17th 2013, 12:57am
includes/mcp/mcp_topic.php
<?php
/**
*
* @package mcp
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}

/**
* View topic in MCP
*/
function mcp_topic_view($id, $mode, $action)
{
global $phpEx, $phpbb_root_path, $config;
global $template, $db, $user, $auth, $cache;
//-- mod : quick title edition -------------------------------------------------
//-- add
global $qte;
//-- fin mod : quick title edition ---------------------------------------------

$url = append_sid("{$phpbb_root_path}mcp.$phpEx?" . extra_url());

$user->add_lang('viewtopic');
$user->add_lang('mods/utb');

$topic_id = request_var('t', 0);
$topic_info = get_topic_data(array($topic_id), false, true);

if (!sizeof($topic_info))
{
trigger_error('TOPIC_NOT_EXIST');
}

$topic_info = $topic_info[$topic_id];
include("{$phpbb_root_path}includes/mods/soft_delete.$phpEx");
soft_delete_update_reply_count($topic_info);

// Set up some vars
$icon_id = request_var('icon', 0);
$subject = utf8_normalize_nfc(request_var('subject', '', true));
$start = request_var('start', 0);
$sort_days_old = request_var('st_old', 0);
$forum_id = request_var('f', 0);
$to_topic_id = request_var('to_topic_id', 0);
$to_forum_id = request_var('to_forum_id', 0);
$sort = isset($_POST['sort']) ? true : false;
$submitted_id_list = request_var('post_ids', array(0));
$checked_ids = $post_id_list = request_var('post_id_list', array(0));

// Resync Topic?
if ($action == 'resync')
{
if (!function_exists('mcp_resync_topics'))
{
include($phpbb_root_path . 'includes/mcp/mcp_forum.' . $phpEx);
}
mcp_resync_topics(array($topic_id));
}

// Split Topic?
if ($action == 'split_all' || $action == 'split_beyond')
{
if (!$sort)
{
split_topic($action, $topic_id, $to_forum_id, $subject);
}
$action = 'split';
}

// Merge Posts?
if ($action == 'merge_posts')
{
if (!$sort)
{
merge_posts($topic_id, $to_topic_id);
}
$action = 'merge';
}

if ($action == 'split' && !$subject)
{
$subject = $topic_info['topic_title'];
}

// Approve posts?
if ($action == 'approve' && $auth->acl_get('m_approve', $topic_info['forum_id']))
{
include($phpbb_root_path . 'includes/mcp/mcp_queue.' . $phpEx);
include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
include_once($phpbb_root_path . 'includes/functions_utb.' . $phpEx);

if (!sizeof($post_id_list))
{
trigger_error('NO_POST_SELECTED');
}

if (!$sort)
{
approve_post($post_id_list, $id, $mode);
}
}
/* BEGIN UTB MOD */

$submit = (isset($_POST['utb'])) ? $_POST['utb'] : '';

if ($submit != '')
{


include_once($phpbb_root_path . 'includes/functions_utb.' . $phpEx);

$username = request_var('ban', '');

make_utb_ban($topic_id, $forum_id, $db, $user, $username);

}

$submit_unban = (isset($_POST['utub'])) ? $_POST['utub'] : '';

if ($submit_unban != '')
{

include_once($phpbb_root_path . 'includes/functions_utb.' . $phpEx);

$username = request_var('unban', '');

make_utb_unban($topic_id, $forum_id, $db, $user, $username);

}

/* END UTB MOD */

// Jumpbox, sort selects and that kind of things
make_jumpbox($url . "&i=$id&mode=forum_view", $topic_info['forum_id'], false, 'm_', true);
$where_sql = ($action == 'reports') ? 'WHERE post_reported = 1 AND ' : 'WHERE';

$sort_days = $total = 0;
$sort_key = $sort_dir = '';
$sort_by_sql = $sort_order_sql = array();
mcp_sorting('viewtopic', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $topic_info['forum_id'], $topic_id, $where_sql);

$limit_time_sql = ($sort_days) ? 'AND p.post_time >= ' . (time() - ($sort_days * 86400)) : '';

if ($total == -1)
{
if ($auth->acl_get('m_approve', $topic_info['forum_id']))
{
$total = $topic_info['topic_replies_real'] + 1;
}
else
{
$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;
}

if ((!empty($sort_days_old) && $sort_days_old != $sort_days) || $total <= $posts_per_page)
{
$start = 0;
}

// Make sure $start is set to the last page if it exceeds the amount
if ($start < 0 || $start >= $total)
{
$start = ($start < 0) ? 0 : floor(($total - 1) / $posts_per_page) * $posts_per_page;
}

$sql = 'SELECT u.username, u.username_clean, u.user_colour, p.*
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
WHERE ' . (($action == 'reports') ? 'p.post_reported = 1 AND ' : '') . '
p.topic_id = ' . $topic_id . ' ' .
((!$auth->acl_get('m_approve', $topic_info['forum_id'])) ? ' AND p.post_approved = 1 ' : ' AND p.post_approved <> ' . POST_DRAFT . ' ') . '
AND p.poster_id = u.user_id ' .
$limit_time_sql . '
ORDER BY ' . $sort_order_sql;

// start mod save full drafts (and end mod too)...added test in preceding $sql definition to exclude drafts
$result = $db->sql_query_limit($sql, $posts_per_page, $start);

$rowset = $post_id_list = array();
$bbcode_bitfield = '';
while ($row = $db->sql_fetchrow($result))
{
$rowset[] = $row;
$post_id_list[] = $row['post_id'];
$bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']);
}
$db->sql_freeresult($result);

if ($bbcode_bitfield !== '')
{
include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
$bbcode = new bbcode(base64_encode($bbcode_bitfield));
}

$topic_tracking_info = array();

// Get topic tracking info
if ($config['load_db_lastread'])
{
$tmp_topic_data = array($topic_id => $topic_info);
$topic_tracking_info = get_topic_tracking($topic_info['forum_id'], $topic_id, $tmp_topic_data, array($topic_info['forum_id'] => $topic_info['forum_mark_time']));
unset($tmp_topic_data);
}
else
{
$topic_tracking_info = get_complete_topic_tracking($topic_info['forum_id'], $topic_id);
}

$has_unapproved_posts = false;

// Grab extensions
$extensions = $attachments = array();
if ($topic_info['topic_attachment'] && sizeof($post_id_list))
{
$extensions = $cache->obtain_attach_extensions($topic_info['forum_id']);

// Get attachments...
if ($auth->acl_get('u_download') && $auth->acl_get('f_download', $topic_info['forum_id']))
{
$sql = 'SELECT *
FROM ' . ATTACHMENTS_TABLE . '
WHERE ' . $db->sql_in_set('post_msg_id', $post_id_list) . '
AND in_message = 0
ORDER BY attach_id DESC, post_msg_id ASC';
$result = $db->sql_query($sql);

while ($row = $db->sql_fetchrow($result))
{
$attachments[$row['post_msg_id']][] = $row;
}
$db->sql_freeresult($result);
}
}

//-- mod : quick title edition -------------------------------------------------
//-- add
$topic_list = array();
foreach( $rowset as $row )
{
$topic_list[] = (int) $row['topic_id'];
}
$qte->get_users_by_topic_id($topic_list);
//-- fin mod : quick title edition ---------------------------------------------
foreach ($rowset as $i => $row)
{
$message = $row['post_text'];
$post_subject = ($row['post_subject'] != '') ? $row['post_subject'] : $topic_info['topic_title'];

if ($row['bbcode_bitfield'])
{
$bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
}

$message = bbcode_nl2br($message);
$message = smiley_text($message);

if (!empty($attachments[$row['post_id']]))
{
$update_count = array();
parse_attachments($topic_info['forum_id'], $message, $attachments[$row['post_id']], $update_count);
}

if (!$row['post_approved'])
{
$has_unapproved_posts = true;
}

$post_unread = (isset($topic_tracking_info[$topic_id]) && $row['post_time'] > $topic_tracking_info[$topic_id]) ? true : false;

$template->assign_block_vars('postrow', array(
'POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
'POST_AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),

'POST_DATE' => $user->format_date($row['post_time']),
'POST_SUBJECT' => $post_subject,
'MESSAGE' => $message,
'POST_ID' => $row['post_id'],
'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $topic_id) . '">', '</a>'),

'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'),

'S_POST_REPORTED' => ($row['post_reported'] && $auth->acl_get('m_report', $topic_info['forum_id'])),
'S_POST_UNAPPROVED' => (!$row['post_approved'] && $auth->acl_get('m_approve', $topic_info['forum_id'])),
'S_CHECKED' => (($submitted_id_list && !in_array(intval($row['post_id']), $submitted_id_list)) || in_array(intval($row['post_id']), $checked_ids)) ? true : false,
'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false,
'S_POST_DELETED' => ($row['post_deleted'] == 0) ? false : true,

'U_POST_DETAILS' => "$url&i=$id&p={$row['post_id']}&mode=post_details" . (($forum_id) ? "&f=$forum_id" : ''),
'U_MCP_APPROVE' => ($auth->acl_get('m_approve', $topic_info['forum_id'])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $topic_info['forum_id'] . '&p=' . $row['post_id']) : '',
'U_MCP_REPORT' => ($auth->acl_get('m_report', $topic_info['forum_id'])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $topic_info['forum_id'] . '&p=' . $row['post_id']) : '')
);
//-- mod : quick title edition -------------------------------------------------
//-- add
if ( !empty($topic_info['topic_attr_id']) && !$i )
{
$template->alter_block_array('postrow', array(
'S_TOPIC_ATTR' => true,
'TOPIC_ATTRIBUTE' => $qte->attr_display($topic_info['topic_attr_id'], $topic_info['topic_attr_user'], $topic_info['topic_attr_time']),
), true, 'change');
}
//-- fin mod : quick title edition ---------------------------------------------
// Display not already displayed Attachments for this post, we already parsed them. ;)
if (!empty($attachments[$row['post_id']]))
{
foreach ($attachments[$row['post_id']] as $attachment)
{
$template->assign_block_vars('postrow.attachment', array(
'DISPLAY_ATTACHMENT' => $attachment)
);
}
}

unset($rowset[$i]);
}

// Display topic icons for split topic
$s_topic_icons = false;

if ($auth->acl_gets('m_split', 'm_merge', (int) $topic_info['forum_id']))
{
include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
$s_topic_icons = posting_gen_topic_icons('', $icon_id);

// Has the user selected a topic for merge?
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;
}
else
{
$to_topic_info = $to_topic_info[$to_topic_id];

if (!$to_topic_info['enable_icons'] || $auth->acl_get('!f_icons', $topic_info['forum_id']))
{
$s_topic_icons = false;
}
}
}
}

$s_hidden_fields = build_hidden_fields(array(
'st_old' => $sort_days,
'post_ids' => $post_id_list,
));
//-- mod : quick title edition -------------------------------------------------
//-- add
if ( $action == 'split' )
{
$topic_info['hide_attr'] = unserialize(trim($topic_info['hide_attr']));
if ( $topic_info['hide_attr'] === false )
{
$topic_info['hide_attr'] = array();
}

$qte->attr_select($topic_info['forum_id'], $user->data['user_id'], '', $topic_info['hide_attr']);
}
//-- fin mod : quick title edition ---------------------------------------------

$template->assign_vars(array(
'TOPIC_TITLE' => $topic_info['topic_title'],
'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", '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, '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $to_topic_info['forum_id'] . '&t=' . $to_topic_id) . '">' . $to_topic_info['topic_title'] . '</a>') : '',

'SPLIT_SUBJECT' => $subject,
'POSTS_PER_PAGE' => $posts_per_page,
'ACTION' => $action,

'REPORTED_IMG' => $user->img('icon_topic_reported', 'POST_REPORTED'),
'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED'),
'INFO_IMG' => $user->img('icon_post_info', 'VIEW_INFO'),

'S_MCP_ACTION' => "$url&i=$id&mode=$mode&action=$action&start=$start",
'S_FORUM_SELECT' => ($to_forum_id) ? make_forum_select($to_forum_id, false, false, true, true, true) : make_forum_select($topic_info['forum_id'], false, false, true, true, true),
'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_CAN_LOCK' => ($auth->acl_get('m_lock', $topic_info['forum_id'])) ? true : false,
'S_CAN_REPORT' => ($auth->acl_get('m_report', $topic_info['forum_id'])) ? true : false,
'S_CAN_SYNC' => $auth->acl_get('m_', $topic_info['forum_id']),
'S_REPORT_VIEW' => ($action == 'reports') ? true : false,
'S_MERGE_VIEW' => ($action == 'merge') ? true : false,
'S_SPLIT_VIEW' => ($action == 'split') ? true : false,

'S_HIDDEN_FIELDS' => $s_hidden_fields,

'S_SHOW_TOPIC_ICONS' => $s_topic_icons,
'S_TOPIC_ICON' => $icon_id,

'U_SELECT_TOPIC' => "$url&i=$id&mode=forum_view&action=merge_select" . (($forum_id) ? "&f=$forum_id" : ''),
'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=mcp&field=ban&select_single=true'),
'U_UFIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=mcp&field=unban&select_single=true'),
'U_ACTION' => append_sid($url, ""),

/*** 2012-03-01 BEGIN AmigoJack
Also incorporate board seach for getting a topic ID ***/
'U_FIND_TOPIC'=> append_sid( 'search.'. $phpEx, 'sr=topics&sf=titleonly&form=mcp&field=to_topic_id&simple=1' ),
/*** 2012-03-01 END ***/

'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f={$topic_info['forum_id']}&t={$topic_info['topic_id']}&start=$start") . '">', '</a>'),
'RETURN_FORUM' => sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", "f={$topic_info['forum_id']}&start=$start") . '">', '</a>'),

'PAGE_NUMBER' => on_page($total, $posts_per_page, $start),
'PAGINATION' => (!$posts_per_page) ? '' : generate_pagination(append_sid("{$phpbb_root_path}mcp.$phpEx", "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_POSTS' => ($total == 1) ? $user->lang['VIEW_TOPIC_POST'] : sprintf($user->lang['VIEW_TOPIC_POSTS'], $total),
));
}

/**
* Split topic
*/
function split_topic($action, $topic_id, $to_forum_id, $subject)
{
global $db, $template, $user, $phpEx, $phpbb_root_path, $auth, $config;

$post_id_list = request_var('post_id_list', array(0));
$forum_id = request_var('forum_id', 0);
$start = request_var('start', 0);

if (!sizeof($post_id_list))
{
$template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']);
return;
}

if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_split')))
{
return;
}

$post_id = $post_id_list[0];
$post_info = get_post_data(array($post_id));

if (!sizeof($post_info))
{
$template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']);
return;
}

$post_info = $post_info[$post_id];
$subject = trim($subject);

// Make some tests
if (!$subject)
{
$template->assign_var('MESSAGE', $user->lang['EMPTY_SUBJECT']);
return;
}

if ($to_forum_id <= 0)
{
$template->assign_var('MESSAGE', $user->lang['NO_DESTINATION_FORUM']);
return;
}

$forum_info = get_forum_data(array($to_forum_id), 'f_post');

if (!sizeof($forum_info))
{
$template->assign_var('MESSAGE', $user->lang['USER_CANNOT_POST']);
return;
}

$forum_info = $forum_info[$to_forum_id];

if ($forum_info['forum_type'] != FORUM_POST)
{
$template->assign_var('MESSAGE', $user->lang['FORUM_NOT_POSTABLE']);
return;
}

$redirect = request_var('redirect', build_url(array('quickmod')));

$s_hidden_fields = build_hidden_fields(array(
'i' => 'main',
'post_id_list' => $post_id_list,
'f' => $forum_id,
'mode' => 'topic_view',
'start' => $start,
'action' => $action,
't' => $topic_id,
'redirect' => $redirect,
'subject' => $subject,
'to_forum_id' => $to_forum_id,
'icon' => request_var('icon', 0))
);
//-- mod : quick title edition -------------------------------------------------
//-- add
$s_hidden_fields .= build_hidden_fields(array('attr_id' => request_var('attr_id', 0)));
//-- fin mod : quick title edition ---------------------------------------------
$success_msg = $return_link = '';

if (confirm_box(true))
{
if ($action == 'split_beyond')
{
$sort_days = $total = 0;
$sort_key = $sort_dir = '';
$sort_by_sql = $sort_order_sql = array();
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)) : '';

if ($sort_order_sql[0] == 'u')
{
$sql = 'SELECT p.post_id, p.forum_id, p.post_approved
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u
WHERE p.topic_id = $topic_id
AND p.poster_id = u.user_id
$limit_time_sql
ORDER BY $sort_order_sql";
}
else
{
$sql = 'SELECT p.post_id, p.forum_id, p.post_approved
FROM ' . POSTS_TABLE . " p
WHERE p.topic_id = $topic_id
$limit_time_sql
ORDER BY $sort_order_sql";
}
$result = $db->sql_query_limit($sql, 0, $start);

$store = false;
$post_id_list = array();
while ($row = $db->sql_fetchrow($result))
{
// If split from selected post (split_beyond), we split the unapproved items too.
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'];
}
}
$db->sql_freeresult($result);
}

if (!sizeof($post_id_list))
{
trigger_error('NO_POST_SELECTED');
}

$icon_id = request_var('icon', 0);

$sql_ary = array(
'forum_id' => $to_forum_id,
'topic_title' => $subject,
'icon_id' => $icon_id,
'topic_approved'=> 1
);
//-- mod : quick title edition -------------------------------------------------
//-- add
$attr_id = request_var('attr_id', 0);
if ( $attr_id == -1 )
{
$sql_ary += array('topic_attr_id' => 0, 'topic_attr_user' => 0, 'topic_attr_time' => 0);
}
else
{
$sql_ary += array(
'topic_attr_id' => $attr_id,
'topic_attr_user' => (int) $user->data['user_id'],
'topic_attr_time' => time(),
);
}
//-- fin mod : quick title edition ---------------------------------------------

$sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql);

$to_topic_id = $db->sql_nextid();
move_posts($post_id_list, $to_topic_id);

$topic_info = get_topic_data(array($topic_id));
$topic_info = $topic_info[$topic_id];

add_log('mod', $to_forum_id, $to_topic_id, 'LOG_SPLIT_DESTINATION', $subject);
add_log('mod', $forum_id, $topic_id, 'LOG_SPLIT_SOURCE', $topic_info['topic_title']);

// Change topic title of first post
$sql = 'UPDATE ' . POSTS_TABLE . "
SET post_subject = '" . $db->sql_escape($subject) . "'
WHERE post_id = {$post_id_list[0]}";
$db->sql_query($sql);

// Copy topic subscriptions to new topic
$sql = 'SELECT user_id, notify_status
FROM ' . TOPICS_WATCH_TABLE . '
WHERE topic_id = ' . $topic_id;
$result = $db->sql_query($sql);

$sql_ary = array();
while ($row = $db->sql_fetchrow($result))
{
$sql_ary[] = array(
'topic_id' => (int) $to_topic_id,
'user_id' => (int) $row['user_id'],
'notify_status' => (int) $row['notify_status'],
);
}
$db->sql_freeresult($result);

if (sizeof($sql_ary))
{
$db->sql_multi_insert(TOPICS_WATCH_TABLE, $sql_ary);
}

// Copy bookmarks to new topic
$sql = 'SELECT user_id
FROM ' . BOOKMARKS_TABLE . '
WHERE topic_id = ' . $topic_id;
$result = $db->sql_query($sql);

$sql_ary = array();
while ($row = $db->sql_fetchrow($result))
{
$sql_ary[] = array(
'topic_id' => (int) $to_topic_id,
'user_id' => (int) $row['user_id'],
);
}
$db->sql_freeresult($result);

if (sizeof($sql_ary))
{
$db->sql_multi_insert(BOOKMARKS_TABLE, $sql_ary);
}


include("{$phpbb_root_path}includes/mods/soft_delete.$phpEx");
mcp_split_merge_posts_helper($topic_id, $to_topic_id);
$success_msg = 'TOPIC_SPLIT_SUCCESS';

// Update forum statistics
set_config_count('num_topics', 1, true);

// Link back to both topics
$return_link = sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&t=' . $post_info['topic_id']) . '">', '</a>') . '<br /><br />' . sprintf($user->lang['RETURN_NEW_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $to_forum_id . '&t=' . $to_topic_id) . '">', '</a>');
}
else
{
confirm_box(false, ($action == 'split_all') ? 'SPLIT_TOPIC_ALL' : 'SPLIT_TOPIC_BEYOND', $s_hidden_fields);
}

$redirect = request_var('redirect', "index.$phpEx");
$redirect = reapply_sid($redirect);

if (!$success_msg)
{
return;
}
else
{
meta_refresh(3, append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$to_forum_id&t=$to_topic_id"));
trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_link);
}
}

/**
* Merge selected posts into selected topic
*/
function merge_posts($topic_id, $to_topic_id)
{
global $db, $template, $user, $phpEx, $phpbb_root_path, $auth;

if (!$to_topic_id)
{
$template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']);
return;
}

$topic_data = get_topic_data(array($to_topic_id), 'm_merge');

if (!sizeof($topic_data))
{
$template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']);
return;
}

$topic_data = $topic_data[$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 (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_merge')))
{
return;
}

$redirect = request_var('redirect', build_url(array('quickmod')));

$s_hidden_fields = build_hidden_fields(array(
'i' => 'main',
'post_id_list' => $post_id_list,
'to_topic_id' => $to_topic_id,
'mode' => 'topic_view',
'action' => 'merge_posts',
'start' => $start,
'redirect' => $redirect,
't' => $topic_id)
);
$success_msg = $return_link = '';

if (confirm_box(true))
{
$to_forum_id = $topic_data['forum_id'];

move_posts($post_id_list, $to_topic_id);
add_log('mod', $to_forum_id, $to_topic_id, 'LOG_MERGE', $topic_data['topic_title']);


include("{$phpbb_root_path}includes/mods/soft_delete.$phpEx");
mcp_split_merge_posts_helper($topic_id, $to_topic_id);
// Message and return links
$success_msg = 'POSTS_MERGED_SUCCESS';

// Does the original topic still exist? If yes, link back to it
$sql = 'SELECT forum_id
FROM ' . TOPICS_TABLE . '
WHERE topic_id = ' . $topic_id;
$result = $db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);

if ($row)
{
$return_link .= sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $topic_id) . '">', '</a>');
}
else
{
if (!function_exists('phpbb_update_rows_avoiding_duplicates_notify_status'))
{
include($phpbb_root_path . 'includes/functions_database_helper.' . $phpEx);
}

// If the topic no longer exist, we will update the topic watch table.
phpbb_update_rows_avoiding_duplicates_notify_status($db, TOPICS_WATCH_TABLE, 'topic_id', array($topic_id), $to_topic_id);

// If the topic no longer exist, we will update the bookmarks table.
phpbb_update_rows_avoiding_duplicates($db, BOOKMARKS_TABLE, 'topic_id', array($topic_id), $to_topic_id);
}

// Link to the new topic
$return_link .= (($return_link) ? '<br /><br />' : '') . sprintf($user->lang['RETURN_NEW_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $to_forum_id . '&t=' . $to_topic_id) . '">', '</a>');
}
else
{
confirm_box(false, 'MERGE_POSTS', $s_hidden_fields);
}

$redirect = request_var('redirect', "index.$phpEx");
$redirect = reapply_sid($redirect);

if (!$success_msg)
{
return;
}
else
{
meta_refresh(3, append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$to_forum_id&t=$to_topic_id"));
trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_link);
}
}

?>
φ
Posts: 103
Joined: July 19th 2012, 8:17pm
Location: Pennsylvania
Likes Given: 9
Likes Received: 8
MCP View topic quick mod tools do not work
Posted October 17th 2013, 6:21am
Heya. It's a little after 8am and hopefully I understood your topic right. not sure if this will help much but that's happened to me tons of times with testing boards that are heavily modded.

You could make a backup of your boards files and replace them with fresh phpbb files.. not all of them ofc but especailly in /mcp/ or even the includes directory. you'll probably run into other errors but the point is to narrow it down to find the file that is giving you the trouble.
φ
Posts: 22
Joined: February 9th 2013, 6:43pm
Likes Given: 7
Likes Received: 4
MCP View topic quick mod tools do not work
Posted October 17th 2013, 9:40am
Jessica said:
Okay I checked the browser error log. There's nothing. Doesn't seem to be a javascript error?

By any chance did you AJAXify the submit buttons in the MCP? If so, remove the AJAXify code from the MCP template files.

If not, please check the <INPUT /> tag for the submit button in the mcp_topic.html template file. If it is type="submit", then you have a javascript issue/conflict/error. The form would otherwise be submitted, and any PHP errors would result in your seeing the page updated to a blank screen or one with error messaages at the top.
φ
Posts: 1599
Joined: March 12th 2009, 11:00pm
Location: Uncertain due to momentum
Likes Given: 26
Likes Received: 357
MCP View topic quick mod tools do not work
Posted October 17th 2013, 1:19pm
I managed to fix it, it was some mod. I removed it, didn't need it anyways (called User Topic Ban, don't know what made me install it back in March...)

Thanks for your help.
φ
Posts: 103
Joined: July 19th 2012, 8:17pm
Location: Pennsylvania
Likes Given: 9
Likes Received: 8

Who is online

Users browsing this forum: No registered users and 1 guest