diff options
author | David King <imkingdavid@gmail.com> | 2013-07-13 14:06:43 -0400 |
---|---|---|
committer | David King <imkingdavid@gmail.com> | 2013-07-13 14:06:43 -0400 |
commit | dfe0f6b1439ba13d433a2290a10450405428d3ef (patch) | |
tree | 9339f82c28cf3dd3495fdbe7f8e8a184d9974fd7 /phpBB/includes/functions_display.php | |
parent | 3be753cd5c64b80569f9c1189b39e8e47c248d89 (diff) | |
parent | 9d86385a362868bcd82901e1c7df18ba80eda945 (diff) | |
download | forums-dfe0f6b1439ba13d433a2290a10450405428d3ef.tar forums-dfe0f6b1439ba13d433a2290a10450405428d3ef.tar.gz forums-dfe0f6b1439ba13d433a2290a10450405428d3ef.tar.bz2 forums-dfe0f6b1439ba13d433a2290a10450405428d3ef.tar.xz forums-dfe0f6b1439ba13d433a2290a10450405428d3ef.zip |
Merge branch 'develop' into ticket/11215
* develop: (214 commits)
[ticket/10999] Fix assets_version in ACP
[prep-release-3.0.12] More changelog items for the 3.0.12 release.
[ticket/11687] Add assets_version to phpbb_config
[ticket/11670] Consistency with logo: Replace "phpBB(tm)" with "phpBB(R)".
[ticket/11674] Do not include vendor folder if there are no dependencies.
[ticket/11685] Remove logout confirmation page
[ticket/11684] Remove useless confirmation page after login and admin login
[ticket/9657] Define user before injecting
[ticket/9657] Remove old code
[ticket/9657] Keep approval state of posts/topics when copying them
[ticket/9657] Add functional tests for forking a copy
[ticket/9657] Add functional test for splitting topic
[ticket/11112] Do not change opensource.org link to https
[ticket/9657] Add functional test for restoring a post/topic
[ticket/11112] Use https for user-visible links to phpbb.com
[ticket/9657] Fix a little error when moving softdeleted topics
[ticket/9657] Add unit tests for softdeleting and moving posts/topics
[ticket/9657] Remove last references to m_restore permission
[ticket/9657] Fix english language :(
[ticket/9657] Notifications do not require emails or jabber anymore
...
Diffstat (limited to 'phpBB/includes/functions_display.php')
-rw-r--r-- | phpBB/includes/functions_display.php | 115 |
1 files changed, 55 insertions, 60 deletions
diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 9854cd6d70..143813e4ed 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -22,7 +22,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod { global $db, $auth, $user, $template; global $phpbb_root_path, $phpEx, $config; - global $request, $phpbb_dispatcher; + global $request, $phpbb_dispatcher, $phpbb_container; $forum_rows = $subforums = $forum_ids = $forum_ids_moderator = $forum_moderators = $active_forum_ary = array(); $parent_id = $visible_forums = 0; @@ -149,6 +149,8 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $forum_tracking_info = array(); $branch_root_id = $root_data['forum_id']; + $phpbb_content_visibility = $phpbb_container->get('content.visibility'); + while ($row = $db->sql_fetchrow($result)) { /** @@ -214,8 +216,9 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod } // Count the difference of real to public topics, so we can display an information to moderators - $row['forum_id_unapproved_topics'] = ($auth->acl_get('m_approve', $forum_id) && ($row['forum_topics_real'] != $row['forum_topics'])) ? $forum_id : 0; - $row['forum_topics'] = ($auth->acl_get('m_approve', $forum_id)) ? $row['forum_topics_real'] : $row['forum_topics']; + $row['forum_id_unapproved_topics'] = ($auth->acl_get('m_approve', $forum_id) && $row['forum_topics_unapproved']) ? $forum_id : 0; + $row['forum_posts'] = $phpbb_content_visibility->get_count('forum_posts', $row, $forum_id); + $row['forum_topics'] = $phpbb_content_visibility->get_count('forum_topics', $row, $forum_id); // Display active topics from this forum? if ($show_active && $row['forum_type'] == FORUM_POST && $auth->acl_get('f_read', $forum_id) && ($row['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS)) @@ -815,7 +818,7 @@ function gen_forum_auth_level($mode, $forum_id, $forum_status) ($auth->acl_get('f_post', $forum_id) && !$locked) ? $user->lang['RULES_POST_CAN'] : $user->lang['RULES_POST_CANNOT'], ($auth->acl_get('f_reply', $forum_id) && !$locked) ? $user->lang['RULES_REPLY_CAN'] : $user->lang['RULES_REPLY_CANNOT'], ($user->data['is_registered'] && $auth->acl_gets('f_edit', 'm_edit', $forum_id) && !$locked) ? $user->lang['RULES_EDIT_CAN'] : $user->lang['RULES_EDIT_CANNOT'], - ($user->data['is_registered'] && $auth->acl_gets('f_delete', 'm_delete', $forum_id) && !$locked) ? $user->lang['RULES_DELETE_CAN'] : $user->lang['RULES_DELETE_CANNOT'], + ($user->data['is_registered'] && ($auth->acl_gets('f_delete', 'm_delete', $forum_id) || $auth->acl_gets('f_softdelete', 'm_softdelete', $forum_id)) && !$locked) ? $user->lang['RULES_DELETE_CAN'] : $user->lang['RULES_DELETE_CANNOT'], ); if ($config['allow_attachments']) @@ -1005,7 +1008,7 @@ function display_reasons($reason_id = 0) function display_user_activity(&$userdata) { global $auth, $template, $db, $user; - global $phpbb_root_path, $phpEx; + global $phpbb_root_path, $phpEx, $phpbb_container; // Do not display user activity for users having more than 5000 posts... if ($userdata['user_posts'] > 5000) @@ -1015,73 +1018,65 @@ function display_user_activity(&$userdata) $forum_ary = array(); - // Do not include those forums the user is not having read access to... - $forum_read_ary = $auth->acl_getf('!f_read'); - - foreach ($forum_read_ary as $forum_id => $not_allowed) + $forum_read_ary = $auth->acl_getf('f_read'); + foreach ($forum_read_ary as $forum_id => $allowed) { - if ($not_allowed['f_read']) + if ($allowed['f_read']) { $forum_ary[] = (int) $forum_id; } } - $forum_ary = array_unique($forum_ary); - $forum_sql = (sizeof($forum_ary)) ? 'AND ' . $db->sql_in_set('forum_id', $forum_ary, true) : ''; - - $fid_m_approve = $auth->acl_getf('m_approve', true); - $sql_m_approve = (!empty($fid_m_approve)) ? 'OR ' . $db->sql_in_set('forum_id', array_keys($fid_m_approve)) : ''; - - // Obtain active forum - $sql = 'SELECT forum_id, COUNT(post_id) AS num_posts - FROM ' . POSTS_TABLE . ' - WHERE poster_id = ' . $userdata['user_id'] . " - AND post_postcount = 1 - AND (post_approved = 1 - $sql_m_approve) - $forum_sql - GROUP BY forum_id - ORDER BY num_posts DESC"; - $result = $db->sql_query_limit($sql, 1); - $active_f_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); + $forum_ary = array_diff($forum_ary, $user->get_passworded_forums()); - if (!empty($active_f_row)) + $active_f_row = $active_t_row = array(); + if (!empty($forum_ary)) { - $sql = 'SELECT forum_name - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $active_f_row['forum_id']; - $result = $db->sql_query($sql, 3600); - $active_f_row['forum_name'] = (string) $db->sql_fetchfield('forum_name'); + $phpbb_content_visibility = $phpbb_container->get('content.visibility'); + + // Obtain active forum + $sql = 'SELECT forum_id, COUNT(post_id) AS num_posts + FROM ' . POSTS_TABLE . ' + WHERE poster_id = ' . $userdata['user_id'] . ' + AND post_postcount = 1 + AND ' . $phpbb_content_visibility->get_forums_visibility_sql('post', $forum_ary) . ' + GROUP BY forum_id + ORDER BY num_posts DESC'; + $result = $db->sql_query_limit($sql, 1); + $active_f_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - } - // Obtain active topic - // We need to exclude passworded forums here so we do not leak the topic title - $forum_ary_topic = array_unique(array_merge($forum_ary, $user->get_passworded_forums())); - $forum_sql_topic = (!empty($forum_ary_topic)) ? 'AND ' . $db->sql_in_set('forum_id', $forum_ary_topic, true) : ''; - - $sql = 'SELECT topic_id, COUNT(post_id) AS num_posts - FROM ' . POSTS_TABLE . ' - WHERE poster_id = ' . $userdata['user_id'] . " - AND post_postcount = 1 - AND (post_approved = 1 - $sql_m_approve) - $forum_sql_topic - GROUP BY topic_id - ORDER BY num_posts DESC"; - $result = $db->sql_query_limit($sql, 1); - $active_t_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); + if (!empty($active_f_row)) + { + $sql = 'SELECT forum_name + FROM ' . FORUMS_TABLE . ' + WHERE forum_id = ' . $active_f_row['forum_id']; + $result = $db->sql_query($sql, 3600); + $active_f_row['forum_name'] = (string) $db->sql_fetchfield('forum_name'); + $db->sql_freeresult($result); + } - if (!empty($active_t_row)) - { - $sql = 'SELECT topic_title - FROM ' . TOPICS_TABLE . ' - WHERE topic_id = ' . $active_t_row['topic_id']; - $result = $db->sql_query($sql); - $active_t_row['topic_title'] = (string) $db->sql_fetchfield('topic_title'); + // Obtain active topic + $sql = 'SELECT topic_id, COUNT(post_id) AS num_posts + FROM ' . POSTS_TABLE . ' + WHERE poster_id = ' . $userdata['user_id'] . ' + AND post_postcount = 1 + AND ' . $phpbb_content_visibility->get_forums_visibility_sql('post', $forum_ary) . ' + GROUP BY topic_id + ORDER BY num_posts DESC'; + $result = $db->sql_query_limit($sql, 1); + $active_t_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); + + if (!empty($active_t_row)) + { + $sql = 'SELECT topic_title + FROM ' . TOPICS_TABLE . ' + WHERE topic_id = ' . $active_t_row['topic_id']; + $result = $db->sql_query($sql); + $active_t_row['topic_title'] = (string) $db->sql_fetchfield('topic_title'); + $db->sql_freeresult($result); + } } $userdata['active_t_row'] = $active_t_row; |