1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

[feature/soft-delete] Add unit tests for the phpbb_visibility class

Add unit tests for the phpbb_visibility class.  Adjust the phpbb_visibility class to pass those unit tests.  The changes are pretty small, actually.

PHPBB3-9657
This commit is contained in:
Josh Woody
2010-06-29 21:47:18 -05:00
committed by Joas Schilling
parent fb13ab83e4
commit 6739375135
7 changed files with 609 additions and 8 deletions

View File

@@ -48,11 +48,12 @@ class phpbb_visibility
$clause = $db->sql_in_set($table_alias . $mode . '_visibility', $status_ary);
// only allow the user to view deleted posts he himself made
if ($auth->acl_get('f_restore', $forum_id))
if ($auth->acl_get('f_restore', $forum_id) && !$auth->acl_get('m_restore', $forum_id))
{
$clause = 'AND (' . $clause . "
$poster_column = ($mode == 'topic') ? 'topic_poster' : 'poster_id';
$clause = '(' . $clause . "
OR ($table_alias{$mode}_visibility = " . ITEM_DELETED . "
AND {$table_alias}poster_id = " . $user->data['user_id'] . '))';
AND $table_alias$poster_column = " . $user->data['user_id'] . '))';
}
@@ -92,10 +93,12 @@ class phpbb_visibility
// we also allow the user to view deleted posts he himself made
$user_restore_forums = array_diff(array_keys($auth->acl_getf('f_restore', true)), $exclude_forum_ids);
if (sizeof($user_restore_forums))
if (sizeof($user_restore_forums) && !sizeof($restore_forums))
{
$poster_column = ($mode == 'topic') ? 'topic_poster' : 'poster_id';
// specify the poster ID, the visibility type, and the forums we're interested in
$where_sql .= " OR ($table_alias{$mode}poster_id = " . $user->data['user_id'] . "
$where_sql .= " OR ($table_alias$poster_column = " . $user->data['user_id'] . "
AND $table_alias{$mode}_visibility = " . ITEM_DELETED . "
AND " . $db->sql_in_set($table_alias . 'forum_id', $user_restore_forums) . ')';
}
@@ -187,7 +190,7 @@ class phpbb_visibility
{
return true;
}
else if ($auth->acl_get('f_softdelete', $forum_id) && $poster_id == $user->data['poster_id'] && !$post_locked)
else if ($auth->acl_get('f_softdelete', $forum_id) && $poster_id == $user->data['user_id'] && !$post_locked)
{
return true;
}
@@ -245,7 +248,7 @@ class phpbb_visibility
// If this is an edited topic or the first post the topic gets completely disapproved later on...
$sql_data[FORUMS_TABLE] = 'forum_topics = forum_topics - 1';
$sql_data[FORUMS_TABLE] = 'forum_posts = forum_posts - ' . ($topic_row['topic_replies'] + 1);
$sql_data[FORUMS_TABLE] .= ', forum_posts = forum_posts - ' . ($topic_row['topic_replies'] + 1);
set_config_count('num_topics', -1, true);
set_config_count('num_posts', ($topic_row['topic_replies'] + 1) * (-1), true);

View File

@@ -138,7 +138,6 @@
<h3 <!-- IF postrow.S_FIRST_ROW -->class="first"<!-- ENDIF -->><!-- IF postrow.POST_ICON_IMG --><img src="{T_ICONS_PATH}{postrow.POST_ICON_IMG}" width="{postrow.POST_ICON_IMG_WIDTH}" height="{postrow.POST_ICON_IMG_HEIGHT}" alt="" /> <!-- ENDIF --><a href="#p{postrow.POST_ID}">{postrow.POST_SUBJECT}</a></h3>
<p class="author"><!-- IF S_IS_BOT -->{postrow.MINI_POST_IMG}<!-- ELSE --><a href="{postrow.U_MINI_POST}">{postrow.MINI_POST_IMG}</a><!-- ENDIF -->{L_POST_BY_AUTHOR} <strong>{postrow.POST_AUTHOR_FULL}</strong> &raquo; {postrow.POST_DATE} </p>
<<<<<<< HEAD
<!-- IF postrow.S_POST_UNAPPROVED or postrow.S_POST_REPORTED -->
<form method="post" class="mcp_approve" action="{postrow.U_APPROVE_ACTION}" data-ajax="post_approve">
<p class="rules">