예제 #1
0
 public function getItemsWithState($options = array())
 {
     $db = FD::db();
     $sql = $db->sql();
     // Determines if user is filtering the items
     $state = $this->getState('state');
     $sql->column('a.*');
     $sql->column('b.name', 'actorName');
     $sql->column('c.title', 'clusterName');
     if ($state == '3') {
         $sql->select('#__social_stream_history', 'a');
     } else {
         $sql->select('#__social_stream', 'a');
     }
     $sql->join('#__users', 'b', 'INNER');
     $sql->on('a.actor_id', 'b.id');
     $sql->join('#__social_clusters', 'c', 'LEFT');
     $sql->on('a.cluster_id', 'c.id');
     if (!is_null($state) && $state != '3') {
         if ($state == 'all') {
             $sql->where('(', '', '', 'AND');
             $sql->where('a.state', '1', '=', 'OR');
             $sql->where('a.state', '2', '=', 'OR');
             $sql->where(')');
         } else {
             $sql->where('a.state', $state);
         }
     }
     // Ordering
     $ordering = $this->getState('ordering', 'created');
     if ($ordering) {
         $direction = $this->getState('direction') ? $this->getState('direction') : 'DESC';
         $sql->order($ordering, $direction);
     }
     // Set the total
     $this->setTotal($sql->getTotalSql());
     $result = parent::getData($sql->getSql());
     $this->pagination = parent::getPagination();
     return $result;
 }