Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

WIP: [feature/moderator-needed] Display # of Items Requiring Moderator Attention #809

Closed
wants to merge 10 commits into from

5 participants

@imkingdavid

Old PR: #780

Display number of reported posts/PMs and unapproved topics/posts with MCP link for moderators with m_approve and m_report permissions.

Because Unknown Bliss asked me to sort of finish this up, I have begun a new pull request from my own branch so that he does not have to cherry pick my changes into the old PR. I tried to address all of the comments made on the old PR, but if I missed anything, or if you see something else that needs fixing, let me know.

EDIT: bantu suggested:

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

I will look into this later when I have some time. Until then, this needs some testing.

@travisbot

This pull request fails (merged 7d20c6e into f3d33bf).

@michaelcullum

Do you need this %d as we know it will be one? Same above.

@michaelcullum

Thanks

@Senky

Haven't you forget about subsilver2?

@imkingdavid

Not forgot, just haven't gotten to it yet. This is a WIP. ;)

@travisbot

This pull request passes (merged 48ae5e8 into f3d33bf).

@travisbot

This pull request fails (merged 3da0853 into f3d33bf).

@RMcGirr83

Seeing as nearly all of the code is being used from a mod I wrote a while ago, wouldn't a "Gee, thanks RMcGirr83" comment in the code be apropos?

/me slaps unknownbliss

@imkingdavid

I didnt even check this code against your MOD. I figured @unknownbliss had done it himself. I'll be sure to add a credit line for you before this gets merged, unless someone else does it first.

@michaelcullum

@imkingdavid It was mentioned in the RFC. Also see the first commit message. ;)

@michaelcullum

Perhaps this should be merged. Later on a template event can be added allowing extensions to add something here, but for now template events aren't merged so that isn't possible.

@imkingdavid

This is being closed because Reported posts and Posts awaiting approval are two moderator-level notifications introduced by #992 so this would be redundant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 20, 2012
  1. @michaelcullum @imkingdavid

    [feature/moderator-needed] Adding information about items requiring a…

    michaelcullum authored imkingdavid committed
    … moderators attention
    
    With thanks to RMcGirr83 for his Moderator Needed MOD.
    
    PHPBB3-10857
  2. @michaelcullum @imkingdavid
  3. @michaelcullum @imkingdavid

    [feature/moderator-needed] Remove extra } and adjust docblock indenta…

    michaelcullum authored imkingdavid committed
    …tion
    
    PHPBB3-10857
  4. @michaelcullum @imkingdavid
  5. @michaelcullum @imkingdavid

    [feature/moderator-needed] Fixing a php fatal error

    michaelcullum authored imkingdavid committed
    PHPBB3-10857
  6. @imkingdavid

    [feature/moderator-needed] Reorganize logic, use language plurals, an…

    imkingdavid authored
    …d other changes
    
    PHPBB3-10857
  7. @imkingdavid
  8. @imkingdavid

    [feature/moderator-needed] Add function call in page_header(), a few …

    imkingdavid authored
    …comment changes
    
    PHPBB3-10857
Commits on May 27, 2012
  1. @imkingdavid
  2. @imkingdavid
This page is out of date. Refresh to see the latest.
View
7 phpBB/includes/functions.php
@@ -4802,6 +4802,13 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
'A_COOKIE_SETTINGS' => addslashes('; path=' . $config['cookie_path'] . ((!$config['cookie_domain'] || $config['cookie_domain'] == 'localhost' || $config['cookie_domain'] == '127.0.0.1') ? '' : '; domain=' . $config['cookie_domain']) . ((!$config['cookie_secure']) ? '' : '; secure')),
));
+ // Determine the number of items requiring moderator attention
+ if (!function_exists('phpbb_mcp_quick_info'))
+ {
+ include("{$phpbb_root_path}includes/functions_display.$phpEx");
+ }
+ phpbb_mcp_quick_info();
+
$vars = array('page_title', 'display_online_list', 'item_id', 'item');
extract($phpbb_dispatcher->trigger_event('core.page_header', compact($vars)));
View
113 phpBB/includes/functions_display.php
@@ -1322,3 +1322,116 @@ function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $
$avatar_img .= $avatar;
return '<img src="' . (str_replace(' ', '%20', $avatar_img)) . '" width="' . $avatar_width . '" height="' . $avatar_height . '" alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />';
}
+
+/**
+* Fetches the number of items which need a moderators attention
+*
+* @return null
+*/
+function phpbb_mcp_quick_info()
+{
+ global $auth, $cache, $db, $template, $user, $phpEx, $phpbb_root_path;
+
+ $m_approve = $auth->acl_getf_global('m_approve');
+ $m_report = $auth->acl_getf_global('m_report');
+
+ // We have one or both of m_report and m_approve
+ if ($m_approve || $m_report)
+ {
+ $reported_posts_count = $unapproved_posts_count = $unapproved_topics_count = 0;
+
+ $sql_where = '';
+
+ // Check for m_report
+ if ($m_report)
+ {
+ // We add a ternary conditional to allow for having both permissions
+ $sql_where .= '(' . $db->sql_in_set('forum_id', get_forum_list('m_report')) . '
+ AND post_reported = 1)' . ($m_approve ? ' OR ' : '');
+ }
+
+ // Check for m_approve
+ if ($m_approve)
+ {
+ $sql_where .= '(' . $db->sql_in_set('forum_id', get_forum_list('m_approve')) . '
+ AND post_approved = 0)';
+
+ $sql = 'SELECT topic_first_post_id
+ FROM ' . TOPICS_TABLE . '
+ WHERE ' . $db->sql_in_set('forum_id', get_forum_list('m_approve')) . '
+ AND topic_approved = 0';
+ $result = $db->sql_query($sql);
+
+ $unapproved_topics_array = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $unapproved_topics_array[] = $row['topic_first_post_id'];
+ }
+ $db->sql_freeresult($result);
+
+ $unapproved_topics_count = count($unapproved_topics_array);
+
+ $sql_where .= $unapproved_topics_count ? ' AND ' . $db->sql_in_set('post_id', $unapproved_topics_array, true) : '';
+ }
+
+ // Reported Posts and Approved Posts
+ $sql = 'SELECT post_reported, post_approved
+ FROM ' . POSTS_TABLE . "
+ WHERE $sql_where";
+ $result = $db->sql_query($sql);
+
+ // Count number of unapproved and reported posts
+ while ($row = $db->sql_fetchrow($result))
+ {
+ // Count the reported posts
+ if ($row['post_reported'])
+ {
+ $reported_posts_count++;
+ }
+ // Count the unapproved posts
+ if (!$row['post_approved'])
+ {
+ $unapproved_posts_count++;
+ }
+ }
+ $db->sql_freeresult($result);
+
+ $template->assign_vars(array(
+ 'TOTAL_MODERATOR_REPORTS' => $user->lang('MODERATOR_REPORTED_POSTS', $reported_posts_count),
+ 'TOTAL_MODERATOR_POSTS' => $user->lang('MODERATOR_APPROVE_POSTS', $unapproved_posts_count),
+ 'TOTAL_MODERATOR_TOPICS' => $user->lang('MODERATOR_APPROVE_TOPICS', $unapproved_topics_count),
+
+ 'U_MODERATOR_REPORTS' => append_sid("{$phpbb_root_path}mcp.$phpEx", array('i' => 'reports', 'mode' => 'reports'), true, $user->session_id),
+ 'U_MODERATOR_APPROVE_POSTS' => append_sid("{$phpbb_root_path}mcp.$phpEx", array('i' => 'queue', 'mode' => 'unapproved_posts'), true, $user->session_id),
+ 'U_MODERATOR_APPROVE_TOPICS' => append_sid("{$phpbb_root_path}mcp.$phpEx", array('i' => 'queue', 'mode' => 'unapproved_topics'), true, $user->session_id),
+ ));
+ }
+
+ // Don't forget reported PMs
+ if ($auth->acl_getf_global('m_'))
+ {
+ $reported_pms = 0;
+
+ if (($reported_pms = $cache->get('_reported_pms')) === false)
+ {
+ $sql = 'SELECT COUNT(msg_id) AS pms_count
+ FROM ' . PRIVMSGS_TABLE . '
+ WHERE message_reported = 1';
+ $result = $db->sql_query($sql);
+ $reported_pms = (int) $db->sql_fetchfield('pms_count');
+ $db->sql_freeresult($result);
+
+ // Cache for a few minutes to optimize. Might add to topics/posts later
+ $cache->put('_reported_pms', $reported_pms, 300);
+ }
+
+ // Dump to the template
+ if ($reported_pms)
+ {
+ $template->assign_vars(array(
+ 'TOTAL_MODERATOR_PMS' => $user->lang('MODERATOR_REPORTED_PMS', $reported_pms),
+ 'U_MODERATOR_PMS' => append_sid("{$phpbb_root_path}mcp.$phpEx", array('i' => 'pm_reports', 'mode' => 'pm_reports'), true, $user->session_id),
+ ));
+ }
+ }
+}
View
1  phpBB/includes/mcp/mcp_pm_reports.php
@@ -61,6 +61,7 @@ function main($id, $mode)
}
close_report($report_id_list, $mode, $action, true);
+ $cache->purge('_reported_pms');
break;
}
View
16 phpBB/language/en/common.php
@@ -358,6 +358,22 @@
'MINUTES' => 'Minutes',
'MODERATE' => 'Moderate',
'MODERATOR' => 'Moderator',
+ 'MODERATOR_REPORTED_POSTS' => array(
+ 1 => '<strong>%d</strong> reported post',
+ 2 => '<strong>%d</strong> reported posts',
+ ),
+ 'MODERATOR_APPROVE_POSTS' => array(
+ 1 => '<strong>%d</strong> post awaiting approval',
+ 2 => '<strong>%d</strong> posts awaiting approval',
+ ),
+ 'MODERATOR_APPROVE_TOPICS' => array(
+ 1 => '<strong>%d</strong> topic awaiting approval',
+ 2 => '<strong>%d</strong> topics awaiting approval',
+ ),
+ 'MODERATOR_REPORTED_PMS' => array(
+ 1 => '<strong>%d</strong> reported PM',
+ 2 => '<strong>%d</strong> reported PMs',
+ ),
'MODERATORS' => 'Moderators',
'MONTH' => 'Month',
'MOVE' => 'Move',
View
2  phpBB/styles/prosilver/template/index_body.html
@@ -1,7 +1,7 @@
<!-- INCLUDE overall_header.html -->
<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>
-<!-- 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 -->
+<!-- IF U_MCP --><p>{CURRENT_TIME} <br />[&nbsp;<a href="{U_MCP}">{L_MCP}</a><!-- IF TOTAL_MODERATOR_REPORTS --> | <a href="{U_MODERATOR_REPORTS}">{TOTAL_MODERATOR_REPORTS}</a><!-- ENDIF --><!-- IF TOTAL_MODERATOR_POSTS --> | <a href="{U_MODERATOR_APPROVE_POSTS}">{TOTAL_MODERATOR_POSTS}</a><!-- ENDIF --><!-- IF TOTAL_MODERATOR_TOPICS --> | <a href="{U_MODERATOR_APPROVE_TOPICS}">{TOTAL_MODERATOR_TOPICS}</a><!-- ENDIF --><!-- IF TOTAL_MODERATOR_PMS --> | <a href="{U_MODERATOR_PMS}">{TOTAL_MODERATOR_PMS}</a><!-- ENDIF -->&nbsp;]</p><!-- ELSEIF S_USER_LOGGED_IN --><p>{CURRENT_TIME}</p><!-- ENDIF -->
<!-- IF S_DISPLAY_SEARCH or (S_USER_LOGGED_IN and not S_IS_BOT) -->
<ul class="linklist">
View
2  phpBB/styles/prosilver/template/viewforum_body.html
@@ -1,5 +1,5 @@
<!-- INCLUDE overall_header.html -->
-<!-- IF U_MCP --><p>[&nbsp;<a href="{U_MCP}">{L_MCP}</a>&nbsp;]</p><!-- ENDIF -->
+<!-- IF U_MCP --><p>[&nbsp;<a href="{U_MCP}">{L_MCP}</a><!-- IF TOTAL_MODERATOR_REPORTS --> | <a href="{U_MODERATOR_REPORTS}">{TOTAL_MODERATOR_REPORTS}</a><!-- ENDIF --><!-- IF TOTAL_MODERATOR_POSTS --> | <a href="{U_MODERATOR_APPROVE_POSTS}">{TOTAL_MODERATOR_POSTS}</a><!-- ENDIF --><!-- IF TOTAL_MODERATOR_TOPICS --> | <a href="{U_MODERATOR_APPROVE_TOPICS}">{TOTAL_MODERATOR_TOPICS}</a><!-- ENDIF --><!-- IF TOTAL_MODERATOR_PMS --> | <a href="{U_MODERATOR_PMS}">{TOTAL_MODERATOR_PMS}</a><!-- ENDIF -->&nbsp;]</p><!-- ENDIF -->
<h2><a href="{U_VIEW_FORUM}">{FORUM_NAME}</a></h2>
<!-- IF FORUM_DESC or MODERATORS or U_MCP -->
View
2  phpBB/styles/prosilver/template/viewtopic_body.html
@@ -1,5 +1,5 @@
<!-- INCLUDE overall_header.html -->
-<!-- IF U_MCP --><p>[&nbsp;<a href="{U_MCP}">{L_MCP}</a>&nbsp;]</p><!-- ENDIF -->
+<!-- IF U_MCP --><p>[&nbsp;<a href="{U_MCP}">{L_MCP}</a><!-- IF TOTAL_MODERATOR_REPORTS --> | <a href="{U_MODERATOR_REPORTS}">{TOTAL_MODERATOR_REPORTS}</a><!-- ENDIF --><!-- IF TOTAL_MODERATOR_POSTS --> | <a href="{U_MODERATOR_APPROVE_POSTS}">{TOTAL_MODERATOR_POSTS}</a><!-- ENDIF --><!-- IF TOTAL_MODERATOR_TOPICS --> | <a href="{U_MODERATOR_APPROVE_TOPICS}">{TOTAL_MODERATOR_TOPICS}</a><!-- ENDIF --><!-- IF TOTAL_MODERATOR_PMS --> | <a href="{U_MODERATOR_PMS}">{TOTAL_MODERATOR_PMS}</a><!-- ENDIF -->&nbsp;]</p><!-- ENDIF -->
<h2><a href="{U_VIEW_TOPIC}">{TOPIC_TITLE}</a></h2>
<!-- NOTE: remove the style="display: none" when you want to have the forum description on the topic body -->
<!-- IF FORUM_DESC --><div style="display: none !important;">{FORUM_DESC}<br /></div><!-- ENDIF -->
View
2  phpBB/styles/subsilver2/template/index_body.html
@@ -2,7 +2,7 @@
<!-- IF U_MCP -->
<div id="pageheader">
- <p class="linkmcp">[ <a href="{U_MCP}">{L_MCP}</a> ]</p>
+ <p class="linkmcp">[ <a href="{U_MCP}">{L_MCP}</a><!-- IF TOTAL_MODERATOR_REPORTS --> | <a href="{U_MODERATOR_REPORTS}">{TOTAL_MODERATOR_REPORTS}</a><!-- ENDIF --><!-- IF TOTAL_MODERATOR_POSTS --> | <a href="{U_MODERATOR_APPROVE_POSTS}">{TOTAL_MODERATOR_POSTS}</a><!-- ENDIF --><!-- IF TOTAL_MODERATOR_TOPICS --> | <a href="{U_MODERATOR_APPROVE_TOPICS}">{TOTAL_MODERATOR_TOPICS}</a><!-- ENDIF --><!-- IF TOTAL_MODERATOR_PMS --> | <a href="{U_MODERATOR_PMS}">{TOTAL_MODERATOR_PMS}</a><!-- ENDIF --> ]</p>
</div>
<br clear="all" /><br />
View
2  phpBB/styles/subsilver2/template/viewforum_body.html
@@ -95,7 +95,7 @@
<p class="moderators"><!-- IF S_SINGLE_MODERATOR -->{L_MODERATOR}<!-- ELSE -->{L_MODERATORS}<!-- ENDIF -->: {MODERATORS}</p>
<!-- ENDIF -->
<!-- IF U_MCP -->
- <p class="linkmcp">[ <a href="{U_MCP}">{L_MCP}</a> ]</p>
+ <p class="linkmcp">[ <a href="{U_MCP}">{L_MCP}</a><!-- IF TOTAL_MODERATOR_REPORTS --> | <a href="{U_MODERATOR_REPORTS}">{TOTAL_MODERATOR_REPORTS}</a><!-- ENDIF --><!-- IF TOTAL_MODERATOR_POSTS --> | <a href="{U_MODERATOR_APPROVE_POSTS}">{TOTAL_MODERATOR_POSTS}</a><!-- ENDIF --><!-- IF TOTAL_MODERATOR_TOPICS --> | <a href="{U_MODERATOR_APPROVE_TOPICS}">{TOTAL_MODERATOR_TOPICS}</a><!-- ENDIF --><!-- IF TOTAL_MODERATOR_PMS --> | <a href="{U_MODERATOR_PMS}">{TOTAL_MODERATOR_PMS}</a><!-- ENDIF --> ]</p>
<!-- ENDIF -->
</div>
View
2  phpBB/styles/subsilver2/template/viewtopic_body.html
@@ -21,7 +21,7 @@
<p class="moderators"><!-- IF S_SINGLE_MODERATOR -->{L_MODERATOR}<!-- ELSE -->{L_MODERATORS}<!-- ENDIF -->: {MODERATORS}</p>
<!-- ENDIF -->
<!-- IF U_MCP -->
- <p class="linkmcp">[ <a href="{U_MCP}">{L_MCP}</a> ]</p>
+ <p class="linkmcp">[ <a href="{U_MCP}">{L_MCP}</a><!-- IF TOTAL_MODERATOR_REPORTS --> | <a href="{U_MODERATOR_REPORTS}">{TOTAL_MODERATOR_REPORTS}</a><!-- ENDIF --><!-- IF TOTAL_MODERATOR_POSTS --> | <a href="{U_MODERATOR_APPROVE_POSTS}">{TOTAL_MODERATOR_POSTS}</a><!-- ENDIF --><!-- IF TOTAL_MODERATOR_TOPICS --> | <a href="{U_MODERATOR_APPROVE_TOPICS}">{TOTAL_MODERATOR_TOPICS}</a><!-- ENDIF --><!-- IF TOTAL_MODERATOR_PMS --> | <a href="{U_MODERATOR_PMS}">{TOTAL_MODERATOR_PMS}</a><!-- ENDIF --> ]</p>
<!-- ENDIF -->
</div>
Something went wrong with that request. Please try again.