Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

[ticket/10857] Adding information about items requiring a moderators attention #780

Closed
wants to merge 5 commits into from

8 participants

Michael C. Oleg Pudeyev brunoais Don't Add Me To Your Organization a.k.a The Travis Bot Andreas Fischer David King Callum Macrae Joas Schilling
Michael C. [ticket/10857] Adding information about items requiring a moderators …
…attention

With thanks to RMcGirr83 for his Moderator Needed MOD.

PHPBB3-10857
56474da
phpBB/includes/functions_display.php
((84 lines not shown))
  1405
+			$total_unapproved_topics = sprintf($l_unapproved_topics_count, $unapproved_topics_count);
  1406
+			$l_unapproved_posts_count = $unapproved_posts_count ? (($unapproved_posts_count == 1) ? $user->lang['MODERATOR_NEEDED_APPROVE_POST'] : $user->lang['MODERATOR_NEEDED_APPROVE_POSTS']) : '';
  1407
+			$total_unapproved_posts = sprintf($l_unapproved_posts_count, $unapproved_posts_count);
  1408
+
  1409
+			// And export variables to the template
  1410
+			$template->assign_vars(array(
  1411
+				'TOTAL_MODERATOR_REPORTS'		=> $total_reported_posts,
  1412
+				'TOTAL_MODERATOR_POSTS'			=> $total_unapproved_posts,
  1413
+				'TOTAL_MODERATOR_TOPICS'    	=> $total_unapproved_topics,
  1414
+
  1415
+				'U_MODERATOR_REPORTS'			=> append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=reports', true, $user->session_id),
  1416
+				'U_MODERATOR_APPROVE_POSTS'		=> append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=unapproved_posts', true, $user->session_id),
  1417
+				'U_MODERATOR_APPROVE_TOPICS'    => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=unapproved_topics', true, $user->session_id),
  1418
+			));
  1419
+		}
  1420
+    }
2
David King Collaborator

Indentation

Fixed. It shouldn't have been there anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
phpBB/language/en/common.php
@@ -358,6 +358,14 @@
358 358
 	'MINUTES'				=> 'Minutes',
359 359
 	'MODERATE'				=> 'Moderate',
360 360
 	'MODERATOR'				=> 'Moderator',
  361
+	'MODERATOR_REPORTED_POST'	=> '<strong>%d</strong> Post is reported',
  362
+	'MODERATOR_REPORTED_POSTS'	=> '<strong>%d</strong> Posts are reported',
  363
+	'MODERATOR_APPROVE_POST'	=> '<strong>%d</strong> Post needs approval',
  364
+	'MODERATOR_APPROVE_POSTS'	=> '<strong>%d</strong> Posts need approval',
  365
+	'MODERATOR_APPROVE_TOPIC'	=> '<strong>%d</strong> Topic needs approval',
  366
+	'MODERATOR_APPROVE_TOPICS'	=> '<strong>%d</strong> Topics need approval',
2
David King Collaborator

Post and topic are not proper nouns, so they should not be capitalized.

Also, I think better language would be like:
"%d reported posts" (same with topics).
and
"%d posts awaiting approval"

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
David King imkingdavid commented on the diff April 30, 2012
phpBB/includes/functions_display.php
((107 lines not shown))
  1428
+		{
  1429
+			$sql = 'SELECT COUNT(msg_id) AS pms_count
  1430
+				FROM ' . PRIVMSGS_TABLE . '
  1431
+				WHERE message_reported = 1';
  1432
+			$result = $db->sql_query($sql);
  1433
+			$reported_pms = (int) $db->sql_fetchfield('pms_count');
  1434
+			$db->sql_freeresult($result);
  1435
+
  1436
+			// Cache for a few minutes to optimize. Might add to topics/posts later
  1437
+			$cache->put('_reported_pms', $reported_pms, 300);
  1438
+		}
  1439
+
  1440
+		// Dump to the template again
  1441
+		if ($reported_pms)
  1442
+		{
  1443
+			$l_reported_pms_count = $reported_pms ? (($reported_pms == 1) ? $user->lang['MODERATOR_NEEDED_REPORTED_PM'] : $user->lang['MODERATOR_NEEDED_REPORTED_PMS']) : '';
1
David King Collaborator

Use the lang() method rather than the lang array. Applies to any other similar uses of $user->lang[]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
David King imkingdavid commented on the diff April 30, 2012
phpBB/language/en/common.php
@@ -358,6 +358,14 @@
358 358
 	'MINUTES'				=> 'Minutes',
359 359
 	'MODERATE'				=> 'Moderate',
360 360
 	'MODERATOR'				=> 'Moderator',
  361
+	'MODERATOR_REPORTED_POST'	=> '<strong>%d</strong> reported post',
  362
+	'MODERATOR_REPORTED_POSTS'	=> '<strong>%d</strong> reported posts',
  363
+	'MODERATOR_APPROVE_POST'	=> '<strong>%d</strong> post awaiting approval',
  364
+	'MODERATOR_APPROVE_POSTS'	=> '<strong>%d</strong> posts awaiting approve',
  365
+	'MODERATOR_APPROVE_TOPIC'	=> '<strong>%d</strong> topic awaiting approval',
  366
+	'MODERATOR_APPROVE_TOPICS'	=> '<strong>%d</strong> topics awaiting approval',
  367
+	'MODERATOR_REPORTED_PM'		=> '<strong>%d</strong> PM is reported',
  368
+	'MODERATOR_REPORTED_PMS'	=> '<strong>%d</strong> PMs are reported',
4
David King Collaborator

probably "%d reported PMs" like you did with posts and topics would be better for consistency.

Callum Macrae
callumacrae added a note May 15, 2012

+1

brunoais
brunoais added a note May 15, 2012

I think the new system for plural form should be used instead.

@brunoais That has already been said.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Callum Macrae callumacrae commented on the diff April 30, 2012
phpBB/language/en/common.php
@@ -358,6 +358,14 @@
358 358
 	'MINUTES'				=> 'Minutes',
359 359
 	'MODERATE'				=> 'Moderate',
360 360
 	'MODERATOR'				=> 'Moderator',
  361
+	'MODERATOR_REPORTED_POST'	=> '<strong>%d</strong> reported post',
  362
+	'MODERATOR_REPORTED_POSTS'	=> '<strong>%d</strong> reported posts',
  363
+	'MODERATOR_APPROVE_POST'	=> '<strong>%d</strong> post awaiting approval',
  364
+	'MODERATOR_APPROVE_POSTS'	=> '<strong>%d</strong> posts awaiting approve',
2

approval

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Callum Macrae callumacrae commented on the diff April 30, 2012
phpBB/language/en/common.php
@@ -358,6 +358,14 @@
358 358
 	'MINUTES'				=> 'Minutes',
359 359
 	'MODERATE'				=> 'Moderate',
360 360
 	'MODERATOR'				=> 'Moderator',
  361
+	'MODERATOR_REPORTED_POST'	=> '<strong>%d</strong> reported post',
2

Is this every going to be anything but 1?

No, hence the point of having post and posts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
David King imkingdavid commented on the diff April 30, 2012
phpBB/includes/functions_display.php
((71 lines not shown))
  1392
+			if (!$row['post_approved'])
  1393
+			{
  1394
+				$unapproved_posts_count++;
  1395
+			}
  1396
+		}
  1397
+		$db->sql_freeresult($result);
  1398
+
  1399
+		// Lets use this data
  1400
+		if ($reported_posts_count || $unapproved_posts_count || $unapproved_topics_count)
  1401
+		{
  1402
+			$l_reported_posts_count = $reported_posts_count ? (($reported_posts_count == 1) ? $user->lang['MODERATOR_NEEDED_REPORTED_POST'] : $user->lang['MODERATOR_NEEDED_REPORTED_POSTS']) : '';
  1403
+			$total_reported_posts = sprintf($l_reported_posts_count, $reported_posts_count);
  1404
+			$l_unapproved_topics_count = $unapproved_topics_count ? (($unapproved_topics_count == 1) ? $user->lang['MODERATOR_NEEDED_APPROVE_TOPIC'] : $user->lang['MODERATOR_NEEDED_APPROVE_TOPICS']) : '';
  1405
+			$total_unapproved_topics = sprintf($l_unapproved_topics_count, $unapproved_topics_count);
  1406
+			$l_unapproved_posts_count = $unapproved_posts_count ? (($unapproved_posts_count == 1) ? $user->lang['MODERATOR_NEEDED_APPROVE_POST'] : $user->lang['MODERATOR_NEEDED_APPROVE_POSTS']) : '';
  1407
+			$total_unapproved_posts = sprintf($l_unapproved_posts_count, $unapproved_posts_count);
1
David King Collaborator

Use $user->lang() instead of $user->lang[] so don't have to use sprintf, and you can condense this by 3 lines if you do so, I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Oleg Pudeyev p commented on the diff April 30, 2012
phpBB/language/en/common.php
@@ -358,6 +358,14 @@
358 358
 	'MINUTES'				=> 'Minutes',
359 359
 	'MODERATE'				=> 'Moderate',
360 360
 	'MODERATOR'				=> 'Moderator',
  361
+	'MODERATOR_REPORTED_POST'	=> '<strong>%d</strong> reported post',
  362
+	'MODERATOR_REPORTED_POSTS'	=> '<strong>%d</strong> reported posts',
  363
+	'MODERATOR_APPROVE_POST'	=> '<strong>%d</strong> post awaiting approval',
  364
+	'MODERATOR_APPROVE_POSTS'	=> '<strong>%d</strong> posts awaiting approve',
  365
+	'MODERATOR_APPROVE_TOPIC'	=> '<strong>%d</strong> topic awaiting approval',
  366
+	'MODERATOR_APPROVE_TOPICS'	=> '<strong>%d</strong> topics awaiting approval',
1
Oleg Pudeyev
p added a note April 30, 2012

Plurals need to be done via the 3.1 plural system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Oleg Pudeyev p commented on the diff April 30, 2012
phpBB/includes/functions_display.php
@@ -1322,3 +1322,133 @@ function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $
1322 1322
 	$avatar_img .= $avatar;
1323 1323
 	return '<img src="' . (str_replace(' ', '%20', $avatar_img)) . '" width="' . $avatar_width . '" height="' . $avatar_height . '" alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />';
1324 1324
 }
  1325
+
  1326
+/**
  1327
+* Fetches the number of items which need a moderators attention
  1328
+*/
  1329
+function mcp_quick_info()
2
Oleg Pudeyev
p added a note April 30, 2012

Needs a phpbb prefix.

brunoais
brunoais added a note May 07, 2012

Found the problem.
This function is never called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Oleg Pudeyev
p commented April 30, 2012

You are adding 3 queries for each page view for moderators/admins? Have you checked that all of them use indexes we have?

phpBB/includes/functions_display.php
((86 lines not shown))
  1407
+			$total_unapproved_posts = sprintf($l_unapproved_posts_count, $unapproved_posts_count);
  1408
+
  1409
+			// And export variables to the template
  1410
+			$template->assign_vars(array(
  1411
+				'TOTAL_MODERATOR_REPORTS'		=> $total_reported_posts,
  1412
+				'TOTAL_MODERATOR_POSTS'			=> $total_unapproved_posts,
  1413
+				'TOTAL_MODERATOR_TOPICS'    	=> $total_unapproved_topics,
  1414
+
  1415
+				'U_MODERATOR_REPORTS'			=> append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&amp;mode=reports', true, $user->session_id),
  1416
+				'U_MODERATOR_APPROVE_POSTS'		=> append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&amp;mode=unapproved_posts', true, $user->session_id),
  1417
+				'U_MODERATOR_APPROVE_TOPICS'    => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&amp;mode=unapproved_topics', true, $user->session_id),
  1418
+			));
  1419
+		}
  1420
+
  1421
+    // Don't forget PMs
  1422
+	if ($auth->acl_getf_global('m_'))
1
Oleg Pudeyev
p added a note April 30, 2012

Indentation looks wrong here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Oleg Pudeyev p commented on the diff April 30, 2012
phpBB/includes/functions_display.php
((66 lines not shown))
  1387
+			if ($row['post_reported'])
  1388
+			{
  1389
+				$reported_posts_count++;
  1390
+			}
  1391
+			// count the unapproved posts
  1392
+			if (!$row['post_approved'])
  1393
+			{
  1394
+				$unapproved_posts_count++;
  1395
+			}
  1396
+		}
  1397
+		$db->sql_freeresult($result);
  1398
+
  1399
+		// Lets use this data
  1400
+		if ($reported_posts_count || $unapproved_posts_count || $unapproved_topics_count)
  1401
+		{
  1402
+			$l_reported_posts_count = $reported_posts_count ? (($reported_posts_count == 1) ? $user->lang['MODERATOR_NEEDED_REPORTED_POST'] : $user->lang['MODERATOR_NEEDED_REPORTED_POSTS']) : '';
1
Oleg Pudeyev
p added a note April 30, 2012

The plurals logic here should be replaced with the 3.1 plurals stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Andreas Fischer bantu commented on the diff May 01, 2012
phpBB/includes/functions_display.php
@@ -1322,3 +1322,133 @@ function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $
1322 1322
 	$avatar_img .= $avatar;
1323 1323
 	return '<img src="' . (str_replace(' ', '%20', $avatar_img)) . '" width="' . $avatar_width . '" height="' . $avatar_height . '" alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />';
1324 1324
 }
  1325
+
  1326
+/**
  1327
+* Fetches the number of items which need a moderators attention
  1328
+*/
  1329
+function mcp_quick_info()
  1330
+{
  1331
+	global $auth, $cache, $db, $template, $user, $phpEx, $phpbb_root_path;
  1332
+
  1333
+	$allow = false;
  1334
+
  1335
+	// Check for approve and report permissions
  1336
+	if ($auth->acl_getf_global('m_approve') && $auth->acl_getf_global('m_report'))
  1337
+	{
  1338
+		$sql_where = ' WHERE (' . $db->sql_in_set('forum_id', get_forum_list('m_approve')) . ' or ' . $db->sql_in_set('forum_id', get_forum_list('m_report')) . ') AND (post_reported = 1 or post_approved = 0)';
2
Andreas Fischer Collaborator
bantu added a note May 01, 2012

"or" should be upper case.

Andreas Fischer Collaborator
bantu added a note May 01, 2012

Query should be broken into multiple lines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Andreas Fischer bantu commented on the diff May 01, 2012
phpBB/includes/functions_display.php
((5 lines not shown))
  1326
+/**
  1327
+* Fetches the number of items which need a moderators attention
  1328
+*/
  1329
+function mcp_quick_info()
  1330
+{
  1331
+	global $auth, $cache, $db, $template, $user, $phpEx, $phpbb_root_path;
  1332
+
  1333
+	$allow = false;
  1334
+
  1335
+	// Check for approve and report permissions
  1336
+	if ($auth->acl_getf_global('m_approve') && $auth->acl_getf_global('m_report'))
  1337
+	{
  1338
+		$sql_where = ' WHERE (' . $db->sql_in_set('forum_id', get_forum_list('m_approve')) . ' or ' . $db->sql_in_set('forum_id', get_forum_list('m_report')) . ') AND (post_reported = 1 or post_approved = 0)';
  1339
+		$allow = true;
  1340
+	}
  1341
+	elseif ($auth->acl_getf_global('m_approve'))
1
Andreas Fischer Collaborator
bantu added a note May 01, 2012

Space between else and if

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Andreas Fischer bantu commented on the diff May 01, 2012
phpBB/includes/functions_display.php
((36 lines not shown))
  1357
+		if ($auth->acl_getf_global('m_approve'))
  1358
+		{
  1359
+			$sql = 'SELECT topic_first_post_id
  1360
+						FROM ' . TOPICS_TABLE . '
  1361
+					WHERE ' . $db->sql_in_set('forum_id', get_forum_list('m_approve')) . ' AND topic_approved = 0';
  1362
+			$result = $db->sql_query($sql);
  1363
+
  1364
+			$unapproved_topics_array = array();
  1365
+			while ($row = $db->sql_fetchrow($result))
  1366
+			{
  1367
+				$unapproved_topics_array[] = (int) $row['topic_first_post_id'];
  1368
+				$unapproved_topics_count++;
  1369
+			}
  1370
+			$db->sql_freeresult($result);
  1371
+
  1372
+			if(sizeof($unapproved_topics_array))
1
Andreas Fischer Collaborator
bantu added a note May 01, 2012

Space after if.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Andreas Fischer bantu commented on the diff May 01, 2012
phpBB/includes/functions_display.php
((32 lines not shown))
  1353
+	{
  1354
+		$reported_posts_count = $unapproved_posts_count = $unapproved_topics_count = $reported_pms = 0;
  1355
+
  1356
+		// Topic Approval
  1357
+		if ($auth->acl_getf_global('m_approve'))
  1358
+		{
  1359
+			$sql = 'SELECT topic_first_post_id
  1360
+						FROM ' . TOPICS_TABLE . '
  1361
+					WHERE ' . $db->sql_in_set('forum_id', get_forum_list('m_approve')) . ' AND topic_approved = 0';
  1362
+			$result = $db->sql_query($sql);
  1363
+
  1364
+			$unapproved_topics_array = array();
  1365
+			while ($row = $db->sql_fetchrow($result))
  1366
+			{
  1367
+				$unapproved_topics_array[] = (int) $row['topic_first_post_id'];
  1368
+				$unapproved_topics_count++;
3
Andreas Fischer Collaborator
bantu added a note May 01, 2012

Counting seems unnecessary here as the array seems to count for you. You can use $unapproved_topics_count = sizeof($unapproved_topics_array); after the loop.

Callum Macrae
callumacrae added a note May 01, 2012
Andreas Fischer Collaborator
bantu added a note May 01, 2012

The array data structure in php carries a counter. sizeof() returns that counter. when you add an element using [], the counter is incremented. So php already does the counting work for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Andreas Fischer bantu commented on the diff May 01, 2012
phpBB/includes/functions_display.php
@@ -1322,3 +1322,133 @@ function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $
1322 1322
 	$avatar_img .= $avatar;
1323 1323
 	return '<img src="' . (str_replace(' ', '%20', $avatar_img)) . '" width="' . $avatar_width . '" height="' . $avatar_height . '" alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />';
1324 1324
 }
  1325
+
  1326
+/**
  1327
+* Fetches the number of items which need a moderators attention
  1328
+*/
  1329
+function mcp_quick_info()
  1330
+{
  1331
+	global $auth, $cache, $db, $template, $user, $phpEx, $phpbb_root_path;
  1332
+
  1333
+	$allow = false;
  1334
+
  1335
+	// Check for approve and report permissions
  1336
+	if ($auth->acl_getf_global('m_approve') && $auth->acl_getf_global('m_report'))
1
Andreas Fischer Collaborator
bantu added a note May 01, 2012

This seems to be unnecessarily complex. it should be possible to build a query using the two individual cases m_approve and m_report with two independent ifs below

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Andreas Fischer bantu commented on the diff May 01, 2012
phpBB/includes/functions_display.php
((45 lines not shown))
  1366
+			{
  1367
+				$unapproved_topics_array[] = (int) $row['topic_first_post_id'];
  1368
+				$unapproved_topics_count++;
  1369
+			}
  1370
+			$db->sql_freeresult($result);
  1371
+
  1372
+			if(sizeof($unapproved_topics_array))
  1373
+			{
  1374
+				$sql_where .= ' AND ' . $db->sql_in_set('post_id', $unapproved_topics_array, true);
  1375
+			}
  1376
+		}
  1377
+
  1378
+		// Reported Posts and Approved Posts
  1379
+		$sql = 'SELECT post_reported, post_approved
  1380
+					FROM ' . POSTS_TABLE .
  1381
+				$sql_where . ' OR (forum_id = 0 and post_reported = 1)';
5
Andreas Fischer Collaborator
bantu added a note May 01, 2012

Can forum_id = 0 on develop?

Andreas Fischer Collaborator
bantu added a note May 01, 2012

Upper case AND

Callum Macrae
callumacrae added a note May 01, 2012
Andreas Fischer Collaborator
bantu added a note May 01, 2012

Has to be handled by the convertor.

Joas Schilling Collaborator

forum_id can not be 0 anymore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Andreas Fischer bantu commented on the diff May 01, 2012
phpBB/includes/functions_display.php
((48 lines not shown))
  1369
+			}
  1370
+			$db->sql_freeresult($result);
  1371
+
  1372
+			if(sizeof($unapproved_topics_array))
  1373
+			{
  1374
+				$sql_where .= ' AND ' . $db->sql_in_set('post_id', $unapproved_topics_array, true);
  1375
+			}
  1376
+		}
  1377
+
  1378
+		// Reported Posts and Approved Posts
  1379
+		$sql = 'SELECT post_reported, post_approved
  1380
+					FROM ' . POSTS_TABLE .
  1381
+				$sql_where . ' OR (forum_id = 0 and post_reported = 1)';
  1382
+		$result = $db->sql_query($sql);
  1383
+
  1384
+		while ($row = $db->sql_fetchrow($result))
1
Andreas Fischer Collaborator
bantu added a note May 01, 2012

Wouldn't it make more sense to do this logic in SQL?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Andreas Fischer bantu commented on the diff May 01, 2012
phpBB/includes/functions_display.php
((91 lines not shown))
  1412
+				'TOTAL_MODERATOR_POSTS'			=> $total_unapproved_posts,
  1413
+				'TOTAL_MODERATOR_TOPICS'    	=> $total_unapproved_topics,
  1414
+
  1415
+				'U_MODERATOR_REPORTS'			=> append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&amp;mode=reports', true, $user->session_id),
  1416
+				'U_MODERATOR_APPROVE_POSTS'		=> append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&amp;mode=unapproved_posts', true, $user->session_id),
  1417
+				'U_MODERATOR_APPROVE_TOPICS'    => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&amp;mode=unapproved_topics', true, $user->session_id),
  1418
+			));
  1419
+		}
  1420
+
  1421
+    // Don't forget PMs
  1422
+	if ($auth->acl_getf_global('m_'))
  1423
+	{
  1424
+		$reported_pms = 0;
  1425
+
  1426
+		// Lets have a cache
  1427
+		if (($reported_pms = $cache->get('_reported_pms')) === false)
1
Andreas Fischer Collaborator
bantu added a note May 01, 2012

Maybe this should be in cache.php or at least its own function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Joas Schilling nickvergessen commented on the diff May 02, 2012
phpBB/styles/prosilver/template/index_body.html
... ...
@@ -1,7 +1,7 @@
1 1
 <!-- INCLUDE overall_header.html -->
2 2
 
3 3
 <p class="{S_CONTENT_FLOW_END}<!-- IF S_USER_LOGGED_IN --> rightside<!-- ENDIF -->"><!-- IF S_USER_LOGGED_IN -->{LAST_VISIT_DATE}<!-- ELSE -->{CURRENT_TIME}<!-- ENDIF --></p>
4  
-<!-- IF U_MCP --><p>{CURRENT_TIME} <br />[&nbsp;<a href="{U_MCP}">{L_MCP}</a>&nbsp;]</p><!-- ELSEIF S_USER_LOGGED_IN --><p>{CURRENT_TIME}</p><!-- ENDIF -->
  4
+<!-- IF U_MCP --><p>{CURRENT_TIME} <br />[&nbsp;<a href="{U_MCP}">{L_MCP}</a><!-- IF TOTAL_MODERATOR_REPORTS --> &bull; <a href="{U_MODERATOR_REPORTS}">{TOTAL_MODERATOR_REPORTS}</a><!-- ENDIF --><!-- IF TOTAL_MODERATOR_POSTS --> &bull; <a href="{U_MODERATOR_APPROVE_POSTS}">{TOTAL_MODERATOR_POSTS}</a><!-- ENDIF --><!-- IF TOTAL_MODERATOR_TOPICS --> &bull; <a href="{U_MODERATOR_APPROVE_TOPICS}">{TOTAL_MODERATOR_TOPICS}</a><!-- ENDIF --><!-- IF TOTAL_MODERATOR_PMS --> &bull; <a href="{U_MODERATOR_PMS}">{TOTAL_MODERATOR_PMS}</a><!-- ENDIF -->&nbsp;]</p><!-- ELSEIF S_USER_LOGGED_IN --><p>{CURRENT_TIME}</p><!-- ENDIF -->
1
Joas Schilling Collaborator

I'd prefer | over the bull here.
That's the way we use do it inside of [ ]:
Example in profile:
Warnings:
0 [ View user notes | Warn user ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
brunoais

Does not work. It gives unexpected $end.
I still don't know where it is failing. norepad++ finds an if that is closing at near bottom.
Indentation as is makes the job harder.
I'm just unable to make this work.

Michael C.

Ah this is fixed locally but I forgot to push.

Michael C.

There you are.

@brunoais What do you mean indentation as-is? It looks fine to me but if you notice something wrong with it please add an in-line comment....

Don't Add Me To Your Organization a.k.a The Travis Bot

This pull request fails (merged 83057f1 into 2a92fee).

brunoais

Where should this appear? Near: [ Moderator Control Panel ] ex: in index.php, right?
It's not there :(

Andreas Fischer
Collaborator
bantu commented May 09, 2012

Since this is for develop, maybe the implementation should be more object oriented and "plugin-aware". Maybe it could be changed so you can just drop in files/classes to add new items requiring moderator attention. Maybe also with the ability to display some information on the index page like http://www.phpbb.com/customise/db/mod/mcp_info_on_index The exising code could be decomposed into two plugins: a) reported posts b) posts in moderation queue

Callum Macrae callumacrae commented on the diff May 15, 2012
phpBB/includes/functions_display.php
((20 lines not shown))
  1341
+	elseif ($auth->acl_getf_global('m_approve'))
  1342
+	{
  1343
+		$sql_where = ' WHERE ' . $db->sql_in_set('forum_id', get_forum_list('m_approve')) . ' AND post_approved = 0';
  1344
+		$allow = true;
  1345
+	}
  1346
+	elseif ($auth->acl_getf_global('m_report'))
  1347
+	{
  1348
+		$sql_where = ' WHERE ' . $db->sql_in_set('forum_id', get_forum_list('m_report')) . ' AND post_reported = 1';
  1349
+		$allow = true;
  1350
+	}
  1351
+
  1352
+	if ($allow)
  1353
+	{
  1354
+		$reported_posts_count = $unapproved_posts_count = $unapproved_topics_count = $reported_pms = 0;
  1355
+
  1356
+		// Topic Approval
1
Callum Macrae
callumacrae added a note May 15, 2012

Not that it is hugely significant, but shouldn't this be "Topic approval"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Callum Macrae callumacrae commented on the diff May 15, 2012
phpBB/includes/functions_display.php
((25 lines not shown))
  1346
+	elseif ($auth->acl_getf_global('m_report'))
  1347
+	{
  1348
+		$sql_where = ' WHERE ' . $db->sql_in_set('forum_id', get_forum_list('m_report')) . ' AND post_reported = 1';
  1349
+		$allow = true;
  1350
+	}
  1351
+
  1352
+	if ($allow)
  1353
+	{
  1354
+		$reported_posts_count = $unapproved_posts_count = $unapproved_topics_count = $reported_pms = 0;
  1355
+
  1356
+		// Topic Approval
  1357
+		if ($auth->acl_getf_global('m_approve'))
  1358
+		{
  1359
+			$sql = 'SELECT topic_first_post_id
  1360
+						FROM ' . TOPICS_TABLE . '
  1361
+					WHERE ' . $db->sql_in_set('forum_id', get_forum_list('m_approve')) . ' AND topic_approved = 0';
1
Callum Macrae
callumacrae added a note May 15, 2012

Spacing is weird here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Callum Macrae callumacrae commented on the diff May 15, 2012
phpBB/includes/functions_display.php
((109 lines not shown))
  1430
+			$sql = 'SELECT COUNT(msg_id) AS pms_count
  1431
+				FROM ' . PRIVMSGS_TABLE . '
  1432
+				WHERE message_reported = 1';
  1433
+			$result = $db->sql_query($sql);
  1434
+			$reported_pms = (int) $db->sql_fetchfield('pms_count');
  1435
+			$db->sql_freeresult($result);
  1436
+
  1437
+			// Cache for a few minutes to optimize. Might add to topics/posts later
  1438
+			$cache->put('_reported_pms', $reported_pms, 300);
  1439
+		}
  1440
+
  1441
+		// Dump to the template again
  1442
+		if ($reported_pms)
  1443
+		{
  1444
+			$l_reported_pms_count = $reported_pms ? (($reported_pms == 1) ? $user->lang['MODERATOR_NEEDED_REPORTED_PM'] : $user->lang['MODERATOR_NEEDED_REPORTED_PMS']) : '';
  1445
+			$total_reported_pms = 	sprintf($l_reported_pms_count, $reported_pms);
3
Callum Macrae
callumacrae added a note May 15, 2012

Random extra spaces after =

brunoais
brunoais added a note May 15, 2012

Not completely random, but padding wrongly applied. IMO, if there's a search for a padding, then it should be before the = and not after.

@brunoais It was a mistake, not on purpose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
David King
Collaborator

New PR: #809

David King imkingdavid closed this May 19, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
130  phpBB/includes/functions_display.php
@@ -1322,3 +1322,133 @@ function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $
1322 1322
 	$avatar_img .= $avatar;
1323 1323
 	return '<img src="' . (str_replace(' ', '%20', $avatar_img)) . '" width="' . $avatar_width . '" height="' . $avatar_height . '" alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />';
1324 1324
 }
  1325
+
  1326
+/**
  1327
+* Fetches the number of items which need a moderators attention
  1328
+*/
  1329
+function mcp_quick_info()
  1330
+{
  1331
+	global $auth, $cache, $db, $template, $user, $phpEx, $phpbb_root_path;
  1332
+
  1333
+	$allow = false;
  1334
+
  1335
+	// Check for approve and report permissions
  1336
+	if ($auth->acl_getf_global('m_approve') && $auth->acl_getf_global('m_report'))
  1337
+	{
  1338
+		$sql_where = ' WHERE (' . $db->sql_in_set('forum_id', get_forum_list('m_approve')) . ' or ' . $db->sql_in_set('forum_id', get_forum_list('m_report')) . ') AND (post_reported = 1 or post_approved = 0)';
  1339
+		$allow = true;
  1340
+	}
  1341
+	elseif ($auth->acl_getf_global('m_approve'))
  1342
+	{
  1343
+		$sql_where = ' WHERE ' . $db->sql_in_set('forum_id', get_forum_list('m_approve')) . ' AND post_approved = 0';
  1344
+		$allow = true;
  1345
+	}
  1346
+	elseif ($auth->acl_getf_global('m_report'))
  1347
+	{
  1348
+		$sql_where = ' WHERE ' . $db->sql_in_set('forum_id', get_forum_list('m_report')) . ' AND post_reported = 1';
  1349
+		$allow = true;
  1350
+	}
  1351
+
  1352
+	if ($allow)
  1353
+	{
  1354
+		$reported_posts_count = $unapproved_posts_count = $unapproved_topics_count = $reported_pms = 0;
  1355
+
  1356
+		// Topic Approval
  1357
+		if ($auth->acl_getf_global('m_approve'))
  1358
+		{
  1359
+			$sql = 'SELECT topic_first_post_id
  1360
+						FROM ' . TOPICS_TABLE . '
  1361
+					WHERE ' . $db->sql_in_set('forum_id', get_forum_list('m_approve')) . ' AND topic_approved = 0';
  1362
+			$result = $db->sql_query($sql);
  1363
+
  1364
+			$unapproved_topics_array = array();
  1365
+			while ($row = $db->sql_fetchrow($result))
  1366
+			{
  1367
+				$unapproved_topics_array[] = (int) $row['topic_first_post_id'];
  1368
+				$unapproved_topics_count++;
  1369
+			}
  1370
+			$db->sql_freeresult($result);
  1371
+
  1372
+			if(sizeof($unapproved_topics_array))
  1373
+			{
  1374
+				$sql_where .= ' AND ' . $db->sql_in_set('post_id', $unapproved_topics_array, true);
  1375
+			}
  1376
+		}
  1377
+
  1378
+		// Reported Posts and Approved Posts
  1379
+		$sql = 'SELECT post_reported, post_approved
  1380
+					FROM ' . POSTS_TABLE .
  1381
+				$sql_where . ' OR (forum_id = 0 and post_reported = 1)';
  1382
+		$result = $db->sql_query($sql);
  1383
+
  1384
+		while ($row = $db->sql_fetchrow($result))
  1385
+		{
  1386
+			// count the reported posts
  1387
+			if ($row['post_reported'])
  1388
+			{
  1389
+				$reported_posts_count++;
  1390
+			}
  1391
+			// count the unapproved posts
  1392
+			if (!$row['post_approved'])
  1393
+			{
  1394
+				$unapproved_posts_count++;
  1395
+			}
  1396
+		}
  1397
+		$db->sql_freeresult($result);
  1398
+
  1399
+		// Lets use this data
  1400
+		if ($reported_posts_count || $unapproved_posts_count || $unapproved_topics_count)
  1401
+		{
  1402
+			$l_reported_posts_count = $reported_posts_count ? (($reported_posts_count == 1) ? $user->lang['MODERATOR_NEEDED_REPORTED_POST'] : $user->lang['MODERATOR_NEEDED_REPORTED_POSTS']) : '';
  1403
+			$total_reported_posts = sprintf($l_reported_posts_count, $reported_posts_count);
  1404
+			$l_unapproved_topics_count = $unapproved_topics_count ? (($unapproved_topics_count == 1) ? $user->lang['MODERATOR_NEEDED_APPROVE_TOPIC'] : $user->lang['MODERATOR_NEEDED_APPROVE_TOPICS']) : '';
  1405
+			$total_unapproved_topics = sprintf($l_unapproved_topics_count, $unapproved_topics_count);
  1406
+			$l_unapproved_posts_count = $unapproved_posts_count ? (($unapproved_posts_count == 1) ? $user->lang['MODERATOR_NEEDED_APPROVE_POST'] : $user->lang['MODERATOR_NEEDED_APPROVE_POSTS']) : '';
  1407
+			$total_unapproved_posts = sprintf($l_unapproved_posts_count, $unapproved_posts_count);
  1408
+
  1409
+			// And export variables to the template
  1410
+			$template->assign_vars(array(
  1411
+				'TOTAL_MODERATOR_REPORTS'		=> $total_reported_posts,
  1412
+				'TOTAL_MODERATOR_POSTS'			=> $total_unapproved_posts,
  1413
+				'TOTAL_MODERATOR_TOPICS'    	=> $total_unapproved_topics,
  1414
+
  1415
+				'U_MODERATOR_REPORTS'			=> append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&amp;mode=reports', true, $user->session_id),
  1416
+				'U_MODERATOR_APPROVE_POSTS'		=> append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&amp;mode=unapproved_posts', true, $user->session_id),
  1417
+				'U_MODERATOR_APPROVE_TOPICS'    => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&amp;mode=unapproved_topics', true, $user->session_id),
  1418
+			));
  1419
+		}
  1420
+	}
  1421
+
  1422
+    // Don't forget PMs
  1423
+	if ($auth->acl_getf_global('m_'))
  1424
+	{
  1425
+		$reported_pms = 0;
  1426
+
  1427
+		// Lets have a cache
  1428
+		if (($reported_pms = $cache->get('_reported_pms')) === false)
  1429
+		{
  1430
+			$sql = 'SELECT COUNT(msg_id) AS pms_count
  1431
+				FROM ' . PRIVMSGS_TABLE . '
  1432
+				WHERE message_reported = 1';
  1433
+			$result = $db->sql_query($sql);
  1434
+			$reported_pms = (int) $db->sql_fetchfield('pms_count');
  1435
+			$db->sql_freeresult($result);
  1436
+
  1437
+			// Cache for a few minutes to optimize. Might add to topics/posts later
  1438
+			$cache->put('_reported_pms', $reported_pms, 300);
  1439
+		}
  1440
+
  1441
+		// Dump to the template again
  1442
+		if ($reported_pms)
  1443
+		{
  1444
+			$l_reported_pms_count = $reported_pms ? (($reported_pms == 1) ? $user->lang['MODERATOR_NEEDED_REPORTED_PM'] : $user->lang['MODERATOR_NEEDED_REPORTED_PMS']) : '';
  1445
+			$total_reported_pms = 	sprintf($l_reported_pms_count, $reported_pms);
  1446
+
  1447
+			$template->assign_vars(array(
  1448
+				'TOTAL_MODERATOR_PMS'			=> $total_reported_pms,
  1449
+				'U_MODERATOR_PMS'				=> append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=pm_reports&amp;mode=pm_reports', true, $user->session_id),
  1450
+			));
  1451
+		}
  1452
+	}
  1453
+	return;
  1454
+}
1  phpBB/includes/mcp/mcp_pm_reports.php
@@ -61,6 +61,7 @@ function main($id, $mode)
61 61
 				}
62 62
 
63 63
 				close_report($report_id_list, $mode, $action, true);
  64
+				$cache->purge('_reported_pms');
64 65
 
65 66
 			break;
66 67
 		}
8  phpBB/language/en/common.php
@@ -358,6 +358,14 @@
358 358
 	'MINUTES'				=> 'Minutes',
359 359
 	'MODERATE'				=> 'Moderate',
360 360
 	'MODERATOR'				=> 'Moderator',
  361
+	'MODERATOR_REPORTED_POST'	=> '<strong>%d</strong> reported post',
  362
+	'MODERATOR_REPORTED_POSTS'	=> '<strong>%d</strong> reported posts',
  363
+	'MODERATOR_APPROVE_POST'	=> '<strong>%d</strong> post awaiting approval',
  364
+	'MODERATOR_APPROVE_POSTS'	=> '<strong>%d</strong> posts awaiting approve',
  365
+	'MODERATOR_APPROVE_TOPIC'	=> '<strong>%d</strong> topic awaiting approval',
  366
+	'MODERATOR_APPROVE_TOPICS'	=> '<strong>%d</strong> topics awaiting approval',
  367
+	'MODERATOR_REPORTED_PM'		=> '<strong>%d</strong> PM is reported',
  368
+	'MODERATOR_REPORTED_PMS'	=> '<strong>%d</strong> PMs are reported',
361 369
 	'MODERATORS'			=> 'Moderators',
362 370
 	'MONTH'					=> 'Month',
363 371
 	'MOVE'					=> 'Move',
2  phpBB/styles/prosilver/template/index_body.html
... ...
@@ -1,7 +1,7 @@
1 1
 <!-- INCLUDE overall_header.html -->
2 2
 
3 3
 <p class="{S_CONTENT_FLOW_END}<!-- IF S_USER_LOGGED_IN --> rightside<!-- ENDIF -->"><!-- IF S_USER_LOGGED_IN -->{LAST_VISIT_DATE}<!-- ELSE -->{CURRENT_TIME}<!-- ENDIF --></p>
4  
-<!-- IF U_MCP --><p>{CURRENT_TIME} <br />[&nbsp;<a href="{U_MCP}">{L_MCP}</a>&nbsp;]</p><!-- ELSEIF S_USER_LOGGED_IN --><p>{CURRENT_TIME}</p><!-- ENDIF -->
  4
+<!-- IF U_MCP --><p>{CURRENT_TIME} <br />[&nbsp;<a href="{U_MCP}">{L_MCP}</a><!-- IF TOTAL_MODERATOR_REPORTS --> &bull; <a href="{U_MODERATOR_REPORTS}">{TOTAL_MODERATOR_REPORTS}</a><!-- ENDIF --><!-- IF TOTAL_MODERATOR_POSTS --> &bull; <a href="{U_MODERATOR_APPROVE_POSTS}">{TOTAL_MODERATOR_POSTS}</a><!-- ENDIF --><!-- IF TOTAL_MODERATOR_TOPICS --> &bull; <a href="{U_MODERATOR_APPROVE_TOPICS}">{TOTAL_MODERATOR_TOPICS}</a><!-- ENDIF --><!-- IF TOTAL_MODERATOR_PMS --> &bull; <a href="{U_MODERATOR_PMS}">{TOTAL_MODERATOR_PMS}</a><!-- ENDIF -->&nbsp;]</p><!-- ELSEIF S_USER_LOGGED_IN --><p>{CURRENT_TIME}</p><!-- ENDIF -->
5 5
 
6 6
 <!-- IF S_DISPLAY_SEARCH or (S_USER_LOGGED_IN and not S_IS_BOT) -->
7 7
 <ul class="linklist">
2  phpBB/styles/prosilver/template/viewforum_body.html
... ...
@@ -1,5 +1,5 @@
1 1
 <!-- INCLUDE overall_header.html -->
2  
-<!-- IF U_MCP --><p>[&nbsp;<a href="{U_MCP}">{L_MCP}</a>&nbsp;]</p><!-- ENDIF -->
  2
+<!-- IF U_MCP --><p>[&nbsp;<a href="{U_MCP}">{L_MCP}</a><!-- IF TOTAL_MODERATOR_REPORTS --> &bull; <a href="{U_MODERATOR_REPORTS}">{TOTAL_MODERATOR_REPORTS}</a><!-- ENDIF --><!-- IF TOTAL_MODERATOR_POSTS --> &bull; <a href="{U_MODERATOR_APPROVE_POSTS}">{TOTAL_MODERATOR_POSTS}</a><!-- ENDIF --><!-- IF TOTAL_MODERATOR_TOPICS --> &bull; <a href="{U_MODERATOR_APPROVE_TOPICS}">{TOTAL_MODERATOR_TOPICS}</a><!-- ENDIF --><!-- IF TOTAL_MODERATOR_PMS --> &bull; <a href="{U_MODERATOR_PMS}">{TOTAL_MODERATOR_PMS}</a><!-- ENDIF -->&nbsp;]</p><!-- ENDIF -->
3 3
 <h2><a href="{U_VIEW_FORUM}">{FORUM_NAME}</a></h2>
4 4
 
5 5
 <!-- IF FORUM_DESC or MODERATORS or U_MCP -->
2  phpBB/styles/prosilver/template/viewtopic_body.html
... ...
@@ -1,5 +1,5 @@
1 1
 <!-- INCLUDE overall_header.html -->
2  
-<!-- IF U_MCP --><p>[&nbsp;<a href="{U_MCP}">{L_MCP}</a>&nbsp;]</p><!-- ENDIF -->
  2
+<!-- IF U_MCP --><p>[&nbsp;<a href="{U_MCP}">{L_MCP}</a><!-- IF TOTAL_MODERATOR_REPORTS --> &bull; <a href="{U_MODERATOR_REPORTS}">{TOTAL_MODERATOR_REPORTS}</a><!-- ENDIF --><!-- IF TOTAL_MODERATOR_POSTS --> &bull; <a href="{U_MODERATOR_APPROVE_POSTS}">{TOTAL_MODERATOR_POSTS}</a><!-- ENDIF --><!-- IF TOTAL_MODERATOR_TOPICS --> &bull; <a href="{U_MODERATOR_APPROVE_TOPICS}">{TOTAL_MODERATOR_TOPICS}</a><!-- ENDIF --><!-- IF TOTAL_MODERATOR_PMS --> &bull; <a href="{U_MODERATOR_PMS}">{TOTAL_MODERATOR_PMS}</a><!-- ENDIF -->&nbsp;]</p><!-- ENDIF -->
3 3
 <h2><a href="{U_VIEW_TOPIC}">{TOPIC_TITLE}</a></h2>
4 4
 <!-- NOTE: remove the style="display: none" when you want to have the forum description on the topic body -->
5 5
 <!-- IF FORUM_DESC --><div style="display: none !important;">{FORUM_DESC}<br /></div><!-- ENDIF -->
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.