当前位置: 首页>>代码示例>>PHP>>正文


PHP get_unread_topics函数代码示例

本文整理汇总了PHP中get_unread_topics函数的典型用法代码示例。如果您正苦于以下问题:PHP get_unread_topics函数的具体用法?PHP get_unread_topics怎么用?PHP get_unread_topics使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_unread_topics函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_forum_func


//.........这里部分代码省略.........
    foreach ($forum_rows as $id => $value) {
        if (!in_array($value['parent_id'], $fids)) {
            unset($forum_rows[$id]);
        } else {
            if ($value['left_id'] > $value['right_id']) {
                unset($forum_rows[$id]);
            } else {
                $fids[] = $id;
            }
        }
    }
    while (empty($forum_rows[$root_forum_id]['child']) && count($forum_rows) > 1) {
        $current_parent_id = -1;
        $leaves_forum = array();
        foreach ($forum_rows as $row) {
            $row_parent_id = $row['parent_id'];
            if ($row_parent_id != $current_parent_id) {
                if (isset($leaves_forum[$row_parent_id])) {
                    $leaves_forum[$row_parent_id] = array();
                } else {
                    if (isset($leaves_forum[$forum_rows[$row_parent_id]['parent_id']])) {
                        $leaves_forum[$forum_rows[$row_parent_id]['parent_id']] = array();
                    }
                    $leaves_forum[$row_parent_id][] = $row['forum_id'];
                }
                $current_parent_id = $row_parent_id;
            } else {
                if ($row_parent_id == $current_parent_id) {
                    if (!empty($leaves_forum[$row_parent_id])) {
                        $leaves_forum[$row_parent_id][] = $row['forum_id'];
                    }
                }
            }
        }
        foreach ($leaves_forum as $node_forum_id => $leaves) {
            foreach ($leaves as $forum_id) {
                $forum =& $forum_rows[$forum_id];
                if (function_exists('get_unread_topics')) {
                    $unread_count = count(get_unread_topics(false, "AND t.forum_id = {$forum_id}"));
                } else {
                    $unread_count = count(tt_get_unread_topics(false, "AND t.forum_id = {$forum_id}"));
                }
                $forum['unread_count'] += $unread_count;
                if ($forum['unread_count']) {
                    $forum_rows[$forum['parent_id']]['unread_count'] += $forum['unread_count'];
                }
                $forum_type = $forum['forum_link'] ? 'link' : ($forum['forum_type'] != FORUM_POST ? 'category' : 'forum');
                if ($logo_icon_name = tp_get_forum_icon($forum_id, $forum_type, $forum['forum_status'], $forum['unread_count'])) {
                    $logo_url = $phpbb_home . $config['tapatalkdir'] . '/forum_icons/' . $logo_icon_name;
                } else {
                    if ($forum['forum_image']) {
                        if (preg_match('#^https?://#i', $forum['forum_image'])) {
                            $logo_url = $forum['forum_image'];
                        } else {
                            $logo_url = $phpbb_home . $forum['forum_image'];
                        }
                    } else {
                        $logo_url = '';
                    }
                }
                $xmlrpc_forum = array('forum_id' => new xmlrpcval($forum_id), 'forum_name' => new xmlrpcval(basic_clean($forum['forum_name']), 'base64'), 'parent_id' => new xmlrpcval($node_forum_id), 'logo_url' => new xmlrpcval($logo_url), 'url' => new xmlrpcval($forum['forum_link']));
                if ($forum['unread_count']) {
                    $xmlrpc_forum['unread_count'] = new xmlrpcval($forum['unread_count'], 'int');
                }
                if ($forum['unread_count']) {
                    $xmlrpc_forum['new_post'] = new xmlrpcval(true, 'boolean');
                }
                if ($forum['forum_password']) {
                    $xmlrpc_forum['is_protected'] = new xmlrpcval(true, 'boolean');
                }
                if (!empty($forum['can_subscribe'])) {
                    $xmlrpc_forum['can_subscribe'] = new xmlrpcval(true, 'boolean');
                } else {
                    $xmlrpc_forum['can_subscribe'] = new xmlrpcval(false, 'boolean');
                }
                if (!empty($forum['is_subscribed'])) {
                    $xmlrpc_forum['is_subscribed'] = new xmlrpcval(true, 'boolean');
                } else {
                    $xmlrpc_forum['is_subscribed'] = new xmlrpcval(false, 'boolean');
                }
                if ($forum['forum_type'] != FORUM_POST) {
                    $xmlrpc_forum['sub_only'] = new xmlrpcval(true, 'boolean');
                }
                if ($return_description) {
                    $description = smiley_text($forum['forum_desc'], true);
                    $description = generate_text_for_display($description, $forum['forum_desc_uid'], $forum['forum_desc_bitfield'], $forum['forum_desc_options']);
                    $description = preg_replace('/<br *?\\/?>/i', "\n", $description);
                    $xmlrpc_forum['description'] = new xmlrpcval(basic_clean($description), 'base64');
                }
                if (isset($forum['child'])) {
                    $xmlrpc_forum['child'] = new xmlrpcval($forum['child'], 'array');
                }
                $forum_rows[$node_forum_id]['child'][] = new xmlrpcval($xmlrpc_forum, 'struct');
                unset($forum_rows[$forum_id]);
            }
        }
    }
    $response = new xmlrpcval($forum_rows[$root_forum_id]['child'], 'array');
    return new xmlrpcresp($response);
}
开发者ID:danielgospodinow,项目名称:GamingZone,代码行数:101,代码来源:get_forum.php

示例2: display_forums

/**
* Display Forums
*/
function display_forums($root_data = '', $display_moderators = true, $return_moderators = false)
{
    global $db, $auth, $user, $template;
    global $phpbb_root_path, $phpEx, $config;
    $forum_rows = $subforums = $forum_ids = $forum_ids_moderator = $forum_moderators = $active_forum_ary = array();
    $parent_id = $visible_forums = 0;
    $sql_from = '';
    // Mark forums read?
    $mark_read = request_var('mark', '');
    if ($mark_read == 'all') {
        $mark_read = '';
    }
    if (!$root_data) {
        if ($mark_read == 'forums') {
            $mark_read = 'all';
        }
        $root_data = array('forum_id' => 0);
        $sql_where = '';
    } else {
        $sql_where = 'left_id > ' . $root_data['left_id'] . ' AND left_id < ' . $root_data['right_id'];
    }
    // Display list of active topics for this category?
    $show_active = isset($root_data['forum_flags']) && $root_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS ? true : false;
    $sql_array = array('SELECT' => 'f.*', 'FROM' => array(FORUMS_TABLE => 'f'), 'LEFT_JOIN' => array());
    if ($config['load_db_lastread'] && $user->data['is_registered']) {
        $sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND ft.forum_id = f.forum_id');
        $sql_array['SELECT'] .= ', ft.mark_time';
    } else {
        if ($config['load_anon_lastread'] || $user->data['is_registered']) {
            $tracking_topics = isset($_COOKIE[$config['cookie_name'] . '_track']) ? STRIP ? stripslashes($_COOKIE[$config['cookie_name'] . '_track']) : $_COOKIE[$config['cookie_name'] . '_track'] : '';
            $tracking_topics = $tracking_topics ? tracking_unserialize($tracking_topics) : array();
            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;
            }
        }
    }
    if ($show_active) {
        $sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_ACCESS_TABLE => 'fa'), 'ON' => "fa.forum_id = f.forum_id AND fa.session_id = '" . $db->sql_escape($user->session_id) . "'");
        $sql_array['SELECT'] .= ', fa.user_id';
    }
    $sql = $db->sql_build_query('SELECT', array('SELECT' => $sql_array['SELECT'], 'FROM' => $sql_array['FROM'], 'LEFT_JOIN' => $sql_array['LEFT_JOIN'], 'WHERE' => $sql_where, 'ORDER_BY' => 'f.left_id'));
    $result = $db->sql_query($sql);
    $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'];
        // Mark forums read?
        if ($mark_read == 'forums' || $mark_read == 'all') {
            if ($auth->acl_get('f_list', $forum_id)) {
                $forum_ids[] = $forum_id;
                continue;
            }
        }
        // Category with no members
        if ($row['forum_type'] == FORUM_CAT && $row['left_id'] + 1 == $row['right_id']) {
            continue;
        }
        // Skip branch
        if (isset($right_id)) {
            if ($row['left_id'] < $right_id) {
                continue;
            }
            unset($right_id);
        }
        if (!$auth->acl_get('f_list', $forum_id)) {
            // if the user does not have permissions to list this forum, skip everything until next branch
            $right_id = $row['right_id'];
            continue;
        }
        $forum_ids[] = $forum_id;
        if ($config['load_db_lastread'] && $user->data['is_registered']) {
            $forum_tracking_info[$forum_id] = !empty($row['mark_time']) ? $row['mark_time'] : $user->data['user_lastmark'];
        } else {
            if ($config['load_anon_lastread'] || $user->data['is_registered']) {
                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;
                }
                $forum_tracking_info[$forum_id] = isset($tracking_topics['f'][$forum_id]) ? (int) (base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']) : $user->data['user_lastmark'];
            }
        }
        // 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'];
        // 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) {
            if (!isset($active_forum_ary['forum_topics'])) {
                $active_forum_ary['forum_topics'] = 0;
            }
            if (!isset($active_forum_ary['forum_posts'])) {
//.........这里部分代码省略.........
开发者ID:ubick,项目名称:lorekeepers.org,代码行数:101,代码来源:functions_display.php

示例3: str_replace

				$l_search_title = $user->lang['SEARCH_UNREAD'];
				// force sorting
				$show_results = 'topics';
				$sort_key = 't';
				$sort_by_sql['t'] = 't.topic_last_post_time';
				$sql_sort = 'ORDER BY ' . $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC');

				$sql_where = 'AND t.topic_moved_id = 0
					' . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . '
					' . ((sizeof($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '');

				gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
				$s_sort_key = $s_sort_dir = $u_sort_param = $s_limit_days = '';

				$unread_list = array();
				$unread_list = get_unread_topics($user->data['user_id'], $sql_where, $sql_sort);

				if (!empty($unread_list))
				{
					$sql = 'SELECT t.topic_id
						FROM ' . TOPICS_TABLE . ' t
						WHERE ' . $db->sql_in_set('t.topic_id', array_keys($unread_list)) . "
						$sql_sort";
					$field = 'topic_id';
				}
			break;

			case 'newposts':
				$l_search_title = $user->lang['SEARCH_NEW'];
				// force sorting
				$show_results = (request_var('sr', 'topics') == 'posts') ? 'posts' : 'topics';
开发者ID:renemilk,项目名称:spring-website,代码行数:31,代码来源:search.php

示例4: if

	{
		if ($sql)
		{
			// Only return up to $total_matches_limit+1 ids (the last one will be removed later)
			$result = $db->sql_query_limit($sql, $total_matches_limit + 1);

			while ($row = $db->sql_fetchrow($result))
			{
				$id_ary[] = (int) $row[$field];
			}
			$db->sql_freeresult($result);
		}
		else if ($search_id == 'unreadposts')
		{
			// Only return up to $total_matches_limit+1 ids (the last one will be removed later)
			$id_ary = array_keys(get_unread_topics($user->data['user_id'], $sql_where, $sql_sort, $total_matches_limit + 1));
		}
		else
		{
			$search_id = '';
		}

		$total_match_count = sizeof($id_ary);
		if ($total_match_count)
		{
			// Limit the number to $total_matches_limit for pre-made searches
			if ($total_match_count > $total_matches_limit)
			{
				$found_more_search_matches = true;
				$total_match_count = $total_matches_limit;
			}
开发者ID:abhinay100,项目名称:phpbb_app,代码行数:31,代码来源:search.php

示例5: while

 $total_match_count = 0;
 if ($search_id) {
     if ($sql) {
         // only return up to 1000 ids (the last one will be removed later)
         $result = $db->sql_query_limit($sql, 1001 - $start, $start);
         while ($row = $db->sql_fetchrow($result)) {
             $id_ary[] = (int) $row[$field];
         }
         $db->sql_freeresult($result);
         $total_match_count = sizeof($id_ary) + $start;
         $id_ary = array_slice($id_ary, 0, $per_page);
     } else {
         if ($search_id == 'unreadposts') {
             // tapatalk update
             if (function_exists('get_unread_topics')) {
                 $id_ary = array_keys(get_unread_topics($user->data['user_id'], $sql_where, $sql_sort, 1001 - $request_params[0], $request_params[0]));
             } else {
                 $id_ary = array_keys(tt_get_unread_topics($user->data['user_id'], $sql_where, $sql_sort, 1001 - $request_params[0], $request_params[0]));
             }
             $total_match_count = sizeof($id_ary) + $start;
             $id_ary = array_slice($id_ary, 0, $per_page);
         } else {
             $search_id = '';
         }
     }
 }
 sort($ex_fid_ary);
 sort($m_approve_fid_ary);
 sort($author_id_ary);
 if (!empty($search->search_query)) {
     // tapatalk change
开发者ID:danielgospodinow,项目名称:GamingZone,代码行数:31,代码来源:search.php

示例6: get_template_side

    /**
     * {@inheritdoc}
     */
    public function get_template_side($module_id)
    {
        if (!function_exists('phpbb_get_user_rank')) {
            include $this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext;
        }
        if ($this->user->data['is_registered']) {
            //
            // + new posts since last visit & you post number
            //
            $ex_fid_ary = array_unique(array_merge(array_keys($this->auth->acl_getf('!f_read', true)), array_keys($this->auth->acl_getf('!f_search', true))));
            if ($this->auth->acl_get('m_approve')) {
                $m_approve_fid_sql = '';
            } else {
                if ($this->auth->acl_getf_global('m_approve')) {
                    $m_approve_fid_ary = array_diff(array_keys($this->auth->acl_getf('!m_approve', true)), $ex_fid_ary);
                    $m_approve_fid_sql = ' AND (p.post_visibility = 1' . (sizeof($m_approve_fid_ary) ? ' OR ' . $this->db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) : '') . ')';
                } else {
                    $m_approve_fid_sql = ' AND p.post_visibility = 1';
                }
            }
            $sql = 'SELECT COUNT(DISTINCT t.topic_id) as total
						FROM ' . TOPICS_TABLE . ' t
						WHERE t.topic_last_post_time > ' . (int) $this->user->data['user_lastvisit'] . '
							AND t.topic_moved_id = 0
							' . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . '
							' . (sizeof($ex_fid_ary) ? 'AND ' . $this->db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '');
            $result = $this->db->sql_query($sql, 600);
            $new_posts_count = (int) $this->db->sql_fetchfield('total');
            $this->db->sql_freeresult($result);
            // unread posts
            $sql_where = 'AND t.topic_moved_id = 0
							' . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . '
							' . (sizeof($ex_fid_ary) ? 'AND ' . $this->db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '');
            $unread_list = get_unread_topics($this->user->data['user_id'], $sql_where, 'ORDER BY t.topic_id DESC');
            $unread_posts_count = sizeof($unread_list);
            // Get user avatar and rank
            $user_id = $this->user->data['user_id'];
            $username = $this->user->data['username'];
            $colour = $this->user->data['user_colour'];
            $avatar_img = phpbb_get_avatar(\phpbb\avatar\manager::clean_row($this->user->data, 'user'), 'USER_AVATAR');
            $rank_data = phpbb_get_user_rank($this->user->data, $this->user->data['user_posts']);
            // Assign specific vars
            $this->template->assign_vars(array('L_NEW_POSTS' => $this->user->lang['SEARCH_NEW'] . '&nbsp;(' . $new_posts_count . ')', 'L_SELF_POSTS' => $this->user->lang['SEARCH_SELF'] . '&nbsp;(' . $this->user->data['user_posts'] . ')', 'L_UNREAD_POSTS' => $this->user->lang['SEARCH_UNREAD'] . '&nbsp;(' . $unread_posts_count . ')', 'B3P_AVATAR_IMG' => $avatar_img, 'B3P_RANK_TITLE' => $rank_data['title'], 'B3P_RANK_IMG' => $rank_data['img'], 'RANK_IMG_SRC' => $rank_data['img_src'], 'USERNAME_FULL' => get_username_string('full', $user_id, $username, $colour), 'U_VIEW_PROFILE' => get_username_string('profile', $user_id, $username, $colour), 'U_NEW_POSTS' => append_sid("{$this->phpbb_root_path}search.{$this->php_ext}", 'search_id=newposts'), 'U_SELF_POSTS' => append_sid("{$this->phpbb_root_path}search.{$this->php_ext}", 'search_id=egosearch'), 'U_UNREAD_POSTS' => append_sid("{$this->phpbb_root_path}search.{$this->php_ext}", 'search_id=unreadposts'), 'U_UM_BOOKMARKS' => $this->config['allow_bookmarks'] ? append_sid("{$this->phpbb_root_path}ucp.{$this->php_ext}", 'i=main&amp;mode=bookmarks') : '', 'U_UM_MAIN_SUBSCRIBED' => append_sid("{$this->phpbb_root_path}ucp.{$this->php_ext}", 'i=main&amp;mode=subscribed'), 'U_UM_MCP' => $this->auth->acl_get('m_') || $this->auth->acl_getf_global('m_') ? append_sid("{$this->phpbb_root_path}mcp.{$this->php_ext}", 'i=main&amp;mode=front', true, $this->user->session_id) : '', 'S_DISPLAY_SUBSCRIPTIONS' => $this->config['allow_topic_notify'] || $this->config['allow_forum_notify'] ? true : false));
            return 'user_menu_side.html';
        } else {
            /*
             * Assign specific vars
             * Need to remove web root path as ucp.php will do the
             * redirect
             */
            $this->template->assign_vars(array('U_PORTAL_REDIRECT' => $this->path_helper->remove_web_root_path($this->controller_helper->route('board3_portal_controller')), 'S_DISPLAY_FULL_LOGIN' => true, 'S_AUTOLOGIN_ENABLED' => $this->config['allow_autologin'] ? true : false, 'S_LOGIN_ACTION' => append_sid("{$this->phpbb_root_path}ucp.{$this->php_ext}", 'mode=login'), 'S_SHOW_REGISTER' => $this->config['board3_user_menu_register_' . $module_id] ? true : false));
            return 'login_box_side.html';
        }
    }
开发者ID:alhitary,项目名称:Board3-Portal,代码行数:57,代码来源:user_menu.php

示例7: display_recent_topics

    public function display_recent_topics($tpl_loopname = 'recent_topics', $spec_forum_id = 0, $include_subforums = true)
    {
        $this->user->add_lang_ext('paybas/recenttopics', 'recenttopics');
        /**
         * Set some internal needed variables
         */
        $topics_per_page = $this->config['rt_number'];
        $num_pages = $this->config['rt_page_number'];
        $min_topic_level = $this->config['rt_min_topic_level'];
        $excluded_topics = $this->config['rt_anti_topics'];
        $display_parent_forums = $this->config['rt_parents'];
        $unread_only = $this->config['rt_unreadonly'];
        $sort_topics = $this->config['rt_sort_start_time'] ? 'topic_time' : 'topic_last_post_time';
        $persistent_display = $this->config['rt_persistent_display'];
        if ($persistent_display) {
            $this->template->assign_vars(array(strtoupper($tpl_loopname) . '_DISPLAY' => true));
        }
        $start = $this->request->variable($tpl_loopname . '_start', 0);
        $excluded_topic_ids = explode(', ', $excluded_topics);
        $total_limit = $topics_per_page * $num_pages;
        if (!function_exists('display_forums')) {
            include $this->root_path . 'includes/functions_display.' . $this->phpEx;
        }
        /**
         * Get the forums we take our topics from
         */
        // Get the allowed forums
        $forum_ary = array();
        $forum_read_ary = $this->auth->acl_getf('f_read');
        foreach ($forum_read_ary as $forum_id => $allowed) {
            if ($allowed['f_read']) {
                $forum_ary[] = (int) $forum_id;
            }
        }
        $forum_ids = array_unique($forum_ary);
        if (!sizeof($forum_ids)) {
            // No forums with f_read
            return;
        }
        $spec_forum_ary = array();
        if ($spec_forum_id) {
            // Only take a special-forum
            if (!$include_subforums) {
                if (!in_array($spec_forum_id, $forum_ids)) {
                    return;
                }
                $forum_ids = array();
                $sql = 'SELECT 1 as display_forum
					FROM ' . FORUMS_TABLE . '
					WHERE forum_id = ' . intval($spec_forum_id) . '
						AND forum_recent_topics = 1';
                $result = $this->db->sql_query_limit($sql, 1);
                $display_forum = (bool) $this->db->sql_fetchfield('display_forum');
                $this->db->sql_freeresult($result);
                if ($display_forum) {
                    $forum_ids = array($spec_forum_id);
                }
            } else {
                // ... and it's subforums
                $sql = 'SELECT f2.forum_id
					FROM ' . FORUMS_TABLE . ' f1
					LEFT JOIN ' . FORUMS_TABLE . " f2\n\t\t\t\t\t\tON (f2.left_id BETWEEN f1.left_id AND f1.right_id\n\t\t\t\t\t\t\tAND f2.forum_recent_topics = 1)\n\t\t\t\t\tWHERE f1.forum_id = {$spec_forum_id}\n\t\t\t\t\t\tAND f1.forum_recent_topics = 1\n\t\t\t\t\tORDER BY f2.left_id DESC";
                $result = $this->db->sql_query($sql);
                while ($row = $this->db->sql_fetchrow($result)) {
                    $spec_forum_ary[] = $row['forum_id'];
                }
                $this->db->sql_freeresult($result);
                $forum_ids = array_intersect($forum_ids, $spec_forum_ary);
                if (!sizeof($forum_ids)) {
                    return;
                }
            }
        } else {
            $sql = 'SELECT forum_id
				FROM ' . FORUMS_TABLE . '
				WHERE ' . $this->db->sql_in_set('forum_id', $forum_ids) . '
					AND forum_recent_topics = 1';
            $result = $this->db->sql_query($sql);
            $forum_ids = array();
            while ($row = $this->db->sql_fetchrow($result)) {
                $forum_ids[] = $row['forum_id'];
            }
            $this->db->sql_freeresult($result);
        }
        // No forums with f_read or recent topics enabled
        if (!sizeof($forum_ids)) {
            return;
        }
        // Remove duplicated ids
        $forum_ids = array_unique($forum_ids);
        $forums = $topic_list = array();
        $topics_count = 0;
        $obtain_icons = false;
        // Either use the phpBB core function to get unread topics, or the custom function for default behavior
        if ($unread_only && $this->user->data['user_id'] != ANONYMOUS) {
            // Get unread topics
            $sql_extra = ' AND ' . $this->db->sql_in_set('t.topic_id', $excluded_topic_ids, true);
            $sql_extra .= ' AND ' . $this->content_visibility->get_forums_visibility_sql('topic', $forum_ids, $table_alias = 't.');
            $unread_topics = get_unread_topics(false, $sql_extra, '', $total_limit);
            foreach ($unread_topics as $topic_id => $mark_time) {
//.........这里部分代码省略.........
开发者ID:NuLeaf,项目名称:nuleaf-forum,代码行数:101,代码来源:recenttopics.php

示例8: get_unread_topics_count

 /**
  * Get number of topics that have unread posts. Returns a negative number to signal error.
  */
 protected function get_unread_topics_count($limit, $exist_unread)
 {
     if (!$this->config['load_db_lastread'] || !$this->user->data['is_registered'] || $this->user->data['is_bot']) {
         return -1;
     }
     $unread_topics_count = 0;
     if (is_null($exist_unread) || $exist_unread && $limit > 1) {
         $forum_ids = array_unique(array_keys($this->auth->acl_getf('f_read')));
         if (sizeof($forum_ids)) {
             $sql_where = ' AND ' . $this->content_visibility->get_forums_visibility_sql('topic', $forum_ids, $table_alias = 't.');
             $sql_sort = '';
             $unread_topics_count = sizeof(get_unread_topics($this->user->data['user_id'], $sql_where, $sql_sort, $limit));
         }
     } else {
         $unread_topics_count = $exist_unread ? 1 : 0;
     }
     return $unread_topics_count;
 }
开发者ID:phpbb-es,项目名称:phpbb-ext-markpostunread,代码行数:21,代码来源:core.php

示例9: get_template_side

	public function get_template_side($module_id)
	{
		global $config, $template, $user, $auth, $db, $phpEx, $phpbb_root_path;

		if (!function_exists('display_forums'))
		{
			include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
		}

		if ($user->data['is_registered'])
		{
			//
			// + new posts since last visit & you post number
			//
			$ex_fid_ary = array_unique(array_merge(array_keys($auth->acl_getf('!f_read', true)), array_keys($auth->acl_getf('!f_search', true))));

			if ($auth->acl_get('m_approve'))
			{
				$m_approve_fid_ary = array(-1);
				$m_approve_fid_sql = '';
			}
			else if ($auth->acl_getf_global('m_approve'))
			{
				$m_approve_fid_ary = array_diff(array_keys($auth->acl_getf('!m_approve', true)), $ex_fid_ary);
				$m_approve_fid_sql = ' AND (p.post_approved = 1' . ((sizeof($m_approve_fid_ary)) ? ' OR ' . $db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) : '') . ')';
			}
			else
			{
				$m_approve_fid_ary = array();
				$m_approve_fid_sql = ' AND p.post_approved = 1';
			}

			$sql = 'SELECT COUNT(distinct t.topic_id) as total
						FROM ' . TOPICS_TABLE . ' t
						WHERE t.topic_last_post_time > ' . $user->data['user_lastvisit'] . '
							AND t.topic_moved_id = 0
							' . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . '
							' . ((sizeof($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '');
			$result = $db->sql_query($sql);
			$new_posts_count = (int) $db->sql_fetchfield('total');
			$db->sql_freeresult($result);

			// unread posts
			$sql_where = 'AND t.topic_moved_id = 0
							' . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . '
							' . ((sizeof($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '');
			$unread_list = array();
			$unread_list = get_unread_topics($user->data['user_id'], $sql_where, 'ORDER BY t.topic_id DESC');
			$unread_posts_count = sizeof($unread_list);


			// Get user avatar and rank
			$user_id = $user->data['user_id'];
			$username = $user->data['username'];
			$colour = $user->data['user_colour'];
			$avatar_img = get_user_avatar($user->data['user_avatar'], $user->data['user_avatar_type'], $user->data['user_avatar_width'], $user->data['user_avatar_height']);
			$rank_title = $rank_img = '';
			get_user_rank($user->data['user_rank'], $user->data['user_posts'], $rank_title, $rank_img, $rank_img_src);

			// Assign specific vars
			$template->assign_vars(array(
				'L_NEW_POSTS'	=> $user->lang['SEARCH_NEW'] . '&nbsp;(' . $new_posts_count . ')',
				'L_SELF_POSTS'	=> $user->lang['SEARCH_SELF'] . '&nbsp;(' . $user->data['user_posts'] . ')',
				'L_UNREAD_POSTS'=> $user->lang['SEARCH_UNREAD'] . '&nbsp;(' . $unread_posts_count . ')',

				'B3P_AVATAR_IMG'    => $avatar_img,
				'B3P_RANK_TITLE'    => $rank_title,
				'B3P_RANK_IMG'        => $rank_img,
				'RANK_IMG_SRC'    => $rank_img_src,

				'USERNAME_FULL'        => get_username_string('full', $user_id, $username, $colour),
				'U_VIEW_PROFILE'	=> get_username_string('profile', $user_id, $username, $colour),

				'U_NEW_POSTS'			=> append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=newposts'),
				'U_SELF_POSTS'			=> append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=egosearch'),
				'U_UNREAD_POSTS'		=> append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unreadposts'),
				'U_UM_BOOKMARKS'		=> ($config['allow_bookmarks']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=main&amp;mode=bookmarks') : '',
				'U_UM_MAIN_SUBSCRIBED'	=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=main&amp;mode=subscribed'),
				'U_UM_MCP'				=> ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&amp;mode=front', true, $user->session_id) : '',
				'S_DISPLAY_SUBSCRIPTIONS' => ($config['allow_topic_notify'] || $config['allow_forum_notify']) ? true : false,
			));

			return 'user_menu_side.html';
		}
		else
		{
			// Assign specific vars
			$template->assign_vars(array(
				'U_PORTAL'				=> append_sid("{$phpbb_root_path}portal.$phpEx"),
				'S_DISPLAY_FULL_LOGIN'	=> true,
				'S_AUTOLOGIN_ENABLED'	=> ($config['allow_autologin']) ? true : false,
				'S_LOGIN_ACTION'		=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'),
				'S_SHOW_REGISTER'	=> ($config['board3_user_menu_register_' . $module_id]) ? true : false,
			));

			return 'login_box_side.html';
		}
	}
开发者ID:gonzo1247,项目名称:hitman_roa,代码行数:98,代码来源:portal_user_menu.php

示例10: display_forums_categories

/**
* This code is only processed for the portal page in order to allow displaying
* of categories, it is not required for normal phpbb pages as the data is
* available in the data pool (globally)...
*
* The function simply reuses phpbb code but will be updated when block code is rewrittten as classes
* Will use dependency injection later
*/
function display_forums_categories()
{
    // A rewrite for phpBB3 display_forums code drastically reduced to provide categories block with data //
    global $db, $auth, $user, $template;
    global $phpbb_root_path, $phpEx, $config;
    $default_icon = $phpbb_root_path . 'ext/phpbbireland/portal/images/forum_icons/default.png';
    $forum_rows = $subforums = $forum_ids = $active_forum_ary = array();
    // $forum_ids_moderator = $forum_moderators = $active_forum_ary = array();
    $parent_id = $visible_forums = 0;
    $sql_from = '';
    $root_data = array('forum_id' => 0);
    $sql_where = '';
    $sql_array = array('SELECT' => 'f.*', 'FROM' => array(FORUMS_TABLE => 'f'), 'LEFT_JOIN' => array());
    $sql = $db->sql_build_query('SELECT', array('SELECT' => $sql_array['SELECT'], 'FROM' => $sql_array['FROM'], 'LEFT_JOIN' => $sql_array['LEFT_JOIN'], 'WHERE' => $sql_where, 'ORDER_BY' => 'f.left_id'));
    $result = $db->sql_query($sql);
    $branch_root_id = $root_data['forum_id'];
    $cnt = 0;
    // 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'];
        // Category with no members
        if ($row['forum_type'] == FORUM_CAT && $row['left_id'] + 1 == $row['right_id']) {
            continue;
        }
        // Skip branch
        if (isset($right_id)) {
            if ($row['left_id'] < $right_id) {
                continue;
            }
            unset($right_id);
        }
        if (!$auth->acl_get('f_list', $forum_id)) {
            // if the user does not have permissions to list this forum, skip everything until next branch
            $right_id = $row['right_id'];
            continue;
        }
        // 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_id_unapproved_topics'] = $auth->acl_get('m_approve', $forum_id) && $row['forum_topics_approved'] != $row['forum_topics_approved'] ? $forum_id : 0;
        //$row['forum_topics'] = ($auth->acl_get('m_approve', $forum_id)) ? $row['forum_topics_real'] : $row['forum_topics'];
        $row['forum_topics'] = $auth->acl_get('m_approve', $forum_id) ? $row['forum_topics_approved'] : $row['forum_topics_approved'];
        if ($row['parent_id'] == $root_data['forum_id'] || $row['parent_id'] == $branch_root_id) {
            // Direct child of current branch
            $parent_id = $forum_id;
            $forum_rows[$forum_id] = $row;
            if ($row['forum_type'] == FORUM_CAT && $row['parent_id'] == $root_data['forum_id']) {
                $branch_root_id = $forum_id;
            }
            $forum_rows[$parent_id]['forum_id_last_post'] = $row['forum_id'];
            $forum_rows[$parent_id]['orig_forum_last_post_time'] = $row['forum_last_post_time'];
        } else {
            if ($row['forum_type'] != FORUM_CAT) {
                $subforums[$parent_id][$forum_id]['display'] = $row['display_on_index'] ? true : false;
                $subforums[$parent_id][$forum_id]['name'] = $row['forum_name'];
                $subforums[$parent_id][$forum_id]['orig_forum_last_post_time'] = $row['forum_last_post_time'];
                $subforums[$parent_id][$forum_id]['children'] = array();
                if (isset($subforums[$parent_id][$row['parent_id']]) && !$row['display_on_index']) {
                    $subforums[$parent_id][$row['parent_id']]['children'][] = $forum_id;
                }
                if (!$forum_rows[$parent_id]['forum_id_unapproved_topics'] && $row['forum_id_unapproved_topics']) {
                    $forum_rows[$parent_id]['forum_id_unapproved_topics'] = $forum_id;
                }
                $forum_rows[$parent_id]['forum_topics'] += $row['forum_topics'];
                // Do not list redirects in LINK Forums as Posts.
                if ($row['forum_type'] != FORUM_LINK) {
                    $forum_rows[$parent_id]['forum_posts_approved'] += $row['forum_posts_approved'];
                }
            }
        }
    }
    $db->sql_freeresult($result);
    // Used to tell whatever we have to create a dummy category or not.
    $last_catless = true;
    foreach ($forum_rows as $row) {
        // Empty category
        if ($row['parent_id'] == $root_data['forum_id'] && $row['forum_type'] == FORUM_CAT) {
            $template->assign_block_vars('forumrow', array('S_ID' => $cnt, 'S_IS_CAT' => true, 'FORUM_ID' => $row['forum_id'], 'FORUM_NAME' => $row['forum_name'], 'FORUM_DESC' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']), 'FORUM_IMAGE_SRC' => $row['forum_image'] ? $row['forum_image'] : $default_icon, 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $row['forum_id'])));
            continue;
        }
        $visible_forums++;
        $forum_id = $row['forum_id'];
        $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;
//.........这里部分代码省略.........
开发者ID:phpbbireland,项目名称:portal,代码行数:101,代码来源:block_forum_categories.php

示例11: while

 // show_results should not change after this
 $per_page = $show_results == 'posts' ? $config['posts_per_page'] : $config['topics_per_page'];
 $total_match_count = 0;
 if ($search_id) {
     if ($sql) {
         // only return up to 1000 ids (the last one will be removed later)
         $result = $db->sql_query_limit($sql, 1001 - $start, $start);
         while ($row = $db->sql_fetchrow($result)) {
             $id_ary[] = (int) $row[$field];
         }
         $db->sql_freeresult($result);
         $total_match_count = sizeof($id_ary) + $start;
         $id_ary = array_slice($id_ary, 0, $per_page);
     } else {
         if ($search_id == 'unreadposts') {
             $id_ary = array_keys(get_unread_topics($user->data['user_id'], $sql_where, $sql_sort, 1001 - $start, $start));
             $total_match_count = sizeof($id_ary) + $start;
             $id_ary = array_slice($id_ary, 0, $per_page);
         } else {
             $search_id = '';
         }
     }
 }
 // make sure that some arrays are always in the same order
 sort($ex_fid_ary);
 sort($m_approve_fid_ary);
 sort($author_id_ary);
 if (!empty($search->search_query)) {
     $total_match_count = $search->keyword_search($show_results, $search_fields, $search_terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_id_ary, $sql_author_match, $id_ary, $start, $per_page);
 } else {
     if (sizeof($author_id_ary)) {
开发者ID:danielheyman,项目名称:EazySubs,代码行数:31,代码来源:search.php

示例12: fetch_topics

/**
 * Retrieve a set of topics and trim the names if necessary
 *
 * @param array $forum_id_ary
 * @param int $num_topics
 * @param int $num_chars
 * @return multitype:
 */
function fetch_topics($forum_id_ary, $num_topics, $num_chars)
{
    global $db, $cache, $user, $config, $auth, $template, $phpbb_root_path, $phpEx;
    //No authed forums, or desired number of topics is zero or less
    if (!sizeof($forum_id_ary) || $num_topics < 1) {
        return array();
    }
    $sql_arr = array('SELECT' => 't.*, tp.topic_posted, f.forum_name, f.parent_id, f.forum_parents, f.left_id, f.right_id ', 'FROM' => array(TOPICS_TABLE => 't'), 'LEFT_JOIN' => array(array('FROM' => array(TOPICS_POSTED_TABLE => 'tp'), 'ON' => 't.topic_id = tp.topic_id AND tp.user_id = ' . $user->data['user_id']), array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 'f.forum_id = t.forum_id')), 'WHERE' => ' topic_type <> ' . POST_GLOBAL . ' AND ' . $db->sql_in_set('t.forum_id', $forum_id_ary), 'ORDER_BY' => 't.topic_last_post_time DESC');
    $sql = $db->sql_build_query('SELECT', $sql_arr);
    $result = $db->sql_query_limit($sql, $num_topics);
    $row = $db->sql_fetchrowset($result);
    $db->sql_freeresult($result);
    /**
     * Get list of unread topics
     * @return array[int][int]		Topic ids as keys, mark_time of topic as value
     */
    $unreadlist = \get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $sql_limit = 1001, $sql_limit_offset = 0);
    $topics = array();
    $i = 0;
    foreach ($row as $topic) {
        // FORUM LINK
        $view_forum_url = append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $topic['forum_id']);
        $topic_moderation = false;
        $posts_moderation = false;
        $u_mcp_queue = '';
        //is this topic not approved and does poster have moderation permission ?
        if (!$topic['topic_approved']) {
            if ($auth->acl_get('m_approve', $topic['forum_id'])) {
                $topic_moderation = true;
            }
        } else {
            //if this topic is approved, are there replies yet unapproved ?
            if ($topic['topic_replies'] < $topic['topic_replies_real']) {
                if ($auth->acl_get('m_approve', $topic['forum_id'])) {
                    $posts_moderation = true;
                }
            }
        }
        // build the moderation queue url
        $u_mcp_queue = $topic_moderation || $posts_moderation ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&amp;mode=' . ($topic_moderation ? 'approve_details' : 'unapproved_posts') . '&amp;t=' . $topic['topic_id'], true, $user->session_id) : '';
        //count the number of replies to the topic
        $replies = $auth->acl_get('m_approve', $topic['forum_id']) ? $topic['topic_replies_real'] : $topic['topic_replies'];
        //build the folder names
        $folder = $folder_new = '';
        if ($topic['topic_status'] == ITEM_MOVED) {
            $topic_type = $user->lang['VIEW_TOPIC_MOVED'];
            $folder_img = 'topic_moved';
            $folder_alt = 'TOPIC_MOVED';
        } else {
            switch ($topic['topic_type']) {
                case POST_GLOBAL:
                    $topic_type = $user->lang['VIEW_TOPIC_GLOBAL'];
                    $folder = 'global_read';
                    $folder_new = 'global_unread';
                    break;
                case POST_ANNOUNCE:
                    $topic_type = $user->lang['VIEW_TOPIC_ANNOUNCEMENT'];
                    $folder = 'announce_read';
                    $folder_new = 'announce_unread';
                    break;
                case POST_STICKY:
                    $topic_type = $user->lang['VIEW_TOPIC_STICKY'];
                    $folder = 'sticky_read';
                    $folder_new = 'sticky_unread';
                    break;
                default:
                    $topic_type = '';
                    $folder = 'topic_read';
                    $folder_new = 'topic_unread';
                    // Hot topic threshold is for posts in a topic, which is replies + the first post. ;)
                    if ($config['hot_threshold'] && $replies + 1 >= $config['hot_threshold'] && $topic['topic_status'] != ITEM_LOCKED) {
                        $folder .= '_hot';
                        $folder_new .= '_hot';
                    }
                    break;
            }
            if ($topic['topic_status'] == ITEM_LOCKED) {
                $topic_type = $user->lang['VIEW_TOPIC_LOCKED'];
                $folder .= '_locked';
                $folder_new .= '_locked';
            }
            if (array_key_exists($topic['topic_id'], $unreadlist)) {
                $folder_img = $folder_new;
                $folder_alt = 'UNREAD_POSTS';
                $topic['unread'] = true;
            } else {
                $topic['unread'] = false;
                $folder_img = $folder;
                $folder_alt = $topic['topic_status'] == ITEM_LOCKED ? 'TOPIC_LOCKED' : 'NO_UNREAD_POSTS';
            }
            // Posted image?
            if (!empty($topic['topic_posted']) && $topic['topic_posted']) {
//.........这里部分代码省略.........
开发者ID:ZerGabriel,项目名称:bbDKP,代码行数:101,代码来源:recentblock.php


注:本文中的get_unread_topics函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。