X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FEvent%2Fnewrsvp.php;h=e9adf405d85841bbb5f50899ddef05eba2a092de;hb=5e97047f8ff328e514ae84760692e43190f131e6;hp=da613ec6c78c1ec2dae5b2dac2f95006b3f18025;hpb=35429c28e5bdde71fe9dff9e69ef795a31a96e8d;p=quix0rs-gnu-social.git diff --git a/plugins/Event/newrsvp.php b/plugins/Event/newrsvp.php index da613ec6c7..e9adf405d8 100644 --- a/plugins/Event/newrsvp.php +++ b/plugins/Event/newrsvp.php @@ -4,7 +4,7 @@ * Copyright (C) 2011, StatusNet, Inc. * * RSVP for an event - * + * * PHP version 5 * * This program is free software: you can redistribute it and/or modify @@ -27,6 +27,7 @@ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ + if (!defined('STATUSNET')) { // This check helps protect against security problems; // your code file can't be executed directly from the web. @@ -43,22 +44,21 @@ if (!defined('STATUSNET')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ - class NewrsvpAction extends Action { protected $user = null; protected $event = null; - protected $type = null; + protected $verb = null; /** * Returns the title of the action * * @return string Action title */ - function title() { - return _('New RSVP'); + // TRANS: Title for RSVP ("please respond") action. + return _m('TITLE','New RSVP'); } /** @@ -68,36 +68,51 @@ class NewrsvpAction extends Action * * @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)) { - throw new ClientException(_('No such event.')); + // 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)) { - throw new ClientException(_('No such 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)) { - throw new ClientException(_('You must be logged in to RSVP for an event.')); + // 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.')); } - if ($this->arg('yes')) { - $this->type = RSVP::POSITIVE; - } else if ($this->arg('no')) { - $this->type = RSVP::NEGATIVE; - } else { - $this->type = RSVP::POSSIBLE; + 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; } @@ -108,7 +123,6 @@ class NewrsvpAction extends Action * * @return void */ - function handle($argarray=null) { parent::handle($argarray); @@ -127,13 +141,12 @@ class NewrsvpAction extends Action * * @return void */ - function newRSVP() { try { $saved = RSVP::saveNew($this->user->getProfile(), $this->event, - $this->type); + $this->verb); } catch (ClientException $ce) { $this->error = $ce->getMessage(); $this->showPage(); @@ -146,8 +159,8 @@ class NewrsvpAction extends Action $this->xw->startDocument('1.0', 'UTF-8'); $this->elementStart('html'); $this->elementStart('head'); - // TRANS: Page title after sending a notice. - $this->element('title', null, _('Event saved')); + // TRANS: Page title after creating an event. + $this->element('title', null, _m('Event saved')); $this->elementEnd('head'); $this->elementStart('body'); $this->elementStart('body'); @@ -166,7 +179,6 @@ class NewrsvpAction extends Action * * @return void */ - function showContent() { if (!empty($this->error)) { @@ -189,7 +201,6 @@ class NewrsvpAction extends Action * * @return boolean is read only action? */ - function isReadOnly($args) { if ($_SERVER['REQUEST_METHOD'] == 'GET' ||