Beispiel #1
0
function feed_get_status($pListHash)
{
    global $gBitDb;
    $whereSql = '';
    $bindVars = array();
    $statuses = array();
    BitBase::prepGetList($pListHash);
    if (!empty($pListHash['user_id'])) {
        $whereSql = " WHERE lal.user_id = ? ";
        $bindVars[] = $pListHash['user_id'];
    } else {
        $whereSql = "WHERE 1=1 ";
    }
    $query = "SELECT lal.content_id, lal.user_id, lal.log_message, MAX(lal.last_modified) AS last_modified, lc.data, uu.login, uu.real_name, uu.email\n\t\t\t  FROM liberty_action_log lal\n\t\t\t  INNER JOIN liberty_content lc ON (lc.content_id=lal.content_id)\n\t\t\t  INNER JOIN liberty_comments lcs ON (lcs.content_id = lc.content_id)\n\t\t\t  INNER JOIN users_users uu ON (uu.user_id=lal.user_id)\n\t\t\t  {$whereSql} AND lc.content_type_guid = 'feedstatus'\n\t\t\t  GROUP BY lal.content_id, lal.user_id, uu.login, uu.real_name, uu.email, lal.log_message,lc.data\n\t\t\t  ORDER BY MAX(lal.last_modified) DESC";
    $res = $gBitDb->query($query, $bindVars, $pListHash['max_records']);
    $user = new BitUser($pListHash['user_id']);
    $user->load();
    while ($status = $res->fetchRow()) {
        $avatarUrl = $user->getThumbnailUrl();
        if (empty($avatarUrl)) {
            $avatarUrl = USERS_PKG_URI . "icons/silhouette.png";
        }
        $status['feed_icon_url'] = $avatarUrl;
        $comment = new LibertyComment(NULL, $status['content_id']);
        $replies = $comment->getComments($status['content_id'], null, null, 'commentDate_asc');
        $status['replies'] = $replies;
        foreach ($status['replies'] as &$reply) {
            $replyUser = new BitUser($reply['user_id']);
            $replyUser->load();
            $replyAvatarUrl = $replyUser->getThumbnailUrl();
            if (empty($replyAvatarUrl)) {
                $replyAvatarUrl = USERS_PKG_URI . "icons/silhouette.png";
            }
            $reply['feed_icon_url'] = $replyAvatarUrl;
        }
        //after loading up the thumbnails in the prior array layout for ease, we break up the array to split long comment threads
        $MAX_SHOWN_REPLIES = 3;
        if (count($status['replies']) > $MAX_SHOWN_REPLIES) {
            $maxIteration = count($status['replies']) - $MAX_SHOWN_REPLIES;
            $i = 0;
            foreach ($status['replies'] as $excess) {
                if ($i < $maxIteration) {
                    $status['replies_excess'][$excess['content_id']] = $excess;
                    //use content_id to index for consistency with normal replies array
                    unset($status['replies'][$excess['content_id']]);
                    //remove from the normal replies array
                } else {
                    break;
                }
                $i++;
            }
        }
        $statuses[] = $status;
    }
    return $statuses;
}
Beispiel #2
0
 } else {
     if (@BitBase::verifyId($commentsParentIds)) {
         $parents = $commentsParentIds;
     } else {
         $parents = $commentsParentId;
     }
     // pass in a reference to the root object so that we can do proper permissions checks
     if (is_object($gContent)) {
         $gComment->mRootObj = $gContent;
     }
     $numComments = $gComment->getNumComments($commentsParentId);
     if ($commentOffset > $numComments) {
         $commentOffset = $numComments / $maxComments;
         $currentPage = ceil($commentOffset + 1 / $maxComments);
     }
     $comments = $gComment->getComments($parents, $maxComments, $commentOffset, $comments_sort_mode, $comments_display_style);
 }
 if ($comments_display_style == 'flat') {
     $commentsTree = $comments;
 } else {
     $commentsTree = array();
     foreach ($comments as $id => $node) {
         if (!empty($comments[$node['parent_id']])) {
             $comments[$node['parent_id']]['children'][$id] =& $comments[$id];
         }
         if ($node['parent_id'] == $node['root_id'] || empty($comments[$node['parent_id']])) {
             $comments[$id]['level'] = 0;
             $commentsTree[$id] =& $comments[$id];
         }
     }
 }
Beispiel #3
0
 /**
  * Load a Blog Post section
  */
 function load($pContentId = NULL, $pPluginParams = NULL)
 {
     if ($this->verifyId($this->mPostId) || $this->verifyId($this->mContentId)) {
         global $gBitSystem, $gBitUser, $gLibertySystem;
         $bindVars = array();
         $selectSql = '';
         $joinSql = '';
         $whereSql = '';
         $lookupColumn = $this->verifyId($this->mPostId) ? 'post_id' : 'content_id';
         $lookupId = $this->verifyId($this->mPostId) ? $this->mPostId : $this->mContentId;
         array_push($bindVars, $lookupId);
         $this->getServicesSql('content_load_sql_function', $selectSql, $joinSql, $whereSql, $bindVars);
         $query = "\n\t\t\t\tSELECT bp.*, lc.*, lcds.`data` AS `summary`, lch.`hits`, 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\t\t\t{$selectSql}\n\t\t\t\tFROM `" . BIT_DB_PREFIX . "blog_posts` bp\n\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON (lc.`content_id` = bp.`content_id`)\n\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "users_users` uu ON( uu.`user_id` = lc.`user_id` )\n\t\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\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_content_hits` lch ON( lch.`content_id` = lc.`content_id` )\n\t\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_attachments` laa ON (uu.`user_id` = laa.`user_id` AND uu.`avatar_attachment_id`=laa.`attachment_id`)\n\t\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_files` lfa ON (lfa.`file_id` = laa.`foreign_id`)\n\t\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\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_files` lfp ON( lfp.`file_id` = lap.`foreign_id` )\n\t\t\t\t\t{$joinSql}\n\t\t\t\tWHERE bp.`{$lookupColumn}`=? {$whereSql} ";
         if ($this->mInfo = $this->mDb->getRow($query, $bindVars)) {
             $this->mPostId = $this->mInfo['post_id'];
             $this->mContentId = $this->mInfo['content_id'];
             $this->mInfo['blogs'] = $this->getBlogMemberships($this->mContentId);
             // this is bad news right here, 'url' is wrong, standard is 'display_url'
             // we should remove this now that display_url is added
             $this->mInfo['url'] = BitBlogPost::getDisplayUrlFromHash($this->mInfo);
             $this->mInfo['display_url'] = BitBlogPost::getDisplayUrlFromHash($this->mInfo);
             foreach (array('avatar', 'image') as $img) {
                 $this->mInfo[$img] = liberty_fetch_thumbnails(array('source_file' => $this->getSourceFile(array('user_id' => $this->getField('user_id'), 'package' => liberty_mime_get_storage_sub_dir_name(array('mime_type' => $this->getField($img . '_mime_type'), 'name' => $this->getField($img . '_file_name'))), 'file_name' => basename($this->mInfo[$img . '_file_name']), 'sub_dir' => $this->getField($img . '_attachment_id')))));
             }
             $this->mInfo['raw'] = $this->mInfo['data'];
             //for two text field auto split
             if ($gBitSystem->isFeatureActive('blog_posts_autosplit') && preg_match(LIBERTY_SPLIT_REGEX, $this->mInfo['raw'])) {
                 $format = $this->mInfo['format_guid'];
                 $linebreak = $gLibertySystem->mPlugins[$format]['linebreak'];
                 if (preg_match("/\\.{3}split\\.{3}(" . preg_quote($linebreak, "/") . "){2}/i", $this->mInfo['raw'])) {
                     $parts = preg_split("/\\.{3}split\\.{3}(" . preg_quote($linebreak, "/") . "){2}/i", $this->mInfo['raw']);
                 } else {
                     $parts = preg_split("/\\.{3}split\\.{3}/i", $this->mInfo['raw']);
                 }
                 $this->mInfo['raw'] = isset($parts[0]) ? $parts[0] : $this->mInfo['raw'];
                 $this->mInfo['raw_more'] = isset($parts[1]) ? $parts[1] : NULL;
             }
             $this->mInfo['data'] = preg_replace(LIBERTY_SPLIT_REGEX, "", $this->mInfo['data']);
             $this->mInfo['use_title'] = $gBitUser->getPreference('user_blog_posts_use_title', 'y', $this->mInfo['user_id']);
             if (isset($pPluginParams['load_comments']) and $pPluginParams['load_comments']) {
                 $comment = new LibertyComment();
                 $comment->mRootObj = $this;
                 $this->mInfo['num_comments'] = $comment->getNumComments($this->mInfo['content_id']);
                 // Get the comments associated with this post
                 $this->mInfo['comments'] = $comment->getComments($this->mInfo['content_id'], $gBitSystem->getConfig('comments_per_page', 10));
             }
             if (!$this->mInfo['trackbacks_from'] || $this->mInfo['trackbacks_from'] === null) {
                 $this->mInfo['trackbacks_from'] = serialize(array());
             }
             if (!$this->mInfo['trackbacks_to'] || $this->mInfo['trackbacks_to'] === null) {
                 $this->mInfo['trackbacks_to'] = serialize(array());
             }
             $this->mInfo['trackbacks_from_count'] = count(array_keys(unserialize($this->mInfo['trackbacks_from'])));
             $this->mInfo['trackbacks_from'] = unserialize($this->mInfo['trackbacks_from']);
             $this->mInfo['trackbacks_to'] = unserialize($this->mInfo['trackbacks_to']);
             $this->mInfo['trackbacks_to_count'] = count($this->mInfo['trackbacks_to']);
             LibertyMime::load();
             if ($this->mStorage) {
                 foreach (array_keys($this->mStorage) as $key) {
                     $this->mStorage[$key]['wiki_plugin_link'] = '{attachment id=' . $key . '}';
                 }
             }
         } else {
             $this->mPostId = NULL;
             $this->mContentId = NULL;
         }
     }
     return count($this->mInfo);
 }