Exemple #1
0
 public function getPosts()
 {
     $inUser = cmsUser::getInstance();
     $sql = "SELECT p.id, p.thread_id, p.user_id, p.pubdate, p.editdate, p.edittimes, p.rating, p.attach_count, p.content_html, p.pinned,\r\n                       u.nickname, u.login, u.is_deleted, u.logdate, u.status,\r\n                       up.imageurl, up.signature_html, up.city, up.karma, g.access as group_access, g.is_admin {$this->inDB->select}\r\n                FROM cms_forum_posts p\r\n                {$this->inDB->join}\r\n                LEFT JOIN cms_users u ON u.id = p.user_id\r\n                LEFT JOIN cms_user_profiles up ON up.user_id = u.id\r\n                LEFT JOIN cms_user_groups g ON u.group_id = g.id\r\n                WHERE 1=1\r\n                {$this->inDB->where}\r\n                {$this->inDB->group_by}\r\n                {$this->inDB->order_by} \n";
     if ($this->inDB->limit) {
         $sql .= "LIMIT {$this->inDB->limit}";
     }
     $result = $this->inDB->query($sql);
     $this->inDB->resetConditions();
     if (!$this->inDB->num_rows($result)) {
         return array();
     }
     while ($post = $this->inDB->fetch_assoc($result)) {
         $post['fpubdate'] = cmsCore::dateFormat($post['pubdate']);
         $post['wday'] = cmsCore::dateToWday($post['pubdate']);
         $post['peditdate'] = cmsCore::dateFormat($post['editdate'], true, true);
         $post['post_count'] = $this->getUserPostsCount($post['user_id']);
         $post['avatar_url'] = cmsUser::getUserAvatarUrl($post['user_id'], 'small', $post['imageurl'], $post['is_deleted']);
         $post['flogdate'] = cmsUser::getOnlineStatus($post['user_id'], $post['logdate']);
         $post['userrank'] = $this->getForumUserRank($post);
         $post['user_awards'] = cmsUser::getAwardsList($post['user_id']);
         $post['attached_files'] = $this->config['fa_on'] && $post['attach_count'] ? $this->getPostAttachments($post['id']) : array();
         $end_min = $this->checkEditTime($post['pubdate']);
         $post['is_author'] = $post['user_id'] == cmsUser::getInstance()->id;
         $post['is_author_can_edit'] = (is_bool($end_min) ? $end_min : $end_min > 0) && $post['is_author'];
         if ($inUser->id) {
             $post['is_voted'] = $post['is_author'] ? true : cmsUser::isRateUser('forum_post', $inUser->id, $post['id']);
         } else {
             $post['is_voted'] = true;
         }
         $posts[] = $post;
     }
     $this->resetAbstractArray();
     return cmsCore::callEvent('GET_FORUM_POSTS', $posts);
 }
Exemple #2
0
    public function getMessages($show_notice = false) {
        if ($show_notice) { return $this->getNotices(); }

        $sql = "SELECT m.*, u.id as user_id, u.nickname as author,
				u.login as author_login, u.logdate,
				m.from_id as sender_id, u.is_deleted,
				p.imageurl {$this->inDB->select}
                FROM cms_users u
				INNER JOIN cms_user_profiles p ON p.user_id = u.id
				{$this->inDB->join}
                WHERE 1=1
                      {$this->inDB->where}

                {$this->inDB->group_by}

                {$this->inDB->order_by}\n";

        if ($this->inDB->limit) {
            $sql .= 'LIMIT '. $this->inDB->limit;
        }

        $result = $this->inDB->query($sql);

        $this->inDB->resetConditions();

        if (!$this->inDB->num_rows($result)) { return false; }

        while ($msg = $this->inDB->fetch_assoc($result)) {
            $msg['authorlink'] = cmsUser::getProfileLink($msg['author_login'], $msg['author']);
            $msg['fpubdate'] = cmsCore::dateFormat($msg['senddate'], true, true, true);
            $msg['user_img']  = cmsUser::getUserAvatarUrl($msg['sender_id'], 'small', $msg['imageurl'], $msg['is_deleted']);
            $msg['online_status'] = cmsUser::getOnlineStatus($msg['user_id'], $msg['logdate']);

            $msgs[] = $msg;
        }

        return $msgs;
    }
Exemple #3
0
 /**
  * Возвращает клуб и его администратора
  * @return array
  */
 public function getClub($club_id)
 {
     if (isset($this->clubs[$club_id])) {
         return $this->clubs[$club_id];
     }
     $sql = "SELECT c.*, c.enabled_blogs as orig_enabled_blogs, c.enabled_photos as orig_enabled_photos, u.nickname as nickname, u.login as login, u.status, u.logdate, p.karma, p.gender as gender, p.imageurl as admin_avatar, u.is_deleted, c.typeofclub as typeofclub\n\t\t\t\tFROM cms_clubs c\n\t\t\t\tLEFT JOIN cms_users u ON u.id = c.admin_id\n\t\t\t\tLEFT JOIN cms_user_profiles p ON p.user_id = u.id\n\t\t\t\tWHERE c.id = '{$club_id}' LIMIT 1";
     $result = $this->inDB->query($sql);
     if (!$this->inDB->num_rows($result)) {
         return false;
     }
     $club = $this->inDB->fetch_assoc($result);
     $club['f_imageurl'] = self::getClubImage($club['imageurl']);
     $club['fpubdate'] = cmsCore::dateFormat($club['pubdate'], true, true);
     $club['flogdate'] = cmsUser::getOnlineStatus($club['admin_id'], $club['logdate']);
     $club['admin_avatar'] = cmsUser::getUserAvatarUrl($club['admin_id'], 'small', $club['admin_avatar'], $club['is_deleted']);
     $club['enabled_blogs'] = $club['enabled_blogs'] == -1 ? $this->config['enabled_blogs'] : $club['enabled_blogs'];
     $club['enabled_photos'] = $club['enabled_photos'] == -1 ? $this->config['enabled_photos'] : $club['enabled_photos'];
     return $this->clubs[$club_id] = cmsCore::callEvent('GET_CLUB', $club);
 }