예제 #1
0
파일: search.php 프로젝트: pguilford/vcomcc
 /**
  * Method to get a pagination object for the posts
  *
  * @access public
  * @return integer
  */
 public function getPagination($parent_id = 0, $sort = 'latest', $filter = '', $category = '', $featuredOnly = 'all')
 {
     $this->_parent = $parent_id;
     // Lets load the content if it doesn't already exist
     if (empty($this->_pagination)) {
         $this->_pagination = DiscussHelper::getPagination($this->getTotal($sort, $filter, $category, $featuredOnly), $this->getState('limitstart'), $this->getState('limit'));
     }
     return $this->_pagination;
 }
예제 #2
0
 /**
  * Retrieves a list of conversations for a particular node
  *
  * @since	3.0
  * @access	public
  * @param	int		The current user id of the viewer
  */
 public function getConversations($userId, $options = array())
 {
     $db = DiscussHelper::getDBO();
     $query = 'SELECT a.*,b.' . $db->nameQuote('message') . ',c.' . $db->nameQuote('isread') . 'FROM ' . $db->nameQuote('#__discuss_conversations') . ' AS a ' . 'INNER JOIN ' . $db->nameQuote('#__discuss_conversations_message') . ' AS b ' . 'ON a.' . $db->nameQuote('id') . ' = b.' . $db->nameQuote('conversation_id') . ' ' . 'INNER JOIN ' . $db->nameQuote('#__discuss_conversations_message_maps') . ' AS c ' . 'ON c.' . $db->nameQuote('message_id') . ' = b.' . $db->nameQuote('id') . ' ' . 'WHERE c.' . $db->nameQuote('user_id') . ' = ' . $db->Quote($userId);
     // @rule: Process any additional filters here.
     if (isset($options['archives']) && $options['archives']) {
         $query .= ' AND c.' . $db->nameQuote('state') . ' = ' . $db->Quote(DISCUSS_CONVERSATION_ARCHIVED);
     } else {
         $query .= ' AND c.' . $db->nameQuote('state') . ' = ' . $db->Quote(DISCUSS_CONVERSATION_PUBLISHED);
     }
     // @rule: Respect filter options
     if (isset($options['filter'])) {
         switch ($options['filter']) {
             case 'unread':
                 $query .= ' AND c.' . $db->nameQuote('isread') . '=' . $db->Quote(DISCUSS_CONVERSATION_UNREAD);
                 break;
         }
     }
     $query .= ' GROUP BY b.' . $db->nameQuote('conversation_id');
     $sorting = isset($options['sorting']) ? $options['sorting'] : 'latest';
     switch ($sorting) {
         case 'latest':
         default:
             $query .= ' ORDER BY a.' . $db->nameQuote('lastreplied') . ' DESC';
             break;
     }
     // If limit is provided, only show certain number of items.
     if (isset($options['limit'])) {
         $limit = $options['limit'];
         $query .= ' LIMIT 0,' . $limit;
     } else {
         $limitstart = $this->getState('limitstart');
         $limit = $this->getState('limit');
         $paginationQuery = str_ireplace('SELECT a.*,b.' . $db->nameQuote('message') . ',c.' . $db->nameQuote('isread'), 'SELECT COUNT(1) AS count FROM ( SELECT a.* ', $query);
         $paginationQuery .= ') AS x';
         $db->setQuery($paginationQuery);
         $total = $db->loadResult();
         $this->_pagination = DiscussHelper::getPagination($total, $limitstart, $limit);
         $query .= ' LIMIT ' . $limitstart . ' , ' . $limit;
     }
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     if (!$rows) {
         return $rows;
     }
     foreach ($rows as $row) {
         $conversation = DiscussHelper::getTable('Conversation');
         $conversation->bind($row);
         $conversations[] = $conversation;
     }
     return $conversations;
 }
예제 #3
0
 /**
  * Retrieve replies from a specific user
  **/
 public function getRepliesFromUser($userId, $ordering = '')
 {
     $db = DiscussHelper::getDBO();
     $date = DiscussHelper::getDate();
     $limitstart = $this->getState('limitstart');
     $limit = $this->getState('limit');
     $query = 'SELECT DATEDIFF(' . $db->Quote($date->toMySQL()) . ', b.`created`) as `noofdays`, ';
     $query .= ' DATEDIFF(' . $db->Quote($date->toMySQL()) . ', b.`created`) as `daydiff`, TIMEDIFF(' . $db->Quote($date->toMySQL()) . ', b.`created`) as `timediff`,';
     $query .= ' b.`id`, b.`title`, b.`alias`, b.`created`, b.`modified`, b.`replied`,b.`legacy`,';
     $query .= ' b.`content`, b.`category_id`, b.`published`, b.`ordering`, b.`vote`, a.`hits`, b.`islock`,';
     $query .= ' b.`featured`, b.`isresolve`, b.`isreport`, b.`user_id`, b.`parent_id`,';
     $query .= ' b.`user_type`, b.`poster_name`, b.`poster_email`, b.`num_likes`,';
     $query .= ' b.`num_negvote`, b.`sum_totalvote`, b.`answered`,';
     $query .= ' b.`post_status`, b.`post_type`, pt.`title` AS `post_type_title`,pt.`suffix` AS `post_type_suffix`,';
     $query .= ' count(a.id) as `num_replies`,';
     $query .= ' c.`title` as `category`, b.`password`';
     $query .= ' FROM ' . $db->nameQuote('#__discuss_posts') . ' AS a ';
     $query .= ' INNER JOIN ' . $db->nameQuote('#__discuss_posts') . ' AS b ';
     $query .= ' ON a.' . $db->nameQuote('parent_id') . ' = b.' . $db->nameQuote('id');
     $query .= ' LEFT JOIN ' . $db->nameQuote('#__discuss_category') . ' AS c';
     $query .= ' ON c.' . $db->nameQuote('id') . ' = b.' . $db->nameQuote('category_id');
     $query .= ' LEFT JOIN ' . $db->nameQuote('#__discuss_post_types') . ' AS pt';
     $query .= ' ON b.`post_type` = pt.' . $db->nameQuote('alias');
     $query .= ' WHERE a.' . $db->nameQuote('user_id') . ' = ' . $db->Quote($userId);
     $query .= ' AND a.' . $db->nameQuote('published') . ' = ' . $db->Quote(1);
     $query .= ' AND a.`parent_id` != ' . $db->Quote('0');
     $query .= ' AND b.' . $db->nameQuote('published') . ' = ' . $db->Quote(1);
     $query .= ' AND b.`parent_id` = ' . $db->Quote('0');
     $query .= ' GROUP BY b.`id`';
     if (!empty($ordering)) {
         if ($ordering == 'latest') {
             $query .= ' ORDER BY a.`created` DESC';
         }
     }
     $this->_total = $this->_getListCount($query);
     $this->_pagination = DiscussHelper::getPagination($this->_total, $limitstart, $limit);
     $this->_data = $this->_getList($query, $limitstart, $limit);
     return $this->_data;
 }
예제 #4
0
 /**
  * Method to get a pagination object for the categories
  *
  * @access public
  * @return integer
  */
 function getPagination()
 {
     // Lets load the content if it doesn't already exist
     if (empty($this->_pagination)) {
         $this->_pagination = DiscussHelper::getPagination($this->getTotal(), $this->getState('limitstart'), $this->getState('limit'));
     }
     return $this->_pagination;
 }