aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/mcp
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/mcp')
-rw-r--r--phpBB/includes/mcp/mcp_queue.php82
-rw-r--r--phpBB/includes/mcp/mcp_warn.php122
2 files changed, 166 insertions, 38 deletions
diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php
index a71bc997e9..5f96d5952b 100644
--- a/phpBB/includes/mcp/mcp_queue.php
+++ b/phpBB/includes/mcp/mcp_queue.php
@@ -578,6 +578,7 @@ class mcp_queue
$redirect = reapply_sid($redirect);
$success_msg = $post_url = '';
$approve_log = array();
+ $num_topics = 0;
$s_hidden_fields = build_hidden_fields(array(
'i' => $id,
@@ -634,11 +635,6 @@ class mcp_queue
$phpbb_content_visibility->set_post_visibility(ITEM_APPROVED, $topic_data['posts'], $topic_id, $topic_data['forum_id'], $user->data['user_id'], time(), '', isset($topic_data['first_post']), isset($topic_data['last_post']));
}
- if (sizeof($post_info) >= 1)
- {
- $success_msg = (sizeof($post_info) == 1) ? 'POST_' . strtoupper($action) . 'D_SUCCESS' : 'POSTS_' . strtoupper($action) . 'D_SUCCESS';
- }
-
foreach ($approve_log as $log_data)
{
add_log('mod', $log_data['forum_id'], $log_data['topic_id'], 'LOG_POST_' . strtoupper($action) . 'D', $log_data['post_subject']);
@@ -656,21 +652,32 @@ class mcp_queue
if (!$post_data['topic_posts_approved'])
{
$phpbb_notifications->delete_notifications('topic_in_queue', $post_data['topic_id']);
+
+ if ($post_data['post_visibility'] == ITEM_UNAPPROVED)
+ {
+ $phpbb_notifications->add_notifications(array('topic'), $post_data);
+ }
+ if ($post_data['post_visibility'] != ITEM_APPROVED)
+ {
+ $num_topics++;
+ }
}
- $phpbb_notifications->delete_notifications('post_in_queue', $post_id);
-
- // Only add notifications, if we are not reapproving post
- // When the topic was already approved, but was edited and
- // now needs re-approval, we don't want to notify the users
- // again.
- if ($post_data['post_visibility'] == ITEM_UNAPPROVED)
+ else
{
- $phpbb_notifications->add_notifications(array(
- 'quote',
- 'bookmark',
- 'post',
- ), $post_data);
+ // Only add notifications, if we are not reapproving post
+ // When the topic was already approved, but was edited and
+ // now needs re-approval, we don't want to notify the users
+ // again.
+ if ($post_data['post_visibility'] == ITEM_UNAPPROVED)
+ {
+ $phpbb_notifications->add_notifications(array(
+ 'bookmark',
+ 'post',
+ ), $post_data);
+ }
}
+ $phpbb_notifications->add_notifications(array('quote'), $post_data);
+ $phpbb_notifications->delete_notifications('post_in_queue', $post_id);
$phpbb_notifications->mark_notifications_read(array(
'quote',
@@ -686,11 +693,27 @@ class mcp_queue
continue;
}
- $phpbb_notifications->add_notifications('approve_post', $post_data);
+ if (!$post_data['topic_posts_approved'])
+ {
+ $phpbb_notifications->add_notifications('approve_post', $post_data);
+ }
+ else
+ {
+ $phpbb_notifications->add_notifications('approve_topic', $post_data);
+ }
}
}
}
+ if ($num_topics >= 1)
+ {
+ $success_msg = ($num_topics == 1) ? 'TOPIC_' . strtoupper($action) . 'D_SUCCESS' : 'TOPICS_' . strtoupper($action) . 'D_SUCCESS';
+ }
+ else
+ {
+ $success_msg = (sizeof($post_info) == 1) ? 'POST_' . strtoupper($action) . 'D_SUCCESS' : 'POSTS_' . strtoupper($action) . 'D_SUCCESS';
+ }
+
meta_refresh(3, $redirect);
$message = $user->lang[$success_msg];
@@ -721,14 +744,14 @@ class mcp_queue
{
foreach ($post_info as $post_data)
{
- if ($post_data['poster_id'] == ANONYMOUS)
+ if (!$post_data['topic_posts_approved'])
{
- continue;
+ $num_topics++;
}
- else
+
+ if (!$show_notify && $post_data['poster_id'] != ANONYMOUS)
{
$show_notify = true;
- break;
}
}
}
@@ -738,7 +761,18 @@ class mcp_queue
'S_' . strtoupper($action) => true,
));
- confirm_box(false, strtoupper($action) . '_POST' . ((sizeof($post_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html');
+ // Create the confirm box message
+ $action_msg = strtoupper($action);
+ $num_posts = sizeof($post_id_list) - $num_topics;
+ if ($num_topics > 0 && $num_posts <= 0)
+ {
+ $action_msg .= '_TOPIC' . (($num_topics == 1) ? '' : 'S');
+ }
+ else
+ {
+ $action_msg .= '_POST' . ((sizeof($post_id_list) == 1) ? '' : 'S');
+ }
+ confirm_box(false, $action_msg, $s_hidden_fields, 'mcp_approve.html');
}
redirect($redirect);
@@ -834,7 +868,7 @@ class mcp_queue
'post_subject' => $topic_data['topic_title'],
'post_time' => $topic_data['topic_time'],
'poster_id' => $topic_data['topic_poster'],
- 'username' => $topic_data['topic_first_poster_name'],
+ 'post_username' => $topic_data['topic_first_poster_name'],
));
$phpbb_notifications->delete_notifications('topic_in_queue', $topic_id);
diff --git a/phpBB/includes/mcp/mcp_warn.php b/phpBB/includes/mcp/mcp_warn.php
index 4275182d26..ea6277ae2c 100644
--- a/phpBB/includes/mcp/mcp_warn.php
+++ b/phpBB/includes/mcp/mcp_warn.php
@@ -187,7 +187,7 @@ class mcp_warn
function mcp_warn_post_view($action)
{
global $phpEx, $phpbb_root_path, $config;
- global $template, $db, $user, $auth;
+ global $template, $db, $user, $auth, $phpbb_dispatcher;
$post_id = request_var('p', 0);
$forum_id = request_var('f', 0);
@@ -264,16 +264,65 @@ class mcp_warn
{
if (check_form_key('mcp_warn'))
{
- add_warning($user_row, $warning, $notify, $post_id);
- $msg = $user->lang['USER_WARNING_ADDED'];
+ $s_mcp_warn_post = true;
+
+ /**
+ * Event for before warning a user for a post.
+ *
+ * @event core.mcp_warn_post_before
+ * @var array user_row The entire user row
+ * @var string warning The warning message
+ * @var bool notify If true, we notify the user for the warning
+ * @var int post_id The post id for which the warning is added
+ * @var bool s_mcp_warn_post If true, we add the warning else we omit it
+ * @since 3.1.0-b4
+ */
+ $vars = array(
+ 'user_row',
+ 'warning',
+ 'notify',
+ 'post_id',
+ 's_mcp_warn_post',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.mcp_warn_post_before', compact($vars)));
+
+ if ($s_mcp_warn_post)
+ {
+ add_warning($user_row, $warning, $notify, $post_id);
+ $message = $user->lang['USER_WARNING_ADDED'];
+
+ /**
+ * Event for after warning a user for a post.
+ *
+ * @event core.mcp_warn_post_after
+ * @var array user_row The entire user row
+ * @var string warning The warning message
+ * @var bool notify If true, the user was notified for the warning
+ * @var int post_id The post id for which the warning is added
+ * @var string message Message displayed to the moderator
+ * @since 3.1.0-b4
+ */
+ $vars = array(
+ 'user_row',
+ 'warning',
+ 'notify',
+ 'post_id',
+ 'message',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.mcp_warn_post_after', compact($vars)));
+ }
}
else
{
- $msg = $user->lang['FORM_INVALID'];
+ $message = $user->lang['FORM_INVALID'];
+ }
+
+ if (!empty($message))
+ {
+ $redirect = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=notes&amp;mode=user_notes&amp;u=$user_id");
+ meta_refresh(2, $redirect);
+ trigger_error($message . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
}
- $redirect = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=notes&amp;mode=user_notes&amp;u=$user_id");
- meta_refresh(2, $redirect);
- trigger_error($msg . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
}
// OK, they didn't submit a warning so lets build the page for them to do so
@@ -318,7 +367,7 @@ class mcp_warn
function mcp_warn_user_view($action)
{
global $phpEx, $phpbb_root_path, $config, $module;
- global $template, $db, $user, $auth;
+ global $template, $db, $user, $auth, $phpbb_dispatcher;
$user_id = request_var('u', 0);
$username = request_var('username', '', true);
@@ -376,16 +425,61 @@ class mcp_warn
{
if (check_form_key('mcp_warn'))
{
- add_warning($user_row, $warning, $notify);
- $msg = $user->lang['USER_WARNING_ADDED'];
+ $s_mcp_warn_user = true;
+
+ /**
+ * Event for before warning a user from MCP.
+ *
+ * @event core.mcp_warn_user_before
+ * @var array user_row The entire user row
+ * @var string warning The warning message
+ * @var bool notify If true, we notify the user for the warning
+ * @var bool s_mcp_warn_user If true, we add the warning else we omit it
+ * @since 3.1.0-b4
+ */
+ $vars = array(
+ 'user_row',
+ 'warning',
+ 'notify',
+ 's_mcp_warn_user',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.mcp_warn_user_before', compact($vars)));
+
+ if ($s_mcp_warn_user)
+ {
+ add_warning($user_row, $warning, $notify);
+ $message = $user->lang['USER_WARNING_ADDED'];
+
+ /**
+ * Event for after warning a user from MCP.
+ *
+ * @event core.mcp_warn_user_after
+ * @var array user_row The entire user row
+ * @var string warning The warning message
+ * @var bool notify If true, the user was notified for the warning
+ * @var string message Message displayed to the moderator
+ * @since 3.1.0-b4
+ */
+ $vars = array(
+ 'user_row',
+ 'warning',
+ 'notify',
+ 'message',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.mcp_warn_user_after', compact($vars)));
+ }
}
else
{
- $msg = $user->lang['FORM_INVALID'];
+ $message = $user->lang['FORM_INVALID'];
+ }
+
+ if (!empty($message))
+ {
+ $redirect = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=notes&amp;mode=user_notes&amp;u=$user_id");
+ meta_refresh(2, $redirect);
+ trigger_error($message . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
}
- $redirect = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=notes&amp;mode=user_notes&amp;u=$user_id");
- meta_refresh(2, $redirect);
- trigger_error($msg . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
}
// Generate the appropriate user information for the user we are looking at