Beispiel #1
0
 /**
  * Constructor
  *
  * @param User $user User to get a stream for
  */
 function __construct($user)
 {
     $this->user = $user;
     $this->inbox = Inbox::staticGet('user_id', $user->id);
 }
 /**
  * Constructor
  *
  * @param User $user User to get a stream for
  */
 function __construct($user, $bFilter = false)
 {
     $this->user = $user;
     $this->inbox = Inbox::staticGet('user_id', $user->id);
     $this->needFilter = $bFilter;
 }
 function stream($user_id, $offset, $limit, $since_id, $max_id, $own = false)
 {
     $inbox = Inbox::staticGet('user_id', $user_id);
     if (empty($inbox)) {
         $inbox = Inbox::fromNoticeInbox($user_id);
         if (empty($inbox)) {
             return array();
         } else {
             $inbox->encache();
         }
     }
     $ids = $inbox->unpack();
     if (!empty($since_id)) {
         $newids = array();
         foreach ($ids as $id) {
             if ($id > $since_id) {
                 $newids[] = $id;
             }
         }
         $ids = $newids;
     }
     if (!empty($max_id)) {
         $newids = array();
         foreach ($ids as $id) {
             if ($id <= $max_id) {
                 $newids[] = $id;
             }
         }
         $ids = $newids;
     }
     $ids = array_slice($ids, $offset, $limit);
     return $ids;
 }
function initializeInbox($user)
{
    if (!have_option('q', 'quiet')) {
        print "Initializing inbox for {$user->nickname}...";
    }
    $inbox = Inbox::staticGet('user_id', $user->id);
    if ($inbox && !empty($inbox->fake)) {
        if (!have_option('q', 'quiet')) {
            echo "(replacing faux cached inbox)";
        }
        $inbox = false;
    }
    if (!empty($inbox)) {
        if (!have_option('q', 'quiet')) {
            print "SKIP\n";
        }
    } else {
        $inbox = Inbox::initialize($user->id);
        if (!have_option('q', 'quiet')) {
            if (empty($inbox)) {
                print "ERR\n";
            } else {
                print "DONE\n";
            }
        }
    }
}