phpBB

Code Changes

File: includes/mcp/mcp_queue.php

  Unmodified   Added   Modified   Removed
Line 105Line 105
				{
$template->assign_vars(array(
'S_TOPIC_REVIEW' => true,

				{
$template->assign_vars(array(
'S_TOPIC_REVIEW' => true,

 
						'S_BBCODE_ALLOWED'	=> $post_info['enable_bbcode'],

						'TOPIC_TITLE'		=> $post_info['topic_title'])
);
}

						'TOPIC_TITLE'		=> $post_info['topic_title'])
);
}

Line 195Line 196
					'U_VIEW_POST'			=> $post_url,
'U_VIEW_TOPIC' => $topic_url,


					'U_VIEW_POST'			=> $post_url,
'U_VIEW_TOPIC' => $topic_url,


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

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


'RETURN_QUEUE' => sprintf($user->lang['RETURN_QUEUE'], '<a href="' . append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue' . (($topic_id) ? '&amp;mode=unapproved_topics' : '&amp;mode=unapproved_posts')) . "&amp;start=$start\">", '</a>'),
'RETURN_POST' => sprintf($user->lang['RETURN_POST'], '<a href="' . $post_url . '">', '</a>'),


'RETURN_QUEUE' => sprintf($user->lang['RETURN_QUEUE'], '<a href="' . append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue' . (($topic_id) ? '&amp;mode=unapproved_topics' : '&amp;mode=unapproved_posts')) . "&amp;start=$start\">", '</a>'),
'RETURN_POST' => sprintf($user->lang['RETURN_POST'], '<a href="' . $post_url . '">', '</a>'),

Line 215Line 216
					'POST_IP'				=> $post_info['poster_ip'],
'POST_IPADDR' => ($auth->acl_get('m_info', $post_info['forum_id']) && request_var('lookup', '')) ? @gethostbyaddr($post_info['poster_ip']) : '',
'POST_ID' => $post_info['post_id'],

					'POST_IP'				=> $post_info['poster_ip'],
'POST_IPADDR' => ($auth->acl_get('m_info', $post_info['forum_id']) && request_var('lookup', '')) ? @gethostbyaddr($post_info['poster_ip']) : '',
'POST_ID' => $post_info['post_id'],

 
					'S_FIRST_POST'			=> ($post_info['topic_first_post_id'] == $post_id),


'U_LOOKUP_IP' => ($auth->acl_get('m_info', $post_info['forum_id'])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&amp;mode=approve_details&amp;f=' . $post_info['forum_id'] . '&amp;p=' . $post_id . '&amp;lookup=' . $post_info['poster_ip']) . '#ip' : '',
));


'U_LOOKUP_IP' => ($auth->acl_get('m_info', $post_info['forum_id'])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&amp;mode=approve_details&amp;f=' . $post_info['forum_id'] . '&amp;p=' . $post_id . '&amp;lookup=' . $post_info['poster_ip']) . '#ip' : '',
));

Line 427Line 429

'POST_ID' => $row['post_id'],
'FORUM_NAME' => (!$global_topic) ? $forum_names[$row['forum_id']] : $user->lang['GLOBAL_ANNOUNCEMENT'],


'POST_ID' => $row['post_id'],
'FORUM_NAME' => (!$global_topic) ? $forum_names[$row['forum_id']] : $user->lang['GLOBAL_ANNOUNCEMENT'],

						'POST_SUBJECT'	=> $row['post_subject'],

						'POST_SUBJECT'	=> ($row['post_subject'] != '') ? $row['post_subject'] : $user->lang['NO_SUBJECT'],

						'TOPIC_TITLE'	=> $row['topic_title'],
'POST_TIME' => $user->format_date($row['post_time']))
);

						'TOPIC_TITLE'	=> $row['topic_title'],
'POST_TIME' => $user->format_date($row['post_time']))
);

Line 491Line 493
		// If Post -> total_posts = total_posts+1, forum_posts = forum_posts+1, topic_replies = topic_replies+1

$total_topics = $total_posts = 0;

		// If Post -> total_posts = total_posts+1, forum_posts = forum_posts+1, topic_replies = topic_replies+1

$total_topics = $total_posts = 0;

		$forum_topics_posts = $topic_approve_sql = $topic_replies_sql = $post_approve_sql = $topic_id_list = $forum_id_list = $approve_log = array();
$user_posts_sql = array();

$update_forum_information = false;

		$topic_approve_sql = $post_approve_sql = $topic_id_list = $forum_id_list = $approve_log = array();
$user_posts_sql = $post_approved_list = array();




foreach ($post_info as $post_id => $post_data)
{


foreach ($post_info as $post_id => $post_data)
{

 
			if ($post_data['post_approved'])
{
$post_approved_list[] = $post_id;
continue;
}


			$topic_id_list[$post_data['topic_id']] = 1;

if ($post_data['forum_id'])

			$topic_id_list[$post_data['topic_id']] = 1;

if ($post_data['forum_id'])

Line 505Line 511
				$forum_id_list[$post_data['forum_id']] = 1;
}


				$forum_id_list[$post_data['forum_id']] = 1;
}


			// User post update (we do not care about topic or post, since user posts are strictly connected to posts




			// User post update (we do not care about topic or post, since user posts are strictly connected to posts)
// But we care about forums where post counts get not increased. ;)
if ($post_data['post_postcount'])
{

			$user_posts_sql[$post_data['poster_id']] = (empty($user_posts_sql[$post_data['poster_id']])) ? 1 : $user_posts_sql[$post_data['poster_id']] + 1;

			$user_posts_sql[$post_data['poster_id']] = (empty($user_posts_sql[$post_data['poster_id']])) ? 1 : $user_posts_sql[$post_data['poster_id']] + 1;

 
			}


// Topic or Post. ;)
if ($post_data['topic_first_post_id'] == $post_id)
{
if ($post_data['forum_id'])
{


// Topic or Post. ;)
if ($post_data['topic_first_post_id'] == $post_id)
{
if ($post_data['forum_id'])
{

					if (!isset($forum_topics_posts[$post_data['forum_id']]))
{
$forum_topics_posts[$post_data['forum_id']] = array(
'forum_posts' => 0,
'forum_topics' => 0
);
}


 
					$total_topics++;

					$total_topics++;

					$forum_topics_posts[$post_data['forum_id']]['forum_topics']++;

 
				}
$topic_approve_sql[] = $post_data['topic_id'];


				}
$topic_approve_sql[] = $post_data['topic_id'];


Line 535Line 536
			}
else
{

			}
else
{

				if (!isset($topic_replies_sql[$post_data['topic_id']]))
{
$topic_replies_sql[$post_data['topic_id']] = 0;
}
$topic_replies_sql[$post_data['topic_id']]++;


 
				$approve_log[] = array(
'type' => 'post',
'post_subject' => $post_data['post_subject'],

				$approve_log[] = array(
'type' => 'post',
'post_subject' => $post_data['post_subject'],

Line 551Line 546

if ($post_data['forum_id'])
{


if ($post_data['forum_id'])
{

				if (!isset($forum_topics_posts[$post_data['forum_id']]))
{
$forum_topics_posts[$post_data['forum_id']] = array(
'forum_posts' => 0,
'forum_topics' => 0
);
}


 
				$total_posts++;

				$total_posts++;

				$forum_topics_posts[$post_data['forum_id']]['forum_posts']++;

 

// Increment by topic_replies if we approve a topic...
// This works because we do not adjust the topic_replies when re-approving a topic after an edit.
if ($post_data['topic_first_post_id'] == $post_id && $post_data['topic_replies'])
{
$total_posts += $post_data['topic_replies'];


// Increment by topic_replies if we approve a topic...
// This works because we do not adjust the topic_replies when re-approving a topic after an edit.
if ($post_data['topic_first_post_id'] == $post_id && $post_data['topic_replies'])
{
$total_posts += $post_data['topic_replies'];

					$forum_topics_posts[$post_data['forum_id']]['forum_posts'] += $post_data['topic_replies'];

 
				}
}

$post_approve_sql[] = $post_id;

				}
}

$post_approve_sql[] = $post_id;

 
		}





			// If the post is newer than the last post information stored we need to update the forum information
if ($post_data['post_time'] >= $post_data['forum_last_post_time'])

		$post_id_list = array_values(array_diff($post_id_list, $post_approved_list));
for ($i = 0, $size = sizeof($post_approved_list); $i < $size; $i++)

			{

			{

				$update_forum_information = true;
}

			unset($post_info[$post_approved_list[$i]]);


		}

if (sizeof($topic_approve_sql))

		}

if (sizeof($topic_approve_sql))

Line 595Line 580
				WHERE ' . $db->sql_in_set('post_id', $post_approve_sql);
$db->sql_query($sql);
}

				WHERE ' . $db->sql_in_set('post_id', $post_approve_sql);
$db->sql_query($sql);
}

 

unset($topic_approve_sql, $post_approve_sql);


foreach ($approve_log as $log_data)
{
add_log('mod', $log_data['forum_id'], $log_data['topic_id'], ($log_data['type'] == 'topic') ? 'LOG_TOPIC_APPROVED' : 'LOG_POST_APPROVED', $log_data['post_subject']);


foreach ($approve_log as $log_data)
{
add_log('mod', $log_data['forum_id'], $log_data['topic_id'], ($log_data['type'] == 'topic') ? 'LOG_TOPIC_APPROVED' : 'LOG_POST_APPROVED', $log_data['post_subject']);

		}

if (sizeof($topic_replies_sql))
{
foreach ($topic_replies_sql as $topic_id => $num_replies)
{
$sql = 'UPDATE ' . TOPICS_TABLE . "
SET topic_replies = topic_replies + $num_replies
WHERE topic_id = $topic_id";
$db->sql_query($sql);
}
}

if (sizeof($forum_topics_posts))
{
foreach ($forum_topics_posts as $forum_id => $row)
{
$sql = 'UPDATE ' . FORUMS_TABLE . '
SET ';
$sql .= ($row['forum_topics']) ? "forum_topics = forum_topics + {$row['forum_topics']}" : '';
$sql .= ($row['forum_topics'] && $row['forum_posts']) ? ', ' : '';
$sql .= ($row['forum_posts']) ? "forum_posts = forum_posts + {$row['forum_posts']}" : '';
$sql .= " WHERE forum_id = $forum_id";

$db->sql_query($sql);
}

 
		}

if (sizeof($user_posts_sql))

		}

if (sizeof($user_posts_sql))

Line 648Line 609

if ($total_topics)
{


if ($total_topics)
{

			set_config('num_topics', $config['num_topics'] + $total_topics, true);

			set_config_count('num_topics', $total_topics, true);

		}

if ($total_posts)
{

		}

if ($total_posts)
{

			set_config('num_posts', $config['num_posts'] + $total_posts, true);

			set_config_count('num_posts', $total_posts, true);

		}

		}

		unset($topic_approve_sql, $topic_replies_sql, $post_approve_sql);

 




		update_post_information('topic', array_keys($topic_id_list));

if ($update_forum_information)
{
update_post_information('forum', array_keys($forum_id_list));
}

		sync('topic', 'topic_id', array_keys($topic_id_list), true);
sync('forum', 'forum_id', array_keys($forum_id_list), true, true);





		unset($topic_id_list, $forum_id_list);

$messenger = new messenger();

		unset($topic_id_list, $forum_id_list);

$messenger = new messenger();

Line 704Line 660

foreach ($post_info as $post_id => $post_data)
{


foreach ($post_info as $post_id => $post_data)
{

 
			$username = ($post_data['post_username']) ? $post_data['post_username'] : $post_data['username'];


			if ($post_id == $post_data['topic_first_post_id'] && $post_id == $post_data['topic_last_post_id'])
{
// Forum Notifications

			if ($post_id == $post_data['topic_first_post_id'] && $post_id == $post_data['topic_last_post_id'])
{
// Forum Notifications

				user_notification('post', $post_data['topic_title'], $post_data['topic_title'], $post_data['forum_name'], $post_data['forum_id'], $post_data['topic_id'], $post_id);

				user_notification('post', $post_data['topic_title'], $post_data['topic_title'], $post_data['forum_name'], $post_data['forum_id'], $post_data['topic_id'], $post_id, $username);

			}
else
{
// Topic Notifications

			}
else
{
// Topic Notifications

				user_notification('reply', $post_data['post_subject'], $post_data['topic_title'], $post_data['forum_name'], $post_data['forum_id'], $post_data['topic_id'], $post_id);

				user_notification('reply', $post_data['post_subject'], $post_data['topic_title'], $post_data['forum_name'], $post_data['forum_id'], $post_data['topic_id'], $post_id, $username);

			}
}


			}
}


Line 729Line 687
		}
else
{

		}
else
{

			$success_msg = (sizeof($post_id_list) == 1) ? 'POST_APPROVED_SUCCESS' : 'POSTS_APPROVED_SUCCESS';

			$success_msg = (sizeof($post_id_list) + sizeof($post_approved_list) == 1) ? 'POST_APPROVED_SUCCESS' : 'POSTS_APPROVED_SUCCESS';

		}
}
else
{
$show_notify = false;


		}
}
else
{
$show_notify = false;


 
		if ($config['email_enable'] || $config['jab_enable'])
{

		foreach ($post_info as $post_data)
{
if ($post_data['poster_id'] == ANONYMOUS)

		foreach ($post_info as $post_data)
{
if ($post_data['poster_id'] == ANONYMOUS)

Line 746Line 706
			{
$show_notify = true;
break;

			{
$show_notify = true;
break;

 
				}

			}
}


			}
}


Line 820Line 781
		if (!$row || (!$reason && strtolower($row['reason_title']) == 'other'))
{
$additional_msg = $user->lang['NO_REASON_DISAPPROVAL'];

		if (!$row || (!$reason && strtolower($row['reason_title']) == 'other'))
{
$additional_msg = $user->lang['NO_REASON_DISAPPROVAL'];

 
			unset($_REQUEST['confirm_key']);
unset($_POST['confirm_key']);

			unset($_POST['confirm']);
}
else

			unset($_POST['confirm']);
}
else

Line 841Line 804

if (confirm_box(true))
{


if (confirm_box(true))
{

 
		$disapprove_log = $disapprove_log_topics = $disapprove_log_posts = array();
$topic_replies_real = $post_disapprove_list = array();





		// If Topic -> forum_topics_real -= 1
// If Post -> topic_replies_real -= 1

$num_disapproved = 0;
$forum_topics_real = $topic_id_list = $forum_id_list = $topic_replies_real_sql = $post_disapprove_sql = $disapprove_log = array();


		// Build a list of posts to be unapproved and get the related topics real replies count






		foreach ($post_info as $post_id => $post_data)
{

		foreach ($post_info as $post_id => $post_data)
{

			$topic_id_list[$post_data['topic_id']] = 1;

if ($post_data['forum_id'])

			$post_disapprove_list[$post_id] = $post_data['topic_id'];
if (!isset($topic_replies_real[$post_data['topic_id']]))


			{

			{

				$forum_id_list[$post_data['forum_id']] = 1;


				$topic_replies_real[$post_data['topic_id']] = $post_data['topic_replies_real'];
}

			}


			}


			// Topic or Post. ;)
/**
* @todo this probably is a different method than the one used by delete_posts, does this cause counter inconsistency?
*/
if ($post_data['topic_first_post_id'] == $post_id && $post_data['topic_last_post_id'] == $post_id)

		// Now we build the log array
foreach ($post_disapprove_list as $post_id => $topic_id)




			{

			{

				if ($post_data['forum_id'])



			// If the count of disapproved posts for the topic is greater
// than topic's real replies count, the whole topic is disapproved/deleted
if (sizeof(array_keys($post_disapprove_list, $topic_id)) > $topic_replies_real[$topic_id])

				{

				{

					if (!isset($forum_topics_real[$post_data['forum_id']]))


				// Don't write the log more than once for every topic
if (!isset($disapprove_log_topics[$topic_id]))

					{

					{

						$forum_topics_real[$post_data['forum_id']] = 0;
}
$forum_topics_real[$post_data['forum_id']]++;
$num_disapproved++;
}

$disapprove_log[] = array(

					// Build disapproved topics log
$disapprove_log_topics[$topic_id] = array(






					'type'			=> 'topic',

					'type'			=> 'topic',

					'post_subject'	=> $post_data['post_subject'],
'forum_id' => $post_data['forum_id'],

						'post_subject'	=> $post_info[$post_id]['topic_title'],
'forum_id' => $post_info[$post_id]['forum_id'],

					'topic_id'		=> 0, // useless to log a topic id, as it will be deleted
);

					'topic_id'		=> 0, // useless to log a topic id, as it will be deleted
);

 
				}

			}
else
{

			}
else
{

				if (!isset($topic_replies_real_sql[$post_data['topic_id']]))
{
$topic_replies_real_sql[$post_data['topic_id']] = 0;
}
$topic_replies_real_sql[$post_data['topic_id']]++;

$disapprove_log[] = array(

				// Build disapproved posts log
$disapprove_log_posts[] = array(






					'type'			=> 'post',

					'type'			=> 'post',

					'post_subject'	=> $post_data['post_subject'],
'forum_id' => $post_data['forum_id'],
'topic_id' => $post_data['topic_id'],

					'post_subject'	=> $post_info[$post_id]['post_subject'],
'forum_id' => $post_info[$post_id]['forum_id'],
'topic_id' => $post_info[$post_id]['topic_id'],

				);

				);

			}

 




			$post_disapprove_sql[] = $post_id;

			}

		}


		}


		unset($post_data);



		// Get disapproved posts/topics counts separately
$num_disapproved_topics = sizeof($disapprove_log_topics);
$num_disapproved_posts = sizeof($disapprove_log_posts);





		if (sizeof($forum_topics_real))
{
foreach ($forum_topics_real as $forum_id => $topics_real)
{
$sql = 'UPDATE ' . FORUMS_TABLE . "
SET forum_topics_real = forum_topics_real - $topics_real
WHERE forum_id = $forum_id";
$db->sql_query($sql);
}
}

		// Build the whole log
$disapprove_log = array_merge($disapprove_log_topics, $disapprove_log_posts);













		if (sizeof($topic_replies_real_sql))
{
foreach ($topic_replies_real_sql as $topic_id => $num_replies)
{
$sql = 'UPDATE ' . TOPICS_TABLE . "
SET topic_replies_real = topic_replies_real - $num_replies
WHERE topic_id = $topic_id";
$db->sql_query($sql);
}
}

		// Unset unneeded arrays
unset($post_data, $disapprove_log_topics, $disapprove_log_posts);













		if (sizeof($post_disapprove_sql))


		// Let's do the job - delete disapproved posts
if (sizeof($post_disapprove_list))

		{
if (!function_exists('delete_posts'))
{

		{
if (!function_exists('delete_posts'))
{

Line 931Line 868
			}

// We do not check for permissions here, because the moderator allowed approval/disapproval should be allowed to delete the disapproved posts

			}

// We do not check for permissions here, because the moderator allowed approval/disapproval should be allowed to delete the disapproved posts

			delete_posts('post_id', $post_disapprove_sql);



			// Note: function delete_posts triggers related forums/topics sync,
// so we don't need to call update_post_information later and to adjust real topic replies or forum topics count manually
delete_posts('post_id', array_keys($post_disapprove_list));


foreach ($disapprove_log as $log_data)
{
add_log('mod', $log_data['forum_id'], $log_data['topic_id'], ($log_data['type'] == 'topic') ? 'LOG_TOPIC_DISAPPROVED' : 'LOG_POST_DISAPPROVED', $log_data['post_subject'], $disapprove_reason);
}
}


foreach ($disapprove_log as $log_data)
{
add_log('mod', $log_data['forum_id'], $log_data['topic_id'], ($log_data['type'] == 'topic') ? 'LOG_TOPIC_DISAPPROVED' : 'LOG_POST_DISAPPROVED', $log_data['post_subject'], $disapprove_reason);
}
}

		unset($post_disapprove_sql, $topic_replies_real_sql);

update_post_information('topic', array_keys($topic_id_list));

if (sizeof($forum_id_list))
{
update_post_information('forum', array_keys($forum_id_list));
}
unset($topic_id_list, $forum_id_list);

 

$messenger = new messenger();



$messenger = new messenger();


Line 975Line 905
						{
// Load up the language pack
$lang = array();

						{
// Load up the language pack
$lang = array();

							@include($phpbb_root_path . '/language/' . $post_data['user_lang'] . '/mcp.' . $phpEx);

							@include($phpbb_root_path . '/language/' . basename($post_data['user_lang']) . '/mcp.' . $phpEx);


// If we find the reason in this language pack use it
if (isset($lang['report_reasons']['DESCRIPTION'][$disapprove_reason_lang]))


// If we find the reason in this language pack use it
if (isset($lang['report_reasons']['DESCRIPTION'][$disapprove_reason_lang]))

Line 1014Line 944

$messenger->save_queue();



$messenger->save_queue();


		if (sizeof($forum_topics_real))

		if ($num_disapproved_topics)

		{

		{

			$success_msg = ($num_disapproved == 1) ? 'TOPIC_DISAPPROVED_SUCCESS' : 'TOPICS_DISAPPROVED_SUCCESS';

			$success_msg = ($num_disapproved_topics == 1) ? 'TOPIC_DISAPPROVED_SUCCESS' : 'TOPICS_DISAPPROVED_SUCCESS';

		}
else
{

		}
else
{

			$success_msg = (sizeof($post_id_list) == 1) ? 'POST_DISAPPROVED_SUCCESS' : 'POSTS_DISAPPROVED_SUCCESS';

			$success_msg = ($num_disapproved_posts == 1) ? 'POST_DISAPPROVED_SUCCESS' : 'POSTS_DISAPPROVED_SUCCESS';

		}
}
else

		}
}
else