コード例 #1
0
 /**
  * For initializing members of the class.
  *
  * @param array $argarray misc. arguments
  *
  * @return boolean true
  */
 function prepare($argarray)
 {
     parent::prepare($argarray);
     $convId = $this->trimmed('id');
     if (empty($convId)) {
         // TRANS: Client exception thrown when no conversation ID is given.
         throw new ClientException(_('No conversation ID.'));
     }
     $this->conversation = Conversation::staticGet('id', $convId);
     if (empty($this->conversation)) {
         // TRANS: Client exception thrown when referring to a non-existing conversation ID (%d).
         $this->clientError(_('No conversation ID found'), 404);
         return false;
     }
     $profile = Profile::current();
     $stream = new ConversationNoticeStream($convId, $profile);
     $notice = $stream->getNotices(($this->page - 1) * $this->count, $this->count, $this->since_id, $this->max_id);
     $this->notices = $notice->fetchAll();
     $originalConversation = new Notice();
     $originalConversation->whereAdd('conversation=' . $convId);
     $originalConversation->limit(1);
     $originalConversation->orderBy('created');
     $originalConversation->find();
     if ($originalConversation->fetch()) {
         $this->originalNotice = $originalConversation;
     }
     return true;
 }
コード例 #2
0
 protected function prepare(array $args = array())
 {
     parent::prepare($args);
     $convId = $this->trimmed('id');
     if (empty($convId)) {
         // TRANS: Client exception thrown when no conversation ID is given.
         throw new ClientException(_('No conversation ID.'));
     }
     $this->conversation = Conversation::getKV('id', $convId);
     if (empty($this->conversation)) {
         // TRANS: Client exception thrown when referring to a non-existing conversation ID (%d).
         throw new ClientException(sprintf(_('No conversation with ID %d.'), $convId), 404);
     }
     $stream = new ConversationNoticeStream($convId, $this->scoped);
     $notice = $stream->getNotices(($this->page - 1) * $this->count, $this->count, $this->since_id, $this->max_id);
     $this->notices = $notice->fetchAll();
     return true;
 }
コード例 #3
0
 /**
  * For initializing members of the class.
  *
  * @param array $argarray misc. arguments
  *
  * @return boolean true
  */
 function prepare($argarray)
 {
     parent::prepare($argarray);
     $convId = $this->trimmed('id');
     if (empty($convId)) {
         // TRANS: Client exception thrown when no conversation ID is given.
         //throw new ClientException(_('No status conversation ID.'));
         $this->clientError(_('No status conversation ID'), 404);
     }
     $this->conversation = Conversation::staticGet('id', $convId);
     if (empty($this->conversation)) {
         // TRANS: Client exception thrown when referring to a non-existing conversation ID (%d).
         $this->clientError(_('No status conversation ID found'), 404);
         return false;
     }
     $profile = Profile::current();
     //TODO since_id max_id support
     $stream = new ConversationNoticeStream($convId, $profile);
     $notice = $stream->getNotices(($this->page - 1) * $this->count, $this->count, $this->since_id, $this->max_id);
     $this->notices = $notice->fetchAll();
     return true;
 }
コード例 #4
0
 /**
  * Initialization.
  *
  * @param array $args Web and URL arguments
  *
  * @return boolean false if id not passed in
  */
 function prepare($args)
 {
     parent::prepare($args);
     $this->id = $this->trimmed('id');
     if (empty($this->id)) {
         return false;
     }
     $this->id = $this->id + 0;
     $this->page = $this->trimmed('page');
     if (empty($this->page)) {
         $this->page = 1;
     }
     $cur = common_current_user();
     if (empty($cur)) {
         $this->userProfile = null;
     } else {
         $this->userProfile = $cur->getProfile();
     }
     $stream = new ConversationNoticeStream($this->id, $this->userProfile);
     $this->notices = $stream->getNotices(0, self::MAX_NOTICES);
     return true;
 }
コード例 #5
0
 public function getNotices(Profile $scoped = null, $offset = 0, $limit = 500)
 {
     $stream = new ConversationNoticeStream($this->getID(), $scoped);
     $notices = $stream->getNotices($offset, $limit);
     return $notices;
 }
コード例 #6
0
ファイル: Notice.php プロジェクト: a780201/gnu-social
 /**
  * Is this notice part of an active conversation?
  *
  * @return boolean true if other messages exist in the same
  *                 conversation, false if this is the only one
  */
 function hasConversation()
 {
     if (empty($this->conversation)) {
         // this notice is not part of a conversation apparently
         // FIXME: all notices should have a conversation value, right?
         return false;
     }
     $stream = new ConversationNoticeStream($this->conversation);
     $notice = $stream->getNotices(1, 1);
     // if our "offset 1, limit 1" query got a result, return true else false
     return $notice->N > 0;
 }
コード例 #7
0
ファイル: Conversation.php プロジェクト: phpsource/gnu-social
 public function getNotices($offset = 0, $limit = 500, Profile $scoped = null)
 {
     if ($scoped === null) {
         $scoped = Profile::current();
     }
     $stream = new ConversationNoticeStream($this->id, $scoped);
     $notices = $stream->getNotices($offset, $limit);
     return $notices;
 }
コード例 #8
0
 /**
  * finish the notice
  *
  * Close the last elements in the notice list item
  *
  * @return void
  */
 function showEnd()
 {
     $max = $this->initialItems();
     if (!$this->repeat instanceof Notice) {
         $stream = new ConversationNoticeStream($this->notice->conversation, $this->userProfile);
         $notice = $stream->getNotices(0, $max + 2);
         $notices = array();
         $cnt = 0;
         $moreCutoff = null;
         while ($notice->fetch()) {
             if (Event::handle('StartAddNoticeReply', array($this, $this->notice, $notice))) {
                 // Don't list repeats as separate notices in a conversation
                 if (!empty($notice->repeat_of)) {
                     continue;
                 }
                 if ($notice->id == $this->notice->id) {
                     // Skip!
                     continue;
                 }
                 $cnt++;
                 if ($cnt > $max) {
                     // boo-yah
                     $moreCutoff = clone $notice;
                     break;
                 }
                 $notices[] = clone $notice;
                 // *grumble* inefficient as hell
                 Event::handle('EndAddNoticeReply', array($this, $this->notice, $notice));
             }
         }
         if (Event::handle('StartShowThreadedNoticeTail', array($this, $this->notice, &$notices))) {
             $threadActive = count($notices) > 0;
             // has this thread had any activity?
             $this->out->elementStart('ul', 'notices threaded-replies xoxo');
             if (Event::handle('StartShowThreadedNoticeTailItems', array($this, $this->notice, &$threadActive))) {
                 // Repeats and Faves/Likes are handled in plugins.
                 Event::handle('EndShowThreadedNoticeTailItems', array($this, $this->notice, &$threadActive));
             }
             if (count($notices) > 0) {
                 if ($moreCutoff) {
                     $item = new ThreadedNoticeListMoreItem($moreCutoff, $this->out, count($notices));
                     $item->show();
                 }
                 foreach (array_reverse($notices) as $notice) {
                     if (Event::handle('StartShowThreadedNoticeSub', array($this, $this->notice, $notice))) {
                         $item = new ThreadedNoticeListSubItem($notice, $this->notice, $this->out);
                         $item->show();
                         Event::handle('EndShowThreadedNoticeSub', array($this, $this->notice, $notice));
                     }
                 }
             }
             Event::handle('EndShowThreadedNoticeTail', array($this, $this->notice, $notices));
             $this->out->elementEnd('ul');
         }
     }
     parent::showEnd();
 }
コード例 #9
0
ファイル: Notice.php プロジェクト: Grasia/bolotweet
 function conversationStream($id, $offset = 0, $limit = 20, $since_id = 0, $max_id = 0)
 {
     $stream = new ConversationNoticeStream($id);
     return $stream->getNotices($offset, $limit, $since_id, $max_id);
 }
コード例 #10
0
 /**
  * finish the notice
  *
  * Close the last elements in the notice list item
  *
  * @return void
  */
 function showEnd()
 {
     $max = $this->initialItems();
     if (!$this->repeat) {
         $stream = new ConversationNoticeStream($this->notice->conversation, $this->userProfile);
         $notice = $stream->getNotices(0, $max + 2);
         $notices = array();
         $cnt = 0;
         $moreCutoff = null;
         while ($notice->fetch()) {
             if (Event::handle('StartAddNoticeReply', array($this, $this->notice, $notice))) {
                 if ($notice->id == $this->notice->id) {
                     // Skip!
                     continue;
                 }
                 $cnt++;
                 if ($cnt > $max) {
                     // boo-yah
                     $moreCutoff = clone $notice;
                     break;
                 }
                 $notices[] = clone $notice;
                 // *grumble* inefficient as hell
                 Event::handle('EndAddNoticeReply', array($this, $this->notice, $notice));
             }
         }
         if (Event::handle('StartShowThreadedNoticeTail', array($this, $this->notice, &$notices))) {
             $this->out->elementStart('ul', 'notices threaded-replies xoxo');
             $item = new ThreadedNoticeListFavesItem($this->notice, $this->out);
             $hasFaves = $item->show();
             $item = new ThreadedNoticeListRepeatsItem($this->notice, $this->out);
             $hasRepeats = $item->show();
             if ($notices) {
                 if ($moreCutoff) {
                     $item = new ThreadedNoticeListMoreItem($moreCutoff, $this->out, count($notices));
                     $item->show();
                 }
                 foreach (array_reverse($notices) as $notice) {
                     if (Event::handle('StartShowThreadedNoticeSub', array($this, $this->notice, $notice))) {
                         $item = new ThreadedNoticeListSubItem($notice, $this->notice, $this->out);
                         $item->show();
                         Event::handle('StartShowThreadedNoticeSub', array($this, $this->notice, $notice));
                     }
                 }
             }
             if ($notices || $hasFaves || $hasRepeats) {
                 // @fixme do a proper can-post check that's consistent
                 // with the JS side
                 if (common_current_user()) {
                     $item = new ThreadedNoticeListReplyItem($this->notice, $this->out);
                     $item->show();
                 }
             }
             $this->out->elementEnd('ul');
             Event::handle('EndShowThreadedNoticeTail', array($this, $this->notice, $notices));
         }
     }
     parent::showEnd();
 }