Merge branch 'develop-ascraeus' into develop

* develop-ascraeus:
  [ticket/12371] Fix language string
  [ticket/12371] Fix typos in comment
  [ticket/12371] Fix redirect link for approve_post and post_in_queue
  [ticket/12371] Delete the approve_post notification when editing a post
  [ticket/12371] Fix language in comment
  [ticket/12371] Reapprove the post and topic again in tests
  [ticket/12371] Correctly set is_starter when editing first post of the topic
  [ticket/12371] Add functional tests for reapproving
  [ticket/12371] Fix query in mcp_sorting()
  [ticket/12371] Rename disapprove and softdelete tests
  [ticket/12371] We do not group quote notifications anymore
  [ticket/12371] Fix SQL query
  [ticket/11772] Do not send out new topic/post notifications when reapproving
  [ticket/12052] Use different visibility when post was edited
  [ticket/12052] Add support for ITEM_UNAPPROVED to set_post_visibility method
  [ticket/12371] Do not add unlimited users as responders
  [ticket/12371] Do not update the notification entry unneccessarily
  [ticket/12371] Do not delete post related notifications when a post is deleted
  [ticket/12371] Allow notification types to redirect to a different url
  [ticket/12371] Do not group "quote" notifications
This commit is contained in:
Nils Adermann 2014-05-02 12:11:30 +02:00
commit fa06988eed
31 changed files with 646 additions and 156 deletions

View file

@ -533,7 +533,7 @@ class acp_prune
WHERE u.user_id <> ' . ANONYMOUS . ' WHERE u.user_id <> ' . ANONYMOUS . '
AND u.user_type <> ' . USER_FOUNDER . AND u.user_type <> ' . USER_FOUNDER .
((!empty($user_ids)) ? 'AND ' . $db->sql_in_set('p.poster_id', $user_ids) : '') . ' ((!empty($user_ids)) ? 'AND ' . $db->sql_in_set('p.poster_id', $user_ids) : '') . '
AND p.post_visibility = ' . ITEM_UNAPPROVED . ' AND ' . $db->sql_in_set('p.post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE)) . '
AND u.user_id = p.poster_id AND u.user_id = p.poster_id
GROUP BY p.poster_id GROUP BY p.poster_id
HAVING queue_posts ' . $key_match[$queue_select] . ' ' . $posts_on_queue; HAVING queue_posts ' . $key_match[$queue_select] . ' ' . $posts_on_queue;

View file

@ -657,6 +657,7 @@ class acp_users
{ {
if ($topic_id_ary[$row['topic_id']][ITEM_APPROVED] == $row['topic_posts_approved'] if ($topic_id_ary[$row['topic_id']][ITEM_APPROVED] == $row['topic_posts_approved']
&& $topic_id_ary[$row['topic_id']][ITEM_UNAPPROVED] == $row['topic_posts_unapproved'] && $topic_id_ary[$row['topic_id']][ITEM_UNAPPROVED] == $row['topic_posts_unapproved']
&& $topic_id_ary[$row['topic_id']][ITEM_REAPPROVE] == $row['topic_posts_unapproved']
&& $topic_id_ary[$row['topic_id']][ITEM_DELETED] == $row['topic_posts_softdeleted']) && $topic_id_ary[$row['topic_id']][ITEM_DELETED] == $row['topic_posts_softdeleted'])
{ {
$move_topic_ary[] = $row['topic_id']; $move_topic_ary[] = $row['topic_id'];
@ -1049,7 +1050,7 @@ class acp_users
$sql = 'SELECT COUNT(post_id) as posts_in_queue $sql = 'SELECT COUNT(post_id) as posts_in_queue
FROM ' . POSTS_TABLE . ' FROM ' . POSTS_TABLE . '
WHERE poster_id = ' . $user_id . ' WHERE poster_id = ' . $user_id . '
AND post_visibility = ' . ITEM_UNAPPROVED; AND ' . $db->sql_in_set('post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE));
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$user_row['posts_in_queue'] = (int) $db->sql_fetchfield('posts_in_queue'); $user_row['posts_in_queue'] = (int) $db->sql_fetchfield('posts_in_queue');
$db->sql_freeresult($result); $db->sql_freeresult($result);

View file

@ -91,6 +91,7 @@ define('ITEM_MOVED', 2);
define('ITEM_UNAPPROVED', 0); // => has not yet been approved define('ITEM_UNAPPROVED', 0); // => has not yet been approved
define('ITEM_APPROVED', 1); // => has been approved, and has not been soft deleted define('ITEM_APPROVED', 1); // => has been approved, and has not been soft deleted
define('ITEM_DELETED', 2); // => has been soft deleted define('ITEM_DELETED', 2); // => has been soft deleted
define('ITEM_REAPPROVE', 3); // => has been edited and needs to be re-approved
// Forum Flags // Forum Flags
define('FORUM_FLAG_LINK_TRACK', 1); define('FORUM_FLAG_LINK_TRACK', 1);

View file

@ -736,8 +736,6 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
// Notifications types to delete // Notifications types to delete
$delete_notifications_types = array( $delete_notifications_types = array(
'quote', 'quote',
'bookmark',
'post',
'approve_post', 'approve_post',
'post_in_queue', 'post_in_queue',
); );
@ -1489,7 +1487,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
ITEM_DELETED => (!empty($topics_softdeleted)) ? ' WHERE ' . $db->sql_in_set('topic_id', $topics_softdeleted) : '', ITEM_DELETED => (!empty($topics_softdeleted)) ? ' WHERE ' . $db->sql_in_set('topic_id', $topics_softdeleted) : '',
); );
foreach ($topic_visiblities as $visibility => $sql_where) foreach ($update_ary as $visibility => $sql_where)
{ {
if ($sql_where) if ($sql_where)
{ {
@ -1778,7 +1776,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
{ {
$forum_data[$forum_id]['topics_approved'] = $row['total_topics']; $forum_data[$forum_id]['topics_approved'] = $row['total_topics'];
} }
else if ($row['topic_visibility'] == ITEM_UNAPPROVED) else if ($row['topic_visibility'] == ITEM_UNAPPROVED || $row['topic_visibility'] == ITEM_REAPPROVE)
{ {
$forum_data[$forum_id]['topics_unapproved'] = $row['total_topics']; $forum_data[$forum_id]['topics_unapproved'] = $row['total_topics'];
} }
@ -2001,7 +1999,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
{ {
$topic_data[$topic_id]['posts_approved'] = $row['total_posts']; $topic_data[$topic_id]['posts_approved'] = $row['total_posts'];
} }
else if ($row['post_visibility'] == ITEM_UNAPPROVED) else if ($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE)
{ {
$topic_data[$topic_id]['posts_unapproved'] = $row['total_posts']; $topic_data[$topic_id]['posts_unapproved'] = $row['total_posts'];
} }
@ -2023,7 +2021,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
$topic_data[$topic_id]['first_post_id'] = (!empty($topic_data[$topic_id]['first_post_id'])) ? min($topic_data[$topic_id]['first_post_id'], $row['first_post_id']) : $row['first_post_id']; $topic_data[$topic_id]['first_post_id'] = (!empty($topic_data[$topic_id]['first_post_id'])) ? min($topic_data[$topic_id]['first_post_id'], $row['first_post_id']) : $row['first_post_id'];
$topic_data[$topic_id]['last_post_id'] = max($topic_data[$topic_id]['last_post_id'], $row['last_post_id']); $topic_data[$topic_id]['last_post_id'] = max($topic_data[$topic_id]['last_post_id'], $row['last_post_id']);
if ($topic_data[$topic_id]['visibility'] == ITEM_UNAPPROVED) if ($topic_data[$topic_id]['visibility'] == ITEM_UNAPPROVED || $topic_data[$topic_id]['visibility'] == ITEM_REAPPROVE)
{ {
// Soft delete status is stronger than unapproved. // Soft delete status is stronger than unapproved.
$topic_data[$topic_id]['visibility'] = $row['post_visibility']; $topic_data[$topic_id]['visibility'] = $row['post_visibility'];

View file

@ -1295,7 +1295,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $
{ {
$sql_data[FORUMS_TABLE] .= 'forum_posts_approved = forum_posts_approved - 1, forum_topics_approved = forum_topics_approved - 1'; $sql_data[FORUMS_TABLE] .= 'forum_posts_approved = forum_posts_approved - 1, forum_topics_approved = forum_topics_approved - 1';
} }
else if ($data['topic_visibility'] == ITEM_UNAPPROVED) else if ($data['topic_visibility'] == ITEM_UNAPPROVED || $data['post_visibility'] == ITEM_REAPPROVE)
{ {
$sql_data[FORUMS_TABLE] .= 'forum_posts_unapproved = forum_posts_unapproved - 1, forum_topics_unapproved = forum_topics_unapproved - 1'; $sql_data[FORUMS_TABLE] .= 'forum_posts_unapproved = forum_posts_unapproved - 1, forum_topics_unapproved = forum_topics_unapproved - 1';
} }
@ -1402,7 +1402,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $
{ {
$phpbb_content_visibility->remove_post_from_statistic($data, $sql_data); $phpbb_content_visibility->remove_post_from_statistic($data, $sql_data);
} }
else if ($data['post_visibility'] == ITEM_UNAPPROVED) else if ($data['post_visibility'] == ITEM_UNAPPROVED || $data['post_visibility'] == ITEM_REAPPROVE)
{ {
$sql_data[FORUMS_TABLE] = (($sql_data[FORUMS_TABLE]) ? $sql_data[FORUMS_TABLE] . ', ' : '') . 'forum_posts_unapproved = forum_posts_unapproved - 1'; $sql_data[FORUMS_TABLE] = (($sql_data[FORUMS_TABLE]) ? $sql_data[FORUMS_TABLE] . ', ' : '') . 'forum_posts_unapproved = forum_posts_unapproved - 1';
$sql_data[TOPICS_TABLE] = (($sql_data[TOPICS_TABLE]) ? $sql_data[TOPICS_TABLE] . ', ' : '') . 'topic_posts_unapproved = topic_posts_unapproved - 1'; $sql_data[TOPICS_TABLE] = (($sql_data[TOPICS_TABLE]) ? $sql_data[TOPICS_TABLE] . ', ' : '') . 'topic_posts_unapproved = topic_posts_unapproved - 1';
@ -1554,16 +1554,25 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
{ {
// Post not approved, but in queue // Post not approved, but in queue
$post_visibility = ITEM_UNAPPROVED; $post_visibility = ITEM_UNAPPROVED;
switch ($post_mode)
{
case 'edit_first_post':
case 'edit':
case 'edit_last_post':
case 'edit_topic':
$post_visibility = ITEM_REAPPROVE;
break;
}
} }
// MODs/Extensions are able to force any visibility on posts // MODs/Extensions are able to force any visibility on posts
if (isset($data['force_approved_state'])) if (isset($data['force_approved_state']))
{ {
$post_visibility = (in_array((int) $data['force_approved_state'], array(ITEM_APPROVED, ITEM_UNAPPROVED, ITEM_DELETED))) ? (int) $data['force_approved_state'] : $post_visibility; $post_visibility = (in_array((int) $data['force_approved_state'], array(ITEM_APPROVED, ITEM_UNAPPROVED, ITEM_DELETED, ITEM_REAPPROVE))) ? (int) $data['force_approved_state'] : $post_visibility;
} }
if (isset($data['force_visibility'])) if (isset($data['force_visibility']))
{ {
$post_visibility = (in_array((int) $data['force_visibility'], array(ITEM_APPROVED, ITEM_UNAPPROVED, ITEM_DELETED))) ? (int) $data['force_visibility'] : $post_visibility; $post_visibility = (in_array((int) $data['force_visibility'], array(ITEM_APPROVED, ITEM_UNAPPROVED, ITEM_DELETED, ITEM_REAPPROVE))) ? (int) $data['force_visibility'] : $post_visibility;
} }
// Start the transaction here // Start the transaction here
@ -2031,6 +2040,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
$first_post_has_topic_info = ($post_mode == 'edit_first_post' && $first_post_has_topic_info = ($post_mode == 'edit_first_post' &&
(($post_visibility == ITEM_DELETED && $data['topic_posts_softdeleted'] == 1) || (($post_visibility == ITEM_DELETED && $data['topic_posts_softdeleted'] == 1) ||
($post_visibility == ITEM_UNAPPROVED && $data['topic_posts_unapproved'] == 1) || ($post_visibility == ITEM_UNAPPROVED && $data['topic_posts_unapproved'] == 1) ||
($post_visibility == ITEM_REAPPROVE && $data['topic_posts_unapproved'] == 1) ||
($post_visibility == ITEM_APPROVED && $data['topic_posts_approved'] == 1))); ($post_visibility == ITEM_APPROVED && $data['topic_posts_approved'] == 1)));
// Fix the post's and topic's visibility and first/last post information, when the post is edited // Fix the post's and topic's visibility and first/last post information, when the post is edited
if (($post_mode != 'post' && $post_mode != 'reply') && $data['post_visibility'] != $post_visibility) if (($post_mode != 'post' && $post_mode != 'reply') && $data['post_visibility'] != $post_visibility)
@ -2038,7 +2048,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
// If the post was not approved, it could also be the starter, // If the post was not approved, it could also be the starter,
// so we sync the starter after approving/restoring, to ensure that the stats are correct // so we sync the starter after approving/restoring, to ensure that the stats are correct
// Same applies for the last post // Same applies for the last post
$is_starter = ($post_mode == 'edit_first_post' || $data['post_visibility'] != ITEM_APPROVED); $is_starter = ($post_mode == 'edit_first_post' || $post_mode == 'edit_topic' || $data['post_visibility'] != ITEM_APPROVED);
$is_latest = ($post_mode == 'edit_last_post' || $post_mode == 'edit_topic' || $data['post_visibility'] != ITEM_APPROVED); $is_latest = ($post_mode == 'edit_last_post' || $post_mode == 'edit_topic' || $data['post_visibility'] != ITEM_APPROVED);
$phpbb_content_visibility = $phpbb_container->get('content.visibility'); $phpbb_content_visibility = $phpbb_container->get('content.visibility');
@ -2271,16 +2281,36 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
case 'edit_first_post': case 'edit_first_post':
case 'edit': case 'edit':
case 'edit_last_post': case 'edit_last_post':
if ($data['topic_visibility'] != ITEM_APPROVED) // Nothing to do here
{ break;
$phpbb_notifications->delete_notifications('topic', $data['topic_id']);
} }
}
else if ($post_visibility == ITEM_REAPPROVE)
{
switch ($mode)
{
case 'edit_topic':
case 'edit_first_post':
$phpbb_notifications->add_notifications('topic_in_queue', $notification_data);
$phpbb_notifications->delete_notifications(array( // Delete the approve_post notification so we can notify the user again,
'quote', // when his post got reapproved
'bookmark', $phpbb_notifications->delete_notifications('approve_post', $notification_data['post_id']);
'post', break;
), $data['post_id']);
case 'edit':
case 'edit_last_post':
$phpbb_notifications->add_notifications('post_in_queue', $notification_data);
// Delete the approve_post notification so we can notify the user again,
// when his post got reapproved
$phpbb_notifications->delete_notifications('approve_post', $notification_data['post_id']);
break;
case 'post':
case 'reply':
case 'quote':
// Nothing to do here
break; break;
} }
} }
@ -2291,23 +2321,11 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
case 'post': case 'post':
case 'reply': case 'reply':
case 'quote': case 'quote':
// Nothing to do here
break;
case 'edit_topic': case 'edit_topic':
case 'edit_first_post': case 'edit_first_post':
case 'edit': case 'edit':
case 'edit_last_post': case 'edit_last_post':
if ($data['topic_visibility'] != ITEM_APPROVED) // Nothing to do here
{
$phpbb_notifications->delete_notifications('topic', $data['topic_id']);
}
$phpbb_notifications->delete_notifications(array(
'quote',
'bookmark',
'post',
), $data['post_id']);
break; break;
} }
} }

View file

@ -224,7 +224,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info)
$topic_title = censor_text($row['topic_title']); $topic_title = censor_text($row['topic_title']);
$topic_unapproved = ($row['topic_visibility'] == ITEM_UNAPPROVED && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false; $topic_unapproved = (($row['topic_visibility'] == ITEM_UNAPPROVED || $row['topic_visibility'] == ITEM_REAPPROVE) && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false;
$posts_unapproved = ($row['topic_visibility'] == ITEM_APPROVED && $row['topic_posts_unapproved'] && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false; $posts_unapproved = ($row['topic_visibility'] == ITEM_APPROVED && $row['topic_posts_unapproved'] && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false;
$topic_deleted = $row['topic_visibility'] == ITEM_DELETED; $topic_deleted = $row['topic_visibility'] == ITEM_DELETED;
$u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? $url . '&amp;i=queue&amp;mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . '&amp;t=' . $row['topic_id'] : ''; $u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? $url . '&amp;i=queue&amp;mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . '&amp;t=' . $row['topic_id'] : '';

View file

@ -39,7 +39,7 @@ function mcp_front_view($id, $mode, $action)
$sql = 'SELECT COUNT(post_id) AS total $sql = 'SELECT COUNT(post_id) AS total
FROM ' . POSTS_TABLE . ' FROM ' . POSTS_TABLE . '
WHERE ' . $db->sql_in_set('forum_id', $forum_list) . ' WHERE ' . $db->sql_in_set('forum_id', $forum_list) . '
AND post_visibility = ' . ITEM_UNAPPROVED; AND ' . $db->sql_in_set('post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE));
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$total = (int) $db->sql_fetchfield('total'); $total = (int) $db->sql_fetchfield('total');
$db->sql_freeresult($result); $db->sql_freeresult($result);
@ -60,7 +60,7 @@ function mcp_front_view($id, $mode, $action)
$sql = 'SELECT post_id $sql = 'SELECT post_id
FROM ' . POSTS_TABLE . ' FROM ' . POSTS_TABLE . '
WHERE ' . $db->sql_in_set('forum_id', $forum_list) . ' WHERE ' . $db->sql_in_set('forum_id', $forum_list) . '
AND post_visibility = ' . ITEM_UNAPPROVED . ' AND ' . $db->sql_in_set('post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE)) . '
ORDER BY post_time DESC'; ORDER BY post_time DESC';
$result = $db->sql_query_limit($sql, 5); $result = $db->sql_query_limit($sql, 5);

View file

@ -493,7 +493,7 @@ function mcp_move_topic($topic_ids)
{ {
$topics_moved++; $topics_moved++;
} }
elseif ($topic_info['topic_visibility'] == ITEM_UNAPPROVED) elseif ($topic_info['topic_visibility'] == ITEM_UNAPPROVED || $topic_info['topic_visibility'] == ITEM_REAPPROVE)
{ {
$topics_moved_unapproved++; $topics_moved_unapproved++;
} }
@ -1230,6 +1230,7 @@ function mcp_fork_topic($topic_ids)
$total_topics++; $total_topics++;
break; break;
case ITEM_UNAPPROVED: case ITEM_UNAPPROVED:
case ITEM_REAPPROVE:
$total_topics_unapproved++; $total_topics_unapproved++;
break; break;
case ITEM_DELETED: case ITEM_DELETED:
@ -1316,6 +1317,7 @@ function mcp_fork_topic($topic_ids)
$total_posts++; $total_posts++;
break; break;
case ITEM_UNAPPROVED: case ITEM_UNAPPROVED:
case ITEM_REAPPROVE:
$total_posts_unapproved++; $total_posts_unapproved++;
break; break;
case ITEM_DELETED: case ITEM_DELETED:

View file

@ -203,7 +203,7 @@ function mcp_post_details($id, $mode, $action)
'S_CAN_DELETE_POST' => $auth->acl_get('m_delete', $post_info['forum_id']), 'S_CAN_DELETE_POST' => $auth->acl_get('m_delete', $post_info['forum_id']),
'S_POST_REPORTED' => ($post_info['post_reported']) ? true : false, 'S_POST_REPORTED' => ($post_info['post_reported']) ? true : false,
'S_POST_UNAPPROVED' => ($post_info['post_visibility'] == ITEM_UNAPPROVED) ? true : false, 'S_POST_UNAPPROVED' => ($post_info['post_visibility'] == ITEM_UNAPPROVED || $post_info['post_visibility'] == ITEM_REAPPROVE) ? true : false,
'S_POST_DELETED' => ($post_info['post_visibility'] == ITEM_DELETED) ? true : false, 'S_POST_DELETED' => ($post_info['post_visibility'] == ITEM_DELETED) ? true : false,
'S_POST_LOCKED' => ($post_info['post_edit_locked']) ? true : false, 'S_POST_LOCKED' => ($post_info['post_edit_locked']) ? true : false,
'S_USER_NOTES' => true, 'S_USER_NOTES' => true,

View file

@ -115,10 +115,10 @@ class mcp_queue
if (!empty($topic_id_list)) if (!empty($topic_id_list))
{ {
$post_visibility = ($mode == 'deleted_topics') ? ITEM_DELETED : ITEM_UNAPPROVED; $post_visibility = ($mode == 'deleted_topics') ? ITEM_DELETED : array(ITEM_UNAPPROVED, ITEM_REAPPROVE);
$sql = 'SELECT post_id $sql = 'SELECT post_id
FROM ' . POSTS_TABLE . ' FROM ' . POSTS_TABLE . '
WHERE post_visibility = ' . $post_visibility . ' WHERE ' . $db->sql_in_set('post_visibility', $post_visibility) . '
AND ' . $db->sql_in_set('topic_id', $topic_id_list); AND ' . $db->sql_in_set('topic_id', $topic_id_list);
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
@ -281,7 +281,7 @@ class mcp_queue
'U_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&amp;p=$post_id&amp;f=$forum_id"), 'U_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&amp;p=$post_id&amp;f=$forum_id"),
'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']), 'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']),
'S_POST_REPORTED' => $post_info['post_reported'], 'S_POST_REPORTED' => $post_info['post_reported'],
'S_POST_UNAPPROVED' => ($post_info['post_visibility'] == ITEM_UNAPPROVED), 'S_POST_UNAPPROVED' => $post_info['post_visibility'] == ITEM_UNAPPROVED || $post_info['post_visibility'] == ITEM_REAPPROVE,
'S_POST_LOCKED' => $post_info['post_edit_locked'], 'S_POST_LOCKED' => $post_info['post_edit_locked'],
'S_USER_NOTES' => true, 'S_USER_NOTES' => true,
'S_POST_DELETED' => ($post_info['post_visibility'] == ITEM_DELETED), 'S_POST_DELETED' => ($post_info['post_visibility'] == ITEM_DELETED),
@ -330,7 +330,7 @@ class mcp_queue
$m_perm = 'm_approve'; $m_perm = 'm_approve';
$is_topics = ($mode == 'unapproved_topics' || $mode == 'deleted_topics') ? true : false; $is_topics = ($mode == 'unapproved_topics' || $mode == 'deleted_topics') ? true : false;
$is_restore = ($mode == 'deleted_posts' || $mode == 'deleted_topics') ? true : false; $is_restore = ($mode == 'deleted_posts' || $mode == 'deleted_topics') ? true : false;
$visibility_const = (!$is_restore) ? ITEM_UNAPPROVED : ITEM_DELETED; $visibility_const = (!$is_restore) ? array(ITEM_UNAPPROVED, ITEM_REAPPROVE) : ITEM_DELETED;
$user->add_lang(array('viewtopic', 'viewforum')); $user->add_lang(array('viewtopic', 'viewforum'));
@ -418,7 +418,7 @@ class mcp_queue
$sql = 'SELECT p.post_id $sql = 'SELECT p.post_id
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . ' FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . '
WHERE ' . $db->sql_in_set('p.forum_id', $forum_list) . ' WHERE ' . $db->sql_in_set('p.forum_id', $forum_list) . '
AND p.post_visibility = ' . $visibility_const . ' AND ' . $db->sql_in_set('p.post_visibility', $visibility_const) . '
' . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.poster_id' : '') . ' ' . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.poster_id' : '') . '
' . (($topic_id) ? 'AND p.topic_id = ' . $topic_id : '') . " ' . (($topic_id) ? 'AND p.topic_id = ' . $topic_id : '') . "
AND t.topic_id = p.topic_id AND t.topic_id = p.topic_id
@ -471,7 +471,7 @@ class mcp_queue
$sql = 'SELECT t.forum_id, t.topic_id, t.topic_title, t.topic_title AS post_subject, t.topic_time AS post_time, t.topic_poster AS poster_id, t.topic_first_post_id AS post_id, t.topic_attachment AS post_attachment, t.topic_first_poster_name AS username, t.topic_first_poster_colour AS user_colour $sql = 'SELECT t.forum_id, t.topic_id, t.topic_title, t.topic_title AS post_subject, t.topic_time AS post_time, t.topic_poster AS poster_id, t.topic_first_post_id AS post_id, t.topic_attachment AS post_attachment, t.topic_first_poster_name AS username, t.topic_first_poster_colour AS user_colour
FROM ' . TOPICS_TABLE . ' t FROM ' . TOPICS_TABLE . ' t
WHERE ' . $db->sql_in_set('forum_id', $forum_list) . ' WHERE ' . $db->sql_in_set('forum_id', $forum_list) . '
AND topic_visibility = ' . $visibility_const . " AND ' . $db->sql_in_set('topic_visibility', $visibility_const) . "
AND topic_delete_user <> 0 AND topic_delete_user <> 0
$limit_time_sql $limit_time_sql
ORDER BY $sort_order_sql"; ORDER BY $sort_order_sql";
@ -659,11 +659,18 @@ class mcp_queue
} }
$phpbb_notifications->delete_notifications('post_in_queue', $post_id); $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)
{
$phpbb_notifications->add_notifications(array( $phpbb_notifications->add_notifications(array(
'quote', 'quote',
'bookmark', 'bookmark',
'post', 'post',
), $post_data); ), $post_data);
}
$phpbb_notifications->mark_notifications_read(array( $phpbb_notifications->mark_notifications_read(array(
'quote', 'quote',
@ -831,10 +838,18 @@ class mcp_queue
)); ));
$phpbb_notifications->delete_notifications('topic_in_queue', $topic_id); $phpbb_notifications->delete_notifications('topic_in_queue', $topic_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 ($topic_data['topic_visibility'] == ITEM_UNAPPROVED)
{
$phpbb_notifications->add_notifications(array( $phpbb_notifications->add_notifications(array(
'quote', 'quote',
'topic', 'topic',
), $topic_data); ), $topic_data);
}
$phpbb_notifications->mark_notifications_read('quote', $topic_data['post_id'], $user->data['user_id']); $phpbb_notifications->mark_notifications_read('quote', $topic_data['post_id'], $user->data['user_id']);
$phpbb_notifications->mark_notifications_read('topic', $topic_id, $user->data['user_id']); $phpbb_notifications->mark_notifications_read('topic', $topic_id, $user->data['user_id']);

View file

@ -186,7 +186,7 @@ class mcp_reports
'S_CLOSE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&amp;mode=report_details&amp;f=' . $post_info['forum_id'] . '&amp;p=' . $post_id), 'S_CLOSE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&amp;mode=report_details&amp;f=' . $post_info['forum_id'] . '&amp;p=' . $post_id),
'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']), 'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']),
'S_POST_REPORTED' => $post_info['post_reported'], 'S_POST_REPORTED' => $post_info['post_reported'],
'S_POST_UNAPPROVED' => ($post_info['post_visibility'] == ITEM_UNAPPROVED), 'S_POST_UNAPPROVED' => $post_info['post_visibility'] == ITEM_UNAPPROVED || $post_info['post_visibility'] == ITEM_REAPPROVE,
'S_POST_LOCKED' => $post_info['post_edit_locked'], 'S_POST_LOCKED' => $post_info['post_edit_locked'],
'S_REPORT_CLOSED' => $report['report_closed'], 'S_REPORT_CLOSED' => $report['report_closed'],
'S_USER_NOTES' => true, 'S_USER_NOTES' => true,

View file

@ -212,7 +212,7 @@ function mcp_topic_view($id, $mode, $action)
parse_attachments($topic_info['forum_id'], $message, $attachments[$row['post_id']], $update_count); parse_attachments($topic_info['forum_id'], $message, $attachments[$row['post_id']], $update_count);
} }
if ($row['post_visibility'] == ITEM_UNAPPROVED) if ($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE)
{ {
$has_unapproved_posts = true; $has_unapproved_posts = true;
} }
@ -239,7 +239,7 @@ function mcp_topic_view($id, $mode, $action)
'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'UNREAD_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'),
'S_POST_REPORTED' => ($row['post_reported'] && $auth->acl_get('m_report', $topic_info['forum_id'])), 'S_POST_REPORTED' => ($row['post_reported'] && $auth->acl_get('m_report', $topic_info['forum_id'])),
'S_POST_UNAPPROVED' => ($row['post_visibility'] == ITEM_UNAPPROVED && $auth->acl_get('m_approve', $topic_info['forum_id'])), 'S_POST_UNAPPROVED' => (($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) && $auth->acl_get('m_approve', $topic_info['forum_id'])),
'S_POST_DELETED' => ($row['post_visibility'] == ITEM_DELETED && $auth->acl_get('m_approve', $topic_info['forum_id'])), 'S_POST_DELETED' => ($row['post_visibility'] == ITEM_DELETED && $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_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_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false,
@ -462,7 +462,7 @@ function split_topic($action, $topic_id, $to_forum_id, $subject)
while ($row = $db->sql_fetchrow($result)) while ($row = $db->sql_fetchrow($result))
{ {
// If split from selected post (split_beyond), we split the unapproved items too. // If split from selected post (split_beyond), we split the unapproved items too.
if ($row['post_visibility'] == ITEM_UNAPPROVED && !$auth->acl_get('m_approve', $row['forum_id'])) if (($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) && !$auth->acl_get('m_approve', $row['forum_id']))
{ {
// continue; // continue;
} }

View file

@ -63,7 +63,7 @@ if (($mark_notification = $request->variable('mark_notification', 0)))
redirect(append_sid($phpbb_root_path . $redirect)); redirect(append_sid($phpbb_root_path . $redirect));
} }
redirect($notification->get_url()); redirect($notification->get_redirect_url());
} }
} }
} }

View file

@ -422,14 +422,16 @@ $lang = array_merge($lang, array(
'NOT_WATCHING_FORUM' => 'You are no longer subscribed to updates on this forum.', 'NOT_WATCHING_FORUM' => 'You are no longer subscribed to updates on this forum.',
'NOT_WATCHING_TOPIC' => 'You are no longer subscribed to this topic.', 'NOT_WATCHING_TOPIC' => 'You are no longer subscribed to this topic.',
'NOTIFICATIONS' => 'Notifications', 'NOTIFICATIONS' => 'Notifications',
// This applies for NOTIFICATION_BOOKMARK, NOTIFICATION_POST, and NOTIFICATION_QUOTE. // This applies for NOTIFICATION_BOOKMARK and NOTIFICATION_POST.
// %1$s will return a list of users that's concatenated using "," and "and" - see STRING_LIST // %1$s will return a list of users that's concatenated using "," and "and" - see STRING_LIST
// Once the user count reaches 5 users or more, the list is trimmed using NOTIFICATION_X_OTHERS // Once the user count reaches 5 users or more, the list is trimmed using NOTIFICATION_X_OTHERS
// Once the user count reaches 20 users or more, the list is trimmed using NOTIFICATION_MANY_OTHERS
// Examples: // Examples:
// A replied... // A replied...
// A and B replied... // A and B replied...
// A, B and C replied... // A, B and C replied...
// A, B, C and 2 others replied... // A, B, C and 2 others replied...
// A, B, C and others replied...
'NOTIFICATION_BOOKMARK' => array( 'NOTIFICATION_BOOKMARK' => array(
1 => '%1$s replied to the topic “%2$s” you have bookmarked.', 1 => '%1$s replied to the topic “%2$s” you have bookmarked.',
), ),
@ -454,7 +456,8 @@ $lang = array_merge($lang, array(
'NOTIFICATION_TOPIC_IN_QUEUE' => 'A new topic titled "%2$s" was posted by %1$s and needs approval.', 'NOTIFICATION_TOPIC_IN_QUEUE' => 'A new topic titled "%2$s" was posted by %1$s and needs approval.',
'NOTIFICATION_TYPE_NOT_EXIST' => 'The notification type "%s" is missing from the file system.', 'NOTIFICATION_TYPE_NOT_EXIST' => 'The notification type "%s" is missing from the file system.',
'NOTIFICATION_ADMIN_ACTIVATE_USER' => 'The user “%1$s” is newly registered and requires activation.', 'NOTIFICATION_ADMIN_ACTIVATE_USER' => 'The user “%1$s” is newly registered and requires activation.',
// Used in conjuction with NOTIFICATION_BOOKMARK, NOTIFICATION_POST, and NOTIFICATION_QUOTE. // Used in conjuction with NOTIFICATION_BOOKMARK and NOTIFICATION_POST.
'NOTIFICATION_MANY_OTHERS' => 'others',
'NOTIFICATION_X_OTHERS' => array( 'NOTIFICATION_X_OTHERS' => array(
2 => '%d others', 2 => '%d others',
), ),

View file

@ -677,7 +677,7 @@ function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql,
case 'unapproved_posts': case 'unapproved_posts':
case 'deleted_posts': case 'deleted_posts':
$visibility_const = ($mode == 'unapproved_posts') ? ITEM_UNAPPROVED : ITEM_DELETED; $visibility_const = ($mode == 'unapproved_posts') ? array(ITEM_UNAPPROVED, ITEM_REAPPROVE) : ITEM_DELETED;
$type = 'posts'; $type = 'posts';
$default_key = 't'; $default_key = 't';
$default_dir = 'd'; $default_dir = 'd';
@ -686,7 +686,7 @@ function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql,
$sql = 'SELECT COUNT(p.post_id) AS total $sql = 'SELECT COUNT(p.post_id) AS total
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t 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'))) . ' $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_visibility = ' . $visibility_const . ' AND ' . $db->sql_in_set('p.post_visibility', $visibility_const) .'
AND t.topic_id = p.topic_id AND t.topic_id = p.topic_id
AND t.topic_visibility <> p.post_visibility'; AND t.topic_visibility <> p.post_visibility';
@ -698,7 +698,7 @@ function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql,
case 'unapproved_topics': case 'unapproved_topics':
case 'deleted_topics': case 'deleted_topics':
$visibility_const = ($mode == 'unapproved_topics') ? ITEM_UNAPPROVED : ITEM_DELETED; $visibility_const = ($mode == 'unapproved_topics') ? array(ITEM_UNAPPROVED, ITEM_REAPPROVE) : ITEM_DELETED;
$type = 'topics'; $type = 'topics';
$default_key = 't'; $default_key = 't';
$default_dir = 'd'; $default_dir = 'd';
@ -706,7 +706,7 @@ function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql,
$sql = 'SELECT COUNT(topic_id) AS total $sql = 'SELECT COUNT(topic_id) AS total
FROM ' . TOPICS_TABLE . " 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'))) . ' $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_visibility = ' . $visibility_const; AND ' . $db->sql_in_set('topic_visibility', $visibility_const);
if ($min_time) if ($min_time)
{ {

View file

@ -624,7 +624,7 @@ switch ($mode)
$sql = 'SELECT COUNT(post_id) as posts_in_queue $sql = 'SELECT COUNT(post_id) as posts_in_queue
FROM ' . POSTS_TABLE . ' FROM ' . POSTS_TABLE . '
WHERE poster_id = ' . $user_id . ' WHERE poster_id = ' . $user_id . '
AND post_visibility = ' . ITEM_UNAPPROVED; AND ' . $db->sql_in_set('post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE));
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$member['posts_in_queue'] = (int) $db->sql_fetchfield('posts_in_queue'); $member['posts_in_queue'] = (int) $db->sql_fetchfield('posts_in_queue');
$db->sql_freeresult($result); $db->sql_freeresult($result);

View file

@ -215,23 +215,23 @@ class content_visibility
/** /**
* Change visibility status of one post or all posts of a topic * Change visibility status of one post or all posts of a topic
* *
* @param $visibility int Element of {ITEM_APPROVED, ITEM_DELETED} * @param $visibility int Element of {ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE}
* @param $post_id mixed Post ID or array of post IDs to act on, * @param $post_id mixed Post ID or array of post IDs to act on,
* if it is empty, all posts of topic_id will be modified * if it is empty, all posts of topic_id will be modified
* @param $topic_id int Topic where $post_id is found * @param $topic_id int Topic where $post_id is found
* @param $forum_id int Forum where $topic_id is found * @param $forum_id int Forum where $topic_id is found
* @param $user_id int User performing the action * @param $user_id int User performing the action
* @param $time int Timestamp when the action is performed * @param $time int Timestamp when the action is performed
* @param $reason string Reason why the visibilty was changed. * @param $reason string Reason why the visibility was changed.
* @param $is_starter bool Is this the first post of the topic changed? * @param $is_starter bool Is this the first post of the topic changed?
* @param $is_latest bool Is this the last post of the topic changed? * @param $is_latest bool Is this the last post of the topic changed?
* @param $limit_visibility mixed Limit updating per topic_id to a certain visibility * @param $limit_visibility mixed Limit updating per topic_id to a certain visibility
* @param $limit_delete_time mixed Limit updating per topic_id to a certain deletion time * @param $limit_delete_time mixed Limit updating per topic_id to a certain deletion time
* @return array Changed post data, empty array if an error occured. * @return array Changed post data, empty array if an error occurred.
*/ */
public function set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest, $limit_visibility = false, $limit_delete_time = false) public function set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest, $limit_visibility = false, $limit_delete_time = false)
{ {
if (!in_array($visibility, array(ITEM_APPROVED, ITEM_DELETED))) if (!in_array($visibility, array(ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE)))
{ {
return array(); return array();
} }
@ -326,7 +326,7 @@ class content_visibility
// Update users postcounts // Update users postcounts
foreach ($postcounts as $num_posts => $poster_ids) foreach ($postcounts as $num_posts => $poster_ids)
{ {
if ($visibility == ITEM_DELETED) if (in_array($visibility, array(ITEM_REAPPROVE, ITEM_DELETED)))
{ {
$sql = 'UPDATE ' . $this->users_table . ' $sql = 'UPDATE ' . $this->users_table . '
SET user_posts = 0 SET user_posts = 0
@ -387,54 +387,36 @@ class content_visibility
// Update the topic's reply count and the forum's post count // Update the topic's reply count and the forum's post count
if ($update_topic_postcount) if ($update_topic_postcount)
{ {
$cur_posts = $cur_unapproved_posts = $cur_softdeleted_posts = 0; $field_alias = array(
ITEM_APPROVED => 'posts_approved',
ITEM_UNAPPROVED => 'posts_unapproved',
ITEM_DELETED => 'posts_softdeleted',
ITEM_REAPPROVE => 'posts_unapproved',
);
$cur_posts = array_fill_keys($field_alias, 0);
foreach ($postcount_visibility as $post_visibility => $visibility_posts) foreach ($postcount_visibility as $post_visibility => $visibility_posts)
{ {
// We need to substract the posts from the counters ... $cur_posts[$field_alias[(int) $post_visibility]] += $visibility_posts;
if ($post_visibility == ITEM_APPROVED)
{
$cur_posts += $visibility_posts;
}
else if ($post_visibility == ITEM_UNAPPROVED)
{
$cur_unapproved_posts += $visibility_posts;
}
else if ($post_visibility == ITEM_DELETED)
{
$cur_softdeleted_posts += $visibility_posts;
}
} }
$sql_ary = array(); $sql_ary = array();
if ($visibility == ITEM_DELETED) $recipient_field = $field_alias[$visibility];
foreach ($cur_posts as $field => $count)
{ {
if ($cur_posts) // Decrease the count for the old statuses.
if ($count && $field != $recipient_field)
{ {
$sql_ary['posts_approved'] = ' - ' . $cur_posts; $sql_ary[$field] = " - $count";
}
if ($cur_unapproved_posts)
{
$sql_ary['posts_unapproved'] = ' - ' . $cur_unapproved_posts;
}
if ($cur_posts + $cur_unapproved_posts)
{
$sql_ary['posts_softdeleted'] = ' + ' . ($cur_posts + $cur_unapproved_posts);
} }
} }
else // Add up the count from all statuses excluding the recipient status.
$count_increase = array_sum(array_diff($cur_posts, array($recipient_field)));
if ($count_increase)
{ {
if ($cur_unapproved_posts) $sql_ary[$recipient_field] = " + $count_increase";
{
$sql_ary['posts_unapproved'] = ' - ' . $cur_unapproved_posts;
}
if ($cur_softdeleted_posts)
{
$sql_ary['posts_softdeleted'] = ' - ' . $cur_softdeleted_posts;
}
if ($cur_softdeleted_posts + $cur_unapproved_posts)
{
$sql_ary['posts_approved'] = ' + ' . ($cur_softdeleted_posts + $cur_unapproved_posts);
}
} }
if (sizeof($sql_ary)) if (sizeof($sql_ary))
@ -475,7 +457,7 @@ class content_visibility
* as soft deleted. * as soft deleted.
* If you want to update all posts, use the force option. * If you want to update all posts, use the force option.
* *
* @param $visibility int Element of {ITEM_APPROVED, ITEM_DELETED} * @param $visibility int Element of {ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE}
* @param $topic_id mixed Topic ID to act on * @param $topic_id mixed Topic ID to act on
* @param $forum_id int Forum where $topic_id is found * @param $forum_id int Forum where $topic_id is found
* @param $user_id int User performing the action * @param $user_id int User performing the action
@ -486,7 +468,7 @@ class content_visibility
*/ */
public function set_topic_visibility($visibility, $topic_id, $forum_id, $user_id, $time, $reason, $force_update_all = false) public function set_topic_visibility($visibility, $topic_id, $forum_id, $user_id, $time, $reason, $force_update_all = false)
{ {
if (!in_array($visibility, array(ITEM_APPROVED, ITEM_DELETED))) if (!in_array($visibility, array(ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE)))
{ {
return array(); return array();
} }
@ -532,7 +514,7 @@ class content_visibility
} }
else if (!$force_update_all && $original_topic_data['topic_visibility'] == ITEM_APPROVED && $visibility == ITEM_DELETED) else if (!$force_update_all && $original_topic_data['topic_visibility'] == ITEM_APPROVED && $visibility == ITEM_DELETED)
{ {
// If we're soft deleting a topic we only approved posts are soft deleted. // If we're soft deleting a topic we only mark approved posts as soft deleted.
$this->set_post_visibility($visibility, false, $topic_id, $forum_id, $user_id, $time, '', true, true, $original_topic_data['topic_visibility']); $this->set_post_visibility($visibility, false, $topic_id, $forum_id, $user_id, $time, '', true, true, $original_topic_data['topic_visibility']);
} }
else else

View file

@ -138,4 +138,12 @@ class approve_post extends \phpbb\notification\type\post
{ {
return 'post_approved'; return 'post_approved';
} }
/**
* {inheritDoc}
*/
public function get_redirect_url()
{
return $this->get_url();
}
} }

View file

@ -275,6 +275,14 @@ abstract class base implements \phpbb\notification\type\type_interface
return $this->mark(true, $return); return $this->mark(true, $return);
} }
/**
* {inheritDoc}
*/
public function get_redirect_url()
{
return $this->get_url();
}
/** /**
* Prepare to output the notification to the template * Prepare to output the notification to the template
* *

View file

@ -110,11 +110,15 @@ class bookmark extends \phpbb\notification\type\post
unset($notify_users[$row['user_id']]); unset($notify_users[$row['user_id']]);
$notification = $this->notification_manager->get_item_type_class($this->get_type(), $row); $notification = $this->notification_manager->get_item_type_class($this->get_type(), $row);
$update_responders = $notification->add_responders($post);
if (!empty($update_responders))
{
$sql = 'UPDATE ' . $this->notifications_table . ' $sql = 'UPDATE ' . $this->notifications_table . '
SET ' . $this->db->sql_build_array('UPDATE', $notification->add_responders($post)) . ' SET ' . $this->db->sql_build_array('UPDATE', $update_responders) . '
WHERE notification_id = ' . $row['notification_id']; WHERE notification_id = ' . $row['notification_id'];
$this->db->sql_query($sql); $this->db->sql_query($sql);
} }
}
$this->db->sql_freeresult($result); $this->db->sql_freeresult($result);
return $notify_users; return $notify_users;

View file

@ -152,11 +152,15 @@ class post extends \phpbb\notification\type\base
unset($notify_users[$row['user_id']]); unset($notify_users[$row['user_id']]);
$notification = $this->notification_manager->get_item_type_class($this->get_type(), $row); $notification = $this->notification_manager->get_item_type_class($this->get_type(), $row);
$update_responders = $notification->add_responders($post);
if (!empty($update_responders))
{
$sql = 'UPDATE ' . $this->notifications_table . ' $sql = 'UPDATE ' . $this->notifications_table . '
SET ' . $this->db->sql_build_array('UPDATE', $notification->add_responders($post)) . ' SET ' . $this->db->sql_build_array('UPDATE', $update_responders) . '
WHERE notification_id = ' . $row['notification_id']; WHERE notification_id = ' . $row['notification_id'];
$this->db->sql_query($sql); $this->db->sql_query($sql);
} }
}
$this->db->sql_freeresult($result); $this->db->sql_freeresult($result);
return $notify_users; return $notify_users;
@ -206,7 +210,11 @@ class post extends \phpbb\notification\type\base
} }
} }
if ($trimmed_responders_cnt) if ($trimmed_responders_cnt > 20)
{
$usernames[] = $this->user->lang('NOTIFICATION_MANY_OTHERS');
}
else if ($trimmed_responders_cnt)
{ {
$usernames[] = $this->user->lang('NOTIFICATION_X_OTHERS', $trimmed_responders_cnt); $usernames[] = $this->user->lang('NOTIFICATION_X_OTHERS', $trimmed_responders_cnt);
} }
@ -269,6 +277,14 @@ class post extends \phpbb\notification\type\base
return append_sid($this->phpbb_root_path . 'viewtopic.' . $this->php_ext, "p={$this->item_id}#p{$this->item_id}"); return append_sid($this->phpbb_root_path . 'viewtopic.' . $this->php_ext, "p={$this->item_id}#p{$this->item_id}");
} }
/**
* {inheritDoc}
*/
public function get_redirect_url()
{
return append_sid($this->phpbb_root_path . 'viewtopic.' . $this->php_ext, "t={$this->item_parent_id}&amp;view=unread#unread");
}
/** /**
* Users needed to query before this notification can be displayed * Users needed to query before this notification can be displayed
* *
@ -384,19 +400,27 @@ class post extends \phpbb\notification\type\base
// Do not add them as a responder if they were the original poster that created the notification // Do not add them as a responder if they were the original poster that created the notification
if ($this->get_data('poster_id') == $post['poster_id']) if ($this->get_data('poster_id') == $post['poster_id'])
{ {
return array('notification_data' => serialize($this->get_data(false))); return array();
} }
$responders = $this->get_data('responders'); $responders = $this->get_data('responders');
$responders = ($responders === null) ? array() : $responders; $responders = ($responders === null) ? array() : $responders;
// Do not add more than 25 responders,
// we trim the username list to "a, b, c and x others" anyway
// so there is no use to add all of them anyway.
if (sizeof($responders) > 25)
{
return array();
}
foreach ($responders as $responder) foreach ($responders as $responder)
{ {
// Do not add them as a responder multiple times // Do not add them as a responder multiple times
if ($responder['poster_id'] == $post['poster_id']) if ($responder['poster_id'] == $post['poster_id'])
{ {
return array('notification_data' => serialize($this->get_data(false))); return array();
} }
} }
@ -407,6 +431,15 @@ class post extends \phpbb\notification\type\base
$this->set_data('responders', $responders); $this->set_data('responders', $responders);
return array('notification_data' => serialize($this->get_data(false))); $serialized_data = serialize($this->get_data(false));
// If the data is longer then 4000 characters, it would cause a SQL error.
// We don't add the username to the list if this is the case.
if (utf8_strlen($serialized_data) >= 4000)
{
return array();
}
return array('notification_data' => $serialized_data);
} }
} }

View file

@ -118,6 +118,14 @@ class post_in_queue extends \phpbb\notification\type\post
return append_sid($this->phpbb_root_path . 'mcp.' . $this->php_ext, "i=queue&amp;mode=approve_details&amp;f={$this->get_data('forum_id')}&amp;p={$this->item_id}"); return append_sid($this->phpbb_root_path . 'mcp.' . $this->php_ext, "i=queue&amp;mode=approve_details&amp;f={$this->get_data('forum_id')}&amp;p={$this->item_id}");
} }
/**
* {inheritDoc}
*/
public function get_redirect_url()
{
return parent::get_url();
}
/** /**
* Function for preparing the data for insertion in an SQL query * Function for preparing the data for insertion in an SQL query
* (The service handles insertion) * (The service handles insertion)

View file

@ -113,29 +113,6 @@ class quote extends \phpbb\notification\type\post
$notify_users = $this->check_user_notification_options($auth_read[$post['forum_id']]['f_read'], $options); $notify_users = $this->check_user_notification_options($auth_read[$post['forum_id']]['f_read'], $options);
// Try to find the users who already have been notified about replies and have not read the topic since and just update their notifications
$update_notifications = array();
$sql = 'SELECT n.*
FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . ' nt
WHERE n.notification_type_id = ' . (int) $this->notification_type_id . '
AND n.item_parent_id = ' . (int) self::get_item_parent_id($post) . '
AND n.notification_read = 0
AND nt.notification_type_id = n.notification_type_id
AND nt.notification_type_enabled = 1';
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
// Do not create a new notification
unset($notify_users[$row['user_id']]);
$notification = $this->notification_manager->get_item_type_class($this->get_type(), $row);
$sql = 'UPDATE ' . $this->notifications_table . '
SET ' . $this->db->sql_build_array('UPDATE', $notification->add_responders($post)) . '
WHERE notification_id = ' . $row['notification_id'];
$this->db->sql_query($sql);
}
$this->db->sql_freeresult($result);
return $notify_users; return $notify_users;
} }
@ -190,6 +167,14 @@ class quote extends \phpbb\notification\type\post
return true; return true;
} }
/**
* {inheritDoc}
*/
public function get_redirect_url()
{
return $this->get_url();
}
/** /**
* Get email template * Get email template
* *

View file

@ -98,6 +98,13 @@ interface type_interface
*/ */
public function get_url(); public function get_url();
/**
* Get the url to redirect after the item has been marked as read
*
* @return string URL
*/
public function get_redirect_url();
/** /**
* URL to unsubscribe to this notification * URL to unsubscribe to this notification
* *

View file

@ -879,7 +879,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
$unread_topic = (isset($topic_tracking_info[$forum_id][$row['topic_id']]) && $row['topic_last_post_time'] > $topic_tracking_info[$forum_id][$row['topic_id']]) ? true : false; $unread_topic = (isset($topic_tracking_info[$forum_id][$row['topic_id']]) && $row['topic_last_post_time'] > $topic_tracking_info[$forum_id][$row['topic_id']]) ? true : false;
$topic_unapproved = ($row['topic_visibility'] == ITEM_UNAPPROVED && $auth->acl_get('m_approve', $forum_id)) ? true : false; $topic_unapproved = (($row['topic_visibility'] == ITEM_UNAPPROVED || $row['topic_visibility'] == ITEM_REAPPROVE) && $auth->acl_get('m_approve', $forum_id)) ? true : false;
$posts_unapproved = ($row['topic_visibility'] == ITEM_APPROVED && $row['topic_posts_unapproved'] && $auth->acl_get('m_approve', $forum_id)) ? true : false; $posts_unapproved = ($row['topic_visibility'] == ITEM_APPROVED && $row['topic_posts_unapproved'] && $auth->acl_get('m_approve', $forum_id)) ? true : false;
$topic_deleted = $row['topic_visibility'] == ITEM_DELETED; $topic_deleted = $row['topic_visibility'] == ITEM_DELETED;
$u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&amp;mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . "&amp;t=$result_topic_id", true, $user->session_id) : ''; $u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&amp;mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . "&amp;t=$result_topic_id", true, $user->session_id) : '';

View file

@ -749,7 +749,7 @@ if (sizeof($topic_list))
$view_topic_url_params = 'f=' . $row['forum_id'] . '&amp;t=' . $topic_id; $view_topic_url_params = 'f=' . $row['forum_id'] . '&amp;t=' . $topic_id;
$view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params); $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params);
$topic_unapproved = ($row['topic_visibility'] == ITEM_UNAPPROVED && $auth->acl_get('m_approve', $row['forum_id'])); $topic_unapproved = (($row['topic_visibility'] == ITEM_UNAPPROVED || $row['topic_visibility'] == ITEM_REAPPROVE) && $auth->acl_get('m_approve', $row['forum_id']));
$posts_unapproved = ($row['topic_visibility'] == ITEM_APPROVED && $row['topic_posts_unapproved'] && $auth->acl_get('m_approve', $row['forum_id'])); $posts_unapproved = ($row['topic_visibility'] == ITEM_APPROVED && $row['topic_posts_unapproved'] && $auth->acl_get('m_approve', $row['forum_id']));
$topic_deleted = $row['topic_visibility'] == ITEM_DELETED; $topic_deleted = $row['topic_visibility'] == ITEM_DELETED;

View file

@ -266,7 +266,7 @@ if ($topic_data['topic_visibility'] != ITEM_APPROVED && !$auth->acl_get('m_appro
if ($post_id) if ($post_id)
{ {
// are we where we are supposed to be? // are we where we are supposed to be?
if ($topic_data['post_visibility'] == ITEM_UNAPPROVED && !$auth->acl_get('m_approve', $topic_data['forum_id'])) if (($topic_data['post_visibility'] == ITEM_UNAPPROVED || $topic_data['post_visibility'] == ITEM_REAPPROVE) && !$auth->acl_get('m_approve', $topic_data['forum_id']))
{ {
// If post_id was submitted, we try at least to display the topic as a last resort... // If post_id was submitted, we try at least to display the topic as a last resort...
if ($topic_id) if ($topic_id)
@ -1028,7 +1028,7 @@ while ($row = $db->sql_fetchrow($result))
{ {
$attach_list[] = (int) $row['post_id']; $attach_list[] = (int) $row['post_id'];
if ($row['post_visibility'] == ITEM_UNAPPROVED) if ($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE)
{ {
$has_attachments = true; $has_attachments = true;
} }
@ -1642,7 +1642,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false, 'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false,
'S_MULTIPLE_ATTACHMENTS' => !empty($attachments[$row['post_id']]) && sizeof($attachments[$row['post_id']]) > 1, 'S_MULTIPLE_ATTACHMENTS' => !empty($attachments[$row['post_id']]) && sizeof($attachments[$row['post_id']]) > 1,
'S_POST_UNAPPROVED' => ($row['post_visibility'] == ITEM_UNAPPROVED) ? true : false, 'S_POST_UNAPPROVED' => ($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) ? true : false,
'S_POST_DELETED' => ($row['post_visibility'] == ITEM_DELETED) ? true : false, 'S_POST_DELETED' => ($row['post_visibility'] == ITEM_DELETED) ? true : false,
'L_POST_DELETED_MESSAGE' => $l_deleted_message, 'L_POST_DELETED_MESSAGE' => $l_deleted_message,
'S_POST_REPORTED' => ($row['post_reported'] && $auth->acl_get('m_report', $forum_id)) ? true : false, 'S_POST_REPORTED' => ($row['post_reported'] && $auth->acl_get('m_report', $forum_id)) ? true : false,

View file

@ -10,7 +10,7 @@
/** /**
* @group functional * @group functional
*/ */
class phpbb_functional_disapprove_test extends phpbb_functional_test_case class phpbb_functional_visibility_disapprove_test extends phpbb_functional_test_case
{ {
protected $data = array(); protected $data = array();

View file

@ -0,0 +1,416 @@
<?php
/**
*
* @package testing
* @copyright (c) 2014 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @group functional
*/
class phpbb_functional_visibility_reapprove_test extends phpbb_functional_test_case
{
protected $data = array();
public function test_setup_forums()
{
$this->login();
$this->admin_login();
$crawler = self::request('GET', "adm/index.php?i=acp_forums&mode=manage&sid={$this->sid}");
$form = $crawler->selectButton('addforum')->form(array(
'forum_name' => 'Reapprove Test #1',
));
$crawler = self::submit($form);
$form = $crawler->selectButton('update')->form(array(
'forum_perm_from' => 2,
));
$crawler = self::submit($form);
// Set flood interval to 0
$this->set_flood_interval(0);
}
public function test_create_posts()
{
$this->login();
$this->load_ids(array(
'forums' => array(
'Reapprove Test #1',
),
));
$this->assert_forum_details($this->data['forums']['Reapprove Test #1'], array(
'forum_posts_approved' => 0,
'forum_posts_unapproved' => 0,
'forum_posts_softdeleted' => 0,
'forum_topics_approved' => 0,
'forum_topics_unapproved' => 0,
'forum_topics_softdeleted' => 0,
'forum_last_post_id' => 0,
), 'initial comparison');
// Test creating topic #1
$post = $this->create_topic($this->data['forums']['Reapprove Test #1'], 'Reapprove Test Topic #1', 'This is a test topic posted by the testing framework.');
$crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
$this->assertContains('Reapprove Test Topic #1', $crawler->filter('h2')->text());
$this->data['topics']['Reapprove Test Topic #1'] = (int) $post['topic_id'];
$this->data['posts']['Reapprove Test Topic #1'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p');
$this->assert_forum_details($this->data['forums']['Reapprove Test #1'], array(
'forum_posts_approved' => 1,
'forum_posts_unapproved' => 0,
'forum_posts_softdeleted' => 0,
'forum_topics_approved' => 1,
'forum_topics_unapproved' => 0,
'forum_topics_softdeleted' => 0,
'forum_last_post_id' => $this->data['posts']['Reapprove Test Topic #1'],
), 'after creating topic #1');
$this->logout();
$this->create_user('reapprove_testuser');
$this->add_user_group('NEWLY_REGISTERED', array('reapprove_testuser'));
$this->login('reapprove_testuser');
// Test creating a reply
$post2 = $this->create_post($this->data['forums']['Reapprove Test #1'], $post['topic_id'], 'Re: Reapprove Test Topic #1-#2', 'This is a test post posted by the testing framework.', array(), 'POST_STORED_MOD');
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Reapprove Test Topic #1']}&sid={$this->sid}");
$this->assertNotContains('Re: Reapprove Test Topic #1-#2', $crawler->filter('#page-body')->text());
$this->assert_forum_details($this->data['forums']['Reapprove Test #1'], array(
'forum_posts_approved' => 1,
'forum_posts_unapproved' => 1,
'forum_posts_softdeleted' => 0,
'forum_topics_approved' => 1,
'forum_topics_unapproved' => 0,
'forum_topics_softdeleted' => 0,
'forum_last_post_id' => $this->data['posts']['Reapprove Test Topic #1'],
), 'after replying');
// Test creating topic #2
$post = $this->create_topic($this->data['forums']['Reapprove Test #1'], 'Reapprove Test Topic #2', 'This is a test topic posted by the testing framework.', array(), 'POST_STORED_MOD');
$crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Reapprove Test #1']}&sid={$this->sid}");
$this->assertNotContains('Reapprove Test Topic #2', $crawler->filter('html')->text());
$this->assert_forum_details($this->data['forums']['Reapprove Test #1'], array(
'forum_posts_approved' => 1,
'forum_posts_unapproved' => 2,
'forum_posts_softdeleted' => 0,
'forum_topics_approved' => 1,
'forum_topics_unapproved' => 1,
'forum_topics_softdeleted' => 0,
'forum_last_post_id' => $this->data['posts']['Reapprove Test Topic #1'],
), 'after creating topic #2');
$this->logout();
}
public function test_approve_post()
{
$this->login();
$this->load_ids(array(
'forums' => array(
'Reapprove Test #1',
),
'topics' => array(
'Reapprove Test Topic #1',
'Reapprove Test Topic #2',
),
'posts' => array(
'Reapprove Test Topic #1',
'Re: Reapprove Test Topic #1-#2',
'Reapprove Test Topic #2',
),
));
$this->assert_forum_details($this->data['forums']['Reapprove Test #1'], array(
'forum_posts_approved' => 1,
'forum_posts_unapproved' => 2,
'forum_posts_softdeleted' => 0,
'forum_topics_approved' => 1,
'forum_topics_unapproved' => 1,
'forum_topics_softdeleted' => 0,
'forum_last_post_id' => $this->data['posts']['Reapprove Test Topic #1'],
), 'before approving post');
$this->add_lang('posting');
$this->add_lang('viewtopic');
$this->add_lang('mcp');
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Reapprove Test Topic #1']}&sid={$this->sid}");
$this->assertContains('Reapprove Test Topic #1', $crawler->filter('h2')->text());
$this->assertContains('Re: Reapprove Test Topic #1-#2', $crawler->filter('#page-body')->text());
$form = $crawler->selectButton($this->lang('APPROVE'))->form();
$crawler = self::submit($form);
$form = $crawler->selectButton($this->lang('YES'))->form();
$crawler = self::submit($form);
$this->assertContainsLang('POST_APPROVED_SUCCESS', $crawler->text());
$this->assert_forum_details($this->data['forums']['Reapprove Test #1'], array(
'forum_posts_approved' => 2,
'forum_posts_unapproved' => 1,
'forum_posts_softdeleted' => 0,
'forum_topics_approved' => 1,
'forum_topics_unapproved' => 1,
'forum_topics_softdeleted' => 0,
'forum_last_post_id' => $this->data['posts']['Re: Reapprove Test Topic #1-#2'],
), 'after approving post');
$link = $crawler->selectLink($this->lang('RETURN_PAGE', '', ''))->link();
$link_url = $link->getUri();
$this->assertContains('viewtopic.php?f=' . $this->data['forums']['Reapprove Test #1'] . '&t=' . $this->data['topics']['Reapprove Test Topic #1'], $link_url);
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Reapprove Test Topic #1']}&sid={$this->sid}");
$this->assertContains('Reapprove Test Topic #1', $crawler->filter('h2')->text());
$this->assertContains('Re: Reapprove Test Topic #1-#2', $crawler->filter('#page-body')->text());
}
public function test_approve_topic()
{
$this->login();
$this->load_ids(array(
'forums' => array(
'Reapprove Test #1',
),
'topics' => array(
'Reapprove Test Topic #1',
'Reapprove Test Topic #2',
),
'posts' => array(
'Reapprove Test Topic #1',
'Re: Reapprove Test Topic #1-#2',
'Reapprove Test Topic #2',
),
));
$this->assert_forum_details($this->data['forums']['Reapprove Test #1'], array(
'forum_posts_approved' => 2,
'forum_posts_unapproved' => 1,
'forum_posts_softdeleted' => 0,
'forum_topics_approved' => 1,
'forum_topics_unapproved' => 1,
'forum_topics_softdeleted' => 0,
'forum_last_post_id' => $this->data['posts']['Re: Reapprove Test Topic #1-#2'],
), 'before approving topic');
$this->add_lang('posting');
$this->add_lang('viewtopic');
$this->add_lang('mcp');
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Reapprove Test Topic #2']}&sid={$this->sid}");
$this->assertContains('Reapprove Test Topic #2', $crawler->filter('h2')->text());
$form = $crawler->selectButton($this->lang('APPROVE'))->form();
$crawler = self::submit($form);
$form = $crawler->selectButton($this->lang('YES'))->form();
$crawler = self::submit($form);
//@todo $this->assertContainsLang('TOPIC_APPROVED_SUCCESS', $crawler->text());
$this->assertContainsLang('POST_APPROVED_SUCCESS', $crawler->text());
$this->assert_forum_details($this->data['forums']['Reapprove Test #1'], array(
'forum_posts_approved' => 3,
'forum_posts_unapproved' => 0,
'forum_posts_softdeleted' => 0,
'forum_topics_approved' => 2,
'forum_topics_unapproved' => 0,
'forum_topics_softdeleted' => 0,
'forum_last_post_id' => $this->data['posts']['Reapprove Test Topic #2'],
), 'after approving topic');
$link = $crawler->selectLink($this->lang('RETURN_PAGE', '', ''))->link();
$link_url = $link->getUri();
$this->assertContains('viewtopic.php?f=' . $this->data['topic']['Reapprove Test Topic #2'], $link_url);
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Reapprove Test Topic #2']}&sid={$this->sid}");
$this->assertContains('Reapprove Test Topic #2', $crawler->filter('h2')->text());
}
public function test_edit_posts()
{
$this->load_ids(array(
'forums' => array(
'Reapprove Test #1',
),
'topics' => array(
'Reapprove Test Topic #1',
'Reapprove Test Topic #2',
),
'posts' => array(
'Reapprove Test Topic #1',
'Re: Reapprove Test Topic #1-#2',
'Reapprove Test Topic #2',
),
));
$this->add_lang('posting');
$this->assert_forum_details($this->data['forums']['Reapprove Test #1'], array(
'forum_posts_approved' => 3,
'forum_posts_unapproved' => 0,
'forum_posts_softdeleted' => 0,
'forum_topics_approved' => 2,
'forum_topics_unapproved' => 0,
'forum_topics_softdeleted' => 0,
'forum_last_post_id' => $this->data['posts']['Reapprove Test Topic #2'],
), 'before editing post');
$this->login('reapprove_testuser');
$this->add_user_group('NEWLY_REGISTERED', array('reapprove_testuser'));
// Test editing a post
$posting_url = "posting.php?mode=edit&f={$this->data['forums']['Reapprove Test #1']}&p={$this->data['posts']['Re: Reapprove Test Topic #1-#2']}&sid={$this->sid}";
$form_data = array(
'message' => 'Post edited by testing framework',
'subject' => 'Re: Reapprove Test Topic #1-#2',
'post' => true,
);
$this->submit_post($posting_url, 'EDIT_POST', $form_data, 'POST_EDITED_MOD');
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Reapprove Test Topic #1']}&sid={$this->sid}");
$this->assertNotContains('Re: Reapprove Test Topic #1-#2', $crawler->filter('#page-body')->text());
$this->assertNotContains('Post edited by testing framework', $crawler->filter('#page-body')->text());
$this->assert_forum_details($this->data['forums']['Reapprove Test #1'], array(
'forum_posts_approved' => 2,
'forum_posts_unapproved' => 1,
'forum_posts_softdeleted' => 0,
'forum_topics_approved' => 2,
'forum_topics_unapproved' => 0,
'forum_topics_softdeleted' => 0,
'forum_last_post_id' => $this->data['posts']['Reapprove Test Topic #2'],
), 'after editing post');
// Test editing a topic
$posting_url = "posting.php?mode=edit&f={$this->data['forums']['Reapprove Test #1']}&p={$this->data['posts']['Reapprove Test Topic #2']}&sid={$this->sid}";
$form_data = array(
'message' => 'Post edited by testing framework',
'subject' => 'Reapprove Test Topic #2',
'post' => true,
);
$this->submit_post($posting_url, 'EDIT_POST', $form_data, 'POST_EDITED_MOD');
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Reapprove Test Topic #2']}&sid={$this->sid}", array(), false);
self::assert_response_html(404);
$this->assertNotContains('Reapprove Test Topic #2', $crawler->filter('#page-body')->text());
$this->assertNotContains('Post edited by testing framework', $crawler->filter('#page-body')->text());
$this->assert_forum_details($this->data['forums']['Reapprove Test #1'], array(
'forum_posts_approved' => 1,
'forum_posts_unapproved' => 2,
'forum_posts_softdeleted' => 0,
'forum_topics_approved' => 1,
'forum_topics_unapproved' => 1,
'forum_topics_softdeleted' => 0,
'forum_last_post_id' => $this->data['posts']['Reapprove Test Topic #1'],
), 'after editing topic');
$this->logout();
$this->login();
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Reapprove Test Topic #1']}&sid={$this->sid}");
$this->assertContains('Re: Reapprove Test Topic #1-#2', $crawler->filter('#page-body')->text());
$this->assertContains('Post edited by testing framework', $crawler->filter('#page-body')->text());
}
public function test_approve_post_again()
{
$this->test_approve_post();
}
public function test_approve_topic_again()
{
$this->test_approve_topic();
}
public function test_reset_flood_interval()
{
$this->login();
$this->admin_login();
// Set flood interval back to 15
$this->set_flood_interval(15);
}
protected function assert_forum_details($forum_id, $details, $additional_error_message = '')
{
$this->db = $this->get_db();
$sql = 'SELECT ' . implode(', ', array_keys($details)) . '
FROM phpbb_forums
WHERE forum_id = ' . (int) $forum_id;
$result = $this->db->sql_query($sql);
$data = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
$this->assertEquals($details, $data, "Forum {$forum_id} does not match expected {$additional_error_message}");
}
protected function set_flood_interval($flood_interval)
{
$crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_board&mode=post');
$form = $crawler->selectButton('Submit')->form();
$values = $form->getValues();
$values["config[flood_interval]"] = $flood_interval;
$form->setValues($values);
$crawler = self::submit($form);
$this->assertGreaterThan(0, $crawler->filter('.successbox')->count());
}
protected function load_ids($data)
{
$this->db = $this->get_db();
if (!empty($data['forums']))
{
$sql = 'SELECT *
FROM phpbb_forums
WHERE ' . $this->db->sql_in_set('forum_name', $data['forums']);
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
if (in_array($row['forum_name'], $data['forums']))
{
$this->data['forums'][$row['forum_name']] = (int) $row['forum_id'];
}
}
$this->db->sql_freeresult($result);
}
if (!empty($data['topics']))
{
$sql = 'SELECT *
FROM phpbb_topics
WHERE ' . $this->db->sql_in_set('topic_title', $data['topics']);
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
if (in_array($row['topic_title'], $data['topics']))
{
$this->data['topics'][$row['topic_title']] = (int) $row['topic_id'];
}
}
$this->db->sql_freeresult($result);
}
if (!empty($data['posts']))
{
$sql = 'SELECT *
FROM phpbb_posts
WHERE ' . $this->db->sql_in_set('post_subject', $data['posts']);
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
if (in_array($row['post_subject'], $data['posts']))
{
$this->data['posts'][$row['post_subject']] = (int) $row['post_id'];
}
}
$this->db->sql_freeresult($result);
}
}
}

View file

@ -10,7 +10,7 @@
/** /**
* @group functional * @group functional
*/ */
class phpbb_functional_softdelete_test extends phpbb_functional_test_case class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_case
{ {
protected $data = array(); protected $data = array();

View file

@ -55,7 +55,7 @@ class phpbb_notification_submit_post_type_quote_test extends phpbb_notification_
* 2 => Poster, should NOT receive a notification * 2 => Poster, should NOT receive a notification
* 3 => Quoted, should receive a notification * 3 => Quoted, should receive a notification
* 4 => Quoted, but unauthed to read, should NOT receive a notification * 4 => Quoted, but unauthed to read, should NOT receive a notification
* 5 => Quoted, but already notified, should NOT receive a new notification * 5 => Quoted, but already notified, should STILL receive a new notification
* 6 => Quoted, but option disabled, should NOT receive a notification * 6 => Quoted, but option disabled, should NOT receive a notification
* 7 => Quoted, option set to default, should receive a notification * 7 => Quoted, option set to default, should receive a notification
*/ */
@ -78,6 +78,7 @@ class phpbb_notification_submit_post_type_quote_test extends phpbb_notification_
array( array(
array('user_id' => 3, 'item_id' => 2, 'item_parent_id' => 1), array('user_id' => 3, 'item_id' => 2, 'item_parent_id' => 1),
array('user_id' => 5, 'item_id' => 1, 'item_parent_id' => 1), array('user_id' => 5, 'item_id' => 1, 'item_parent_id' => 1),
array('user_id' => 5, 'item_id' => 2, 'item_parent_id' => 1),
array('user_id' => 7, 'item_id' => 2, 'item_parent_id' => 1), array('user_id' => 7, 'item_id' => 2, 'item_parent_id' => 1),
), ),
), ),