Файл: adultscript-2.0.3-pro/files/modules/profile/components/friends.php
Строк: 72
<?php
class VComponent_profile_friends extends VModule_profile
{
    public function __construct()
    {
        parent::__construct();
    }
    
    public function render()
    {
        $page    = VUri::request(3); $page = ($page) ? (int) $page : 1;
        $url    = 'users/'.$this->username.'/friends/';
        if ($page > 1) {
            $url    .= $page.'/';
        }
        
        if (!VUri::match($url)) {
            VModule::load('404', true);
        }
        
        if (!$this->profile($this->username)) {
            return false;
        }
        
        VLanguage::load('frontend.global');
        VLanguage::load('frontend.profile');
        $user_id        = (int) $this->user['user_id'];
        $sql_count      = "SELECT COUNT(*) AS total_friends
                           FROM #__user_friends
                           WHERE user_id = ".$user_id."
                           AND status = 'approved'";
        $total_friends  = $this->db->get_field($sql_count, 'total_friends');
        $pagination     = VPagination::get($page, $total_friends, 24);
        $sql            = "SELECT u.user_id, u.username, u.gender, u.avatar, u.online
                           FROM #__user_friends AS uf
                           INNER JOIN #__user AS u ON (u.user_id = uf.friend_id AND u.status = '1')
                           WHERE uf.user_id = ".$user_id."
                           AND uf.status = 'approved'
                           ORDER BY uf.add_date DESC
                           LIMIT ".$pagination['limit'];
        if (!$friends = $this->cache->get($sql, 3600)) {
            $this->db->query($sql);
            if ($this->db->affected_rows()) {
                $friends    = $this->db->fetch_rows($sql);
                $this->cache->store($sql, $friends, 3600);
            } else {
                $friends    = array();
            }
        }
        
        $add    = ($page > 1) ? ' - '.__('page').' '.$page : '';
        $this->tpl->menu          = 'community';
        $this->tpl->submenu       = 'friends';
        
        $this->tpl->title          = __('friends-title');
        
        $this->tpl->meta_title    = __('friends-meta-title', array($this->username, $add, VF::cfg_item('site_name')));
        $this->tpl->meta_desc     = __('friends-meta-desc', array($this->username, $add, VF::cfg_item('site_name')));
        
        $this->tpl->user          = $this->user;
        $this->tpl->username      = e($this->username);
        $this->tpl->is_subscribed = $this->is_subscribed;
        $this->tpl->is_friend     = $this->is_friend;
        $this->tpl->is_self       = $this->is_self;
        $this->tpl->is_moderator  = $this->is_moderator;
        $this->tpl->is_loggedin   = $this->is_loggedin;
        $this->tpl->is_blocked    = $this->is_blocked;
        
        $this->tpl->users            = $friends;
        $this->tpl->pagination        = $pagination;
        $this->tpl->url                = REL_URL.'/users/'.$this->username.'/friends/#PAGE#/';
        
        $this->tpl->load(array('header', 'profile_users', 'footer'));
        $this->tpl->display();
    }
}