1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-09 02:06:32 +02:00

[feature/soft-delete] Append _approved to *_posts and *_topics column names

PHPBB3-9567
This commit is contained in:
Joas Schilling
2012-11-09 13:37:53 +01:00
parent dac798deff
commit 9c2a58eff4
21 changed files with 76 additions and 71 deletions

View File

@@ -856,8 +856,8 @@ class acp_forums
'FORUM_IMAGE_SRC' => ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : '',
'FORUM_NAME' => $row['forum_name'],
'FORUM_DESCRIPTION' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']),
'FORUM_TOPICS' => $row['forum_topics'],
'FORUM_POSTS' => $row['forum_posts'],
'FORUM_TOPICS' => $row['forum_topics_approved'],
'FORUM_POSTS' => $row['forum_posts_approved'],
'S_FORUM_LINK' => ($forum_type == FORUM_LINK) ? true : false,
'S_FORUM_POST' => ($forum_type == FORUM_POST) ? true : false,
@@ -1143,7 +1143,7 @@ class acp_forums
return array($user->lang['NO_FORUM_ACTION']);
}
$forum_data_sql['forum_posts'] = $forum_data_sql['forum_posts_unapproved'] = $forum_data_sql['forum_posts_softdeleted'] = $forum_data_sql['forum_topics'] = $forum_data_sql['forum_topics_unapproved'] = $forum_data_sql['forum_topics_softdeleted'] = 0;
$forum_data_sql['forum_posts_approved'] = $forum_data_sql['forum_posts_unapproved'] = $forum_data_sql['forum_posts_softdeleted'] = $forum_data_sql['forum_topics_approved'] = $forum_data_sql['forum_topics_unapproved'] = $forum_data_sql['forum_topics_softdeleted'] = 0;
$forum_data_sql['forum_last_post_id'] = $forum_data_sql['forum_last_poster_id'] = $forum_data_sql['forum_last_post_time'] = 0;
$forum_data_sql['forum_last_poster_name'] = $forum_data_sql['forum_last_poster_colour'] = '';
}
@@ -1264,10 +1264,10 @@ class acp_forums
else if ($row['forum_type'] == FORUM_CAT && $forum_data_sql['forum_type'] == FORUM_POST)
{
// Changing a category to a forum? Reset the data (you can't post directly in a cat, you must use a forum)
$forum_data_sql['forum_posts'] = 0;
$forum_data_sql['forum_posts_approved'] = 0;
$forum_data_sql['forum_posts_unapproved'] = 0;
$forum_data_sql['forum_posts_softdeleted'] = 0;
$forum_data_sql['forum_topics'] = 0;
$forum_data_sql['forum_topics_approved'] = 0;
$forum_data_sql['forum_topics_unapproved'] = 0;
$forum_data_sql['forum_topics_softdeleted'] = 0;
$forum_data_sql['forum_last_post_id'] = 0;

View File

@@ -60,10 +60,10 @@ class phpbb_content_visibility
if (!$auth->acl_get('m_approve', $forum_id))
{
return (int) $data[$mode];
return (int) $data[$mode . '_approved'];
}
return (int) $data[$mode] + (int) $data[$mode . '_unapproved'] + (int) $data[$mode . '_softdeleted'];
return (int) $data[$mode . '_approved'] + (int) $data[$mode . '_unapproved'] + (int) $data[$mode . '_softdeleted'];
}
/**
@@ -372,7 +372,7 @@ class phpbb_content_visibility
{
if ($cur_posts)
{
$sql_ary['posts'] = ' - ' . $cur_posts;
$sql_ary['posts_approved'] = ' - ' . $cur_posts;
}
if ($cur_unapproved_posts)
{
@@ -395,7 +395,7 @@ class phpbb_content_visibility
}
if ($cur_softdeleted_posts + $cur_unapproved_posts)
{
$sql_ary['posts'] = ' + ' . ($cur_softdeleted_posts + $cur_unapproved_posts);
$sql_ary['posts_approved'] = ' + ' . ($cur_softdeleted_posts + $cur_unapproved_posts);
}
}
@@ -564,7 +564,7 @@ class phpbb_content_visibility
// Do we need to grab some topic informations?
if (!sizeof($topic_row))
{
$sql = 'SELECT topic_type, topic_posts, topic_posts_unapproved, topic_posts_softdeleted, topic_visibility
$sql = 'SELECT topic_type, topic_posts_approved, topic_posts_unapproved, topic_posts_softdeleted, topic_visibility
FROM ' . TOPICS_TABLE . '
WHERE topic_id = ' . $topic_id;
$result = $db->sql_query($sql);
@@ -573,8 +573,8 @@ class phpbb_content_visibility
}
// If this is an edited topic or the first post the topic gets completely disapproved later on...
$sql_data[FORUMS_TABLE] = (($sql_data[FORUMS_TABLE]) ? $sql_data[FORUMS_TABLE] . ', ' : '') . 'forum_topics = forum_topics - 1';
$sql_data[FORUMS_TABLE] .= ', forum_posts = forum_posts - ' . $topic_row['topic_posts'];
$sql_data[FORUMS_TABLE] = (($sql_data[FORUMS_TABLE]) ? $sql_data[FORUMS_TABLE] . ', ' : '') . 'forum_topics_approved = forum_topics_approved - 1';
$sql_data[FORUMS_TABLE] .= ', forum_posts_approved = forum_posts_approved - ' . $topic_row['topic_posts_approved'];
$sql_data[FORUMS_TABLE] .= ', forum_posts_unapproved = forum_posts_unapproved - ' . $topic_row['topic_posts_unapproved'];
$sql_data[FORUMS_TABLE] .= ', forum_posts_softdeleted = forum_posts_softdeleted - ' . $topic_row['topic_posts_softdeleted'];

View File

@@ -1669,10 +1669,10 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
$forum_data[$forum_id] = $row;
if ($sync_extra)
{
$forum_data[$forum_id]['posts'] = 0;
$forum_data[$forum_id]['posts_approved'] = 0;
$forum_data[$forum_id]['posts_unapproved'] = 0;
$forum_data[$forum_id]['posts_softdeleted'] = 0;
$forum_data[$forum_id]['topics'] = 0;
$forum_data[$forum_id]['topics_approved'] = 0;
$forum_data[$forum_id]['topics_unapproved'] = 0;
$forum_data[$forum_id]['topics_softdeleted'] = 0;
}
@@ -1746,7 +1746,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
{
$forum_id = (sizeof($forum_ids) == 1) ? (int) $forum_ids[0] : (int) $row['forum_id'];
$forum_data[$forum_id]['posts'] = (int) $row['forum_posts'];
$forum_data[$forum_id]['posts_approved'] = (int) $row['forum_posts'];
$forum_data[$forum_id]['posts_unapproved'] = (int) $row['forum_posts_unapproved'];
$forum_data[$forum_id]['posts_softdeleted'] = (int) $row['forum_posts_softdeleted'];
}
@@ -1829,7 +1829,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
if ($sync_extra)
{
array_push($fieldnames, 'posts', 'posts_unapproved', 'posts_softdeleted', 'topics', 'topics_unapproved', 'topics_softdeleted');
array_push($fieldnames, 'posts_approved', 'posts_unapproved', 'posts_softdeleted', 'topics_approved', 'topics_unapproved', 'topics_softdeleted');
}
foreach ($forum_data as $forum_id => $row)
@@ -1884,7 +1884,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
$topic_id = (int) $row['topic_id'];
$topic_data[$topic_id] = $row;
$topic_data[$topic_id]['visibility'] = ITEM_UNAPPROVED;
$topic_data[$topic_id]['posts'] = 0;
$topic_data[$topic_id]['posts_approved'] = 0;
$topic_data[$topic_id]['posts_unapproved'] = 0;
$topic_data[$topic_id]['posts_softdeleted'] = 0;
$topic_data[$topic_id]['first_post_id'] = 0;
@@ -1930,7 +1930,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
if ($row['post_visibility'] == ITEM_APPROVED)
{
$topic_data[$topic_id]['posts'] = $row['total_posts'];
$topic_data[$topic_id]['posts_approved'] = $row['total_posts'];
}
else if ($row['post_visibility'] == ITEM_UNAPPROVED)
{
@@ -2141,7 +2141,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
}
// These are fields that will be synchronised
$fieldnames = array('time', 'visibility', 'posts', 'posts_unapproved', 'posts_softdeleted', 'poster', 'first_post_id', 'first_poster_name', 'first_poster_colour', 'last_post_id', 'last_post_subject', 'last_post_time', 'last_poster_id', 'last_poster_name', 'last_poster_colour');
$fieldnames = array('time', 'visibility', 'posts_approved', 'posts_unapproved', 'posts_softdeleted', 'poster', 'first_post_id', 'first_poster_name', 'first_poster_colour', 'last_post_id', 'last_post_subject', 'last_post_time', 'last_poster_id', 'last_poster_name', 'last_poster_colour');
if ($sync_extra)
{

View File

@@ -1418,7 +1418,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $
// Specify our post mode
$post_mode = 'delete';
if (($data['topic_first_post_id'] === $data['topic_last_post_id']) && ($data['topic_posts'] + $data['topic_posts_unapproved'] + $data['topic_posts_softdeleted'] == 1))
if (($data['topic_first_post_id'] === $data['topic_last_post_id']) && ($data['topic_posts_approved'] + $data['topic_posts_unapproved'] + $data['topic_posts_softdeleted'] == 1))
{
$post_mode = 'delete_topic';
}
@@ -1718,7 +1718,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
}
else if ($mode == 'edit')
{
$post_mode = ($data['topic_posts'] + $data['topic_posts_unapproved'] + $data['topic_posts_softdeleted'] == 1) ? 'edit_topic' : (($data['topic_first_post_id'] == $data['post_id']) ? 'edit_first_post' : (($data['topic_last_post_id'] == $data['post_id']) ? 'edit_last_post' : 'edit'));
$post_mode = ($data['topic_posts_approved'] + $data['topic_posts_unapproved'] + $data['topic_posts_softdeleted'] == 1) ? 'edit_topic' : (($data['topic_first_post_id'] == $data['post_id']) ? 'edit_first_post' : (($data['topic_last_post_id'] == $data['post_id']) ? 'edit_last_post' : 'edit'));
}
// First of all make sure the subject and topic title are having the correct length.
@@ -1879,8 +1879,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
'topic_last_view_time' => $current_time,
'forum_id' => $data['forum_id'],
'icon_id' => $data['icon_id'],
'topic_posts' => ($post_visibility == ITEM_APPROVED) ? 1 : 0,
'topic_posts_softdeleted' => ($post_visibility != ITEM_APPROVED) ? 1 : 0,
'topic_posts_approved' => ($post_visibility == ITEM_APPROVED) ? 1 : 0,
'topic_posts_softdeleted' => ($post_visibility == ITEM_DELETED) ? 1 : 0,
'topic_posts_unapproved' => ($post_visibility == ITEM_UNAPPROVED) ? 1 : 0,
'topic_visibility' => $post_visibility,
'topic_delete_user' => ($post_visibility != ITEM_APPROVED) ? (int) $user->data['user_id'] : 0,
'topic_title' => $subject,

View File

@@ -494,7 +494,7 @@ function mcp_move_topic($topic_ids)
$topics_moved_softdeleted++;
}
$posts_moved += $topic_info['topic_posts'];
$posts_moved += $topic_info['topic_posts_approved'];
$posts_moved_unapproved += $topic_info['topic_posts_unapproved'];
$posts_moved_softdeleted += $topic_info['topic_posts_softdeleted'];
}
@@ -534,7 +534,7 @@ function mcp_move_topic($topic_ids)
'topic_time' => (int) $row['topic_time'],
'topic_time_limit' => (int) $row['topic_time_limit'],
'topic_views' => (int) $row['topic_views'],
'topic_posts' => (int) $row['topic_posts'],
'topic_posts_approved' => (int) $row['topic_posts_approved'],
'topic_posts_unapproved'=> (int) $row['topic_posts_unapproved'],
'topic_posts_softdeleted'=> (int) $row['topic_posts_softdeleted'],
'topic_status' => ITEM_MOVED,
@@ -1180,7 +1180,7 @@ function mcp_fork_topic($topic_ids)
'topic_title' => (string) $topic_row['topic_title'],
'topic_poster' => (int) $topic_row['topic_poster'],
'topic_time' => (int) $topic_row['topic_time'],
'topic_posts' => (int) $topic_row['topic_posts'],
'topic_posts_approved' => (int) $topic_row['topic_posts_approved'],
'topic_posts_unapproved' => (int) $topic_row['topic_posts_unapproved'],
'topic_posts_softdeleted' => (int) $topic_row['topic_posts_softdeleted'],
'topic_status' => (int) $topic_row['topic_status'],

View File

@@ -932,7 +932,7 @@ class mcp_queue
// If the count of disapproved posts for the topic is equal
// to the number of unapproved posts in the topic, and there are no different
// posts, we disapprove the hole topic
if ($topic_information[$topic_id]['topic_posts'] == 0 &&
if ($topic_information[$topic_id]['topic_posts_approved'] == 0 &&
$topic_information[$topic_id]['topic_posts_softdeleted'] == 0 &&
$topic_information[$topic_id]['topic_posts_unapproved'] == $topic_posts_unapproved[$topic_id])
{