Пример #1
0
 public static function get_recent_posts($params = NULL, $conditions = NULL)
 {
     Logger::log("Enter: function CNContent::get");
     $sql = " SELECT * FROM {contents} AS C , {recent_media_track} AS RT WHERE RT.cid=C.content_id AND C.is_active = 1 ";
     if ($conditions) {
         $sql = $sql . ' AND ' . $conditions;
     }
     $sort_by = $params['sort_by'] ? $params['sort_by'] : 'C.created';
     $direction = $params['direction'] ? $params['direction'] : 'DESC';
     $order_by = ' ORDER BY ' . $sort_by . ' ' . $direction;
     if (!empty($params['page']) && !empty($params['show']) && empty($params['cnt'])) {
         $start = ($params['page'] - 1) * $params['show'];
         $limit = ' LIMIT ' . $start . ',' . $params['show'];
     } else {
         $limit = "";
     }
     $sql = $sql . $order_by . $limit;
     $res = Dal::query($sql);
     if (!empty($params['cnt']) && $params['cnt'] == TRUE) {
         return $res->numRows();
     }
     $i = 0;
     $content_id = array();
     while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) {
         $content_id[$i] = array('content_id' => $row['content_id'], 'collection_id' => $row['collection_id'], 'title' => $row['title'], 'body' => $row['body'], 'author_id' => $row['author_id'], 'type' => $row['type'], 'changed' => $row['changed'], 'created' => $row['created'], 'is_active' => $row['is_active']);
         $i++;
     }
     $contents = array();
     foreach ($content_id as &$_content) {
         if (!CNContent::check_content_privacy($_content)) {
             // check is content from a  private Group
             $contents[] = $_content;
         }
     }
     //    echo '<pre>'.print_r($cont,1).'</pre>';
     Logger::log("Exit: function CNContent::get");
     return $contents;
 }