/** * 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; }
function getNotice() { $this->id = $this->trimmed('id'); $this->event = Happening::staticGet('id', $this->id); 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->event->getNotice(); if (empty($notice)) { // Did we used to have it, and it got deleted? // TRANS: Client exception thrown when referring to a non-existing event. throw new ClientException(_m('No such event.'), 404); } return $notice; }
/** * 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! } $eventId = $this->trimmed('event'); if (empty($eventId)) { // TRANS: Client exception thrown when requesting a non-exsting event. throw new ClientException(_m('No such event.')); } $this->event = Happening::staticGet('id', $eventId); if (empty($this->event)) { // TRANS: Client exception thrown when requesting a non-exsting event. throw new ClientException(_m('No such event.')); } $this->user = common_current_user(); if (empty($this->user)) { // TRANS: Client exception thrown when trying to RSVP ("please respond") while not logged in. throw new ClientException(_m('You must be logged in to RSVP for an event.')); } common_debug(print_r($this->args, true)); switch (strtolower($this->trimmed('submitvalue'))) { case 'yes': $this->verb = RSVP::POSITIVE; break; case 'no': $this->verb = RSVP::NEGATIVE; break; case 'maybe': $this->verb = RSVP::POSSIBLE; break; default: // TRANS: Client exception thrown when using an invalid value for RSVP ("please respond"). throw new ClientException(_m('Unknown submit value.')); } return true; }
static function fromNotice($notice) { return Happening::staticGet('uri', $notice->uri); }
function asString() { $event = Happening::staticGet('id', $this->event_id); return self::toString($this->getProfile(), $event, $this->response); }
/** * Given a parsed ActivityStreams activity, save it into a notice * and other data structures. * * @param Activity $activity * @param Profile $actor * @param array $options=array() * * @return Notice the resulting notice */ function saveNoticeFromActivity($activity, $actor, $options = array()) { if (count($activity->objects) != 1) { // TRANS: Exception thrown when there are too many activity objects. throw new Exception(_m('Too many activity objects.')); } $happeningObj = $activity->objects[0]; if ($happeningObj->type != Happening::OBJECT_TYPE) { // TRANS: Exception thrown when event plugin comes across a non-event type object. throw new Exception(_m('Wrong type for object.')); } $notice = null; switch ($activity->verb) { case ActivityVerb::POST: // FIXME: get startTime, endTime, location and URL $notice = Happening::saveNew($actor, $start_time, $end_time, $happeningObj->title, null, $happeningObj->summary, null, $options); break; case RSVP::POSITIVE: case RSVP::NEGATIVE: case RSVP::POSSIBLE: $happening = Happening::staticGet('uri', $happeningObj->id); if (empty($happening)) { // FIXME: save the event // TRANS: Exception thrown when trying to RSVP for an unknown event. throw new Exception(_m('RSVP for unknown event.')); } $notice = RSVP::saveNew($actor, $happening, $activity->verb, $options); break; default: // TRANS: Exception thrown when event plugin comes across a undefined verb. throw new Exception(_m('Unknown verb for events.')); } return $notice; }