예제 #1
0
    /**
     * {@inheritdoc}
     */
    public function get_template_side($module_id)
    {
        if (!function_exists('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_title = $rank_img = $rank_img_src = '';
            \get_user_rank($this->user->data['user_rank'], $this->user->data['user_posts'], $rank_title, $rank_img, $rank_img_src);
            // Assign specific vars
            $this->template->assign_vars(array('L_NEW_POSTS' => $this->user->lang['SEARCH_NEW'] . ' (' . $new_posts_count . ')', 'L_SELF_POSTS' => $this->user->lang['SEARCH_SELF'] . ' (' . $this->user->data['user_posts'] . ')', 'L_UNREAD_POSTS' => $this->user->lang['SEARCH_UNREAD'] . ' (' . $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("{$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&mode=bookmarks') : '', 'U_UM_MAIN_SUBSCRIBED' => append_sid("{$this->phpbb_root_path}ucp.{$this->php_ext}", 'i=main&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&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';
        }
    }
예제 #2
0
    /**
     * {@inheritdoc}
     */
    public function get_template_center($module_id)
    {
        //
        // Exclude forums
        //
        $sql_where = '';
        if ($this->config['board3_recent_forum_' . $module_id] > 0) {
            $exclude_forums = explode(',', $this->config['board3_recent_forum_' . $module_id]);
            $sql_where = ' AND ' . $this->db->sql_in_set('forum_id', array_map('intval', $exclude_forums), $this->config['board3_recent_exclude_forums_' . $module_id] ? true : false);
        }
        // Get a list of forums the user cannot read
        $forum_ary = array_unique(array_keys($this->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;
        $forum_sql = '';
        if (sizeof($forum_ary)) {
            $sql .= ' AND ' . $this->db->sql_in_set('forum_id', $forum_ary, true);
            $forum_sql = ' AND ' . $this->db->sql_in_set('t.forum_id', $forum_ary, true);
        }
        $result = $this->db->sql_query_limit($sql, 1, 0, 600);
        $g_forum_id = (int) $this->db->sql_fetchfield('forum_id');
        $this->db->sql_freeresult($result);
        //
        // Recent announcements
        //
        $sql = 'SELECT topic_title, forum_id, topic_id
			FROM ' . TOPICS_TABLE . ' t
			WHERE topic_status <> ' . FORUM_LINK . '
				AND topic_visibility = ' . ITEM_APPROVED . '
				AND (topic_type = ' . POST_ANNOUNCE . ' OR topic_type = ' . POST_GLOBAL . ')
				AND topic_moved_id = 0
				' . $sql_where . $forum_sql . '
			ORDER BY topic_time DESC';
        $result = $this->db->sql_query_limit($sql, $this->config['board3_max_topics_' . $module_id], 0, 30);
        while (($row = $this->db->sql_fetchrow($result)) && $row['topic_title']) {
            // auto auth
            if ($this->auth->acl_get('f_read', $row['forum_id']) || $row['forum_id'] == '0') {
                $this->template->assign_block_vars('latest_announcements', array('TITLE' => character_limit($row['topic_title'], $this->config['board3_recent_title_limit_' . $module_id]), 'FULL_TITLE' => censor_text($row['topic_title']), 'U_VIEW_TOPIC' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . ($row['forum_id'] == 0 ? $g_forum_id : $row['forum_id']) . '&amp;t=' . $row['topic_id'])));
            }
        }
        $this->db->sql_freeresult($result);
        //
        // Recent hot topics
        //
        $sql = 'SELECT topic_title, forum_id, topic_id
			FROM ' . TOPICS_TABLE . ' t
			WHERE topic_visibility = ' . ITEM_APPROVED . '
				AND topic_posts_approved >' . $this->config['hot_threshold'] . '
				AND topic_moved_id = 0
				' . $sql_where . $forum_sql . '
			ORDER BY topic_time DESC';
        $result = $this->db->sql_query_limit($sql, $this->config['board3_max_topics_' . $module_id], 0, 30);
        while (($row = $this->db->sql_fetchrow($result)) && $row['topic_title']) {
            // auto auth
            if ($this->auth->acl_get('f_read', $row['forum_id']) || $row['forum_id'] == '0') {
                $this->template->assign_block_vars('latest_hot_topics', array('TITLE' => character_limit($row['topic_title'], $this->config['board3_recent_title_limit_' . $module_id]), 'FULL_TITLE' => censor_text($row['topic_title']), 'U_VIEW_TOPIC' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . ($row['forum_id'] == 0 ? $g_forum_id : $row['forum_id']) . '&amp;t=' . $row['topic_id'])));
            }
        }
        $this->db->sql_freeresult($result);
        //
        // Recent topic (only show normal topic)
        //
        $sql = 'SELECT topic_title, forum_id, topic_id
			FROM ' . TOPICS_TABLE . ' t
			WHERE topic_status <> ' . ITEM_MOVED . '
				AND topic_visibility = ' . ITEM_APPROVED . '
				AND topic_type = ' . POST_NORMAL . '
				AND topic_moved_id = 0
				' . $sql_where . $forum_sql . '
			ORDER BY topic_time DESC';
        $result = $this->db->sql_query_limit($sql, $this->config['board3_max_topics_' . $module_id], 0, 30);
        while (($row = $this->db->sql_fetchrow($result)) && $row['topic_title']) {
            // auto auth
            if ($this->auth->acl_get('f_read', $row['forum_id']) || $row['forum_id'] == '0') {
                $this->template->assign_block_vars('latest_topics', array('TITLE' => character_limit($row['topic_title'], $this->config['board3_recent_title_limit_' . $module_id]), 'FULL_TITLE' => censor_text($row['topic_title']), 'U_VIEW_TOPIC' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . $row['forum_id'] . '&amp;t=' . $row['topic_id'])));
            }
        }
        $this->db->sql_freeresult($result);
        return 'recent_center.html';
    }