diff options
| author | Josh Woody <a_jelly_doughnut@phpbb.com> | 2010-06-29 21:47:18 -0500 |
|---|---|---|
| committer | Joas Schilling <nickvergessen@gmx.de> | 2012-08-29 17:50:11 +0200 |
| commit | 67393751356e9f02f7c1ab0a2f7a3a508403edc3 (patch) | |
| tree | 3ce9667e340307f77f2679f470ddb1f645aa2558 /phpBB | |
| parent | fb13ab83e476d2afbc7bb181f7ab90df98f996da (diff) | |
| download | forums-67393751356e9f02f7c1ab0a2f7a3a508403edc3.tar forums-67393751356e9f02f7c1ab0a2f7a3a508403edc3.tar.gz forums-67393751356e9f02f7c1ab0a2f7a3a508403edc3.tar.bz2 forums-67393751356e9f02f7c1ab0a2f7a3a508403edc3.tar.xz forums-67393751356e9f02f7c1ab0a2f7a3a508403edc3.zip | |
[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
Diffstat (limited to 'phpBB')
| -rw-r--r-- | phpBB/includes/class_visibility.php | 17 | ||||
| -rw-r--r-- | phpBB/styles/prosilver/template/viewtopic_body.html | 1 |
2 files changed, 10 insertions, 8 deletions
diff --git a/phpBB/includes/class_visibility.php b/phpBB/includes/class_visibility.php index 9798e938b1..869f1078c1 100644 --- a/phpBB/includes/class_visibility.php +++ b/phpBB/includes/class_visibility.php @@ -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); diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index 0c4a7df7f4..60fb080da1 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -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> » {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"> |
