Esempio n. 1
0
 protected function getNotices()
 {
     // is this our own stream?
     $own = $this->scoped instanceof Profile ? $this->target->getID() === $this->scoped->getID() : false;
     $stream = Fave::stream($this->target->getID(), 0, $this->limit, $own);
     return $stream->fetchAll();
 }
Esempio n. 2
0
 /**
  * Get notices
  *
  * @param integer $limit max number of notices to return
  *
  * @return array notices
  */
 function getNotices($limit = 0)
 {
     $notice = Fave::stream($this->user->id, 0, $limit, $false);
     $notices = array();
     while ($notice->fetch()) {
         $notices[] = clone $notice;
     }
     return $notices;
 }
Esempio n. 3
0
 /**
  * Prepare the object
  *
  * Check the input values and initialize the object.
  * Shows an error page on bad input.
  *
  * @param array $args $_REQUEST data
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     parent::prepare($args);
     $nickname = common_canonical_nickname($this->arg('nickname'));
     $this->user = User::getKV('nickname', $nickname);
     if (!$this->user) {
         // TRANS: Client error displayed when trying to display favourite notices for a non-existing user.
         $this->clientError(_('No such user.'));
     }
     $this->page = $this->trimmed('page');
     if (!$this->page) {
         $this->page = 1;
     }
     common_set_returnto($this->selfUrl());
     $cur = common_current_user();
     // Show imported/gateway notices as well as local if
     // the user is looking at their own favorites, otherwise not.
     $this->notice = Fave::stream($this->user->id, ($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1, !empty($cur) && $cur->id == $this->user->id);
     if (empty($this->notice)) {
         // TRANS: Server error displayed when favourite notices could not be retrieved from the database.
         $this->serverError(_('Could not retrieve favorite notices.'));
     }
     if ($this->page > 1 && $this->notice->N == 0) {
         // TRANS: Client error when page not found (404)
         $this->clientError(_('No such page.'), 404);
     }
     return true;
 }
Esempio n. 4
0
 function favoriteNotices($own = false, $offset = 0, $limit = NOTICES_PER_PAGE, $since_id = 0, $max_id = 0)
 {
     $ids = Fave::stream($this->id, $offset, $limit, $own, $since_id, $max_id);
     return Notice::getStreamByIds($ids);
 }
Esempio n. 5
0
 function hasFave($notice)
 {
     $cache = common_memcache();
     // XXX: Kind of a hack.
     if (!empty($cache)) {
         // This is the stream of favorite notices, in rev chron
         // order. This forces it into cache.
         $ids = Fave::stream($this->id, 0, NOTICE_CACHE_WINDOW);
         // If it's in the list, then it's a fave
         if (in_array($notice->id, $ids)) {
             return true;
         }
         // If we're not past the end of the cache window,
         // then the cache has all available faves, so this one
         // is not a fave.
         if (count($ids) < NOTICE_CACHE_WINDOW) {
             return false;
         }
         // Otherwise, cache doesn't have all faves;
         // fall through to the default
     }
     $fave = Fave::pkeyGet(array('user_id' => $this->id, 'notice_id' => $notice->id));
     return is_null($fave) ? false : true;
 }
Esempio n. 6
0
 function favoriteNotices($own = false, $offset = 0, $limit = NOTICES_PER_PAGE, $since_id = 0, $max_id = 0)
 {
     return Fave::stream($this->id, $offset, $limit, $own, $since_id, $max_id);
 }
 /**
  * Get notices
  *
  * @return array notices
  */
 function getNotices()
 {
     $notices = array();
     common_debug("since id = " . $this->since_id . " max id = " . $this->max_id);
     $notice = Fave::stream($this->target->id, ($this->page - 1) * $this->count, $this->count, !empty($this->auth_user) && $this->auth_user->id == $this->target->id, $this->since_id, $this->max_id);
     while ($notice->fetch()) {
         $notices[] = clone $notice;
     }
     return $notices;
 }