Exemple #1
0
        $gBlog = new BitBlog($_REQUEST['blog_id']);
        $gBlog->load();
        if (isset($gBlog->mContentId)) {
            // adjust feed title to blog title
            $rss->title = $gBlog->getTitle() . " at " . $gBitSystem->getConfig('site_title');
            if (isset($userName)) {
                $rss->title = $userName . "'s Posts in " . $rss->title;
            }
            $rss->description = $gBlog->parseData();
        }
    }
    $feeds = $blogPost->getList($listHash);
    // set the rss link
    $rss->link = 'http://' . $_SERVER['HTTP_HOST'] . BLOGS_PKG_URL . (!empty($_REQUEST['blog_id']) ? "?blog_id=" . $_REQUEST['blog_id'] : "");
    // get all the data ready for the feed creator
    foreach ($feeds['data'] as $feed) {
        $item = new FeedItem();
        $item->title = BitBlogPost::getTitleFromHash($feed);
        $item->link = BIT_BASE_URI . BitBlogPost::getDisplayUrlFromHash(NULL, $feed);
        $item->description = $feed['parsed'];
        $item->date = (int) $feed['last_modified'];
        $item->source = 'http://' . $_SERVER['HTTP_HOST'] . BIT_ROOT_URL;
        $item->author = $gBitUser->getDisplayName(FALSE, $feed);
        $item->descriptionTruncSize = $gBitSystem->getConfig('rssfeed_truncate', 50000);
        $item->descriptionHtmlSyndicated = TRUE;
        // pass the item on to the rss feed creator
        $rss->addItem($item);
    }
    // finally we are ready to serve the data
    echo $rss->saveFeed($rss_version_name, $cacheFile);
}
Exemple #2
0
 function getList(&$pListHash)
 {
     global $gBitUser, $gBitSystem;
     $this->prepGetList($pListHash);
     $selectSql = '';
     $joinSql = '';
     $whereSql = '';
     $bindVars = array();
     array_push($bindVars, $this->mContentTypeGuid);
     $this->getServicesSql('content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars, NULL, $pListHash);
     if (@$this->verifyId($pListHash['blog_id'])) {
         $selectSql .= ', bpm.crosspost_note';
         array_push($bindVars, (int) $pListHash['blog_id']);
         $joinSql .= " LEFT OUTER JOIN `" . BIT_DB_PREFIX . "blogs_posts_map` bpm ON ( bpm.`post_content_id` = bp.`content_id` ) ";
         $joinSql .= " LEFT OUTER JOIN `" . BIT_DB_PREFIX . "blogs` b ON ( bpm.`blog_content_id`=b.`content_id` ) ";
         //	" ON ( b.`content_id` = bpm.`blog_content_id` AND bp.`content_id` = bpm.`post_content_id` )";
         $whereSql .= ' AND b.`blog_id` = ? ';
         $pListHash['sort_mode'] = 'publish_date_desc';
     }
     if (@$this->verifyId($pListHash['post_id_gt'])) {
         array_push($bindVars, (int) $pListHash['post_id_gt']);
         $whereSql .= ' AND bp.`post_id` > ? ';
     }
     if (@$this->verifyId($pListHash['post_id_lt'])) {
         array_push($bindVars, (int) $pListHash['post_id_lt']);
         $whereSql .= ' AND bp.`post_id` < ? ';
     }
     if (@$this->verifyId($pListHash['user_id'])) {
         array_push($bindVars, (int) $pListHash['user_id']);
         $whereSql .= ' AND lc.`user_id` = ? ';
     }
     $this->getServicesSql('content_user_collection_function', $selectSql, $joinSql, $whereSql, $bindVars, NULL, $pListHash);
     // map user to login in case we used one instead of the other
     if (!empty($pListHash['user'])) {
         $pListHash['login'] = $pListHash['user'];
     }
     if (!empty($pListHash['login'])) {
         array_push($bindVars, $pListHash['login']);
         $whereSql .= ' AND uu.`login` = ? ';
     }
     if ($pListHash['find']) {
         $findesc = '%' . strtoupper($pListHash['find']) . '%';
         $whereSql .= "AND (UPPER(lc.`data`) like ?) ";
         $bindVars[] = $findesc;
     }
     if (!empty($pListHash['date']) && is_numeric($pListHash['date'])) {
         $whereSql .= " AND  lc.`created`<=? ";
         $bindVars[] = $pListHash['date'];
     }
     if (!empty($pListHash['date_start']) && is_numeric($pListHash['date_start'])) {
         $whereSql .= " AND  lc.`created`>=? ";
         $bindVars[] = $pListHash['date_start'];
     }
     if (!empty($pListHash['date_end']) && is_numeric($pListHash['date_end'])) {
         $whereSql .= " AND  lc.`created`<=? ";
         $bindVars[] = $pListHash['date_end'];
     }
     if (!empty($pListHash['content_perm_name'])) {
         $this->getContentListPermissionsSql($pListHash['content_perm_name'], $selectSql, $joinSql, $whereSql, $bindVars);
     }
     /* Check if the post wants to be viewed before / after respective dates
      * Note: expiring posts are determined by the expired date being greater than the publish date
      */
     static::getDateRestrictions($pListHash, $whereSql, $bindVars);
     /* sort_mode is never empty due to call to prepGetList above
      * I think this will have to be perminently removed and default
      * set before passing the list hash in if a different default is
      * desired from that in prepGetList. -wjames5
      */
     /*
     if( empty( $pListHash['sort_mode'] ) ) {
     	$pListHash['sort_mode'] = 'publish_date_desc';
     	$sortModePrefix = 'bp';
     	//$pListHash['sort_mode'] = 'created_desc';
     } else {
     */
     $sortModePrefix = '';
     if (!empty($pListHash['sort_mode']) && !strpos($pListHash['sort_mode'], '.')) {
         switch ($pListHash['sort_mode']) {
             case 'publish_date_asc':
             case 'publish_date_desc':
             case 'post_id_desc':
             case 'post_id_asc':
                 $sortModePrefix = 'bp.';
                 break;
             case 'date_added_desc':
                 $sortModePrefix = 'bpm.';
                 break;
             case 'hits_asc':
             case 'hits_desc':
                 $sortModePrefix = 'lch.';
                 break;
             case 'sort_date_asc':
             case 'sort_date_desc':
                 break;
             case 'real_name_asc':
             case 'real_name_desc':
                 $sortModePrefix = 'uu.';
                 break;
                 // these technicall are not correct, however, we do not double join on users_users, so we sort by creator real_name
             // these technicall are not correct, however, we do not double join on users_users, so we sort by creator real_name
             case 'creator_real_name_asc':
             case 'modifier_real_name_asc':
                 $sortModePrefix = 'uu.';
                 $pListHash['sort_mode'] = 'real_name_asc';
                 break;
             case 'registration_date_desc':
                 $sortModePrefix = 'uu.';
                 $pListHash['sort_mode'] = 'registration_date_desc';
                 break;
             case 'creator_real_name_desc':
             case 'modifier_real_name_desc':
                 $sortModePrefix = 'uu.';
                 $pListHash['sort_mode'] = 'real_name_desc';
                 break;
             default:
                 $sortModePrefix = 'lc.';
                 break;
         }
     }
     $secondarySortMode = $pListHash['sort_mode'] != 'last_modified_desc' ? ', last_modified DESC' : '';
     $sort_mode = $sortModePrefix . $this->mDb->convertSortmode($pListHash['sort_mode']) . $secondarySortMode;
     $query = "\n\t\t\tSELECT\n\t\t\t\tbp.`post_id`, bp.`publish_date`, bp.`expire_date`, bp.`trackbacks_to`, bp.`trackbacks_from`,\n\t\t\t\tlc.*, lch.`hits`, lcds.`data` AS `summary`, COALESCE( bp.`publish_date`, lc.`last_modified` ) AS sort_date,\n\t\t\t\tuu.`email`, uu.`login`, uu.`real_name`,\n\t\t\t\t\tlfa.`file_name` as `avatar_file_name`, lfa.`mime_type` AS `avatar_mime_type`, laa.`attachment_id` AS `avatar_attachment_id`,\n\t\t\t\t\tlfp.`file_name` AS `image_file_name`, lfp.`mime_type` AS `image_mime_type`, lap.`attachment_id` AS `image_attachment_id`\n\t\t\tFROM `" . BIT_DB_PREFIX . "blog_posts` bp\n\t\t\t\tINNER JOIN      `" . BIT_DB_PREFIX . "liberty_content`       lc ON lc.`content_id`         = bp.`content_id`\n\t\t\t\tINNER JOIN\t\t`" . BIT_DB_PREFIX . "users_users`\t\t\t uu ON uu.`user_id`\t\t\t   = lc.`user_id`\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_content_hits` lch ON lc.`content_id`         = lch.`content_id`\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_content_data` lcds ON (lc.`content_id` = lcds.`content_id` AND lcds.`data_type`='summary')\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_attachments`\tlaa ON (uu.`user_id` = laa.`user_id` AND laa.`attachment_id` = uu.`avatar_attachment_id`)\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_files`\t    lfa ON lfa.`file_id`\t\t   = laa.`foreign_id`\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_attachments`  lap ON lap.`content_id`        = lc.`content_id` AND lap.`is_primary` = 'y'\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_files`        lfp ON lfp.`file_id`           = lap.`foreign_id`\n\t\t\t\t{$joinSql}\n\t\t\tWHERE lc.`content_type_guid` = ? {$whereSql}\n\t\t\tORDER BY {$sort_mode}";
     # Get count of total number of items available
     $query_cant = "\n\t\t\tSELECT COUNT( * )\n\t\t\tFROM `" . BIT_DB_PREFIX . "blog_posts` bp\n\t\t\t\tINNER JOIN      `" . BIT_DB_PREFIX . "liberty_content`       lc ON lc.`content_id` = bp.`content_id`\n\t\t\t\tINNER JOIN\t\t`" . BIT_DB_PREFIX . "users_users`\t\t\t uu ON uu.`user_id`\t\t\t   = lc.`user_id`\n\t\t\t\t{$joinSql}\n\t\t\tWHERE lc.`content_type_guid` = ? {$whereSql} ";
     $cant = $this->mDb->getOne($query_cant, $bindVars);
     $pListHash["cant"] = $cant;
     # Check for offset out of range
     if ($pListHash['offset'] < 0) {
         $pListHash['offset'] = 0;
     } elseif ($pListHash['offset'] > $pListHash["cant"]) {
         $lastPageNumber = ceil($pListHash["cant"] / $pListHash['max_records']) - 1;
         $pListHash['offset'] = $pListHash['max_records'] * $lastPageNumber;
     }
     $result = $this->mDb->query($query, $bindVars, $pListHash['max_records'], $pListHash['offset']);
     $ret = array();
     $comment = new LibertyComment();
     while ($res = $result->fetchRow()) {
         $res['no_fatal'] = TRUE;
         $accessError = $this->invokeServices('content_verify_access', $res, FALSE);
         if (empty($accessError)) {
             foreach (array('avatar', 'image') as $img) {
                 $res[$img] = liberty_fetch_thumbnails(array('source_file' => liberty_mime_get_source_file(array('user_id' => $res['user_id'], 'package' => liberty_mime_get_storage_sub_dir_name(array('mime_type' => $res[$img . '_mime_type'], 'name' => $res[$img . '_file_name'])), 'file_name' => basename($res[$img . '_file_name']), 'sub_dir' => $res[$img . '_attachment_id']))));
             }
             $res['thumbnail_url'] = BitBlogPost::getImageThumbnails($res);
             $res['num_comments'] = $comment->getNumComments($res['content_id']);
             $res['post_url'] = BitBlogPost::getDisplayUrlFromHash($res);
             $res['display_url'] = $res['post_url'];
             $res['display_link'] = $this->getDisplayLink($res['title'], $res);
             $res['blogs'] = $this->getBlogMemberships($res['content_id']);
             // trackbacks
             if ($res['trackbacks_from'] != null) {
                 $res['trackbacks_from'] = unserialize($res['trackbacks_from']);
             }
             if (!is_array($res['trackbacks_from'])) {
                 $res['trackbacks_from'] = array();
             }
             $res['trackbacks_from_count'] = count(array_keys($res['trackbacks_from']));
             if ($res['trackbacks_to'] != null) {
                 $res['trackbacks_to'] = unserialize($res['trackbacks_to']);
             }
             if ($res['user_id'] == $gBitUser->mUserId) {
                 $res['ownsblog'] = 'y';
             } else {
                 $res['ownsblog'] = 'n';
             }
             $res['trackbacks_to_count'] = count($res['trackbacks_to']);
             $res['pages'] = $this->getNumberOfPages($res['data']);
             // deal with the parsing
             $parseHash['format_guid'] = $res['format_guid'];
             $parseHash['content_id'] = $res['content_id'];
             $parseHash['user_id'] = $res['user_id'];
             // support for ...split... and auto split
             if (!empty($pListHash['full_data'])) {
                 $parseHash['data'] = $res['data'];
                 $res['parsed'] = $this->parseData($parseHash);
             } else {
                 $parseHash['data'] = $res['data'];
                 $parseHash['no_cache'] = TRUE;
                 $splitArray = $this->parseSplit($parseHash, $gBitSystem->getConfig('blog_posts_description_length', 500));
                 $res = array_merge($res, $splitArray);
             }
             if (!empty($this->mInfo['summary'])) {
                 $res['summary'] = $parseHash['data'] = $this->mInfo['summary'];
                 $parseHash['no_cache'] = TRUE;
                 $res['parsed_summary'] = $this->parsedData($parseHash);
             }
             if (!empty($res['crosspost_note'])) {
                 $res['crosspost_note_raw'] = $parseHash['data'] = $res['crosspost_note'];
                 $parseHash['no_cache'] = TRUE;
                 $res['crosspost_note'] = $this->parseData($parseHash);
             }
             $ret[] = $res;
         } elseif (!empty($accessError)) {
             if (!empty($accessError['access_control'])) {
                 $res['post_url'] = BitBlogPost::getDisplayUrlFromHash($res['content_id'], $res);
                 $res['display_url'] = $res['post_url'];
                 /* this needs to be part of loop that gets all blogs post is in
                 			$res['blog_url'] = BitBlog::getDisplayUrlFromHash( $res['blog_content_id'] );
                 			*/
                 $res["parsed_data"] = $accessError['access_control'];
                 $ret[] = $res;
             }
         } else {
         }
     }
     LibertyContent::postGetList($pListHash);
     return $ret;
 }