mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[feature/soft-delete] Rename phpbb_visibility class to phpbb_content_visibility
Rename the class to more accurately reflect what it does. PHPBB3-9657
This commit is contained in:
parent
6739375135
commit
a80cfafdd9
12 changed files with 72 additions and 72 deletions
|
@ -83,7 +83,7 @@ require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
|
|||
require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
|
||||
|
||||
|
||||
include($phpbb_root_path . 'includes/class_visibility.'.$phpEx);
|
||||
include($phpbb_root_path . 'includes/class_content_visibility.'.$phpEx);
|
||||
|
||||
// Set PHP error handler to ours
|
||||
set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler');
|
||||
|
|
|
@ -760,7 +760,7 @@ class phpbb_feed_overall extends phpbb_feed_post_base
|
|||
FROM ' . TOPICS_TABLE . '
|
||||
WHERE ' . $db->sql_in_set('forum_id', $forum_ids) . '
|
||||
AND topic_moved_id = 0
|
||||
AND ' . phpbb_visibility::get_visibility_sql_global('topic') . '
|
||||
AND ' . phpbb_content_visibility::get_visibility_sql_global('topic') . '
|
||||
ORDER BY topic_last_post_time DESC';
|
||||
$result = $db->sql_query_limit($sql, $this->num_items);
|
||||
|
||||
|
@ -795,7 +795,7 @@ class phpbb_feed_overall extends phpbb_feed_post_base
|
|||
),
|
||||
),
|
||||
'WHERE' => $db->sql_in_set('p.topic_id', $topic_ids) . '
|
||||
AND ' . phpbb_visibility::get_visibility_sql('post', array(), 'p.') . '
|
||||
AND ' . phpbb_content_visibility::get_visibility_sql('post', array(), 'p.') . '
|
||||
AND p.post_time >= ' . $min_post_time . '
|
||||
AND u.user_id = p.poster_id',
|
||||
'ORDER_BY' => 'p.post_time DESC',
|
||||
|
@ -892,7 +892,7 @@ class phpbb_feed_forum extends phpbb_feed_post_base
|
|||
FROM ' . TOPICS_TABLE . '
|
||||
WHERE forum_id = ' . $this->forum_id . '
|
||||
AND topic_moved_id = 0
|
||||
AND ' . phpbb_visibility::get_visibility_sql('topic', $this->forum_id) . '
|
||||
AND ' . phpbb_content_visibility::get_visibility_sql('topic', $this->forum_id) . '
|
||||
ORDER BY topic_last_post_time DESC';
|
||||
$result = $db->sql_query_limit($sql, $this->num_items);
|
||||
|
||||
|
@ -919,7 +919,7 @@ class phpbb_feed_forum extends phpbb_feed_post_base
|
|||
USERS_TABLE => 'u',
|
||||
),
|
||||
'WHERE' => $db->sql_in_set('p.topic_id', $topic_ids) . '
|
||||
AND ' . phpbb_visibility::get_visibility_sql('post', $this->forum_id, 'p.') . '
|
||||
AND ' . phpbb_content_visibility::get_visibility_sql('post', $this->forum_id, 'p.') . '
|
||||
AND p.post_time >= ' . $min_post_time . '
|
||||
AND p.poster_id = u.user_id',
|
||||
'ORDER_BY' => 'p.post_time DESC',
|
||||
|
@ -1025,7 +1025,7 @@ class phpbb_feed_topic extends phpbb_feed_post_base
|
|||
USERS_TABLE => 'u',
|
||||
),
|
||||
'WHERE' => 'p.topic_id = ' . $this->topic_id . '
|
||||
AND ' . phpbb_visibility::get_visibility_sql('post', $this->forum_id, 'p.') . '
|
||||
AND ' . phpbb_content_visibility::get_visibility_sql('post', $this->forum_id, 'p.') . '
|
||||
AND p.poster_id = u.user_id',
|
||||
'ORDER_BY' => 'p.post_time DESC',
|
||||
);
|
||||
|
|
|
@ -21,7 +21,7 @@ if (!defined('IN_PHPBB'))
|
|||
* Handle fetching and setting the visibility for topics and posts
|
||||
* @package phpbb
|
||||
*/
|
||||
class phpbb_visibility
|
||||
class phpbb_content_visibility
|
||||
{
|
||||
/**
|
||||
* Create topic/post visibility SQL for a given forum ID
|
|
@ -993,7 +993,7 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id
|
|||
$sql = 'SELECT p.post_id
|
||||
FROM ' . POSTS_TABLE . ' p' . "
|
||||
WHERE p.topic_id = $topic_id
|
||||
AND " . phpbb_visibility::get_visibility_sql('post', $forum_id, 'p.') . '
|
||||
AND " . phpbb_content_visibility::get_visibility_sql('post', $forum_id, 'p.') . '
|
||||
' . (($mode == 'post_review') ? " AND p.post_id > $cur_post_id" : '') . '
|
||||
' . (($mode == 'post_review_edit') ? " AND p.post_id = $cur_post_id" : '') . '
|
||||
ORDER BY p.post_time ';
|
||||
|
@ -1466,8 +1466,8 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false)
|
|||
|
||||
if ($is_soft)
|
||||
{
|
||||
phpbb_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_visibility::hide_post($forum_id, time(), $sql_data);
|
||||
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);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1501,8 +1501,8 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false)
|
|||
if ($is_soft)
|
||||
{
|
||||
$topic_row = array();
|
||||
phpbb_visibility::set_topic_visibility(POST_DELETED, $topic_id, $forum_id);
|
||||
phpbb_visibility::hide_topic($topic_id, $forum_id, $topic_row, $sql_data);
|
||||
phpbb_content_visibility::set_topic_visibility(POST_DELETED, $topic_id, $forum_id);
|
||||
phpbb_content_visibility::hide_topic($topic_id, $forum_id, $topic_row, $sql_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1548,8 +1548,8 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false)
|
|||
case 'delete_last_post':
|
||||
if ($is_soft)
|
||||
{
|
||||
phpbb_visibility::hide_post($forum_id, time(), $sql_data);
|
||||
phpbb_visibility::set_post_visibility($post_id, $topic_id, $forum_id, false, true);
|
||||
phpbb_content_visibility::hide_post($forum_id, time(), $sql_data);
|
||||
phpbb_content_visibility::set_post_visibility($post_id, $topic_id, $forum_id, false, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1576,7 +1576,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false)
|
|||
$sql = 'SELECT MAX(post_id) as last_post_id
|
||||
FROM ' . POSTS_TABLE . "
|
||||
WHERE topic_id = $topic_id
|
||||
AND " . phpbb_visibility::get_visibility_sql('post', $forum_id);
|
||||
AND " . phpbb_content_visibility::get_visibility_sql('post', $forum_id);
|
||||
$result = $db->sql_query($sql);
|
||||
$row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
@ -1589,7 +1589,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false)
|
|||
$sql = 'SELECT post_id
|
||||
FROM ' . POSTS_TABLE . "
|
||||
WHERE topic_id = $topic_id
|
||||
AND " . phpbb_visibility::get_visibility_sql('post', $forum_id) . '
|
||||
AND " . phpbb_content_visibility::get_visibility_sql('post', $forum_id) . '
|
||||
AND post_time > ' . $data['post_time'] . '
|
||||
ORDER BY post_time ASC';
|
||||
$result = $db->sql_query_limit($sql, 1);
|
||||
|
@ -1949,7 +1949,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
|
|||
// Correctly set back the topic replies and forum posts... only if the topic was approved before and now gets disapproved
|
||||
if (!$post_approval && $data['topic_visibility'] == ITEM_APPROVED)
|
||||
{
|
||||
phpbb_visibility::hide_topic($data['topic_id'], $data['forum_id'], $topic_row, $sql_data);
|
||||
phpbb_content_visibility::hide_topic($data['topic_id'], $data['forum_id'], $topic_row, $sql_data);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -1960,7 +1960,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
|
|||
// Correctly set back the topic replies and forum posts... but only if the post was approved before.
|
||||
if (!$post_approval && $data['post_visibility'] == ITEM_APPROVED)
|
||||
{
|
||||
//phpbb_visibility::hide_post($forum_id, $current_time, $sql_data);
|
||||
//phpbb_content_visibility::hide_post($forum_id, $current_time, $sql_data);
|
||||
// ^^ hide_post SQL is identical, except that it does not include the ['stat'] sub-array
|
||||
$sql_data[TOPICS_TABLE]['stat'][] = 'topic_replies = topic_replies - 1, topic_last_view_time = ' . $current_time;
|
||||
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts - 1';
|
||||
|
|
|
@ -154,7 +154,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info)
|
|||
$sql = 'SELECT t.topic_id
|
||||
FROM ' . TOPICS_TABLE . ' t
|
||||
WHERE t.forum_id = ' . $forum_id . '
|
||||
' . phpbb_visibility::get_visibility_sql('topic', $forum_id, 't.') . "
|
||||
' . phpbb_content_visibility::get_visibility_sql('topic', $forum_id, 't.') . "
|
||||
$limit_time_sql
|
||||
ORDER BY t.topic_type DESC, $sort_order_sql";
|
||||
$result = $db->sql_query_limit($sql, $topics_per_page, $start);
|
||||
|
|
|
@ -493,7 +493,7 @@ function approve_post($post_id_list, $id, $mode)
|
|||
{
|
||||
$notify_poster = (isset($_REQUEST['notify_poster'])) ? true : false;
|
||||
|
||||
phpbb_visibility::unhide_posts_topics('approve', $post_info, $post_id_list);
|
||||
phpbb_content_visibility::unhide_posts_topics('approve', $post_info, $post_id_list);
|
||||
|
||||
$messenger = new messenger();
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@ function mcp_topic_view($id, $mode, $action)
|
|||
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
|
||||
WHERE ' . (($action == 'reports') ? 'p.post_reported = 1 AND ' : '') . '
|
||||
p.topic_id = ' . $topic_id . '
|
||||
AND ' . phpbb_visibility::get_visibility_sql('post', $topic_info['forum_id'], 'p.') . '
|
||||
AND ' . phpbb_content_visibility::get_visibility_sql('post', $topic_info['forum_id'], 'p.') . '
|
||||
AND p.poster_id = u.user_id ' .
|
||||
$limit_time_sql . '
|
||||
ORDER BY ' . $sort_order_sql;
|
||||
|
|
|
@ -99,7 +99,7 @@ switch ($mode)
|
|||
FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f
|
||||
WHERE t.topic_id = $topic_id
|
||||
AND f.forum_id = t.forum_id
|
||||
AND " . phpbb_visibility::get_visibility_sql('topic', $forum_id, 't.');
|
||||
AND " . phpbb_content_visibility::get_visibility_sql('topic', $forum_id, 't.');
|
||||
break;
|
||||
|
||||
case 'quote':
|
||||
|
@ -128,7 +128,7 @@ switch ($mode)
|
|||
AND t.topic_id = p.topic_id
|
||||
AND u.user_id = p.poster_id
|
||||
AND f.forum_id = t.forum_id
|
||||
AND " . phpbb_visibility::get_visibility_sql('topic', $forum_id, 't.');
|
||||
AND " . phpbb_content_visibility::get_visibility_sql('topic', $forum_id, 't.');
|
||||
break;
|
||||
|
||||
case 'smilies':
|
||||
|
@ -181,13 +181,6 @@ if ($auth->acl_get('m_approve', $forum_id) && ((($mode == 'reply' || $mode == 'b
|
|||
trigger_error(($mode == 'reply' || $mode == 'bump') ? 'TOPIC_UNAPPROVED' : 'POST_UNAPPROVED');
|
||||
}
|
||||
|
||||
if ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED && !isset($_POST['soft_delete']) && phpbb_visibility::can_restore($forum_id, $post_data['poster_id'], $post_data['post_edit_locked']))
|
||||
{
|
||||
// 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
|
||||
phpbb_visibility::unhide_posts_topics('restore', array($post_id => $post_data), array($post_id));
|
||||
}
|
||||
|
||||
if ($mode == 'popup')
|
||||
{
|
||||
upload_popup($post_data['forum_style']);
|
||||
|
@ -891,6 +884,13 @@ if ($submit || $preview || $refresh)
|
|||
$error[] = $user->lang['FORM_INVALID'];
|
||||
}
|
||||
|
||||
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']))
|
||||
{
|
||||
// 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
|
||||
phpbb_content_visibility::unhide_posts_topics('restore', array($post_id => $post_data), array($post_id));
|
||||
}
|
||||
|
||||
// Parse subject
|
||||
if (!$preview && !$refresh && utf8_clean_string($post_data['post_subject']) === '' && ($mode == 'post' || ($mode == 'edit' && $post_data['topic_first_post_id'] == $post_id)))
|
||||
{
|
||||
|
@ -1429,8 +1429,8 @@ $template->assign_vars(array(
|
|||
'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_SOFT_DELETE_CHECKED' => ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED) ? ' checked="checked"' : '',
|
||||
'S_SOFT_DELETE_ALLOWED' => (phpbb_visibility::can_soft_delete($forum_id, $post_data['poster_id'], $lock_post_checked)) ? true : false,
|
||||
'S_RESTORE_ALLOWED' => (phpbb_visibility::can_restore($forum_id, $post_data['poster_id'], $lock_post_checked)) ? true : false,
|
||||
'S_SOFT_DELETE_ALLOWED' => (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_IS_DELETED' => ($post_data['post_visibility'] == POST_DELETED) ? true : false,
|
||||
'S_LINKS_ALLOWED' => $url_status,
|
||||
'S_MAGIC_URL_CHECKED' => ($urls_checked) ? ' checked="checked"' : '',
|
||||
|
|
|
@ -266,7 +266,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
|
|||
$m_approve_fid_sql = ' AND p.post_approved = 1';
|
||||
}
|
||||
*/
|
||||
$m_approve_fid_sql = ' AND ' . phpbb_visibility::get_visibility_sql_global('post', $ex_fid_ary, 'p.');
|
||||
$m_approve_fid_sql = ' AND ' . phpbb_content_visibility::get_visibility_sql_global('post', $ex_fid_ary, 'p.');
|
||||
|
||||
if ($reset_search_forum)
|
||||
{
|
||||
|
|
|
@ -241,7 +241,7 @@ if ($sort_days)
|
|||
AND (topic_last_post_time >= $min_post_time
|
||||
OR topic_type = " . POST_ANNOUNCE . '
|
||||
OR topic_type = ' . POST_GLOBAL . ')
|
||||
AND ' . phpbb_visibility::get_visibility_sql('topic', $forum_id);
|
||||
AND ' . phpbb_content_visibility::get_visibility_sql('topic', $forum_id);
|
||||
$result = $db->sql_query($sql);
|
||||
$topics_count = (int) $db->sql_fetchfield('num_topics');
|
||||
$db->sql_freeresult($result);
|
||||
|
@ -353,7 +353,7 @@ $sql_array = array(
|
|||
'LEFT_JOIN' => array(),
|
||||
);
|
||||
|
||||
$sql_approved = 'AND ' . phpbb_visibility::get_visibility_sql('topic', $forum_id, 't.');
|
||||
$sql_approved = 'AND ' . phpbb_content_visibility::get_visibility_sql('topic', $forum_id, 't.');
|
||||
|
||||
if ($user->data['is_registered'])
|
||||
{
|
||||
|
|
|
@ -83,7 +83,7 @@ if ($view && !$post_id)
|
|||
$sql = 'SELECT post_id, topic_id, forum_id
|
||||
FROM ' . POSTS_TABLE . "
|
||||
WHERE topic_id = $topic_id
|
||||
AND " . phpbb_visibility::get_visibility_sql('post', $forum_id) . "
|
||||
AND " . phpbb_content_visibility::get_visibility_sql('post', $forum_id) . "
|
||||
AND post_time > $topic_last_read
|
||||
AND forum_id = $forum_id
|
||||
ORDER BY post_time ASC";
|
||||
|
@ -137,7 +137,7 @@ if ($view && !$post_id)
|
|||
WHERE forum_id = ' . $row['forum_id'] . "
|
||||
AND topic_moved_id = 0
|
||||
AND topic_last_post_time $sql_condition {$row['topic_last_post_time']}
|
||||
AND" . phpbb_visibility::get_visibility_sql('topic', $row['forum_id']) . "
|
||||
AND" . phpbb_content_visibility::get_visibility_sql('topic', $row['forum_id']) . "
|
||||
ORDER BY topic_last_post_time $sql_ordering";
|
||||
$result = $db->sql_query_limit($sql, 1);
|
||||
$row = $db->sql_fetchrow($result);
|
||||
|
@ -277,7 +277,7 @@ if ($post_id)
|
|||
$sql = 'SELECT COUNT(p.post_id) AS prev_posts
|
||||
FROM ' . POSTS_TABLE . " p
|
||||
WHERE p.topic_id = {$topic_data['topic_id']}
|
||||
" . phpbb_visibility::get_visibility_sql('post', $forum_id, 'p.');
|
||||
" . phpbb_content_visibility::get_visibility_sql('post', $forum_id, 'p.');
|
||||
|
||||
if ($sort_dir == 'd')
|
||||
{
|
||||
|
@ -408,7 +408,7 @@ if ($sort_days)
|
|||
FROM ' . POSTS_TABLE . "
|
||||
WHERE topic_id = $topic_id
|
||||
AND post_time >= $min_post_time
|
||||
AND " . phpbb_visibility::get_visibility_sql('post', $forum_id);
|
||||
AND " . phpbb_content_visibility::get_visibility_sql('post', $forum_id);
|
||||
$result = $db->sql_query($sql);
|
||||
$total_posts = (int) $db->sql_fetchfield('num_posts');
|
||||
$db->sql_freeresult($result);
|
||||
|
@ -945,7 +945,7 @@ $i = $i_total = 0;
|
|||
$sql = 'SELECT p.post_id
|
||||
FROM ' . POSTS_TABLE . ' p' . (($join_user_sql[$sort_key]) ? ', ' . USERS_TABLE . ' u': '') . "
|
||||
WHERE p.topic_id = $topic_id
|
||||
AND " . phpbb_visibility::get_visibility_sql('post', $forum_id, 'p.') . "
|
||||
AND " . phpbb_content_visibility::get_visibility_sql('post', $forum_id, 'p.') . "
|
||||
" . (($join_user_sql[$sort_key]) ? 'AND u.user_id = p.poster_id': '') . "
|
||||
$limit_posts_time
|
||||
ORDER BY $sql_sort_order";
|
||||
|
|
|
@ -12,7 +12,7 @@ require_once 'test_framework/framework.php';
|
|||
require_once 'class_visibility/auth_mock.php';
|
||||
require_once 'class_visibility/user_mock.php';
|
||||
|
||||
require_once '../phpBB/includes/class_visibility.php';
|
||||
require_once '../phpBB/includes/class_content_visibility.php';
|
||||
require_once '../phpBB/includes/db/mysqli.php';
|
||||
require_once '../phpBB/includes/functions.php';
|
||||
require_once '../phpBB/includes/constants.php';
|
||||
|
@ -25,30 +25,30 @@ class phpbb_class_visibility_test extends PHPUnit_Framework_TestCase
|
|||
{
|
||||
$GLOBALS['auth'] = new phpbb_acl_mock_none;
|
||||
|
||||
$sql1 = phpbb_visibility::get_visibility_sql('topic', 1, '');
|
||||
$sql1 = phpbb_content_visibility::get_visibility_sql('topic', 1, '');
|
||||
$this->assertEquals('topic_visibility = 1', $sql1);
|
||||
|
||||
$sql2 = phpbb_visibility::get_visibility_sql('post', 1, '');
|
||||
$sql2 = phpbb_content_visibility::get_visibility_sql('post', 1, '');
|
||||
$this->assertEquals('post_visibility = 1', $sql2);
|
||||
|
||||
$GLOBALS['auth'] = new phpbb_acl_mock_founder;
|
||||
|
||||
$sql3 = phpbb_visibility::get_visibility_sql('topic', 1, '');
|
||||
$sql3 = phpbb_content_visibility::get_visibility_sql('topic', 1, '');
|
||||
$this->assertEquals('topic_visibility IN (1, 0, 2)', $sql3);
|
||||
|
||||
$sql4 = phpbb_visibility::get_visibility_sql('post', 1, '');
|
||||
$sql4 = phpbb_content_visibility::get_visibility_sql('post', 1, '');
|
||||
$this->assertEquals('post_visibility IN (1, 0, 2)', $sql4);
|
||||
|
||||
$GLOBALS['auth'] = new phpbb_acl_mock_user;
|
||||
$GLOBALS['user'] = new phpbb_user_mock;
|
||||
$GLOBALS['user']->data['user_id'] = 2;
|
||||
|
||||
$sql1 = phpbb_visibility::get_visibility_sql('topic', 1, '');
|
||||
$sql1 = phpbb_content_visibility::get_visibility_sql('topic', 1, '');
|
||||
$this->assertEquals('(topic_visibility = 1
|
||||
OR (topic_visibility = 2
|
||||
AND topic_poster = 2))', $sql1);
|
||||
|
||||
$sql2 = phpbb_visibility::get_visibility_sql('post', 1, '');
|
||||
$sql2 = phpbb_content_visibility::get_visibility_sql('post', 1, '');
|
||||
$this->assertEquals('(post_visibility = 1
|
||||
OR (post_visibility = 2
|
||||
AND poster_id = 2))', $sql2);
|
||||
|
@ -58,28 +58,28 @@ class phpbb_class_visibility_test extends PHPUnit_Framework_TestCase
|
|||
{
|
||||
$GLOBALS['auth'] = new phpbb_acl_mock_none;
|
||||
|
||||
$sql1 = phpbb_visibility::get_visibility_sql_global('topic', array(), '');
|
||||
$sql1 = phpbb_content_visibility::get_visibility_sql_global('topic', array(), '');
|
||||
$this->assertEquals('(topic_visibility = 1)', $sql1);
|
||||
|
||||
$sql2 = phpbb_visibility::get_visibility_sql_global('post', array(), '');
|
||||
$sql2 = phpbb_content_visibility::get_visibility_sql_global('post', array(), '');
|
||||
$this->assertEquals('(post_visibility = 1)', $sql2);
|
||||
|
||||
$sql3 = phpbb_visibility::get_visibility_sql_global('post', range(2, 15), '');
|
||||
$sql3 = phpbb_content_visibility::get_visibility_sql_global('post', range(2, 15), '');
|
||||
$this->assertEquals('(post_visibility = 1)', $sql3);
|
||||
|
||||
$GLOBALS['auth'] = new phpbb_acl_mock_founder;
|
||||
|
||||
$sql1 = phpbb_visibility::get_visibility_sql_global('topic', array(), '');
|
||||
$sql1 = phpbb_content_visibility::get_visibility_sql_global('topic', array(), '');
|
||||
$this->assertEquals('(topic_visibility = 1 OR (topic_visibility = 0
|
||||
AND forum_id IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)) OR (topic_visibility = 2
|
||||
AND forum_id IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)))', $sql1);
|
||||
|
||||
$sql2 = phpbb_visibility::get_visibility_sql_global('post', array(), '');
|
||||
$sql2 = phpbb_content_visibility::get_visibility_sql_global('post', array(), '');
|
||||
$this->assertEquals('(post_visibility = 1 OR (post_visibility = 0
|
||||
AND forum_id IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)) OR (post_visibility = 2
|
||||
AND forum_id IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)))', $sql2);
|
||||
|
||||
$sql3 = phpbb_visibility::get_visibility_sql_global('post', range(2, 14), '');
|
||||
$sql3 = phpbb_content_visibility::get_visibility_sql_global('post', range(2, 14), '');
|
||||
$this->assertEquals('(post_visibility = 1 OR (post_visibility = 0
|
||||
AND forum_id = 1) OR (post_visibility = 2
|
||||
AND forum_id = 1))', $sql3);
|
||||
|
@ -88,17 +88,17 @@ class phpbb_class_visibility_test extends PHPUnit_Framework_TestCase
|
|||
$GLOBALS['user'] = new phpbb_user_mock;
|
||||
$GLOBALS['user']->data['user_id'] = 2;
|
||||
|
||||
$sql1 = phpbb_visibility::get_visibility_sql_global('topic', array(), '');
|
||||
$sql1 = phpbb_content_visibility::get_visibility_sql_global('topic', array(), '');
|
||||
$this->assertEquals('(topic_visibility = 1 OR (topic_poster = 2
|
||||
AND topic_visibility = 2
|
||||
AND forum_id IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)))', $sql1);
|
||||
|
||||
$sql2 = phpbb_visibility::get_visibility_sql_global('post', array(), '');
|
||||
$sql2 = phpbb_content_visibility::get_visibility_sql_global('post', array(), '');
|
||||
$this->assertEquals('(post_visibility = 1 OR (poster_id = 2
|
||||
AND post_visibility = 2
|
||||
AND forum_id IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)))', $sql2);
|
||||
|
||||
$sql3 = phpbb_visibility::get_visibility_sql_global('post', range(2, 14), '');
|
||||
$sql3 = phpbb_content_visibility::get_visibility_sql_global('post', range(2, 14), '');
|
||||
$this->assertEquals('(post_visibility = 1 OR (poster_id = 2
|
||||
AND post_visibility = 2
|
||||
AND forum_id = 1))', $sql3);
|
||||
|
@ -110,27 +110,27 @@ class phpbb_class_visibility_test extends PHPUnit_Framework_TestCase
|
|||
$GLOBALS['user']->data['user_id'] = 2;
|
||||
|
||||
$GLOBALS['auth'] = new phpbb_acl_mock_founder;
|
||||
$result = phpbb_visibility::can_soft_delete(1, 4, true);
|
||||
$result = phpbb_content_visibility::can_soft_delete(1, 4, true);
|
||||
$this->assertEquals(true, $result);
|
||||
|
||||
$result = phpbb_visibility::can_soft_delete(1, 2, false);
|
||||
$result = phpbb_content_visibility::can_soft_delete(1, 2, false);
|
||||
$this->assertEquals(true, $result);
|
||||
|
||||
$GLOBALS['auth'] = new phpbb_acl_mock_none;
|
||||
$result = phpbb_visibility::can_soft_delete(1, 4, true);
|
||||
$result = phpbb_content_visibility::can_soft_delete(1, 4, true);
|
||||
$this->assertEquals(false, $result);
|
||||
|
||||
$result = phpbb_visibility::can_soft_delete(1, 2, false);
|
||||
$result = phpbb_content_visibility::can_soft_delete(1, 2, false);
|
||||
$this->assertEquals(false, $result);
|
||||
|
||||
$GLOBALS['auth'] = new phpbb_acl_mock_user;
|
||||
$result = phpbb_visibility::can_soft_delete(1, 4, true);
|
||||
$result = phpbb_content_visibility::can_soft_delete(1, 4, true);
|
||||
$this->assertEquals(false, $result);
|
||||
|
||||
$result = phpbb_visibility::can_soft_delete(1, 2, false);
|
||||
$result = phpbb_content_visibility::can_soft_delete(1, 2, false);
|
||||
$this->assertEquals(true, $result);
|
||||
|
||||
$result = phpbb_visibility::can_soft_delete(1, 2, true);
|
||||
$result = phpbb_content_visibility::can_soft_delete(1, 2, true);
|
||||
$this->assertEquals(false, $result);
|
||||
}
|
||||
|
||||
|
@ -140,27 +140,27 @@ class phpbb_class_visibility_test extends PHPUnit_Framework_TestCase
|
|||
$GLOBALS['user']->data['user_id'] = 2;
|
||||
|
||||
$GLOBALS['auth'] = new phpbb_acl_mock_founder;
|
||||
$result = phpbb_visibility::can_restore(1, 4, true);
|
||||
$result = phpbb_content_visibility::can_restore(1, 4, true);
|
||||
$this->assertEquals(true, $result);
|
||||
|
||||
$result = phpbb_visibility::can_restore(1, 2, false);
|
||||
$result = phpbb_content_visibility::can_restore(1, 2, false);
|
||||
$this->assertEquals(true, $result);
|
||||
|
||||
$GLOBALS['auth'] = new phpbb_acl_mock_none;
|
||||
$result = phpbb_visibility::can_restore(1, 4, true);
|
||||
$result = phpbb_content_visibility::can_restore(1, 4, true);
|
||||
$this->assertEquals(false, $result);
|
||||
|
||||
$result = phpbb_visibility::can_restore(1, 2, false);
|
||||
$result = phpbb_content_visibility::can_restore(1, 2, false);
|
||||
$this->assertEquals(false, $result);
|
||||
|
||||
$GLOBALS['auth'] = new phpbb_acl_mock_user;
|
||||
$result = phpbb_visibility::can_restore(1, 4, true);
|
||||
$result = phpbb_content_visibility::can_restore(1, 4, true);
|
||||
$this->assertEquals(false, $result);
|
||||
|
||||
$result = phpbb_visibility::can_restore(1, 2, false);
|
||||
$result = phpbb_content_visibility::can_restore(1, 2, false);
|
||||
$this->assertEquals(true, $result);
|
||||
|
||||
$result = phpbb_visibility::can_restore(1, 2, true);
|
||||
$result = phpbb_content_visibility::can_restore(1, 2, true);
|
||||
$this->assertEquals(false, $result);
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ class phpbb_class_visibility_test extends PHPUnit_Framework_TestCase
|
|||
|
||||
$topic_row = array('topic_replies' => 3);
|
||||
$sql_data = array();
|
||||
phpbb_visibility::hide_topic(4, 2, $topic_row, $sql_data);
|
||||
phpbb_content_visibility::hide_topic(4, 2, $topic_row, $sql_data);
|
||||
$this->assertEquals(
|
||||
array(FORUMS_TABLE => 'forum_topics = forum_topics - 1, forum_posts = forum_posts - 4', USERS_TABLE => 'user_posts = user_posts - 1'),
|
||||
$sql_data);
|
||||
|
@ -181,7 +181,7 @@ class phpbb_class_visibility_test extends PHPUnit_Framework_TestCase
|
|||
$GLOBALS['auth'] = new phpbb_acl_mock_founder;
|
||||
|
||||
$sql_data = array();
|
||||
phpbb_visibility::hide_post(4, 111122211, $sql_data);
|
||||
phpbb_content_visibility::hide_post(4, 111122211, $sql_data);
|
||||
$this->assertEquals(
|
||||
array(FORUMS_TABLE => 'forum_posts = forum_posts - 1',
|
||||
TOPICS_TABLE => 'topic_replies = topic_replies - 1, topic_last_view_time = 111122211',
|
||||
|
|
Loading…
Add table
Reference in a new issue