示例#1
0
 /**
  * For initializing members of the class.
  *
  * @param array $argarray misc. arguments
  *
  * @return boolean true
  */
 function prepare($argarray)
 {
     parent::prepare($argarray);
     if ($this->boolean('ajax')) {
         StatusNet::setApi(true);
         // short error results!
     }
     $rsvpId = $this->trimmed('rsvp');
     if (empty($rsvpId)) {
         // TRANS: Client exception thrown when referring to a non-existing RSVP ("please respond") item.
         throw new ClientException(_m('No such RSVP.'));
     }
     $this->rsvp = RSVP::staticGet('id', $rsvpId);
     if (empty($this->rsvp)) {
         // TRANS: Client exception thrown when referring to a non-existing RSVP ("please respond") item.
         throw new ClientException(_m('No such RSVP.'));
     }
     $this->event = Happening::staticGet('id', $this->rsvp->event_id);
     if (empty($this->event)) {
         // TRANS: Client exception thrown when referring to a non-existing event.
         throw new ClientException(_m('No such event.'));
     }
     $this->user = common_current_user();
     if (empty($this->user)) {
         // TRANS: Client exception thrown when trying tp RSVP ("please respond") while not logged in.
         throw new ClientException(_m('You must be logged in to RSVP for an event.'));
     }
     return true;
 }
示例#2
0
 function getNotice()
 {
     $this->id = $this->trimmed('id');
     $this->rsvp = RSVP::staticGet('id', $this->id);
     if (empty($this->rsvp)) {
         // TRANS: Client exception thrown when referring to a non-existing RSVP.
         // TRANS: RSVP stands for "Please reply".
         throw new ClientException(_m('No such RSVP.'), 404);
     }
     $this->event = $this->rsvp->getEvent();
     if (empty($this->event)) {
         // TRANS: Client exception thrown when referring to a non-existing event.
         throw new ClientException(_m('No such event.'), 404);
     }
     $notice = $this->rsvp->getNotice();
     if (empty($notice)) {
         // Did we used to have it, and it got deleted?
         // TRANS: Client exception thrown when referring to a non-existing RSVP.
         // TRANS: RSVP stands for "Please reply".
         throw new ClientException(_m('No such RSVP.'), 404);
     }
     return $notice;
 }
示例#3
0
文件: RSVP.php 项目: Grasia/bolotweet
 static function forEvent($event)
 {
     $keypart = sprintf('rsvp:for-event:%s', $event->id);
     $idstr = self::cacheGet($keypart);
     if ($idstr !== false) {
         $ids = explode(',', $idstr);
     } else {
         $ids = array();
         $rsvp = new RSVP();
         $rsvp->selectAdd();
         $rsvp->selectAdd('id');
         $rsvp->event_id = $event->id;
         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::staticGet('id', $id);
         if (!empty($rsvp)) {
             $verb = self::verbFor($rsvp->response);
             $rsvps[$verb][] = $rsvp;
         }
     }
     return $rsvps;
 }