コード例 #1
0
 function getNotifications($offset, $limit, $sinceId, $maxId)
 {
     $all = array();
     do {
         $ids = $this->getNotificationIds($offset, $limit, $sinceId, $maxId);
         $notifications = QvitterNotification::pivotGet('id', $ids);
         // By default, takes out false values
         $notifications = array_filter($notifications);
         $all = array_merge($all, $notifications);
         if (count($notifications < count($ids))) {
             $offset += $limit;
             $limit -= count($notifications);
         }
     } while (count($notifications) < count($ids) && count($ids) > 0);
     return new ArrayWrapper($all);
 }
 /**
  * Handle the request
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 protected function handle()
 {
     parent::handle();
     $n = new QvitterNotification();
     $n->selectAdd();
     $n->selectAdd('id');
     $n->whereAdd(sprintf('qvitternotification.to_profile_id = "%s"', $n->escape($this->auth_user->id)));
     $ids = $n->fetchAll('id');
     $notifications = QvitterNotification::pivotGet('id', $ids);
     $notifications = new ArrayWrapper($notifications);
     $notifications = $notifications->fetchAll();
     foreach ($notifications as $notification) {
         if ($notification->is_seen == 0) {
             $orig = clone $notification;
             $notification->is_seen = 1;
             $notification->update($orig);
         }
     }
     $this->initDocument('json');
     $this->showJsonObjects(true);
     $this->endDocument('json');
 }