/** * For initializing members of the class. * * @param array $argarray misc. arguments * * @return boolean true */ function prepare($argarray) { parent::prepare($argarray); if ($this->boolean('ajax')) { GNUsocial::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::getKV('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::getKV('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 filter($notice) { if (!parent::filter($notice)) { // if not in our scope, return false return false; } if (empty($this->rsvp)) { // Don't filter on RSVP (for only events with RSVP if no responses // are given (give ['Y', 'N', '?'] for only RSVP'd events!). return true; } $rsvp = new RSVP(); $rsvp->profile_id = $this->target->getID(); $rsvp->event_uri = $notice->getUri(); $rsvp->whereAddIn('response', $this->rsvp, $rsvp->columnType('response')); // filter out if no RSVP match was found return $rsvp->N > 0; }
public function postCreate() { $validator = Validator::make(Input::all(), RSVP::$rules); if ($validator->passes()) { // validation has passed, save user in DB $rsvp = new RSVP(); $rsvp->guest1 = Input::get('guest1'); $rsvp->email = Input::get('email'); $rsvp->attending = Input::get('attending'); $rsvp->vegetarian = Input::has('vegetarian') ? 1 : 0; $rsvp->save(); Mail::send('emails.confirm', array('user' => Input::get('guest1')), function ($message) { $message->to(Input::get('email'))->subject('Thank you for your RSVP!'); }); return Redirect::to('/dashboard/#rsvp')->with('message', 'Thanks for your RSVP!'); } else { // validation has failed, display error messages return Redirect::to('/#rsvp')->with('message', 'The following errors occurred')->withErrors($validator)->withInput(); } }
function showContent() { $notice = $this->nli->notice; $out = $this->nli->out; $rsvp = RSVP::fromNotice($notice); if (empty($rsvp)) { // TRANS: Content for a deleted RSVP list item (RSVP stands for "please respond"). $out->element('p', null, _m('Deleted.')); return; } $out->elementStart('div', 'rsvp'); $out->raw($rsvp->asHTML()); $out->elementEnd('div'); return; }
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; }
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; }
/** * Add a new event * * @return void */ function newEvent() { try { if (empty($this->title)) { // TRANS: Client exception thrown when trying to post an event without providing a title. throw new ClientException(_m('Event must have a title.')); } if (empty($this->startTime)) { // TRANS: Client exception thrown when trying to post an event without providing a start time. throw new ClientException(_m('Event must have a start time.')); } if (empty($this->endTime)) { // TRANS: Client exception thrown when trying to post an event without providing an end time. throw new ClientException(_m('Event must have an end time.')); } if (!empty($this->url) && Validate::uri($this->url) === false) { // TRANS: Client exception thrown when trying to post an event with an invalid URL. throw new ClientException(_m('URL must be valid.')); } $options = array(); // Does the heavy-lifting for getting "To:" information ToSelector::fillOptions($this, $options); $profile = $this->user->getProfile(); $saved = Happening::saveNew($profile, $this->startTime, $this->endTime, $this->title, $this->location, $this->description, $this->url, $options); $event = Happening::fromNotice($saved); RSVP::saveNew($profile, $event, RSVP::POSITIVE); } catch (ClientException $ce) { if ($this->boolean('ajax')) { $this->outputAjaxError($ce->getMessage()); return; } else { $this->error = $ce->getMessage(); $this->showPage(); return; } } if ($this->boolean('ajax')) { $this->startHTML('text/xml;charset=utf-8'); $this->elementStart('head'); // TRANS: Page title after sending a notice. $this->element('title', null, _m('Event saved')); $this->elementEnd('head'); $this->elementStart('body'); $this->showNotice($saved); $this->elementEnd('body'); $this->endHTML(); } else { common_redirect($saved->getUrl(), 303); } }
function getRSVP($profile) { return RSVP::pkeyGet(array('profile_id' => $profile->id, 'event_id' => $this->id)); }
/** * Data elements of the form * * @return void */ function formData() { $this->out->elementStart('fieldset', array('id' => 'new_rsvp_data')); $this->out->hidden('rsvp-id', $this->rsvp->id, 'rsvp'); switch (RSVP::verbFor($this->rsvp->response)) { case RSVP::POSITIVE: // TRANS: Possible status for RSVP ("please respond") item. $this->out->text(_m('You will attend this event.')); break; case RSVP::NEGATIVE: // TRANS: Possible status for RSVP ("please respond") item. $this->out->text(_m('You will not attend this event.')); break; case RSVP::POSSIBLE: // TRANS: Possible status for RSVP ("please respond") item. $this->out->text(_m('You might attend this event.')); break; } $this->out->elementEnd('fieldset'); }
public function removeRSVP(SS_HTTPRequest $request) { try { $summit_id = intval($request->param('SUMMIT_ID')); $rsvp_id = intval($request->param('RSVP_ID')); $summit = $this->summit_repository->getById($summit_id); if (is_null($summit)) { throw new NotFoundEntityException('Summit', sprintf(' id %s', $summit_id)); } RSVP::delete_by_id('RSVP', $rsvp_id); return $this->ok(); } catch (NotFoundEntityException $ex2) { SS_Log::log($ex2->getMessage(), SS_Log::WARN); return $this->notFound($ex2->getMessages()); } catch (Exception $ex) { SS_Log::log($ex->getMessage(), SS_Log::ERR); return $this->serverError(); } }
public function makeEventReservation($id) { if (Confide::user()) { $reservation = new RSVP(); $reservation->user_id = Auth::user()->id; $reservation->event_id = $id; $reservation->response = Input::get('response'); $reservation->save(); Session::flash('successMessage', 'Your reservation has been saved'); return Redirect::action('EventsController@index'); } else { Session::flash('successMessage', 'You must first be logged in to register for an event!!'); return View::make('users.login'); } }
/** * @param $data * @param IMessageSenderService $sender_service * @return mixed */ public function addRSVP($data, IMessageSenderService $sender_service) { $rsvp_repository = $this->rsvp_repository; $attendee_repository = $this->attendee_repository; $summitevent_repository = $this->summitevent_repository; return $this->tx_manager->transaction(function () use($data, $attendee_repository, $rsvp_repository, $summitevent_repository, $sender_service) { $member_id = intval($data['member_id']); $summit_id = intval($data['summit_id']); $event_id = intval($data['event_id']); $seat_type = $data['seat_type']; if (empty($seat_type)) { throw new EntityValidationException("invalid seat type!"); } $event = $summitevent_repository->getById($event_id); $summit_attendee = $attendee_repository->getByMemberAndSummit(intval($member_id), intval($summit_id)); if (is_null($summit_attendee)) { throw new EntityValidationException(sprintf("there is no any attendee for member %s and summit %s", $member_id, $summit_id)); } if (!$event) { throw new NotFoundEntityException('Event', ''); } if (!$event->RSVPTemplate()) { throw new EntityValidationException('RSVPTemplate not set'); } // add to schedule the RSVP event if (!$summit_attendee->isScheduled($event_id)) { $summit_attendee->addToSchedule($event); } $old_rsvp = $rsvp_repository->getByEventAndAttendee($event_id, $summit_attendee->getIdentifier()); if (!is_null($old_rsvp)) { throw new EntityValidationException(sprintf("attendee %s already submitted an rsvp for event %s on summit %s", $summit_attendee->getIdentifier(), $event_id, $summit_id)); } $rsvp = new RSVP(); $rsvp->EventID = $event_id; $rsvp->SubmittedByID = $summit_attendee->getIdentifier(); $rsvp->SeatType = $event->getCurrentRSVPSubmissionSeatType(); if (!$event->couldAddSeatType($rsvp->SeatType)) { throw new EntityValidationException(sprintf("you reach the limit of rsvp items for current event %s ( regular seats %s - wait list seats %s)", $event_id, $event->getCurrentSeatsCountByType(IRSVP::SeatTypeRegular), $event->getCurrentSeatsCountByType(IRSVP::SeatTypeWaitList))); } foreach ($event->RSVPTemplate()->getQuestions() as $q) { $question_name = $q->name(); if ($q instanceof RSVPDropDownQuestionTemplate) { $question_name = $q->IsMultiSelect ? $q->name() . '[]' : $question_name; } else { if ($q instanceof RSVPCheckBoxListQuestionTemplate) { $question_name = $q->name() . '[]'; } } if (isset($data[$question_name])) { if (!$rsvp || !($answer = $rsvp->findAnswerByQuestion($q))) { $answer = new RSVPAnswer(); } $answer_value = $data[$question_name]; if (is_array($answer_value)) { $answer_value = str_replace('{comma}', ',', $answer_value); $answer->Value = implode(',', $answer_value); } else { $answer->Value = $answer_value; } $answer->QuestionID = $q->getIdentifier(); $answer->write(); $rsvp->addAnswer($answer); } } if (!is_null($sender_service)) { $rsvp->BeenEmailed = true; $sender_service->send(['Event' => $event, 'Attendee' => $summit_attendee]); } $rsvp->write(); return $rsvp; }); }
/** * When a notice is deleted, clean up related tables. * * @param Notice $notice */ function deleteRelated($notice) { switch ($notice->object_type) { case Happening::OBJECT_TYPE: common_log(LOG_DEBUG, "Deleting event from notice..."); $happening = Happening::fromNotice($notice); $happening->delete(); break; case RSVP::POSITIVE: case RSVP::NEGATIVE: case RSVP::POSSIBLE: common_log(LOG_DEBUG, "Deleting rsvp from notice..."); $rsvp = RSVP::fromNotice($notice); common_log(LOG_DEBUG, "to delete: {$rsvp->id}"); $rsvp->delete(); break; default: common_log(LOG_DEBUG, "Not deleting related, wtf..."); } }
function getRSVP($profile) { return RSVP::pkeyGet(array('profile_id' => $profile->getID(), 'event_uri' => $this->getUri())); }
protected function showRSVP(Notice $stored, HTMLOutputter $out, Profile $scoped = null) { $rsvp = RSVP::fromNotice($stored); if (empty($rsvp)) { // TRANS: Content for a deleted RSVP list item (RSVP stands for "please respond"). $out->element('p', null, _m('Deleted.')); return; } $out->elementStart('div', 'rsvp'); $out->raw($rsvp->asHTML()); $out->elementEnd('div'); }
/** * Add a new event * * @return void */ function newRSVP() { try { $saved = RSVP::saveNew($this->user->getProfile(), $this->event, $this->verb); } catch (ClientException $ce) { $this->error = $ce->getMessage(); $this->showPage(); return; } if ($this->boolean('ajax')) { $rsvp = RSVP::fromNotice($saved); header('Content-Type: text/xml;charset=utf-8'); $this->xw->startDocument('1.0', 'UTF-8'); $this->elementStart('html'); $this->elementStart('head'); // TRANS: Page title after creating an event. $this->element('title', null, _m('Event saved')); $this->elementEnd('head'); $this->elementStart('body'); $this->elementStart('body'); $cancel = new CancelRSVPForm($rsvp, $this); $cancel->show(); $this->elementEnd('body'); $this->elementEnd('body'); $this->elementEnd('html'); } else { common_redirect($saved->bestUrl(), 303); } }
<?php include "src/serverModels/utilities.php"; $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : "home"; if (strpos($action, "api") === 0) { if ($_SERVER['REQUEST_METHOD'] === 'POST') { switch ($action) { case "api/addRsvp": include "src/serverModels/database/rsvp.php"; $postData = file_get_contents("php://input"); $rsvpData = json_decode($postData); $rsvpArray = array(); foreach ($rsvpData as $singleRsvp) { $tempRsvp = new RSVP(); $tempRsvp->createRSVPFromJson($singleRsvp); $tempRsvp->addRsvp(); } break; default: echo "<br>Unexpected action on Post: {$action}<br>(index)"; break; } } if ($_SERVER['REQUEST_METHOD'] === 'GET') { switch ($action) { case "api/features": include "src/serverModels/database/features.php"; $tempFeatures = new Features(); echo json_encode($tempFeatures->getFeatures()); break; default: