aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorOleg Pudeyev <oleg@bsdpower.com>2011-04-11 00:04:19 -0400
committerOleg Pudeyev <oleg@bsdpower.com>2011-04-11 00:04:19 -0400
commit716f514ee9717906e2d62c9c401b78cab80a2141 (patch)
tree9ad7f74cf0e2cd6bd81bed133995501d936e217e /phpBB
parent00a69b43723b89a90bc59763a1cdae9a7001a153 (diff)
parentad81637300bfbbb4f18d80cd87326fbc90dd38f8 (diff)
downloadforums-716f514ee9717906e2d62c9c401b78cab80a2141.tar
forums-716f514ee9717906e2d62c9c401b78cab80a2141.tar.gz
forums-716f514ee9717906e2d62c9c401b78cab80a2141.tar.bz2
forums-716f514ee9717906e2d62c9c401b78cab80a2141.tar.xz
forums-716f514ee9717906e2d62c9c401b78cab80a2141.zip
Merge branch 'ticket/nickvergessen/9684' into develop
* ticket/nickvergessen/9684: [ticket/9684] Also display forum-name in subsilver2 template [ticket/9684] Move currently existing GAs to a selectable forum while updating. [ticket/9684] View origin-forumname for GAs in topic-list [ticket/9684] Fix Forum/Topic-Tracking for global announcements [ticket/9684] Fix a SQL-Error in the posting.php [ticket/9684] Remove code in some more files especially includes/ [ticket/9684] Remove code for global announcement in root-files
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/download/file.php3
-rw-r--r--phpBB/feed.php116
-rw-r--r--phpBB/includes/acp/acp_search.php5
-rw-r--r--phpBB/includes/functions.php66
-rw-r--r--phpBB/includes/functions_admin.php25
-rw-r--r--phpBB/includes/functions_display.php20
-rw-r--r--phpBB/includes/functions_posting.php200
-rw-r--r--phpBB/includes/mcp/mcp_forum.php12
-rw-r--r--phpBB/includes/mcp/mcp_front.php39
-rw-r--r--phpBB/includes/mcp/mcp_main.php193
-rw-r--r--phpBB/includes/mcp/mcp_queue.php61
-rw-r--r--phpBB/includes/mcp/mcp_reports.php11
-rw-r--r--phpBB/includes/ucp/ucp_main.php65
-rw-r--r--phpBB/install/database_update.php140
-rw-r--r--phpBB/language/en/install.php1
-rw-r--r--phpBB/mcp.php14
-rw-r--r--phpBB/memberlist.php2
-rw-r--r--phpBB/posting.php64
-rw-r--r--phpBB/report.php2
-rw-r--r--phpBB/search.php35
-rw-r--r--phpBB/styles/prosilver/template/search_results.html11
-rw-r--r--phpBB/styles/prosilver/template/viewforum_body.html1
-rw-r--r--phpBB/styles/subsilver2/template/search_results.html8
-rw-r--r--phpBB/styles/subsilver2/template/viewforum_body.html1
-rw-r--r--phpBB/viewforum.php120
-rw-r--r--phpBB/viewtopic.php72
26 files changed, 387 insertions, 900 deletions
diff --git a/phpBB/download/file.php b/phpBB/download/file.php
index 5016e7f549..d33a50c149 100644
--- a/phpBB/download/file.php
+++ b/phpBB/download/file.php
@@ -194,8 +194,7 @@ else
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
- // Global announcement?
- $f_download = (!$row) ? $auth->acl_getf_global('f_download') : $auth->acl_get('f_download', $row['forum_id']);
+ $f_download = $auth->acl_get('f_download', $row['forum_id']);
if ($auth->acl_get('u_download') && $f_download)
{
diff --git a/phpBB/feed.php b/phpBB/feed.php
index 7af422629d..1a09e4da23 100644
--- a/phpBB/feed.php
+++ b/phpBB/feed.php
@@ -775,9 +775,6 @@ class phpbb_feed_overall extends phpbb_feed_post_base
return false;
}
- // Add global forum id
- $forum_ids[] = 0;
-
// m_approve forums
$fid_m_approve = $this->get_moderator_approve_forums();
$sql_m_approve = (!empty($fid_m_approve)) ? 'OR ' . $db->sql_in_set('forum_id', $fid_m_approve) : '';
@@ -915,12 +912,11 @@ class phpbb_feed_forum extends phpbb_feed_post_base
global $auth, $db;
$m_approve = ($auth->acl_get('m_approve', $this->forum_id)) ? true : false;
- $forum_ids = array(0, $this->forum_id);
// Determine topics with recent activity
$sql = 'SELECT topic_id, topic_last_post_time
FROM ' . TOPICS_TABLE . '
- WHERE ' . $db->sql_in_set('forum_id', $forum_ids) . '
+ WHERE forum_id = ' . $this->forum_id . '
AND topic_moved_id = 0
' . ((!$m_approve) ? 'AND topic_approved = 1' : '') . '
ORDER BY topic_last_post_time DESC';
@@ -1009,96 +1005,37 @@ class phpbb_feed_topic extends phpbb_feed_post_base
trigger_error('NO_TOPIC');
}
- if ($this->topic_data['topic_type'] == POST_GLOBAL)
- {
- // We need to find at least one postable forum where feeds are enabled,
- // that the user can read and maybe also has approve permissions.
- $in_fid_ary = $this->get_readable_forums();
-
- if (empty($in_fid_ary))
- {
- // User cannot read any forums
- trigger_error('SORRY_AUTH_READ');
- }
-
- if (!$this->topic_data['topic_approved'])
- {
- // Also require m_approve
- $in_fid_ary = array_intersect($in_fid_ary, $this->get_moderator_approve_forums());
-
- if (empty($in_fid_ary))
- {
- trigger_error('SORRY_AUTH_READ');
- }
- }
-
- // Diff excluded forums
- $in_fid_ary = array_diff($in_fid_ary, $this->get_excluded_forums());
-
- if (empty($in_fid_ary))
- {
- trigger_error('SORRY_AUTH_READ');
- }
-
- // Also exclude passworded forums
- $in_fid_ary = array_diff($in_fid_ary, $this->get_passworded_forums());
-
- if (empty($in_fid_ary))
- {
- trigger_error('SORRY_AUTH_READ');
- }
-
- $sql = 'SELECT forum_id, left_id
- FROM ' . FORUMS_TABLE . '
- WHERE forum_type = ' . FORUM_POST . '
- AND ' . $db->sql_in_set('forum_id', $in_fid_ary) . '
- ORDER BY left_id ASC';
- $result = $db->sql_query_limit($sql, 1);
- $this->forum_data = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
-
- if (empty($this->forum_data))
- {
- // No forum found.
- trigger_error('SORRY_AUTH_READ');
- }
+ $this->forum_id = (int) $this->topic_data['forum_id'];
- unset($in_fid_ary);
+ // Make sure topic is either approved or user authed
+ if (!$this->topic_data['topic_approved'] && !$auth->acl_get('m_approve', $this->forum_id))
+ {
+ trigger_error('SORRY_AUTH_READ');
}
- else
+
+ // Make sure forum is not excluded from feed
+ if (phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $this->topic_data['forum_options']))
{
- $this->forum_id = (int) $this->topic_data['forum_id'];
+ trigger_error('NO_FEED');
+ }
- // Make sure topic is either approved or user authed
- if (!$this->topic_data['topic_approved'] && !$auth->acl_get('m_approve', $this->forum_id))
- {
- trigger_error('SORRY_AUTH_READ');
- }
+ // Make sure we can read this forum
+ if (!$auth->acl_get('f_read', $this->forum_id))
+ {
+ trigger_error('SORRY_AUTH_READ');
+ }
- // Make sure forum is not excluded from feed
- if (phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $this->topic_data['forum_options']))
- {
- trigger_error('NO_FEED');
- }
+ // Make sure forum is not passworded or user is authed
+ if ($this->topic_data['forum_password'])
+ {
+ $forum_ids_passworded = $this->get_passworded_forums();
- // Make sure we can read this forum
- if (!$auth->acl_get('f_read', $this->forum_id))
+ if (isset($forum_ids_passworded[$this->forum_id]))
{
trigger_error('SORRY_AUTH_READ');
}
- // Make sure forum is not passworded or user is authed
- if ($this->topic_data['forum_password'])
- {
- $forum_ids_passworded = $this->get_passworded_forums();
-
- if (isset($forum_ids_passworded[$this->forum_id]))
- {
- trigger_error('SORRY_AUTH_READ');
- }
-
- unset($forum_ids_passworded);
- }
+ unset($forum_ids_passworded);
}
}
@@ -1245,9 +1182,6 @@ class phpbb_feed_news extends phpbb_feed_topic_base
return false;
}
- // Add global forum
- $in_fid_ary[] = 0;
-
// We really have to get the post ids first!
$sql = 'SELECT topic_first_post_id, topic_time
FROM ' . TOPICS_TABLE . '
@@ -1318,9 +1252,6 @@ class phpbb_feed_topics extends phpbb_feed_topic_base
return false;
}
- // Add global forum
- $in_fid_ary[] = 0;
-
// We really have to get the post ids first!
$sql = 'SELECT topic_first_post_id, topic_time
FROM ' . TOPICS_TABLE . '
@@ -1410,9 +1341,6 @@ class phpbb_feed_topics_active extends phpbb_feed_topic_base
return false;
}
- // Add global forum
- $in_fid_ary[] = 0;
-
// Search for topics in last X days
$last_post_time_sql = ($this->sort_days) ? ' AND topic_last_post_time > ' . (time() - ($this->sort_days * 24 * 3600)) : '';
diff --git a/phpBB/includes/acp/acp_search.php b/phpBB/includes/acp/acp_search.php
index 21f7e3d31b..a3061ae2da 100644
--- a/phpBB/includes/acp/acp_search.php
+++ b/phpBB/includes/acp/acp_search.php
@@ -397,9 +397,8 @@ class acp_search
$i = 0;
while ($row = ($buffer ? $rows[$i++] : $db->sql_fetchrow($result)))
{
- // Indexing enabled for this forum or global announcement?
- // Global announcements get indexed by default.
- if (!$row['forum_id'] || (isset($forums[$row['forum_id']]) && $forums[$row['forum_id']]))
+ // Indexing enabled for this forum
+ if (isset($forums[$row['forum_id']]) && $forums[$row['forum_id']])
{
$this->search->index('post', $row['post_id'], $row['post_text'], $row['post_subject'], $row['poster_id'], $row['forum_id']);
}
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index f910611b76..0638cfccb6 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -1323,35 +1323,6 @@ function get_topic_tracking($forum_id, $topic_ids, &$rowset, $forum_mark_time, $
{
$mark_time = array();
- // Get global announcement info
- if ($global_announce_list && sizeof($global_announce_list))
- {
- if (!isset($forum_mark_time[0]))
- {
- global $db;
-
- $sql = 'SELECT mark_time
- FROM ' . FORUMS_TRACK_TABLE . "
- WHERE user_id = {$user->data['user_id']}
- AND forum_id = 0";
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
-
- if ($row)
- {
- $mark_time[0] = $row['mark_time'];
- }
- }
- else
- {
- if ($forum_mark_time[0] !== false)
- {
- $mark_time[0] = $forum_mark_time[0];
- }
- }
- }
-
if (!empty($forum_mark_time[$forum_id]) && $forum_mark_time[$forum_id] !== false)
{
$mark_time[$forum_id] = $forum_mark_time[$forum_id];
@@ -1361,14 +1332,7 @@ function get_topic_tracking($forum_id, $topic_ids, &$rowset, $forum_mark_time, $
foreach ($topic_ids as $topic_id)
{
- if ($global_announce_list && isset($global_announce_list[$topic_id]))
- {
- $last_read[$topic_id] = (isset($mark_time[0])) ? $mark_time[0] : $user_lastmark;
- }
- else
- {
- $last_read[$topic_id] = $user_lastmark;
- }
+ $last_read[$topic_id] = $user_lastmark;
}
}
@@ -1412,8 +1376,7 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis
$sql = 'SELECT forum_id, mark_time
FROM ' . FORUMS_TRACK_TABLE . "
WHERE user_id = {$user->data['user_id']}
- AND forum_id " .
- (($global_announce_list && sizeof($global_announce_list)) ? "IN (0, $forum_id)" : "= $forum_id");
+ AND forum_id = $forum_id";
$result = $db->sql_query($sql);
$mark_time = array();
@@ -1427,14 +1390,7 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis
foreach ($topic_ids as $topic_id)
{
- if ($global_announce_list && isset($global_announce_list[$topic_id]))
- {
- $last_read[$topic_id] = (isset($mark_time[0])) ? $mark_time[0] : $user_lastmark;
- }
- else
- {
- $last_read[$topic_id] = $user_lastmark;
- }
+ $last_read[$topic_id] = $user_lastmark;
}
}
}
@@ -1472,13 +1428,6 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis
if (sizeof($topic_ids))
{
$mark_time = array();
- if ($global_announce_list && sizeof($global_announce_list))
- {
- if (isset($tracking_topics['f'][0]))
- {
- $mark_time[0] = base_convert($tracking_topics['f'][0], 36, 10) + $config['board_startdate'];
- }
- }
if (isset($tracking_topics['f'][$forum_id]))
{
@@ -1489,14 +1438,7 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis
foreach ($topic_ids as $topic_id)
{
- if ($global_announce_list && isset($global_announce_list[$topic_id]))
- {
- $last_read[$topic_id] = (isset($mark_time[0])) ? $mark_time[0] : $user_lastmark;
- }
- else
- {
- $last_read[$topic_id] = $user_lastmark;
- }
+ $last_read[$topic_id] = $user_lastmark;
}
}
}
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php
index 1468345003..ee59d77cdb 100644
--- a/phpBB/includes/functions_admin.php
+++ b/phpBB/includes/functions_admin.php
@@ -2208,6 +2208,7 @@ function prune($forum_id, $prune_mode, $prune_date, $prune_flags = 0, $auto_sync
if (!($prune_flags & FORUM_FLAG_PRUNE_ANNOUNCE))
{
$sql_and .= ' AND topic_type <> ' . POST_ANNOUNCE;
+ $sql_and .= ' AND topic_type <> ' . POST_GLOBAL;
}
if (!($prune_flags & FORUM_FLAG_PRUNE_STICKY))
@@ -2695,29 +2696,9 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id
while ($row = $db->sql_fetchrow($result))
{
- if (!$row['forum_id'])
+ if ($auth->acl_get('f_read', $row['forum_id']))
{
- if ($auth->acl_getf_global('f_read'))
- {
- if (!$default_forum_id)
- {
- $sql = 'SELECT forum_id
- FROM ' . FORUMS_TABLE . '
- WHERE forum_type = ' . FORUM_POST;
- $f_result = $db->sql_query_limit($sql, 1);
- $default_forum_id = (int) $db->sql_fetchfield('forum_id', false, $f_result);
- $db->sql_freeresult($f_result);
- }
-
- $is_auth[$row['topic_id']] = $default_forum_id;
- }
- }
- else
- {
- if ($auth->acl_get('f_read', $row['forum_id']))
- {
- $is_auth[$row['topic_id']] = $row['forum_id'];
- }
+ $is_auth[$row['topic_id']] = $row['forum_id'];
}
if ($auth->acl_gets('a_', 'm_', $row['forum_id']))
diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php
index 6314ba0ec9..abc5b3e29f 100644
--- a/phpBB/includes/functions_display.php
+++ b/phpBB/includes/functions_display.php
@@ -104,18 +104,6 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
$forum_tracking_info = array();
$branch_root_id = $root_data['forum_id'];
- // Check for unread global announcements (index page only)
- $ga_unread = false;
- if ($root_data['forum_id'] == 0)
- {
- $unread_ga_list = get_unread_topics($user->data['user_id'], 'AND t.forum_id = 0', '', 1);
-
- if (!empty($unread_ga_list))
- {
- $ga_unread = true;
- }
- }
-
while ($row = $db->sql_fetchrow($result))
{
$forum_id = $row['forum_id'];
@@ -269,8 +257,6 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
}
else
{
- // Add 0 to forums array to mark global announcements correctly
- $forum_ids[] = 0;
markread('topics', $forum_ids);
$message = sprintf($user->lang['RETURN_FORUM'], '<a href="' . $redirect . '">', '</a>');
}
@@ -323,12 +309,6 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
$forum_unread = (isset($forum_tracking_info[$forum_id]) && $row['orig_forum_last_post_time'] > $forum_tracking_info[$forum_id]) ? true : false;
- // Mark the first visible forum on index as unread if there's any unread global announcement
- if ($ga_unread && !empty($forum_ids_moderator) && $forum_id == $forum_ids_moderator[0])
- {
- $forum_unread = true;
- }
-
$folder_image = $folder_alt = $l_subforums = '';
$subforums_list = array();
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php
index 61cc096e26..3f6dbfa41f 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -338,7 +338,7 @@ function posting_gen_topic_types($forum_id, $cur_topic_type = POST_NORMAL)
$topic_type_array[] = array(
'VALUE' => $topic_value['const'],
- 'S_CHECKED' => ($cur_topic_type == $topic_value['const'] || ($forum_id == 0 && $topic_value['const'] == POST_GLOBAL)) ? ' checked="checked"' : '',
+ 'S_CHECKED' => ($cur_topic_type == $topic_value['const']) ? ' checked="checked"' : '',
'L_TOPIC_TYPE' => $user->lang[$topic_value['lang']]
);
}
@@ -1465,11 +1465,8 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
delete_topics('topic_id', array($topic_id), false);
- if ($data['topic_type'] != POST_GLOBAL)
- {
- $sql_data[FORUMS_TABLE] .= 'forum_topics_real = forum_topics_real - 1';
- $sql_data[FORUMS_TABLE] .= ($data['topic_approved']) ? ', forum_posts = forum_posts - 1, forum_topics = forum_topics - 1' : '';
- }
+ $sql_data[FORUMS_TABLE] .= 'forum_topics_real = forum_topics_real - 1';
+ $sql_data[FORUMS_TABLE] .= ($data['topic_approved']) ? ', forum_posts = forum_posts - 1, forum_topics = forum_topics - 1' : '';
$update_sql = update_post_information('forum', $forum_id, true);
if (sizeof($update_sql))
@@ -1489,10 +1486,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
- if ($data['topic_type'] != POST_GLOBAL)
- {
- $sql_data[FORUMS_TABLE] = ($data['post_approved']) ? 'forum_posts = forum_posts - 1' : '';
- }
+ $sql_data[FORUMS_TABLE] = ($data['post_approved']) ? 'forum_posts = forum_posts - 1' : '';
$sql_data[TOPICS_TABLE] = 'topic_poster = ' . intval($row['poster_id']) . ', topic_first_post_id = ' . intval($row['post_id']) . ", topic_first_poster_colour = '" . $db->sql_escape($row['user_colour']) . "', topic_first_poster_name = '" . (($row['poster_id'] == ANONYMOUS) ? $db->sql_escape($row['post_username']) : $db->sql_escape($row['username'])) . "', topic_time = " . (int) $row['post_time'];
@@ -1503,10 +1497,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
break;
case 'delete_last_post':
- if ($data['topic_type'] != POST_GLOBAL)
- {
- $sql_data[FORUMS_TABLE] = ($data['post_approved']) ? 'forum_posts = forum_posts - 1' : '';
- }
+ $sql_data[FORUMS_TABLE] = ($data['post_approved']) ? 'forum_posts = forum_posts - 1' : '';
$update_sql = update_post_information('forum', $forum_id, true);
if (sizeof($update_sql))
@@ -1548,10 +1539,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
- if ($data['topic_type'] != POST_GLOBAL)
- {
- $sql_data[FORUMS_TABLE] = ($data['post_approved']) ? 'forum_posts = forum_posts - 1' : '';
- }
+ $sql_data[FORUMS_TABLE] = ($data['post_approved']) ? 'forum_posts = forum_posts - 1' : '';
$sql_data[TOPICS_TABLE] = 'topic_replies_real = topic_replies_real - 1' . (($data['post_approved']) ? ', topic_replies = topic_replies - 1' : '');
$next_post_id = (int) $row['post_id'];
@@ -1703,7 +1691,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
case 'post':
case 'reply':
$sql_data[POSTS_TABLE]['sql'] = array(
- 'forum_id' => ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id'],
+ 'forum_id' => $data['forum_id'],
'poster_id' => (int) $user->data['user_id'],
'icon_id' => $data['icon_id'],
'poster_ip' => $user->ip,
@@ -1771,7 +1759,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
}
$sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array(
- 'forum_id' => ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id'],
+ 'forum_id' => $data['forum_id'],
'poster_id' => $data['poster_id'],
'icon_id' => $data['icon_id'],
'post_approved' => (!$post_approval) ? 0 : $data['post_approved'],
@@ -1807,7 +1795,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
'topic_poster' => (int) $user->data['user_id'],
'topic_time' => $current_time,
'topic_last_view_time' => $current_time,
- 'forum_id' => ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id'],
+ 'forum_id' => $data['forum_id'],
'icon_id' => $data['icon_id'],
'topic_approved' => $post_approval,
'topic_title' => $subject,
@@ -1843,14 +1831,11 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
$sql_data[USERS_TABLE]['stat'][] = "user_lastpost_time = $current_time" . (($auth->acl_get('f_postcount', $data['forum_id']) && $post_approval) ? ', user_posts = user_posts + 1' : '');
- if ($topic_type != POST_GLOBAL)
+ if ($post_approval)
{
- if ($post_approval)
- {
- $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts + 1';
- }
- $sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_real = forum_topics_real + 1' . (($post_approval) ? ', forum_topics = forum_topics + 1' : '');
+ $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts + 1';
}
+ $sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_real = forum_topics_real + 1' . (($post_approval) ? ', forum_topics = forum_topics + 1' : '');
break;
case 'reply':
@@ -1863,7 +1848,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
$sql_data[USERS_TABLE]['stat'][] = "user_lastpost_time = $current_time" . (($auth->acl_get('f_postcount', $data['forum_id']) && $post_approval) ? ', user_posts = user_posts + 1' : '');
- if ($post_approval && $topic_type != POST_GLOBAL)
+ if ($post_approval)
{
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts + 1';
}
@@ -1887,7 +1872,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
}
$sql_data[TOPICS_TABLE]['sql'] = array(
- 'forum_id' => ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id'],
+ 'forum_id' => $data['forum_id'],
'icon_id' => $data['icon_id'],
'topic_approved' => (!$post_approval) ? 0 : $data['topic_approved'],
'topic_title' => $subject,
@@ -2002,61 +1987,6 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
unset($sql_data[POSTS_TABLE]['sql']);
}
- $make_global = false;
-
- // Are we globalising or unglobalising?
- if ($post_mode == 'edit_first_post' || $post_mode == 'edit_topic')
- {
- if (!sizeof($topic_row))
- {
- $sql = 'SELECT topic_type, topic_replies, topic_replies_real, topic_approved, topic_last_post_id
- FROM ' . TOPICS_TABLE . '
- WHERE topic_id = ' . $data['topic_id'];
- $result = $db->sql_query($sql);
- $topic_row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
- }
-
- // globalise/unglobalise?
- if (($topic_row['topic_type'] != POST_GLOBAL && $topic_type == POST_GLOBAL) || ($topic_row['topic_type'] == POST_GLOBAL && $topic_type != POST_GLOBAL))
- {
- if (!empty($sql_data[FORUMS_TABLE]['stat']) && implode('', $sql_data[FORUMS_TABLE]['stat']))
- {
- $db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET ' . implode(', ', $sql_data[FORUMS_TABLE]['stat']) . ' WHERE forum_id = ' . $data['forum_id']);
- }
-
- $make_global = true;
- $sql_data[FORUMS_TABLE]['stat'] = array();
- }
-
- // globalise
- if ($topic_row['topic_type'] != POST_GLOBAL && $topic_type == POST_GLOBAL)
- {
- // Decrement topic/post count
- $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts - ' . ($topic_row['topic_replies_real'] + 1);
- $sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_real = forum_topics_real - 1' . (($topic_row['topic_approved']) ? ', forum_topics = forum_topics - 1' : '');
-
- // Update forum_ids for all posts
- $sql = 'UPDATE ' . POSTS_TABLE . '
- SET forum_id = 0
- WHERE topic_id = ' . $data['topic_id'];
- $db->sql_query($sql);
- }
- // unglobalise
- else if ($topic_row['topic_type'] == POST_GLOBAL && $topic_type != POST_GLOBAL)
- {
- // Increment topic/post count
- $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts + ' . ($topic_row['topic_replies_real'] + 1);
- $sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_real = forum_topics_real + 1' . (($topic_row['topic_approved']) ? ', forum_topics = forum_topics + 1' : '');
-
- // Update forum_ids for all posts
- $sql = 'UPDATE ' . POSTS_TABLE . '
- SET forum_id = ' . $data['forum_id'] . '
- WHERE topic_id = ' . $data['topic_id'];
- $db->sql_query($sql);
- }
- }
-
// Update the topics table
if (isset($sql_data[TOPICS_TABLE]['sql']))
{
@@ -2219,9 +2149,8 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
}
// we need to update the last forum information
- // only applicable if the topic is not global and it is approved
- // we also check to make sure we are not dealing with globaling the latest topic (pretty rare but still needs to be checked)
- if ($topic_type != POST_GLOBAL && !$make_global && ($post_approved || !$data['post_approved']))
+ // only applicable if the topic is approved
+ if ($post_approved || !$data['post_approved'])
{
// the last post makes us update the forum table. This can happen if...
// We make a new topic
@@ -2311,78 +2240,6 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
}
}
}
- else if ($make_global)
- {
- // somebody decided to be a party pooper, we must recalculate the whole shebang (maybe)
- $sql = 'SELECT forum_last_post_id
- FROM ' . FORUMS_TABLE . '
- WHERE forum_id = ' . (int) $data['forum_id'];
- $result = $db->sql_query($sql);
- $forum_row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
-
- // we made a topic global, go get new data
- if ($topic_row['topic_type'] != POST_GLOBAL && $topic_type == POST_GLOBAL && $forum_row['forum_last_post_id'] == $topic_row['topic_last_post_id'])
- {
- // we need a fresh change of socks, everything has become invalidated
- $sql = 'SELECT MAX(topic_last_post_id) as last_post_id
- FROM ' . TOPICS_TABLE . '
- WHERE forum_id = ' . (int) $data['forum_id'] . '
- AND topic_approved = 1';
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
-
- // any posts left in this forum?
- if (!empty($row['last_post_id']))
- {
- $sql = 'SELECT p.post_id, p.post_subject, p.post_time, p.poster_id, p.post_username, u.user_id, u.username, u.user_colour
- FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
- WHERE p.poster_id = u.user_id
- AND p.post_id = ' . (int) $row['last_post_id'];
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
-
- // salvation, a post is found! jam it into the forums table
- $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_id = ' . (int) $row['post_id'];
- $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_post_subject = '" . $db->sql_escape($row['post_subject']) . "'";
- $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_time = ' . (int) $row['post_time'];
- $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_id = ' . (int) $row['poster_id'];
- $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = '" . $db->sql_escape(($row['poster_id'] == ANONYMOUS) ? $row['post_username'] : $row['username']) . "'";
- $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = '" . $db->sql_escape($row['user_colour']) . "'";
- }
- else
- {
- // just our luck, the last topic in the forum has just been globalized...
- $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_id = 0';
- $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_post_subject = ''";
- $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_time = 0';
- $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_id = 0';
- $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = ''";
- $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = ''";
- }
- }
- else if ($topic_row['topic_type'] == POST_GLOBAL && $topic_type != POST_GLOBAL && $forum_row['forum_last_post_id'] < $topic_row['topic_last_post_id'])
- {
- // this post has a higher id, it is newer
- $sql = 'SELECT p.post_id, p.post_subject, p.post_time, p.poster_id, p.post_username, u.user_id, u.username, u.user_colour
- FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
- WHERE p.poster_id = u.user_id
- AND p.post_id = ' . (int) $topic_row['topic_last_post_id'];
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
-
- // salvation, a post is found! jam it into the forums table
- $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_id = ' . (int) $row['post_id'];
- $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_post_subject = '" . $db->sql_escape($row['post_subject']) . "'";
- $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_time = ' . (int) $row['post_time'];
- $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_id = ' . (int) $row['poster_id'];
- $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = '" . $db->sql_escape(($row['poster_id'] == ANONYMOUS) ? $row['post_username'] : $row['username']) . "'";
- $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = '" . $db->sql_escape($row['user_colour']) . "'";
- }
- }
// topic sync time!
// simply, we update if it is a reply or the last post is edited
@@ -2470,7 +2327,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
}
// Delete topic shadows (if any exist). We do not need a shadow topic for an global announcement
- if ($make_global)
+ if ($topic_type == POST_GLOBAL)
{
$sql = 'DELETE FROM ' . TOPICS_TABLE . '
WHERE topic_moved_id = ' . $data['topic_id'];
@@ -2514,7 +2371,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
trigger_error($error);
}
- $search->index($mode, $data['post_id'], $data['message'], $subject, $poster_id, ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id']);
+ $search->index($mode, $data['post_id'], $data['message'], $subject, $poster_id, $data['forum_id']);
}
// Topic Notification, do not change if moderator is changing other users posts...
@@ -2543,7 +2400,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
// Mark this topic as read
// We do not use post_time here, this is intended (post_time can have a date in the past if editing a message)
- markread('topic', (($topic_type == POST_GLOBAL) ? 0 : $data['forum_id']), $data['topic_id'], time());
+ markread('topic', $data['forum_id'], $data['topic_id'], time());
//
if ($config['load_db_lastread'] && $user->data['is_registered'])
@@ -2551,7 +2408,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
$sql = 'SELECT mark_time
FROM ' . FORUMS_TRACK_TABLE . '
WHERE user_id = ' . $user->data['user_id'] . '
- AND forum_id = ' . (($topic_type == POST_GLOBAL) ? 0 : $data['forum_id']);
+ AND forum_id = ' . $data['forum_id'];
$result = $db->sql_query($sql);
$f_mark_time = (int) $db->sql_fetchfield('mark_time');
$db->sql_freeresult($result);
@@ -2564,23 +2421,14 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
if (($config['load_db_lastread'] && $user->data['is_registered']) || $config['load_anon_lastread'] || $user->data['is_registered'])
{
// Update forum info
- if ($topic_type == POST_GLOBAL)
- {
- $sql = 'SELECT MAX(topic_last_post_time) as forum_last_post_time
- FROM ' . TOPICS_TABLE . '
- WHERE forum_id = 0';
- }
- else
- {
- $sql = 'SELECT forum_last_post_time
- FROM ' . FORUMS_TABLE . '
- WHERE forum_id = ' . $data['forum_id'];
- }
+ $sql = 'SELECT forum_last_post_time
+ FROM ' . FORUMS_TABLE . '
+ WHERE forum_id = ' . $data['forum_id'];
$result = $db->sql_query($sql);
$forum_last_post_time = (int) $db->sql_fetchfield('forum_last_post_time');
$db->sql_freeresult($result);
- update_forum_tracking_info((($topic_type == POST_GLOBAL) ? 0 : $data['forum_id']), $forum_last_post_time, $f_mark_time, false);
+ update_forum_tracking_info($data['forum_id'], $forum_last_post_time, $f_mark_time, false);
}
// Send Notifications
diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php
index aad030a7d3..f170dd68eb 100644
--- a/phpBB/includes/mcp/mcp_forum.php
+++ b/phpBB/includes/mcp/mcp_forum.php
@@ -150,10 +150,10 @@ function mcp_forum_view($id, $mode, $action, $forum_info)
$read_tracking_join = $read_tracking_select = '';
}
- $sql = "SELECT t.topic_id
- FROM " . TOPICS_TABLE . " t
- WHERE t.forum_id IN($forum_id, 0)
- " . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1') . "
+ $sql = 'SELECT t.topic_id
+ FROM ' . TOPICS_TABLE . ' t
+ WHERE t.forum_id = ' . $forum_id . '
+ ' . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1') . "
$limit_time_sql
ORDER BY t.topic_type DESC, $sort_order_sql";
$result = $db->sql_query_limit($sql, $topics_per_page, $start);
@@ -188,11 +188,11 @@ function mcp_forum_view($id, $mode, $action, $forum_info)
{
if ($config['load_db_lastread'])
{
- $topic_tracking_info = get_topic_tracking($forum_id, $topic_list, $topic_rows, array($forum_id => $forum_info['mark_time']), array());
+ $topic_tracking_info = get_topic_tracking($forum_id, $topic_list, $topic_rows, array($forum_id => $forum_info['mark_time']));
}
else
{
- $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list, array());
+ $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list);
}
}
diff --git a/phpBB/includes/mcp/mcp_front.php b/phpBB/includes/mcp/mcp_front.php
index 7375e20d96..eca67c5ac1 100644
--- a/phpBB/includes/mcp/mcp_front.php
+++ b/phpBB/includes/mcp/mcp_front.php
@@ -39,7 +39,7 @@ function mcp_front_view($id, $mode, $action)
{
$sql = 'SELECT COUNT(post_id) AS total
FROM ' . POSTS_TABLE . '
- WHERE forum_id IN (0, ' . implode(', ', $forum_list) . ')
+ WHERE ' . $db->sql_in_set('forum_id', $forum_list) . '
AND post_approved = 0';
$result = $db->sql_query($sql);
$total = (int) $db->sql_fetchfield('total');
@@ -47,8 +47,6 @@ function mcp_front_view($id, $mode, $action)
if ($total)
{
- $global_id = $forum_list[0];
-
$sql = 'SELECT forum_id, forum_name
FROM ' . FORUMS_TABLE . '
WHERE ' . $db->sql_in_set('forum_id', $forum_list);
@@ -62,7 +60,7 @@ function mcp_front_view($id, $mode, $action)
$sql = 'SELECT post_id
FROM ' . POSTS_TABLE . '
- WHERE forum_id IN (0, ' . implode(', ', $forum_list) . ')
+ WHERE ' . $db->sql_in_set('forum_id', $forum_list) . '
AND post_approved = 0
ORDER BY post_time DESC';
$result = $db->sql_query_limit($sql, 5);
@@ -91,17 +89,11 @@ function mcp_front_view($id, $mode, $action)
while ($row = $db->sql_fetchrow($result))
{
- $global_topic = ($row['forum_id']) ? false : true;
- if ($global_topic)
- {
- $row['forum_id'] = $global_id;
- }
-
$template->assign_block_vars('unapproved', array(
'U_POST_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&amp;mode=approve_details&amp;f=' . $row['forum_id'] . '&amp;p=' . $row['post_id']),
- 'U_MCP_FORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&amp;mode=forum_view&amp;f=' . $row['forum_id']) : '',
+ 'U_MCP_FORUM' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&amp;mode=forum_view&amp;f=' . $row['forum_id']),
'U_MCP_TOPIC' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&amp;mode=topic_view&amp;f=' . $row['forum_id'] . '&amp;t=' . $row['topic_id']),
- 'U_FORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) : '',
+ 'U_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']),
'U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&amp;t=' . $row['topic_id']),
'AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour']),
@@ -109,7 +101,7 @@ function mcp_front_view($id, $mode, $action)
'AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour']),
'U_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour']),
- 'FORUM_NAME' => (!$global_topic) ? $forum_names[$row['forum_id']] : $user->lang['GLOBAL_ANNOUNCEMENT'],
+ 'FORUM_NAME' => $forum_names[$row['forum_id']],
'POST_ID' => $row['post_id'],
'TOPIC_TITLE' => $row['topic_title'],
'SUBJECT' => ($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT'],
@@ -159,15 +151,13 @@ function mcp_front_view($id, $mode, $action)
WHERE r.post_id = p.post_id
AND r.pm_id = 0
AND r.report_closed = 0
- AND p.forum_id IN (0, ' . implode(', ', $forum_list) . ')';
+ AND ' . $db->sql_in_set('p.forum_id', $forum_list);
$result = $db->sql_query($sql);
$total = (int) $db->sql_fetchfield('total');
$db->sql_freeresult($result);
if ($total)
{
- $global_id = $forum_list[0];
-
$sql = $db->sql_build_query('SELECT', array(
'SELECT' => 'r.report_time, p.post_id, p.post_subject, p.post_time, u.username, u.username_clean, u.user_colour, u.user_id, u2.username as author_name, u2.username_clean as author_name_clean, u2.user_colour as author_colour, u2.user_id as author_id, t.topic_id, t.topic_title, f.forum_id, f.forum_name',
@@ -193,7 +183,7 @@ function mcp_front_view($id, $mode, $action)
AND p.topic_id = t.topic_id
AND r.user_id = u.user_id
AND p.poster_id = u2.user_id
- AND p.forum_id IN (0, ' . implode(', ', $forum_list) . ')',
+ AND ' . $db->sql_in_set('p.forum_id', $forum_list),
'ORDER_BY' => 'p.post_time DESC'
));
@@ -201,17 +191,11 @@ function mcp_front_view($id, $mode, $action)
while ($row = $db->sql_fetchrow($result))
{
- $global_topic = ($row['forum_id']) ? false : true;
- if ($global_topic)
- {
- $row['forum_id'] = $global_id;
- }
-
$template->assign_block_vars('report', array(
'U_POST_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . '&amp;p=' . $row['post_id'] . "&amp;i=reports&amp;mode=report_details"),
- 'U_MCP_FORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . "&amp;i=$id&amp;mode=forum_view") : '',
+ 'U_MCP_FORUM' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . "&amp;i=$id&amp;mode=forum_view"),
'U_MCP_TOPIC' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . '&amp;t=' . $row['topic_id'] . "&amp;i=$id&amp;mode=topic_view"),
- 'U_FORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) : '',
+ 'U_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']),
'U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&amp;t=' . $row['topic_id']),
'REPORTER_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
@@ -224,7 +208,7 @@ function mcp_front_view($id, $mode, $action)
'AUTHOR_COLOUR' => get_username_string('colour', $row['author_id'], $row['author_name'], $row['author_colour']),
'U_AUTHOR' => get_username_string('profile', $row['author_id'], $row['author_name'], $row['author_colour']),
- 'FORUM_NAME' => (!$global_topic) ? $row['forum_name'] : $user->lang['GLOBAL_ANNOUNCEMENT'],
+ 'FORUM_NAME' => $row['forum_name'],
'TOPIC_TITLE' => $row['topic_title'],
'SUBJECT' => ($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT'],
'REPORT_TIME' => $user->format_date($row['report_time']),
@@ -347,9 +331,6 @@ function mcp_front_view($id, $mode, $action)
if (!empty($forum_list))
{
- // Add forum_id 0 for global announcements
- $forum_list[] = 0;
-
$log_count = false;
$log = array();
view_log('mod', $log, $log_count, 5, 0, $forum_list);
diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php
index db7bc7c7ea..212c8dcdaf 100644
--- a/phpBB/includes/mcp/mcp_main.php
+++ b/phpBB/includes/mcp/mcp_main.php
@@ -333,131 +333,22 @@ function change_topic_type($action, $topic_ids)
if (confirm_box(true))
{
- if ($new_topic_type != POST_GLOBAL)
+ $sql = 'UPDATE ' . TOPICS_TABLE . "
+ SET topic_type = $new_topic_type
+ WHERE " . $db->sql_in_set('topic_id', $topic_ids);
+ $db->sql_query($sql);
+
+ if (($new_topic_type == POST_GLOBAL) && sizeof($topic_ids))
{
+ // Delete topic shadows for global announcements
+ $sql = 'DELETE FROM ' . TOPICS_TABLE . '
+ WHERE ' . $db->sql_in_set('topic_moved_id', $topic_ids);
+ $db->sql_query($sql);
+
$sql = 'UPDATE ' . TOPICS_TABLE . "
SET topic_type = $new_topic_type
- WHERE " . $db->sql_in_set('topic_id', $topic_ids) . '
- AND forum_id <> 0';
+ WHERE " . $db->sql_in_set('topic_id', $topic_ids);
$db->sql_query($sql);
-
- // Reset forum id if a global topic is within the array
- $to_forum_id = request_var('to_forum_id', 0);
-
- if ($to_forum_id)
- {
- $sql = 'UPDATE ' . TOPICS_TABLE . "
- SET topic_type = $new_topic_type, forum_id = $to_forum_id
- WHERE " . $db->sql_in_set('topic_id', $topic_ids) . '
- AND forum_id = 0';
- $db->sql_query($sql);
-
- // Update forum_ids for all posts
- $sql = 'UPDATE ' . POSTS_TABLE . "
- SET forum_id = $to_forum_id
- WHERE " . $db->sql_in_set('topic_id', $topic_ids) . '
- AND forum_id = 0';
- $db->sql_query($sql);
-
- // Do a little forum sync stuff
- $sql = 'SELECT SUM(t.topic_replies + t.topic_approved) as topic_posts, COUNT(t.topic_approved) as topics_authed
- FROM ' . TOPICS_TABLE . ' t
- WHERE ' . $db->sql_in_set('t.topic_id', $topic_ids);
- $result = $db->sql_query($sql);
- $row_data = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
-
- $sync_sql = array();
-
- if ($row_data['topic_posts'])
- {
- $sync_sql[$to_forum_id][] = 'forum_posts = forum_posts + ' . (int) $row_data['topic_posts'];
- }
-
- if ($row_data['topics_authed'])
- {
- $sync_sql[$to_forum_id][] = 'forum_topics = forum_topics + ' . (int) $row_data['topics_authed'];
- }
-
- $sync_sql[$to_forum_id][] = 'forum_topics_real = forum_topics_real + ' . (int) sizeof($topic_ids);
-
- foreach ($sync_sql as $forum_id_key => $array)
- {
- $sql = 'UPDATE ' . FORUMS_TABLE . '
- SET ' . implode(', ', $array) . '
- WHERE forum_id = ' . $forum_id_key;
- $db->sql_query($sql);
- }
-
- sync('forum', 'forum_id', $to_forum_id);
- }
- }
- else
- {
- // Get away with those topics already being a global announcement by re-calculating $topic_ids
- $sql = 'SELECT topic_id
- FROM ' . TOPICS_TABLE . '
- WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . '
- AND forum_id <> 0';
- $result = $db->sql_query($sql);
-
- $topic_ids = array();
- while ($row = $db->sql_fetchrow($result))
- {
- $topic_ids[] = $row['topic_id'];
- }
- $db->sql_freeresult($result);
-
- if (sizeof($topic_ids))
- {
- // Delete topic shadows for global announcements
- $sql = 'DELETE FROM ' . TOPICS_TABLE . '
- WHERE ' . $db->sql_in_set('topic_moved_id', $topic_ids);
- $db->sql_query($sql);
-
- $sql = 'UPDATE ' . TOPICS_TABLE . "
- SET topic_type = $new_topic_type, forum_id = 0
- WHERE " . $db->sql_in_set('topic_id', $topic_ids);
- $db->sql_query($sql);
-
- // Update forum_ids for all posts
- $sql = 'UPDATE ' . POSTS_TABLE . '
- SET forum_id = 0
- WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
- $db->sql_query($sql);
-
- // Do a little forum sync stuff
- $sql = 'SELECT SUM(t.topic_replies + t.topic_approved) as topic_posts, COUNT(t.topic_approved) as topics_authed
- FROM ' . TOPICS_TABLE . ' t
- WHERE ' . $db->sql_in_set('t.topic_id', $topic_ids);
- $result = $db->sql_query($sql);
- $row_data = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
-
- $sync_sql = array();
-
- if ($row_data['topic_posts'])
- {
- $sync_sql[$forum_id][] = 'forum_posts = forum_posts - ' . (int) $row_data['topic_posts'];
- }
-
- if ($row_data['topics_authed'])
- {
- $sync_sql[$forum_id][] = 'forum_topics = forum_topics - ' . (int) $row_data['topics_authed'];
- }
-
- $sync_sql[$forum_id][] = 'forum_topics_real = forum_topics_real - ' . (int) sizeof($topic_ids);
-
- foreach ($sync_sql as $forum_id_key => $array)
- {
- $sql = 'UPDATE ' . FORUMS_TABLE . '
- SET ' . implode(', ', $array) . '
- WHERE forum_id = ' . $forum_id_key;
- $db->sql_query($sql);
- }
-
- sync('forum', 'forum_id', $forum_id);
- }
}
$success_msg = (sizeof($topic_ids) == 1) ? 'TOPIC_TYPE_CHANGED' : 'TOPICS_TYPE_CHANGED';
@@ -474,41 +365,7 @@ function change_topic_type($action, $topic_ids)
}
else
{
- // Global topic involved?
- $global_involved = false;
-
- if ($new_topic_type != POST_GLOBAL)
- {
- $sql = 'SELECT forum_id
- FROM ' . TOPICS_TABLE . '
- WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . '
- AND forum_id = 0';
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
-
- if ($row)
- {
- $global_involved = true;
- }
- }
-
- if ($global_involved)
- {
- global $template;
-
- $template->assign_vars(array(
- 'S_FORUM_SELECT' => make_forum_select(request_var('f', $forum_id), false, false, true, true),
- 'S_CAN_LEAVE_SHADOW' => false,
- 'ADDITIONAL_MSG' => (sizeof($topic_ids) == 1) ? $user->lang['SELECT_FORUM_GLOBAL_ANNOUNCEMENT'] : $user->lang['SELECT_FORUM_GLOBAL_ANNOUNCEMENTS'])
- );
-
- confirm_box(false, $l_new_type, build_hidden_fields($s_hidden_fields), 'mcp_move.html');
- }
- else
- {
- confirm_box(false, $l_new_type, build_hidden_fields($s_hidden_fields));
- }
+ confirm_box(false, $l_new_type, build_hidden_fields($s_hidden_fields));
}
$redirect = request_var('redirect', "index.$phpEx");
@@ -628,16 +485,13 @@ function mcp_move_topic($topic_ids)
$topic_posts_added += $topic_info['topic_replies'];
- if ($topic_info['topic_type'] != POST_GLOBAL)
- {
- $topics_removed++;
- $topic_posts_removed += $topic_info['topic_replies'];
+ $topics_removed++;
+ $topic_posts_removed += $topic_info['topic_replies'];
- if ($topic_info['topic_approved'])
- {
- $topics_authed_removed++;
- $topic_posts_removed++;
- }
+ if ($topic_info['topic_approved'])
+ {
+ $topics_authed_removed++;
+ $topic_posts_removed++;
}
}
@@ -675,15 +529,6 @@ function mcp_move_topic($topic_ids)
$forum_ids[] = $row['forum_id'];
add_log('mod', $to_forum_id, $topic_id, 'LOG_MOVE', $row['forum_name'], $forum_data['forum_name']);
- // If we have moved a global announcement, we need to correct the topic type
- if ($row['topic_type'] == POST_GLOBAL)
- {
- $sql = 'UPDATE ' . TOPICS_TABLE . '
- SET topic_type = ' . POST_ANNOUNCE . '
- WHERE topic_id = ' . (int) $row['topic_id'];
- $db->sql_query($sql);
- }
-
// Leave a redirection if required and only if the topic is visible to users
if ($leave_shadow && $row['topic_approved'] && $row['topic_type'] != POST_GLOBAL)
{
diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php
index a5e0e426be..0630f55b12 100644
--- a/phpBB/includes/mcp/mcp_queue.php
+++ b/phpBB/includes/mcp/mcp_queue.php
@@ -268,13 +268,11 @@ class mcp_queue
trigger_error('NOT_MODERATOR');
}
- $global_id = $forum_list[0];
-
$forum_list = implode(', ', $forum_list);
$sql = 'SELECT SUM(forum_topics) as sum_forum_topics
- FROM ' . FORUMS_TABLE . "
- WHERE forum_id IN (0, $forum_list)";
+ FROM ' . FORUMS_TABLE . '
+ WHERE ' . $db->sql_in_set('forum_id', $forum_list);
$result = $db->sql_query($sql);
$forum_info['forum_topics'] = (int) $db->sql_fetchfield('sum_forum_topics');
$db->sql_freeresult($result);
@@ -290,7 +288,6 @@ class mcp_queue
$forum_info = $forum_info[$forum_id];
$forum_list = $forum_id;
- $global_id = $forum_id;
}
$forum_options = '<option value="0"' . (($forum_id == 0) ? ' selected="selected"' : '') . '>' . $user->lang['ALL_FORUMS'] . '</option>';
@@ -312,10 +309,10 @@ class mcp_queue
if ($mode == 'unapproved_posts')
{
$sql = 'SELECT p.post_id
- FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . "
- WHERE p.forum_id IN (0, $forum_list)
+ FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . '
+ WHERE ' . $db->sql_in_set('p.forum_id', $forum_list) . '
AND p.post_approved = 0
- " . (($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 : '') . "
AND t.topic_id = p.topic_id
AND t.topic_first_post_id <> p.post_id
@@ -345,10 +342,7 @@ class mcp_queue
$post_data = $rowset = array();
while ($row = $db->sql_fetchrow($result))
{
- if ($row['forum_id'])
- {
- $forum_names[] = $row['forum_id'];
- }
+ $forum_names[] = $row['forum_id'];
$post_data[$row['post_id']] = $row;
}
$db->sql_freeresult($result);
@@ -368,7 +362,7 @@ class mcp_queue
{
$sql = 'SELECT t.forum_id, t.topic_id, t.topic_title, t.topic_title AS post_subject, t.topic_time AS post_time, t.topic_poster AS poster_id, t.topic_first_post_id AS post_id, t.topic_first_poster_name AS username, t.topic_first_poster_colour AS user_colour
FROM ' . TOPICS_TABLE . " t
- WHERE forum_id IN (0, $forum_list)
+ WHERE " . $db->sql_in_set('forum_id', $forum_list) . "
AND topic_approved = 0
$limit_time_sql
ORDER BY $sort_order_sql";
@@ -377,10 +371,7 @@ class mcp_queue
$rowset = array();
while ($row = $db->sql_fetchrow($result))
{
- if ($row['forum_id'])
- {
- $forum_names[] = $row['forum_id'];
- }
+ $forum_names[] = $row['forum_id'];
$rowset[] = $row;
}
$db->sql_freeresult($result);
@@ -404,12 +395,6 @@ class mcp_queue
foreach ($rowset as $row)
{
- $global_topic = ($row['forum_id']) ? false : true;
- if ($global_topic)
- {
- $row['forum_id'] = $global_id;
- }
-
if (empty($row['post_username']))
{
$row['post_username'] = $user->lang['GUEST'];
@@ -417,7 +402,7 @@ class mcp_queue
$template->assign_block_vars('postrow', array(
'U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&amp;t=' . $row['topic_id']),
- 'U_VIEWFORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) : '',
+ 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']),
'U_VIEWPOST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&amp;p=' . $row['post_id']) . (($mode == 'unapproved_posts') ? '#p' . $row['post_id'] : ''),
'U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&amp;start=$start&amp;mode=approve_details&amp;f={$row['forum_id']}&amp;p={$row['post_id']}" . (($mode == 'unapproved_topics') ? "&amp;t={$row['topic_id']}" : '')),
@@ -427,7 +412,7 @@ class mcp_queue
'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
'POST_ID' => $row['post_id'],
- 'FORUM_NAME' => (!$global_topic) ? $forum_names[$row['forum_id']] : $user->lang['GLOBAL_ANNOUNCEMENT'],
+ 'FORUM_NAME' => $forum_names[$row['forum_id']],
'POST_SUBJECT' => ($row['post_subject'] != '') ? $row['post_subject'] : $user->lang['NO_SUBJECT'],
'TOPIC_TITLE' => $row['topic_title'],
'POST_TIME' => $user->format_date($row['post_time']))
@@ -504,11 +489,7 @@ function approve_post($post_id_list, $id, $mode)
}
$topic_id_list[$post_data['topic_id']] = 1;
-
- if ($post_data['forum_id'])
- {
- $forum_id_list[$post_data['forum_id']] = 1;
- }
+ $forum_id_list[$post_data['forum_id']] = 1;
// User post update (we do not care about topic or post, since user posts are strictly connected to posts)
// But we care about forums where post counts get not increased. ;)
@@ -520,10 +501,7 @@ function approve_post($post_id_list, $id, $mode)
// Topic or Post. ;)
if ($post_data['topic_first_post_id'] == $post_id)
{
- if ($post_data['forum_id'])
- {
- $total_topics++;
- }
+ $total_topics++;
$topic_approve_sql[] = $post_data['topic_id'];
$approve_log[] = array(
@@ -543,16 +521,13 @@ function approve_post($post_id_list, $id, $mode)
);
}
- if ($post_data['forum_id'])
- {
- $total_posts++;
+ $total_posts++;
- // Increment by topic_replies if we approve a topic...
- // This works because we do not adjust the topic_replies when re-approving a topic after an edit.
- if ($post_data['topic_first_post_id'] == $post_id && $post_data['topic_replies'])
- {
- $total_posts += $post_data['topic_replies'];
- }
+ // Increment by topic_replies if we approve a topic...
+ // This works because we do not adjust the topic_replies when re-approving a topic after an edit.
+ if ($post_data['topic_first_post_id'] == $post_id && $post_data['topic_replies'])
+ {
+ $total_posts += $post_data['topic_replies'];
}
$post_approve_sql[] = $post_id;
diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php
index f6e46b57ee..a7275382e6 100644
--- a/phpBB/includes/mcp/mcp_reports.php
+++ b/phpBB/includes/mcp/mcp_reports.php
@@ -312,7 +312,6 @@ class mcp_reports
$forum_info = $forum_info[$forum_id];
$forum_list = array($forum_id);
- $global_id = $forum_id;
}
$forum_list[] = 0;
@@ -382,14 +381,8 @@ class mcp_reports
$report_data = $rowset = array();
while ($row = $db->sql_fetchrow($result))
{
- $global_topic = ($row['forum_id']) ? false : true;
- if ($global_topic)
- {
- $row['forum_id'] = $global_id;
- }
-
$template->assign_block_vars('postrow', array(
- 'U_VIEWFORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) : '',
+ 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']),
'U_VIEWPOST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&amp;p=' . $row['post_id']) . '#p' . $row['post_id'],
'U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=reports&amp;start=$start&amp;mode=report_details&amp;f={$row['forum_id']}&amp;r={$row['report_id']}"),
@@ -403,7 +396,7 @@ class mcp_reports
'REPORTER' => get_username_string('username', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']),
'U_REPORTER' => get_username_string('profile', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']),
- 'FORUM_NAME' => (!$global_topic) ? $forum_data[$row['forum_id']]['forum_name'] : $user->lang['GLOBAL_ANNOUNCEMENT'],
+ 'FORUM_NAME' => $forum_data[$row['forum_id']]['forum_name'],
'POST_ID' => $row['post_id'],
'POST_SUBJECT' => ($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT'],
'POST_TIME' => $user->format_date($row['post_time']),
diff --git a/phpBB/includes/ucp/ucp_main.php b/phpBB/includes/ucp/ucp_main.php
index 249c8e5750..f4fdb50ecd 100644
--- a/phpBB/includes/ucp/ucp_main.php
+++ b/phpBB/includes/ucp/ucp_main.php
@@ -57,38 +57,29 @@ class ucp_main
$sql_from .= ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.topic_id = t.topic_id
AND tt.user_id = ' . $user->data['user_id'] . ')';
$sql_select .= ', tt.mark_time';
+
+ $sql_from .= ' LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.forum_id = t.forum_id
+ AND ft.user_id = ' . $user->data['user_id'] . ')';
+ $sql_select .= ', ft.mark_time AS forum_mark_time';
}
$topic_type = $user->lang['VIEW_TOPIC_GLOBAL'];
$folder = 'global_read';
$folder_new = 'global_unread';
- // Get cleaned up list... return only those forums not having the f_read permission
- $forum_ary = $auth->acl_getf('!f_read', true);
+ // Get cleaned up list... return only those forums having the f_read permission
+ $forum_ary = $auth->acl_getf('f_read', true);
$forum_ary = array_unique(array_keys($forum_ary));
- // Determine first forum the user is able to read into - for global announcement link
- $sql = 'SELECT forum_id
- FROM ' . FORUMS_TABLE . '
- WHERE forum_type = ' . FORUM_POST;
-
- if (sizeof($forum_ary))
- {
- $sql .= ' AND ' . $db->sql_in_set('forum_id', $forum_ary, true);
- }
- $result = $db->sql_query_limit($sql, 1);
- $g_forum_id = (int) $db->sql_fetchfield('forum_id');
- $db->sql_freeresult($result);
-
$sql = "SELECT t.* $sql_select
FROM $sql_from
- WHERE t.forum_id = 0
- AND t.topic_type = " . POST_GLOBAL . '
+ WHERE t.topic_type = " . POST_GLOBAL . '
+ AND ' . $db->sql_in_set('t.forum_id', $forum_ary) . '
ORDER BY t.topic_last_post_time DESC';
$topic_list = $rowset = array();
// If the user can't see any forums, he can't read any posts because fid of 0 is invalid
- if ($g_forum_id)
+ if (!empty($forum_ary))
{
$result = $db->sql_query($sql);
@@ -100,15 +91,34 @@ class ucp_main
$db->sql_freeresult($result);
}
- $topic_tracking_info = array();
+ $topic_forum_list = array();
+ foreach ($rowset as $t_id => $row)
+ {
+ if (isset($forum_tracking_info[$row['forum_id']]))
+ {
+ $row['forum_mark_time'] = $forum_tracking_info[$row['forum_id']];
+ }
+
+ $topic_forum_list[$row['forum_id']]['forum_mark_time'] = ($config['load_db_lastread'] && $user->data['is_registered'] && isset($row['forum_mark_time'])) ? $row['forum_mark_time'] : 0;
+ $topic_forum_list[$row['forum_id']]['topics'][] = (int) $t_id;
+ }
+
+ $topic_tracking_info = $tracking_topics = array();
if ($config['load_db_lastread'])
{
- $topic_tracking_info = get_topic_tracking(0, $topic_list, $rowset, false, $topic_list);
+ foreach ($topic_forum_list as $f_id => $topic_row)
+ {
+ $topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time']));
+ }
}
else
{
- $topic_tracking_info = get_complete_topic_tracking(0, $topic_list, $topic_list);
+ foreach ($topic_forum_list as $f_id => $topic_row)
+ {
+ $topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics']);
+ }
}
+ unset($topic_forum_list);
foreach ($topic_list as $topic_id)
{
@@ -158,10 +168,10 @@ class ucp_main
'S_UNREAD' => $unread_topic,
'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
- 'U_LAST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$g_forum_id&amp;t=$topic_id&amp;p=" . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'],
+ 'U_LAST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;p=" . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'],
'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
- 'U_NEWEST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$g_forum_id&amp;t=$topic_id&amp;view=unread") . '#unread',
- 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$g_forum_id&amp;t=$topic_id"))
+ 'U_NEWEST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;view=unread") . '#unread',
+ 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id"))
);
}
@@ -750,14 +760,14 @@ class ucp_main
{
foreach ($topic_forum_list as $f_id => $topic_row)
{
- $topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time']), ($f_id == 0) ? $global_announce_list : false);
+ $topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time']));
}
}
else
{
foreach ($topic_forum_list as $f_id => $topic_row)
{
- $topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics'], $global_announce_list);
+ $topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics']);
}
}
@@ -805,9 +815,8 @@ class ucp_main
'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
'S_DELETED_TOPIC' => (!$row['topic_id']) ? true : false,
- 'S_GLOBAL_TOPIC' => (!$forum_id) ? true : false,
- 'PAGINATION' => topic_generate_pagination($replies, append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($row['forum_id']) ? $row['forum_id'] : $forum_id) . "&amp;t=$topic_id")),
+ 'PAGINATION' => topic_generate_pagination($replies, append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . "&amp;t=$topic_id")),
'REPLIES' => $replies,
'VIEWS' => $row['topic_views'],
'TOPIC_TITLE' => censor_text($row['topic_title']),
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php
index cf611ca951..0d3e96f342 100644
--- a/phpBB/install/database_update.php
+++ b/phpBB/install/database_update.php
@@ -177,6 +177,69 @@ $database_update_info = database_update_info();
$error_ary = array();
$errored = false;
+$sql = 'SELECT topic_id
+ FROM ' . TOPICS_TABLE . '
+ WHERE forum_id = 0
+ AND topic_type = ' . POST_GLOBAL;
+$result = $db->sql_query_limit($sql, 1);
+$has_global = (int) $db->sql_fetchfield('topic_id');
+$db->sql_freeresult($result);
+$ga_forum_id = request_var('ga_forum_id', 0);
+
+if ($has_global && !$ga_forum_id)
+{
+ ?>
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+ <html xmlns="http://www.w3.org/1999/xhtml" dir="<?php echo $lang['DIRECTION']; ?>" lang="<?php echo $lang['USER_LANG']; ?>" xml:lang="<?php echo $lang['USER_LANG']; ?>">
+ <head>
+
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="content-language" content="<?php echo $lang['USER_LANG']; ?>" />
+ <meta http-equiv="content-style-type" content="text/css" />
+ <meta http-equiv="imagetoolbar" content="no" />
+
+ <title><?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?></title>
+
+ <link href="../adm/style/admin.css" rel="stylesheet" type="text/css" media="screen" />
+
+ </head>
+
+ <body>
+ <div id="wrap">
+ <div id="page-header">&nbsp;</div>
+
+ <div id="page-body">
+ <div id="acp">
+ <div class="panel">
+ <span class="corners-top"><span></span></span>
+ <div id="content">
+ <div id="main" class="install-body">
+
+ <h1><?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?></h1>
+
+ <br />
+
+ <form action="" method="post" id="select_ga_forum_id">
+ <?php
+ if (isset($lang['SELECT_FORUM_GA']))
+ {
+ // Language string is available:
+ echo $lang['SELECT_FORUM_GA'];
+ }
+ else
+ {
+ echo 'In phpBB 3.1 the global announcements are linked to forums. Select a forum for your current global announcements (can be moved later):';
+ }
+ ?>
+ <select id="ga_forum_id" name="ga_forum_id"><?php echo make_forum_select(false, false, true, true) ?></select>
+
+ <input type="submit" name="post" value="<?php echo $lang['SUBMIT']; ?>" class="button1" />
+ </form>
+ <?php
+ _print_footer();
+ exit;
+}
+
header('Content-type: text/html; charset=UTF-8');
?>
@@ -1962,6 +2025,83 @@ function change_database_data(&$no_updates, $version)
_add_modules($modules_to_install);
+ // Localise Global Announcements
+ $sql = 'SELECT topic_id, topic_approved, (topic_replies + 1) AS topic_posts, topic_last_post_id, topic_last_post_subject, topic_last_post_time, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour
+ FROM ' . TOPICS_TABLE . '
+ WHERE forum_id = 0
+ AND topic_type = ' . POST_GLOBAL;
+ $result = $db->sql_query($sql);
+
+ $global_announcements = $update_lastpost_data = array();
+ $update_lastpost_data['forum_last_post_time'] = 0;
+ $update_forum_data = array(
+ 'forum_posts' => 0,
+ 'forum_topics' => 0,
+ 'forum_topics_real' => 0,
+ );
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $global_announcements[] = (int) $row['topic_id'];
+
+ $update_forum_data['forum_posts'] += (int) $row['topic_posts'];
+ $update_forum_data['forum_topics_real']++;
+ if ($row['topic_approved'])
+ {
+ $update_forum_data['forum_topics']++;
+ }
+
+ if ($update_lastpost_data['forum_last_post_time'] < $row['topic_last_post_time'])
+ {
+ $update_lastpost_data = array(
+ 'forum_last_post_id' => (int) $row['topic_last_post_id'],
+ 'forum_last_post_subject' => $row['topic_last_post_subject'],
+ 'forum_last_post_time' => (int) $row['topic_last_post_time'],
+ 'forum_last_poster_id' => (int) $row['topic_last_poster_id'],
+ 'forum_last_poster_name' => $row['topic_last_poster_name'],
+ 'forum_last_poster_colour' => $row['topic_last_poster_colour'],
+ );
+ }
+ }
+ $db->sql_freeresult($result);
+
+ if (!empty($global_announcements))
+ {
+ // Update the post/topic-count for the forum and the last-post if needed
+ $ga_forum_id = request_var('ga_forum_id', 0);
+
+ $sql = 'SELECT forum_last_post_time
+ FROM ' . FORUMS_TABLE . '
+ WHERE forum_id = ' . $ga_forum_id;
+ $result = $db->sql_query($sql);
+ $lastpost = (int) $db->sql_fetchfield('forum_last_post_time');
+ $db->sql_freeresult($result);
+
+ $sql_update = 'forum_posts = forum_posts + ' . $update_forum_data['forum_posts'] . ', ';
+ $sql_update .= 'forum_topics_real = forum_topics_real + ' . $update_forum_data['forum_topics_real'] . ', ';
+ $sql_update .= 'forum_topics = forum_topics + ' . $update_forum_data['forum_topics'];
+ if ($lastpost < $update_lastpost_data['forum_last_post_time'])
+ {
+ $sql_update .= ', ' . $db->sql_build_array('UPDATE', $update_lastpost_data);
+ }
+
+ $sql = 'UPDATE ' . FORUMS_TABLE . '
+ SET ' . $sql_update . '
+ WHERE forum_id = ' . $ga_forum_id;
+ _sql($sql, $errored, $error_ary);
+
+ // Update some forum_ids
+ $table_ary = array(TOPICS_TABLE, POSTS_TABLE, LOG_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE);
+ foreach ($table_ary as $table)
+ {
+ $sql = "UPDATE $table
+ SET forum_id = $ga_forum_id
+ WHERE " . $db->sql_in_set('topic_id', $global_announcements);
+ _sql($sql, $errored, $error_ary);
+ }
+ unset($table_ary);
+ }
+
$no_updates = false;
break;
}
diff --git a/phpBB/language/en/install.php b/phpBB/language/en/install.php
index 021f5eccb0..35fe28d8b5 100644
--- a/phpBB/language/en/install.php
+++ b/phpBB/language/en/install.php
@@ -323,6 +323,7 @@ $lang = array_merge($lang, array(
'SERVER_CONFIG' => 'Server configuration',
'SEARCH_INDEX_UNCONVERTED' => 'Search index was not converted',
'SEARCH_INDEX_UNCONVERTED_EXPLAIN' => 'Your old search index was not converted. Searching will always yield an empty result. To create a new search index go to the Administration Control Panel, select Maintenance and then choose Search index from the submenu.',
+ 'SELECT_FORUM_GA' => 'In phpBB 3.1 the global announcements are linked to forums. Select a forum for your current global announcements (can be moved later):',
'SOFTWARE' => 'Board software',
'SPECIFY_OPTIONS' => 'Specify conversion options',
'STAGE_ADMINISTRATOR' => 'Administrator details',
diff --git a/phpBB/mcp.php b/phpBB/mcp.php
index 401a12d0f9..0029d224cd 100644
--- a/phpBB/mcp.php
+++ b/phpBB/mcp.php
@@ -85,7 +85,7 @@ if ($post_id)
$db->sql_freeresult($result);
$topic_id = (int) $row['topic_id'];
- $forum_id = (int) ($row['forum_id']) ? $row['forum_id'] : $forum_id;
+ $forum_id = (int) $row['forum_id'];
}
else if ($topic_id)
{
@@ -400,12 +400,6 @@ function get_topic_data($topic_ids, $acl_list = false, $read_tracking = false)
while ($row = $db->sql_fetchrow($result))
{
- if (!$row['forum_id'])
- {
- // Global Announcement?
- $row['forum_id'] = request_var('f', 0);
- }
-
$rowset[$row['topic_id']] = $row;
if ($acl_list && !$auth->acl_gets($acl_list, $row['forum_id']))
@@ -485,12 +479,6 @@ function get_post_data($post_ids, $acl_list = false, $read_tracking = false)
while ($row = $db->sql_fetchrow($result))
{
- if (!$row['forum_id'])
- {
- // Global Announcement?
- $row['forum_id'] = request_var('f', 0);
- }
-
if ($acl_list && !$auth->acl_gets($acl_list, $row['forum_id']))
{
continue;
diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php
index ff74d0d0cd..685830c656 100644
--- a/phpBB/memberlist.php
+++ b/phpBB/memberlist.php
@@ -1136,7 +1136,7 @@ switch ($mode)
$sql = 'SELECT DISTINCT poster_id
FROM ' . POSTS_TABLE . '
WHERE poster_ip ' . ((strpos($ips, '%') !== false) ? 'LIKE' : 'IN') . " ($ips)
- AND forum_id IN (0, " . implode(', ', $ip_forums) . ')';
+ AND " . $db->sql_in_set('forum_id', $ip_forums);
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
diff --git a/phpBB/posting.php b/phpBB/posting.php
index 41559056b9..734e97742c 100644
--- a/phpBB/posting.php
+++ b/phpBB/posting.php
@@ -87,9 +87,8 @@ switch ($mode)
$sql = 'SELECT f.*, t.*
FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f
WHERE t.topic_id = $topic_id
- AND (f.forum_id = t.forum_id
- OR f.forum_id = $forum_id)" .
- (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1');
+ AND f.forum_id = t.forum_id" .
+ (($auth->acl_get('m_approve', $forum_id)) ? '' : ' AND t.topic_approved = 1');
break;
case 'quote':
@@ -116,9 +115,8 @@ switch ($mode)
WHERE p.post_id = $post_id
AND t.topic_id = p.topic_id
AND u.user_id = p.poster_id
- AND (f.forum_id = t.forum_id
- OR f.forum_id = $forum_id)" .
- (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND p.post_approved = 1');
+ AND f.forum_id = t.forum_id" .
+ (($auth->acl_get('m_approve', $forum_id)) ? '' : ' AND p.post_approved = 1');
break;
case 'smilies':
@@ -1005,60 +1003,6 @@ if ($submit || $preview || $refresh)
// Store message, sync counters
if (!sizeof($error) && $submit)
{
- // Check if we want to de-globalize the topic... and ask for new forum
- if ($post_data['topic_type'] != POST_GLOBAL)
- {
- $sql = 'SELECT topic_type, forum_id
- FROM ' . TOPICS_TABLE . "
- WHERE topic_id = $topic_id";
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
-
- if ($row && !$row['forum_id'] && $row['topic_type'] == POST_GLOBAL)
- {
- $to_forum_id = request_var('to_forum_id', 0);
-
- if ($to_forum_id)
- {
- $sql = 'SELECT forum_type
- FROM ' . FORUMS_TABLE . '
- WHERE forum_id = ' . $to_forum_id;
- $result = $db->sql_query($sql);
- $forum_type = (int) $db->sql_fetchfield('forum_type');
- $db->sql_freeresult($result);
-
- if ($forum_type != FORUM_POST || !$auth->acl_get('f_post', $to_forum_id) || (!$auth->acl_get('m_approve', $to_forum_id) && !$auth->acl_get('f_noapprove', $to_forum_id)))
- {
- $to_forum_id = 0;
- }
- }
-
- if (!$to_forum_id)
- {
- include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
-
- $template->assign_vars(array(
- 'S_FORUM_SELECT' => make_forum_select(false, false, false, true, true, true),
- 'S_UNGLOBALISE' => true)
- );
-
- $submit = false;
- $refresh = true;
- }
- else
- {
- if (!$auth->acl_get('f_post', $to_forum_id))
- {
- // This will only be triggered if the user tried to trick the forum.
- trigger_error('NOT_AUTHORISED');
- }
-
- $forum_id = $to_forum_id;
- }
- }
- }
-
if ($submit)
{
// Lock/Unlock Topic
diff --git a/phpBB/report.php b/phpBB/report.php
index 8e780813ff..a30914392b 100644
--- a/phpBB/report.php
+++ b/phpBB/report.php
@@ -70,7 +70,7 @@ if ($post_id)
trigger_error('POST_NOT_EXIST');
}
- $forum_id = (int) ($report_data['forum_id']) ? $report_data['forum_id'] : $forum_id;
+ $forum_id = (int) $report_data['forum_id'];
$topic_id = (int) $report_data['topic_id'];
$sql = 'SELECT *
diff --git a/phpBB/search.php b/phpBB/search.php
index 7f5c49f4fc..4b1527b7e7 100644
--- a/phpBB/search.php
+++ b/phpBB/search.php
@@ -719,11 +719,11 @@ if ($keywords || $author || $author_id || $search_id || $submit)
{
if ($user->data['is_registered'] && $config['load_db_lastread'])
{
- $topic_tracking_info[$forum_id] = get_topic_tracking($forum_id, $forum['topic_list'], $forum['rowset'], array($forum_id => $forum['mark_time']), ($forum_id) ? false : $forum['topic_list']);
+ $topic_tracking_info[$forum_id] = get_topic_tracking($forum_id, $forum['topic_list'], $forum['rowset'], array($forum_id => $forum['mark_time']));
}
else if ($config['load_anon_lastread'] || $user->data['is_registered'])
{
- $topic_tracking_info[$forum_id] = get_complete_topic_tracking($forum_id, $forum['topic_list'], ($forum_id) ? false : $forum['topic_list']);
+ $topic_tracking_info[$forum_id] = get_complete_topic_tracking($forum_id, $forum['topic_list']);
if (!$user->data['is_registered'])
{
@@ -832,35 +832,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
$result_topic_id = $row['topic_id'];
$topic_title = censor_text($row['topic_title']);
- // we need to select a forum id for this global topic
- if (!$forum_id)
- {
- if (!isset($g_forum_id))
- {
- // Get a list of forums the user cannot read
- $forum_ary = array_unique(array_keys($auth->acl_getf('!f_read', true)));
-
- // Determine first forum the user is able to read (must not be a category)
- $sql = 'SELECT forum_id
- FROM ' . FORUMS_TABLE . '
- WHERE forum_type = ' . FORUM_POST;
-
- if (sizeof($forum_ary))
- {
- $sql .= ' AND ' . $db->sql_in_set('forum_id', $forum_ary, true);
- }
-
- $result = $db->sql_query_limit($sql, 1);
- $g_forum_id = (int) $db->sql_fetchfield('forum_id');
- }
- $u_forum_id = $g_forum_id;
- }
- else
- {
- $u_forum_id = $forum_id;
- }
-
- $view_topic_url_params = "f=$u_forum_id&amp;t=$result_topic_id" . (($u_hilit) ? "&amp;hilit=$u_hilit" : '');
+ $view_topic_url_params = "f=$forum_id&amp;t=$result_topic_id" . (($u_hilit) ? "&amp;hilit=$u_hilit" : '');
$view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params);
$replies = ($auth->acl_get('m_approve', $forum_id)) ? $row['topic_replies_real'] : $row['topic_replies'];
@@ -911,7 +883,6 @@ if ($keywords || $author || $author_id || $search_id || $submit)
'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
'UNAPPROVED_IMG' => ($topic_unapproved || $posts_unapproved) ? $user->img('icon_topic_unapproved', ($topic_unapproved) ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '',
- 'S_TOPIC_GLOBAL' => (!$forum_id) ? true : false,
'S_TOPIC_TYPE' => $row['topic_type'],
'S_USER_POSTED' => (!empty($row['topic_posted'])) ? true : false,
'S_UNREAD_TOPIC' => $unread_topic,
diff --git a/phpBB/styles/prosilver/template/search_results.html b/phpBB/styles/prosilver/template/search_results.html
index fec71c1051..942d154d44 100644
--- a/phpBB/styles/prosilver/template/search_results.html
+++ b/phpBB/styles/prosilver/template/search_results.html
@@ -58,8 +58,7 @@
<!-- IF searchresults.S_TOPIC_UNAPPROVED or searchresults.S_POSTS_UNAPPROVED --><a href="{searchresults.U_MCP_QUEUE}">{searchresults.UNAPPROVED_IMG}</a> <!-- ENDIF -->
<!-- IF searchresults.S_TOPIC_REPORTED --><a href="{searchresults.U_MCP_REPORT}">{REPORTED_IMG}</a><!-- ENDIF --><br />
<!-- IF searchresults.PAGINATION --><strong class="pagination"><span>{searchresults.PAGINATION}</span></strong><!-- ENDIF -->
- {L_POST_BY_AUTHOR} {searchresults.TOPIC_AUTHOR_FULL} &raquo; {searchresults.FIRST_POST_TIME}
- <!-- IF not searchresults.S_TOPIC_GLOBAL -->{L_IN} <a href="{searchresults.U_VIEW_FORUM}">{searchresults.FORUM_TITLE}</a><!-- ELSE --> ({L_GLOBAL})<!-- ENDIF -->
+ {L_POST_BY_AUTHOR} {searchresults.TOPIC_AUTHOR_FULL} &raquo; {searchresults.FIRST_POST_TIME} &raquo; {L_IN} <a href="{searchresults.U_VIEW_FORUM}">{searchresults.FORUM_TITLE}</a>
</dt>
<dd class="posts">{searchresults.TOPIC_REPLIES}</dd>
<dd class="views">{searchresults.TOPIC_VIEWS}</dd>
@@ -102,12 +101,8 @@
<dt class="author">{L_POST_BY_AUTHOR} {searchresults.POST_AUTHOR_FULL}</dt>
<dd>{searchresults.POST_DATE}</dd>
<dd>&nbsp;</dd>
- <!-- IF searchresults.FORUM_TITLE -->
- <dd>{L_FORUM}: <a href="{searchresults.U_VIEW_FORUM}">{searchresults.FORUM_TITLE}</a></dd>
- <dd>{L_TOPIC}: <a href="{searchresults.U_VIEW_TOPIC}">{searchresults.TOPIC_TITLE}</a></dd>
- <!-- ELSE -->
- <dd>{L_GLOBAL}: <a href="{searchresults.U_VIEW_TOPIC}">{searchresults.TOPIC_TITLE}</a></dd>
- <!-- ENDIF -->
+ <dd>{L_FORUM}: <a href="{searchresults.U_VIEW_FORUM}">{searchresults.FORUM_TITLE}</a></dd>
+ <dd>{L_TOPIC}: <a href="{searchresults.U_VIEW_TOPIC}">{searchresults.TOPIC_TITLE}</a></dd>
<dd>{L_REPLIES}: <strong>{searchresults.TOPIC_REPLIES}</strong></dd>
<dd>{L_VIEWS}: <strong>{searchresults.TOPIC_VIEWS}</strong></dd>
</dl>
diff --git a/phpBB/styles/prosilver/template/viewforum_body.html b/phpBB/styles/prosilver/template/viewforum_body.html
index ff1faa6734..b9e222bff1 100644
--- a/phpBB/styles/prosilver/template/viewforum_body.html
+++ b/phpBB/styles/prosilver/template/viewforum_body.html
@@ -144,6 +144,7 @@
<!-- IF topicrow.S_TOPIC_REPORTED --><a href="{topicrow.U_MCP_REPORT}">{REPORTED_IMG}</a><!-- ENDIF --><br />
<!-- IF topicrow.PAGINATION --><strong class="pagination"><span>{topicrow.PAGINATION}</span></strong><!-- ENDIF -->
<!-- IF topicrow.ATTACH_ICON_IMG -->{topicrow.ATTACH_ICON_IMG} <!-- ENDIF -->{L_POST_BY_AUTHOR} {topicrow.TOPIC_AUTHOR_FULL} &raquo; {topicrow.FIRST_POST_TIME}
+ <!-- IF topicrow.S_POST_GLOBAL and FORUM_ID != topicrow.FORUM_ID --> &raquo; {L_IN} <a href="{topicrow.U_VIEW_FORUM}">{topicrow.FORUM_NAME}</a><!-- ENDIF -->
</dt>
<dd class="posts">{topicrow.REPLIES} <dfn>{L_REPLIES}</dfn></dd>
<dd class="views">{topicrow.VIEWS} <dfn>{L_VIEWS}</dfn></dd>
diff --git a/phpBB/styles/subsilver2/template/search_results.html b/phpBB/styles/subsilver2/template/search_results.html
index 823d057f06..282b0f864b 100644
--- a/phpBB/styles/subsilver2/template/search_results.html
+++ b/phpBB/styles/subsilver2/template/search_results.html
@@ -45,11 +45,7 @@
<!-- IF searchresults.PAGINATION -->
<p class="gensmall"> [ {GOTO_PAGE_IMG}{L_GOTO_PAGE}: {searchresults.PAGINATION} ] </p>
<!-- ENDIF -->
- <!-- IF searchresults.S_TOPIC_GLOBAL -->
- <p class="gensmall">{L_GLOBAL}</p>
- <!-- ELSE -->
- <p class="gensmall">{L_IN} <a href="{searchresults.U_VIEW_FORUM}">{searchresults.FORUM_TITLE}</a></p>
- <!-- ENDIF -->
+ <p class="gensmall">{L_IN} <a href="{searchresults.U_VIEW_FORUM}">{searchresults.FORUM_TITLE}</a></p>
</td>
<td class="row2" width="100" align="center"><p class="topicauthor">{searchresults.TOPIC_AUTHOR_FULL}</p></td>
<td class="row1" width="50" align="center"><p class="topicdetails">{searchresults.TOPIC_REPLIES}</p></td>
@@ -84,7 +80,7 @@
<!-- IF searchresults.S_IGNORE_POST -->
<td class="gensmall" colspan="2" height="25" align="center">{searchresults.L_IGNORE_POST}</td>
<!-- ELSE -->
- <td colspan="2" height="25"><p class="topictitle"><a name="p{searchresults.POST_ID}" id="p{searchresults.POST_ID}"></a>&nbsp;<!-- IF searchresults.FORUM_TITLE -->{L_FORUM}: <a href="{searchresults.U_VIEW_FORUM}">{searchresults.FORUM_TITLE}</a><!-- ELSE -->{L_GLOBAL}<!-- ENDIF --> &nbsp; {L_TOPIC}: <a href="{searchresults.U_VIEW_TOPIC}">{searchresults.TOPIC_TITLE}</a> </p></td>
+ <td colspan="2" height="25"><p class="topictitle"><a name="p{searchresults.POST_ID}" id="p{searchresults.POST_ID}"></a>&nbsp;{L_FORUM}: <a href="{searchresults.U_VIEW_FORUM}">{searchresults.FORUM_TITLE}</a> &nbsp; {L_TOPIC}: <a href="{searchresults.U_VIEW_TOPIC}">{searchresults.TOPIC_TITLE}</a> </p></td>
</tr>
<tr class="row1">
<td width="150" align="center" valign="middle"><b class="postauthor">{searchresults.POST_AUTHOR_FULL}</b></td>
diff --git a/phpBB/styles/subsilver2/template/viewforum_body.html b/phpBB/styles/subsilver2/template/viewforum_body.html
index 65d8ef51c0..5c20b84541 100644
--- a/phpBB/styles/subsilver2/template/viewforum_body.html
+++ b/phpBB/styles/subsilver2/template/viewforum_body.html
@@ -202,6 +202,7 @@
<!-- IF topicrow.PAGINATION -->
<p class="gensmall"> [ {GOTO_PAGE_IMG}{L_GOTO_PAGE}: {topicrow.PAGINATION} ] </p>
<!-- ENDIF -->
+ <!-- IF topicrow.S_POST_GLOBAL and FORUM_ID != topicrow.FORUM_ID --><p class="gensmall">{L_IN} <a href="{topicrow.U_VIEW_FORUM}">{topicrow.FORUM_NAME}</a></p><!-- ENDIF -->
</td>
<td class="row2" width="130" align="center"><p class="topicauthor">{topicrow.TOPIC_AUTHOR_FULL}</p></td>
<td class="row1" width="50" align="center"><p class="topicdetails">{topicrow.REPLIES}</p></td>
diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php
index 16d8b56d88..c53150d89b 100644
--- a/phpBB/viewforum.php
+++ b/phpBB/viewforum.php
@@ -177,8 +177,7 @@ if ($mark_read == 'topics')
$token = request_var('hash', '');
if (check_link_hash($token, 'global'))
{
- // Add 0 to forums array to mark global announcements correctly
- markread('topics', array($forum_id, 0));
+ markread('topics', array($forum_id));
}
$redirect_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id);
meta_refresh(3, $redirect_url);
@@ -238,9 +237,10 @@ if ($sort_days)
$sql = 'SELECT COUNT(topic_id) AS num_topics
FROM ' . TOPICS_TABLE . "
WHERE forum_id = $forum_id
- AND ((topic_type <> " . POST_GLOBAL . " AND topic_last_post_time >= $min_post_time)
- OR topic_type = " . POST_ANNOUNCE . ")
- " . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND topic_approved = 1');
+ AND (topic_last_post_time >= $min_post_time
+ OR topic_type = " . POST_ANNOUNCE . '
+ OR topic_type = ' . POST_GLOBAL . ')
+ ' . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND topic_approved = 1');
$result = $db->sql_query($sql);
$topics_count = (int) $db->sql_fetchfield('num_topics');
$db->sql_freeresult($result);
@@ -324,7 +324,7 @@ $template->assign_vars(array(
$icons = $cache->obtain_icons();
// Grab all topic data
-$rowset = $announcement_list = $topic_list = $global_announce_list = array();
+$rowset = $announcement_list = $topic_list = $global_announce_forums = array();
$sql_array = array(
'SELECT' => 't.*',
@@ -359,14 +359,24 @@ if ($user->data['is_registered'])
if ($forum_data['forum_type'] == FORUM_POST)
{
+ // Get global announcement forums
+ $g_forum_ary = $auth->acl_getf('f_read', true);
+ $g_forum_ary = array_unique(array_keys($g_forum_ary));
+
+ $sql_anounce_array['LEFT_JOIN'] = $sql_array['LEFT_JOIN'];
+ $sql_anounce_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 'f.forum_id = t.forum_id');
+ $sql_anounce_array['SELECT'] = $sql_array['SELECT'] . ', f.forum_name';
+
// Obtain announcements ... removed sort ordering, sort by time in all cases
$sql = $db->sql_build_query('SELECT', array(
- 'SELECT' => $sql_array['SELECT'],
+ 'SELECT' => $sql_anounce_array['SELECT'],
'FROM' => $sql_array['FROM'],
- 'LEFT_JOIN' => $sql_array['LEFT_JOIN'],
+ 'LEFT_JOIN' => $sql_anounce_array['LEFT_JOIN'],
- 'WHERE' => 't.forum_id IN (' . $forum_id . ', 0)
- AND t.topic_type IN (' . POST_ANNOUNCE . ', ' . POST_GLOBAL . ')',
+ 'WHERE' => '(t.forum_id = ' . $forum_id . '
+ AND t.topic_type = ' . POST_ANNOUNCE . ') OR
+ (' . $db->sql_in_set('t.forum_id', $g_forum_ary) . '
+ AND t.topic_type = ' . POST_GLOBAL . ')',
'ORDER_BY' => 't.topic_time DESC',
));
@@ -377,16 +387,35 @@ if ($forum_data['forum_type'] == FORUM_POST)
$rowset[$row['topic_id']] = $row;
$announcement_list[] = $row['topic_id'];
- if ($row['topic_type'] == POST_GLOBAL)
+ if ($forum_id != $row['forum_id'])
{
- $global_announce_list[$row['topic_id']] = true;
+ $topics_count++;
+ $global_announce_forums[] = $row['forum_id'];
}
- else
+ }
+ $db->sql_freeresult($result);
+}
+
+$forum_tracking_info = array();
+
+if ($user->data['is_registered'])
+{
+ $forum_tracking_info[$forum_id] = $forum_data['mark_time'];
+
+ if (!empty($global_announce_forums) && $config['load_db_lastread'])
+ {
+ $sql = 'SELECT forum_id, mark_time
+ FROM ' . FORUMS_TRACK_TABLE . '
+ WHERE ' . $db->sql_in_set('forum_id', $global_announce_forums) . '
+ AND user_id = ' . $user->data['user_id'];
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
{
- $topics_count--;
+ $forum_tracking_info[$row['forum_id']] = $row['mark_time'];
}
+ $db->sql_freeresult($result);
}
- $db->sql_freeresult($result);
}
// If the user is trying to reach late pages, start searching from the end
@@ -546,45 +575,44 @@ if (sizeof($topic_list))
$mark_forum_read = true;
$mark_time_forum = 0;
- // Active topics?
- if ($s_display_active && sizeof($active_forum_ary))
+ // Generate topic forum list...
+ $topic_forum_list = array();
+ foreach ($rowset as $t_id => $row)
{
- // Generate topic forum list...
- $topic_forum_list = array();
- foreach ($rowset as $t_id => $row)
+ if (isset($forum_tracking_info[$row['forum_id']]))
{
- $topic_forum_list[$row['forum_id']]['forum_mark_time'] = ($config['load_db_lastread'] && $user->data['is_registered'] && isset($row['forum_mark_time'])) ? $row['forum_mark_time'] : 0;
- $topic_forum_list[$row['forum_id']]['topics'][] = $t_id;
+ $row['forum_mark_time'] = $forum_tracking_info[$row['forum_id']];
}
- if ($config['load_db_lastread'] && $user->data['is_registered'])
+ $topic_forum_list[$row['forum_id']]['forum_mark_time'] = ($config['load_db_lastread'] && $user->data['is_registered'] && isset($row['forum_mark_time'])) ? $row['forum_mark_time'] : 0;
+ $topic_forum_list[$row['forum_id']]['topics'][] = (int) $t_id;
+ }
+
+ if ($config['load_db_lastread'] && $user->data['is_registered'])
+ {
+ foreach ($topic_forum_list as $f_id => $topic_row)
{
- foreach ($topic_forum_list as $f_id => $topic_row)
- {
- $topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time']), false);
- }
+ $topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time']));
}
- else if ($config['load_anon_lastread'] || $user->data['is_registered'])
+ }
+ else if ($config['load_anon_lastread'] || $user->data['is_registered'])
+ {
+ foreach ($topic_forum_list as $f_id => $topic_row)
{
- foreach ($topic_forum_list as $f_id => $topic_row)
- {
- $topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics'], false);
- }
+ $topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics']);
}
-
- unset($topic_forum_list);
}
- else
+
+ unset($topic_forum_list);
+
+ if (!$s_display_active)
{
if ($config['load_db_lastread'] && $user->data['is_registered'])
{
- $topic_tracking_info = get_topic_tracking($forum_id, $topic_list, $rowset, array($forum_id => $forum_data['mark_time']), $global_announce_list);
$mark_time_forum = (!empty($forum_data['mark_time'])) ? $forum_data['mark_time'] : $user->data['user_lastmark'];
}
else if ($config['load_anon_lastread'] || $user->data['is_registered'])
{
- $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list, $global_announce_list);
-
if (!$user->data['is_registered'])
{
$user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0;
@@ -622,16 +650,16 @@ if (sizeof($topic_list))
topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type);
// Generate all the URIs ...
- $view_topic_url_params = 'f=' . $topic_forum_id . '&amp;t=' . $topic_id;
+ $view_topic_url_params = 'f=' . $row['forum_id'] . '&amp;t=' . $topic_id;
$view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params);
- $topic_unapproved = (!$row['topic_approved'] && $auth->acl_get('m_approve', $topic_forum_id)) ? true : false;
- $posts_unapproved = ($row['topic_approved'] && $row['topic_replies'] < $row['topic_replies_real'] && $auth->acl_get('m_approve', $topic_forum_id)) ? true : false;
+ $topic_unapproved = (!$row['topic_approved'] && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false;
+ $posts_unapproved = ($row['topic_approved'] && $row['topic_replies'] < $row['topic_replies_real'] && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false;
$u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&amp;mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . "&amp;t=$topic_id", true, $user->session_id) : '';
// Send vars to template
$template->assign_block_vars('topicrow', array(
- 'FORUM_ID' => $topic_forum_id,
+ 'FORUM_ID' => $row['forum_id'],
'TOPIC_ID' => $topic_id,
'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
@@ -649,6 +677,7 @@ if (sizeof($topic_list))
'VIEWS' => $row['topic_views'],
'TOPIC_TITLE' => censor_text($row['topic_title']),
'TOPIC_TYPE' => $topic_type,
+ 'FORUM_NAME' => (isset($row['forum_name'])) ? $row['forum_name'] : $forum_data['forum_name'],
'TOPIC_IMG_STYLE' => $folder_img,
'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt),
@@ -660,13 +689,13 @@ if (sizeof($topic_list))
'TOPIC_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '',
'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '',
'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '',
- 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $topic_forum_id) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
+ 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
'UNAPPROVED_IMG' => ($topic_unapproved || $posts_unapproved) ? $user->img('icon_topic_unapproved', ($topic_unapproved) ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '',
'S_TOPIC_TYPE' => $row['topic_type'],
'S_USER_POSTED' => (isset($row['topic_posted']) && $row['topic_posted']) ? true : false,
'S_UNREAD_TOPIC' => $unread_topic,
- 'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && $auth->acl_get('m_report', $topic_forum_id)) ? true : false,
+ 'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && $auth->acl_get('m_report', $row['forum_id'])) ? true : false,
'S_TOPIC_UNAPPROVED' => $topic_unapproved,
'S_POSTS_UNAPPROVED' => $posts_unapproved,
'S_HAS_POLL' => ($row['poll_start']) ? true : false,
@@ -681,7 +710,8 @@ if (sizeof($topic_list))
'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
'U_VIEW_TOPIC' => $view_topic_url,
- 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&amp;mode=reports&amp;f=' . $topic_forum_id . '&amp;t=' . $topic_id, true, $user->session_id),
+ 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']),
+ 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&amp;mode=reports&amp;f=' . $row['forum_id'] . '&amp;t=' . $topic_id, true, $user->session_id),
'U_MCP_QUEUE' => $u_mcp_queue,
'S_TOPIC_TYPE_SWITCH' => ($s_type_switch == $s_type_switch_test) ? -1 : $s_type_switch_test)
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index 6c188eeee3..53119e2ae7 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -152,26 +152,12 @@ if ($view && !$post_id)
else
{
$topic_id = $row['topic_id'];
-
- // Check for global announcement correctness?
- if (!$row['forum_id'] && !$forum_id)
- {
- trigger_error('NO_TOPIC');
- }
- else if ($row['forum_id'])
- {
- $forum_id = $row['forum_id'];
- }
+ $forum_id = $row['forum_id'];
}
}
}
- // Check for global announcement correctness?
- if ((!isset($row) || !$row['forum_id']) && !$forum_id)
- {
- trigger_error('NO_TOPIC');
- }
- else if (isset($row) && $row['forum_id'])
+ if (isset($row) && $row['forum_id'])
{
$forum_id = $row['forum_id'];
}
@@ -186,13 +172,6 @@ $sql_array = array(
'FROM' => array(FORUMS_TABLE => 'f'),
);
-// Firebird handles two columns of the same name a little differently, this
-// addresses that by forcing the forum_id to come from the forums table.
-if ($db->sql_layer === 'firebird')
-{
- $sql_array['SELECT'] = 'f.forum_id AS forum_id, ' . $sql_array['SELECT'];
-}
-
// The FROM-Order is quite important here, else t.* columns can not be correctly bound.
if ($post_id)
{
@@ -247,26 +226,8 @@ else
$sql_array['WHERE'] = "p.post_id = $post_id AND t.topic_id = p.topic_id";
}
-$sql_array['WHERE'] .= ' AND (f.forum_id = t.forum_id';
+$sql_array['WHERE'] .= ' AND f.forum_id = t.forum_id';
-if (!$forum_id)
-{
- // If it is a global announcement make sure to set the forum id to a postable forum
- $sql_array['WHERE'] .= ' OR (t.topic_type = ' . POST_GLOBAL . '
- AND f.forum_type = ' . FORUM_POST . ')';
-}
-else
-{
- $sql_array['WHERE'] .= ' OR (t.topic_type = ' . POST_GLOBAL . "
- AND f.forum_id = $forum_id)";
-}
-
-$sql_array['WHERE'] .= ')';
-
-// Join to forum table on topic forum_id unless topic forum_id is zero
-// whereupon we join on the forum_id passed as a parameter ... this
-// is done so navigation, forum name, etc. remain consistent with where
-// user clicked to view a global topic
$sql = $db->sql_build_query('SELECT', $sql_array);
$result = $db->sql_query($sql);
$topic_data = $db->sql_fetchrow($result);
@@ -1540,7 +1501,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 . '&amp;p=' . $row['post_id']) : '',
'U_MCP_REPORT' => ($auth->acl_get('m_report', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&amp;mode=report_details&amp;f=' . $forum_id . '&amp;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&amp;mode=approve_details&amp;f=' . $forum_id . '&amp;p=' . $row['post_id'], true, $user->session_id) : '',
- 'U_MINI_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['post_id']) . (($topic_data['topic_type'] == POST_GLOBAL) ? '&amp;f=' . $forum_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_PREV_POST_ID' => $prev_post_id,
'U_NOTES' => ($auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&amp;mode=user_notes&amp;u=' . $poster_id, true, $user->session_id) : '',
@@ -1616,34 +1577,13 @@ if (isset($user->data['session_page']) && !$user->data['is_bot'] && (strpos($use
}
}
-// Get last post time for all global announcements
-// to keep proper forums tracking
-if ($topic_data['topic_type'] == POST_GLOBAL)
-{
- $sql = 'SELECT topic_last_post_time as forum_last_post_time
- FROM ' . TOPICS_TABLE . '
- WHERE forum_id = 0
- ORDER BY topic_last_post_time DESC';
- $result = $db->sql_query_limit($sql, 1);
- $topic_data['forum_last_post_time'] = (int) $db->sql_fetchfield('forum_last_post_time');
- $db->sql_freeresult($result);
-
- $sql = 'SELECT mark_time as forum_mark_time
- FROM ' . FORUMS_TRACK_TABLE . '
- WHERE forum_id = 0
- AND user_id = ' . $user->data['user_id'];
- $result = $db->sql_query($sql);
- $topic_data['forum_mark_time'] = (int) $db->sql_fetchfield('forum_mark_time');
- $db->sql_freeresult($result);
-}
-
// Only mark topic if it's currently unread. Also make sure we do not set topic tracking back if earlier pages are viewed.
if (isset($topic_tracking_info[$topic_id]) && $topic_data['topic_last_post_time'] > $topic_tracking_info[$topic_id] && $max_post_time > $topic_tracking_info[$topic_id])
{
- markread('topic', (($topic_data['topic_type'] == POST_GLOBAL) ? 0 : $forum_id), $topic_id, $max_post_time);
+ markread('topic', $forum_id, $topic_id, $max_post_time);
// Update forum info
- $all_marked_read = update_forum_tracking_info((($topic_data['topic_type'] == POST_GLOBAL) ? 0 : $forum_id), $topic_data['forum_last_post_time'], (isset($topic_data['forum_mark_time'])) ? $topic_data['forum_mark_time'] : false, false);
+ $all_marked_read = update_forum_tracking_info($forum_id, $topic_data['forum_last_post_time'], (isset($topic_data['forum_mark_time'])) ? $topic_data['forum_mark_time'] : false, false);
}
else
{