function getNoticeIds($offset, $limit, $since_id, $max_id)
 {
     $inbox = new Group_inbox();
     $inbox->group_id = $this->group->id;
     $inbox->selectAdd();
     $inbox->selectAdd('notice_id');
     Notice::addWhereSinceId($inbox, $since_id, 'notice_id');
     Notice::addWhereMaxId($inbox, $max_id, 'notice_id');
     $inbox->orderBy('created DESC, notice_id DESC');
     if (!is_null($offset)) {
         $inbox->limit($offset, $limit);
     }
     $ids = array();
     if ($inbox->find()) {
         while ($inbox->fetch()) {
             $ids[] = $inbox->notice_id;
         }
     }
     return $ids;
 }
示例#2
0
 function _streamDirect($offset, $limit, $since_id, $max_id)
 {
     $inbox = new Group_inbox();
     $inbox->group_id = $this->id;
     $inbox->selectAdd();
     $inbox->selectAdd('notice_id');
     if ($since_id != 0) {
         $inbox->whereAdd('notice_id > ' . $since_id);
     }
     if ($max_id != 0) {
         $inbox->whereAdd('notice_id <= ' . $max_id);
     }
     $inbox->orderBy('notice_id DESC');
     if (!is_null($offset)) {
         $inbox->limit($offset, $limit);
     }
     $ids = array();
     if ($inbox->find()) {
         while ($inbox->fetch()) {
             $ids[] = $inbox->notice_id;
         }
     }
     return $ids;
 }
示例#3
0
 /**
  * Pull list of groups this notice needs to be delivered to,
  * as previously recorded by saveGroups() or saveKnownGroups().
  *
  * @return array of Group objects
  */
 function getGroups()
 {
     // Don't save groups for repeats
     if (!empty($this->repeat_of)) {
         return array();
     }
     // XXX: cache me
     $groups = array();
     $gi = new Group_inbox();
     $gi->selectAdd();
     $gi->selectAdd('group_id');
     $gi->notice_id = $this->id;
     if ($gi->find()) {
         while ($gi->fetch()) {
             $group = User_group::staticGet('id', $gi->group_id);
             if ($group) {
                 $groups[] = $group;
             }
         }
     }
     $gi->free();
     return $groups;
 }
示例#4
0
 /**
  * Pull list of groups this notice needs to be delivered to,
  * as previously recorded by saveGroups() or saveKnownGroups().
  *
  * @return array of Group objects
  */
 function getGroups()
 {
     // Don't save groups for repeats
     if (!empty($this->repeat_of)) {
         return array();
     }
     $ids = array();
     $keypart = sprintf('notice:groups:%d', $this->id);
     $idstr = self::cacheGet($keypart);
     if ($idstr !== false) {
         $ids = explode(',', $idstr);
     } else {
         $gi = new Group_inbox();
         $gi->selectAdd();
         $gi->selectAdd('group_id');
         $gi->notice_id = $this->id;
         if ($gi->find()) {
             while ($gi->fetch()) {
                 $ids[] = $gi->group_id;
             }
         }
         self::cacheSet($keypart, implode(',', $ids));
     }
     $groups = array();
     foreach ($ids as $id) {
         $group = User_group::staticGet('id', $id);
         if ($group) {
             $groups[] = $group;
         }
     }
     return $groups;
 }