示例#1
0
 static function forEvent(Happening $event)
 {
     $keypart = sprintf('rsvp:for-event:%s', $event->getUri());
     $idstr = self::cacheGet($keypart);
     if ($idstr !== false) {
         $ids = explode(',', $idstr);
     } else {
         $ids = array();
         $rsvp = new RSVP();
         $rsvp->selectAdd();
         $rsvp->selectAdd('id');
         $rsvp->event_uri = $event->getUri();
         if ($rsvp->find()) {
             while ($rsvp->fetch()) {
                 $ids[] = $rsvp->id;
             }
         }
         self::cacheSet($keypart, implode(',', $ids));
     }
     $rsvps = array(RSVP::POSITIVE => array(), RSVP::NEGATIVE => array(), RSVP::POSSIBLE => array());
     foreach ($ids as $id) {
         $rsvp = RSVP::getKV('id', $id);
         if (!empty($rsvp)) {
             $verb = self::verbFor($rsvp->response);
             $rsvps[$verb][] = $rsvp;
         }
     }
     return $rsvps;
 }