mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[feature/soft-delete] Fix some small bugs
To wit: using non-existing constant POST_DELETED in posting.php; first test post was initially unapproved; soft delete checkbox appeared at post time Links pointing to the wrong place. PHPBB3-9657
This commit is contained in:
parent
f570558a8d
commit
1ab41f8dc6
8 changed files with 98 additions and 25 deletions
|
@ -30,7 +30,7 @@ class phpbb_content_visibility
|
||||||
* @param $table_alias string - Table alias to prefix in SQL queries
|
* @param $table_alias string - Table alias to prefix in SQL queries
|
||||||
* @return string with the appropriate combination SQL logic for topic/post_visibility
|
* @return string with the appropriate combination SQL logic for topic/post_visibility
|
||||||
*/
|
*/
|
||||||
public function get_visibility_sql($mode, $forum_id, $table_alias = '')
|
static public function get_visibility_sql($mode, $forum_id, $table_alias = '')
|
||||||
{
|
{
|
||||||
global $auth, $db, $user;
|
global $auth, $db, $user;
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ class phpbb_content_visibility
|
||||||
* @param $table_alias string - Table alias to prefix in SQL queries
|
* @param $table_alias string - Table alias to prefix in SQL queries
|
||||||
* @return string with the appropriate combination SQL logic for topic/post_visibility
|
* @return string with the appropriate combination SQL logic for topic/post_visibility
|
||||||
*/
|
*/
|
||||||
public function get_visibility_sql_global($mode, $exclude_forum_ids = array(), $table_alias = '')
|
static public function get_visibility_sql_global($mode, $exclude_forum_ids = array(), $table_alias = '')
|
||||||
{
|
{
|
||||||
global $auth, $db, $user;
|
global $auth, $db, $user;
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ class phpbb_content_visibility
|
||||||
* @param $forum_id - int - forum ID where $topic_id resides
|
* @param $forum_id - int - forum ID where $topic_id resides
|
||||||
* @return bool true = success, false = fail
|
* @return bool true = success, false = fail
|
||||||
*/
|
*/
|
||||||
public function set_topic_visibility($visibility, $topic_id, $forum_id)
|
static public function set_topic_visibility($visibility, $topic_id, $forum_id)
|
||||||
{
|
{
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ class phpbb_content_visibility
|
||||||
* @param $is_starter - bool - is this the first post of the topic
|
* @param $is_starter - bool - is this the first post of the topic
|
||||||
* @param $is_latest - bool - is this the last post of the topic
|
* @param $is_latest - bool - is this the last post of the topic
|
||||||
*/
|
*/
|
||||||
public function set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $is_starter, $is_latest)
|
static public function set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $is_starter, $is_latest)
|
||||||
{
|
{
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ class phpbb_content_visibility
|
||||||
* @param $post_locked - bool - is the post locked?
|
* @param $post_locked - bool - is the post locked?
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function can_soft_delete($forum_id, $poster_id, $post_locked)
|
static function can_soft_delete($forum_id, $poster_id, $post_locked)
|
||||||
{
|
{
|
||||||
global $auth, $user;
|
global $auth, $user;
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ class phpbb_content_visibility
|
||||||
* @param $sql_data - array - populated with the SQL changes, may be empty at call time
|
* @param $sql_data - array - populated with the SQL changes, may be empty at call time
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function hide_topic($topic_id, $forum_id, &$topic_row, &$sql_data)
|
static public function hide_topic($topic_id, $forum_id, &$topic_row, &$sql_data)
|
||||||
{
|
{
|
||||||
global $auth, $config, $db;
|
global $auth, $config, $db;
|
||||||
|
|
||||||
|
@ -266,14 +266,27 @@ class phpbb_content_visibility
|
||||||
* Notably, we do _not_ need the post ID to do this operation. We're only changing statistic caches
|
* Notably, we do _not_ need the post ID to do this operation. We're only changing statistic caches
|
||||||
* @param $forum_id - int - the forum where the topic resides
|
* @param $forum_id - int - the forum where the topic resides
|
||||||
* @param $current_time - int - passed for consistency instead of calling time() internally
|
* @param $current_time - int - passed for consistency instead of calling time() internally
|
||||||
|
* @param $topic_row - array - contains information from the topics table about given topic
|
||||||
* @param $sql_data - array - populated with the SQL changes, may be empty at call time
|
* @param $sql_data - array - populated with the SQL changes, may be empty at call time
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function hide_post($forum_id, $current_time, &$sql_data)
|
static public function hide_post($forum_id, $current_time, $topic_row, &$sql_data)
|
||||||
{
|
{
|
||||||
global $auth, $config, $db;
|
global $auth, $config, $db;
|
||||||
|
|
||||||
$sql_data[TOPICS_TABLE] = 'topic_replies = topic_replies - 1, topic_last_view_time = ' . $current_time;
|
// initialize the array if needed (php throws E_NOTICE when .= is used
|
||||||
|
// on a non-existing array element)
|
||||||
|
if (empty($sql_data[TOPICS_TABLE]))
|
||||||
|
{
|
||||||
|
$sql_data[TOPICS_TABLE] = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($topic_row['topic_replies'] > 0)
|
||||||
|
{
|
||||||
|
$sql_data[TOPICS_TABLE] = 'topic_replies = topic_replies - 1,';
|
||||||
|
}
|
||||||
|
$sql_data[TOPICS_TABLE] .= ' topic_last_view_time = ' . $current_time;
|
||||||
|
|
||||||
$sql_data[FORUMS_TABLE] = 'forum_posts = forum_posts - 1';
|
$sql_data[FORUMS_TABLE] = 'forum_posts = forum_posts - 1';
|
||||||
|
|
||||||
set_config_count('num_posts', -1, true);
|
set_config_count('num_posts', -1, true);
|
||||||
|
@ -293,7 +306,7 @@ class phpbb_content_visibility
|
||||||
* the posts/topics in question
|
* the posts/topics in question
|
||||||
* @param $post_id_list - array of ints - the set of posts being worked on
|
* @param $post_id_list - array of ints - the set of posts being worked on
|
||||||
*/
|
*/
|
||||||
public function unhide_posts_topics($mode, $post_info, $post_id_list)
|
static public function unhide_posts_topics($mode, $post_info, $post_id_list)
|
||||||
{
|
{
|
||||||
global $db, $config;
|
global $db, $config;
|
||||||
|
|
||||||
|
@ -435,6 +448,15 @@ class phpbb_content_visibility
|
||||||
sync('forum', 'forum_id', array_keys($forum_id_list), true, true);
|
sync('forum', 'forum_id', array_keys($forum_id_list), true, true);
|
||||||
unset($topic_id_list, $forum_id_list);
|
unset($topic_id_list, $forum_id_list);
|
||||||
|
|
||||||
return true;
|
if ($total_topics)
|
||||||
|
{
|
||||||
|
$success_msg = ($total_topics == 1) ? 'TOPIC_APPROVED_SUCCESS' : 'TOPICS_APPROVED_SUCCESS';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$success_msg = (sizeof($post_id_list) + sizeof($post_approved_list) == 1) ? 'POST_APPROVED_SUCCESS' : 'POSTS_APPROVED_SUCCESS';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $success_msg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1467,7 +1467,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false)
|
||||||
if ($is_soft)
|
if ($is_soft)
|
||||||
{
|
{
|
||||||
phpbb_content_visibility::set_post_visibility(ITEM_DELETED, $post_id, $topic_id, $forum_id, ($data['topic_first_post_id'] == $post_id), ($data['topic_last_post_id'] == $post_id));
|
phpbb_content_visibility::set_post_visibility(ITEM_DELETED, $post_id, $topic_id, $forum_id, ($data['topic_first_post_id'] == $post_id), ($data['topic_last_post_id'] == $post_id));
|
||||||
phpbb_content_visibility::hide_post($forum_id, time(), $sql_data);
|
phpbb_content_visibility::hide_post($forum_id, time(), $data, $sql_data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1501,7 +1501,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false)
|
||||||
if ($is_soft)
|
if ($is_soft)
|
||||||
{
|
{
|
||||||
$topic_row = array();
|
$topic_row = array();
|
||||||
phpbb_content_visibility::set_topic_visibility(POST_DELETED, $topic_id, $forum_id);
|
phpbb_content_visibility::set_topic_visibility(ITEM_DELETED, $topic_id, $forum_id);
|
||||||
phpbb_content_visibility::hide_topic($topic_id, $forum_id, $topic_row, $sql_data);
|
phpbb_content_visibility::hide_topic($topic_id, $forum_id, $topic_row, $sql_data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1548,8 +1548,8 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false)
|
||||||
case 'delete_last_post':
|
case 'delete_last_post':
|
||||||
if ($is_soft)
|
if ($is_soft)
|
||||||
{
|
{
|
||||||
phpbb_content_visibility::hide_post($forum_id, time(), $sql_data);
|
phpbb_content_visibility::hide_post($forum_id, time(), $data, $sql_data);
|
||||||
phpbb_content_visibility::set_post_visibility($post_id, $topic_id, $forum_id, false, true);
|
phpbb_content_visibility::set_post_visibility(ITEM_DELETED, $post_id, $topic_id, $forum_id, false, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -322,6 +322,7 @@ class mcp_queue
|
||||||
if ($mode == 'unapproved_posts' || $mode == 'deleted_posts')
|
if ($mode == 'unapproved_posts' || $mode == 'deleted_posts')
|
||||||
{
|
{
|
||||||
$visibility_const = ($mode == 'unapproved_posts') ? ITEM_UNAPPROVED : ITEM_DELETED;
|
$visibility_const = ($mode == 'unapproved_posts') ? ITEM_UNAPPROVED : ITEM_DELETED;
|
||||||
|
$starter_sql = ($mode == 'unapproved_posts') ? 'AND t.topic_first_post_id <> p.post_id' : '';
|
||||||
|
|
||||||
$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' : '') . '
|
||||||
|
@ -330,7 +331,7 @@ class mcp_queue
|
||||||
' . (($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
|
||||||
AND t.topic_first_post_id <> p.post_id
|
$starter_sql
|
||||||
$limit_time_sql
|
$limit_time_sql
|
||||||
ORDER BY $sort_order_sql";
|
ORDER BY $sort_order_sql";
|
||||||
$result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
|
$result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
|
||||||
|
|
|
@ -613,10 +613,10 @@ INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id,
|
||||||
|
|
||||||
|
|
||||||
# -- Demo Topic
|
# -- Demo Topic
|
||||||
INSERT INTO phpbb_topics (topic_title, topic_poster, topic_time, topic_views, topic_replies, topic_replies_real, forum_id, topic_status, topic_type, topic_first_post_id, topic_first_poster_name, topic_first_poster_colour, topic_last_post_id, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour, topic_last_post_subject, topic_last_post_time, topic_last_view_time, poll_title) VALUES ('{L_TOPICS_TOPIC_TITLE}', 2, 972086460, 0, 0, 0, 2, 0, 0, 1, 'Admin', 'AA0000', 1, 2, 'Admin', 'AA0000', '{L_TOPICS_TOPIC_TITLE}', 972086460, 972086460, '');
|
INSERT INTO phpbb_topics (topic_title, topic_poster, topic_time, topic_views, topic_replies, topic_replies_real, forum_id, topic_status, topic_type, topic_first_post_id, topic_first_poster_name, topic_first_poster_colour, topic_last_post_id, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour, topic_last_post_subject, topic_last_post_time, topic_last_view_time, poll_title, topic_visibility) VALUES ('{L_TOPICS_TOPIC_TITLE}', 2, 972086460, 0, 0, 0, 2, 0, 0, 1, 'Admin', 'AA0000', 1, 2, 'Admin', 'AA0000', '{L_TOPICS_TOPIC_TITLE}', 972086460, 972086460, '', 1);
|
||||||
|
|
||||||
# -- Demo Post
|
# -- Demo Post
|
||||||
INSERT INTO phpbb_posts (topic_id, forum_id, poster_id, icon_id, post_time, post_username, poster_ip, post_subject, post_text, post_checksum, bbcode_uid) VALUES (1, 2, 2, 0, 972086460, '', '127.0.0.1', '{L_TOPICS_TOPIC_TITLE}', '{L_DEFAULT_INSTALL_POST}', '5dd683b17f641daf84c040bfefc58ce9', '');
|
INSERT INTO phpbb_posts (topic_id, forum_id, poster_id, icon_id, post_time, post_username, poster_ip, post_subject, post_text, post_checksum, bbcode_uid, post_visibility) VALUES (1, 2, 2, 0, 972086460, '', '127.0.0.1', '{L_TOPICS_TOPIC_TITLE}', '{L_DEFAULT_INSTALL_POST}', '5dd683b17f641daf84c040bfefc58ce9', '', 1);
|
||||||
|
|
||||||
# -- Admin posted to the demo topic
|
# -- Admin posted to the demo topic
|
||||||
INSERT INTO phpbb_topics_posted (user_id, topic_id, topic_posted) VALUES (2, 1, 1);
|
INSERT INTO phpbb_topics_posted (user_id, topic_id, topic_posted) VALUES (2, 1, 1);
|
||||||
|
|
|
@ -886,9 +886,52 @@ if ($submit || $preview || $refresh)
|
||||||
|
|
||||||
if ($submit && $mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED && !isset($_POST['soft_delete']) && phpbb_content_visibility::can_restore($forum_id, $post_data['poster_id'], $post_data['post_edit_locked']))
|
if ($submit && $mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED && !isset($_POST['soft_delete']) && phpbb_content_visibility::can_restore($forum_id, $post_data['poster_id'], $post_data['post_edit_locked']))
|
||||||
{
|
{
|
||||||
|
// if this is the first post of the topic, restore the whole topic
|
||||||
|
if ($post_id == $post_data['topic_first_post_id'])
|
||||||
|
{
|
||||||
|
// that means we need to gather data for all posts in the topic, not
|
||||||
|
// just the one being edited
|
||||||
|
$sql = 'SELECT post_id, poster_id, post_subject, post_postcount
|
||||||
|
FROM ' . POSTS_TABLE . '
|
||||||
|
WHERE topic_id = ' . $post_data['topic_id'] . '
|
||||||
|
AND post_visibility = ' . ITEM_DELETED;
|
||||||
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
|
$post_ids = array();
|
||||||
|
|
||||||
|
while ($row = $db->sql_fetchrow($result))
|
||||||
|
{
|
||||||
|
$post_ids[] = $row['post_id'];
|
||||||
|
|
||||||
|
$posts_data[$row['post_id']] = array(
|
||||||
|
// all posts are from the same topic and forum
|
||||||
|
// and are deleted because of the constraints to the query above
|
||||||
|
'topic_id' => $post_data['topic_id'],
|
||||||
|
'forum_id' => $post_data['forum_id'],
|
||||||
|
'topic_replies' => $post_data['topic_replies'],
|
||||||
|
'topic_first_post_id' => $post_data['topic_first_post_id'],
|
||||||
|
'post_visibility' => ITEM_DELETED,
|
||||||
|
|
||||||
|
'poster_id' => $row['poster_id'],
|
||||||
|
'post_subject' => $row['post_subject'],
|
||||||
|
'post_postcount'=> $row['post_postcount'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// No direct query is needed, just update the array
|
||||||
|
$post_data['post_visibility'] = $post_data['topic_visibility'] = ITEM_APPROVED;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$post_ids = array($post_id);
|
||||||
|
$posts_data = array($post_id => $post_data);
|
||||||
|
|
||||||
|
$post_data['post_visibility'] = ITEM_APPROVED;
|
||||||
|
}
|
||||||
|
|
||||||
// don't feel that a confirm_box is needed for this
|
// don't feel that a confirm_box is needed for this
|
||||||
// do not return / trigger_error after this because the post content can also be changed
|
// do not return / trigger_error after this because the post content can also be changed
|
||||||
phpbb_content_visibility::unhide_posts_topics('restore', array($post_id => $post_data), array($post_id));
|
phpbb_content_visibility::unhide_posts_topics('restore', $posts_data, $post_ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse subject
|
// Parse subject
|
||||||
|
@ -1429,9 +1472,9 @@ $template->assign_vars(array(
|
||||||
'S_LOCK_POST_ALLOWED' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false,
|
'S_LOCK_POST_ALLOWED' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false,
|
||||||
'S_LOCK_POST_CHECKED' => ($lock_post_checked) ? ' checked="checked"' : '',
|
'S_LOCK_POST_CHECKED' => ($lock_post_checked) ? ' checked="checked"' : '',
|
||||||
'S_SOFT_DELETE_CHECKED' => ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED) ? ' checked="checked"' : '',
|
'S_SOFT_DELETE_CHECKED' => ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED) ? ' checked="checked"' : '',
|
||||||
'S_SOFT_DELETE_ALLOWED' => (phpbb_content_visibility::can_soft_delete($forum_id, $post_data['poster_id'], $lock_post_checked)) ? true : false,
|
'S_SOFT_DELETE_ALLOWED' => ($mode == 'edit' && phpbb_content_visibility::can_soft_delete($forum_id, $post_data['poster_id'], $lock_post_checked)) ? true : false,
|
||||||
'S_RESTORE_ALLOWED' => (phpbb_content_visibility::can_restore($forum_id, $post_data['poster_id'], $lock_post_checked)) ? true : false,
|
'S_RESTORE_ALLOWED' => (phpbb_content_visibility::can_restore($forum_id, $post_data['poster_id'], $lock_post_checked)) ? true : false,
|
||||||
'S_IS_DELETED' => ($post_data['post_visibility'] == POST_DELETED) ? true : false,
|
'S_IS_DELETED' => ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED) ? true : false,
|
||||||
'S_LINKS_ALLOWED' => $url_status,
|
'S_LINKS_ALLOWED' => $url_status,
|
||||||
'S_MAGIC_URL_CHECKED' => ($urls_checked) ? ' checked="checked"' : '',
|
'S_MAGIC_URL_CHECKED' => ($urls_checked) ? ' checked="checked"' : '',
|
||||||
'S_TYPE_TOGGLE' => $topic_type_toggle,
|
'S_TYPE_TOGGLE' => $topic_type_toggle,
|
||||||
|
@ -1547,6 +1590,7 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof
|
||||||
'topic_first_post_id' => $post_data['topic_first_post_id'],
|
'topic_first_post_id' => $post_data['topic_first_post_id'],
|
||||||
'topic_last_post_id' => $post_data['topic_last_post_id'],
|
'topic_last_post_id' => $post_data['topic_last_post_id'],
|
||||||
'topic_replies_real' => $post_data['topic_replies_real'],
|
'topic_replies_real' => $post_data['topic_replies_real'],
|
||||||
|
'topic_replies' => $post_data['topic_replies'],
|
||||||
'topic_visibility' => $post_data['topic_visibility'],
|
'topic_visibility' => $post_data['topic_visibility'],
|
||||||
'topic_type' => $post_data['topic_type'],
|
'topic_type' => $post_data['topic_type'],
|
||||||
'post_visibility' => $post_data['post_visibility'],
|
'post_visibility' => $post_data['post_visibility'],
|
||||||
|
|
|
@ -148,7 +148,7 @@
|
||||||
<input type="hidden" name="post_id_list[]" value="{postrow.POST_ID}" />
|
<input type="hidden" name="post_id_list[]" value="{postrow.POST_ID}" />
|
||||||
{S_FORM_TOKEN}
|
{S_FORM_TOKEN}
|
||||||
<br /><!-- ENDIF -->
|
<br /><!-- ENDIF -->
|
||||||
<!-- IF postrow.S_POST_DELETED -->{DELETED_IMG} <a href="{postrow.U_MCP_APPROVE}"><strong>{L_POST_DELETED_RESTORE}</strong></a><br /><!-- ENDIF -->
|
<!-- IF postrow.S_POST_DELETED -->{DELETED_IMG} <a href="{postrow.U_MCP_RESTORE}"><strong>{L_POST_DELETED_RESTORE}</strong></a><br /><!-- ENDIF -->
|
||||||
<!-- IF postrow.S_POST_REPORTED -->{REPORTED_IMG} <a href="{postrow.U_MCP_REPORT}"><strong>{L_POST_REPORTED}</strong></a><!-- ENDIF -->
|
<!-- IF postrow.S_POST_REPORTED -->{REPORTED_IMG} <a href="{postrow.U_MCP_REPORT}"><strong>{L_POST_REPORTED}</strong></a><!-- ENDIF -->
|
||||||
</p>
|
</p>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -1600,6 +1600,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
|
||||||
'U_REPORT' => ($auth->acl_get('f_report', $forum_id)) ? append_sid("{$phpbb_root_path}report.$phpEx", 'f=' . $forum_id . '&p=' . $row['post_id']) : '',
|
'U_REPORT' => ($auth->acl_get('f_report', $forum_id)) ? append_sid("{$phpbb_root_path}report.$phpEx", 'f=' . $forum_id . '&p=' . $row['post_id']) : '',
|
||||||
'U_MCP_REPORT' => ($auth->acl_get('m_report', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '',
|
'U_MCP_REPORT' => ($auth->acl_get('m_report', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '',
|
||||||
'U_MCP_APPROVE' => ($auth->acl_get('m_approve', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '',
|
'U_MCP_APPROVE' => ($auth->acl_get('m_approve', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '',
|
||||||
|
'U_MCP_RESTORE' => ($auth->acl_get('m_restore', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=deleted_posts&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '',
|
||||||
'U_MINI_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['post_id']) . '#p' . $row['post_id'],
|
'U_MINI_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['post_id']) . '#p' . $row['post_id'],
|
||||||
'U_NEXT_POST_ID' => ($i < $i_total && isset($rowset[$post_list[$i + 1]])) ? $rowset[$post_list[$i + 1]]['post_id'] : '',
|
'U_NEXT_POST_ID' => ($i < $i_total && isset($rowset[$post_list[$i + 1]])) ? $rowset[$post_list[$i + 1]]['post_id'] : '',
|
||||||
'U_PREV_POST_ID' => $prev_post_id,
|
'U_PREV_POST_ID' => $prev_post_id,
|
||||||
|
|
|
@ -181,14 +181,19 @@ class phpbb_class_visibility_test extends PHPUnit_Framework_TestCase
|
||||||
$GLOBALS['auth'] = new phpbb_acl_mock_founder;
|
$GLOBALS['auth'] = new phpbb_acl_mock_founder;
|
||||||
|
|
||||||
$sql_data = array();
|
$sql_data = array();
|
||||||
phpbb_content_visibility::hide_post(4, 111122211, $sql_data);
|
phpbb_content_visibility::hide_post(4, 111122211, array('topic_replies' => 1), $sql_data);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
array(FORUMS_TABLE => 'forum_posts = forum_posts - 1',
|
array(FORUMS_TABLE => 'forum_posts = forum_posts - 1',
|
||||||
TOPICS_TABLE => 'topic_replies = topic_replies - 1, topic_last_view_time = 111122211',
|
TOPICS_TABLE => 'topic_replies = topic_replies - 1, topic_last_view_time = 111122211',
|
||||||
USERS_TABLE => 'user_posts = user_posts - 1'),
|
USERS_TABLE => 'user_posts = user_posts - 1'),
|
||||||
$sql_data);
|
$sql_data);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//$a = new phpbb_class_visibility_test;
|
$sql_data = array();
|
||||||
//$a->test_can_soft_delete();
|
phpbb_content_visibility::hide_post(4, 111122211, array('topic_replies' => 0), $sql_data);
|
||||||
|
$this->assertEquals(
|
||||||
|
array(FORUMS_TABLE => 'forum_posts = forum_posts - 1',
|
||||||
|
TOPICS_TABLE => 'topic_last_view_time = 111122211',
|
||||||
|
USERS_TABLE => 'user_posts = user_posts - 1'),
|
||||||
|
$sql_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue