2011-03-09 17:28:25 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* StatusNet - the distributed open-source microblogging tool
|
|
|
|
* Copyright (C) 2011, StatusNet, Inc.
|
|
|
|
*
|
|
|
|
* Cancel the RSVP for an event
|
2011-04-07 13:01:40 +01:00
|
|
|
*
|
2011-03-09 17:28:25 +00:00
|
|
|
* PHP version 5
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* @category Event
|
|
|
|
* @package StatusNet
|
|
|
|
* @author Evan Prodromou <evan@status.net>
|
|
|
|
* @copyright 2011 StatusNet, Inc.
|
|
|
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
|
|
|
* @link http://status.net/
|
|
|
|
*/
|
2011-04-07 13:01:40 +01:00
|
|
|
|
2016-01-19 00:33:09 +00:00
|
|
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
2011-03-09 17:28:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* RSVP for an event
|
|
|
|
*
|
|
|
|
* @category Event
|
|
|
|
* @package StatusNet
|
|
|
|
* @author Evan Prodromou <evan@status.net>
|
|
|
|
* @copyright 2011 StatusNet, Inc.
|
|
|
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
|
|
|
* @link http://status.net/
|
|
|
|
*/
|
2016-01-19 00:41:06 +00:00
|
|
|
class CancelrsvpAction extends FormAction
|
2011-03-09 17:28:25 +00:00
|
|
|
{
|
2016-01-19 00:41:06 +00:00
|
|
|
protected $form = 'CancelRSVP';
|
2011-03-09 17:28:25 +00:00
|
|
|
|
|
|
|
function title()
|
|
|
|
{
|
2011-04-07 13:01:40 +01:00
|
|
|
// TRANS: Title for RSVP ("please respond") action.
|
|
|
|
return _m('TITLE','Cancel RSVP');
|
2011-03-09 17:28:25 +00:00
|
|
|
}
|
|
|
|
|
2016-01-19 00:41:06 +00:00
|
|
|
// FIXME: Merge this action with RSVPAction and add a 'cancel' thing there...
|
|
|
|
protected function doPreparation()
|
2011-03-09 17:28:25 +00:00
|
|
|
{
|
|
|
|
$rsvpId = $this->trimmed('rsvp');
|
|
|
|
if (empty($rsvpId)) {
|
2011-04-07 13:01:40 +01:00
|
|
|
// TRANS: Client exception thrown when referring to a non-existing RSVP ("please respond") item.
|
2011-03-30 21:30:23 +01:00
|
|
|
throw new ClientException(_m('No such RSVP.'));
|
2011-03-09 17:28:25 +00:00
|
|
|
}
|
|
|
|
|
2013-08-18 12:04:58 +01:00
|
|
|
$this->rsvp = RSVP::getKV('id', $rsvpId);
|
2011-03-09 17:28:25 +00:00
|
|
|
if (empty($this->rsvp)) {
|
2011-04-07 13:01:40 +01:00
|
|
|
// TRANS: Client exception thrown when referring to a non-existing RSVP ("please respond") item.
|
2011-03-30 21:30:23 +01:00
|
|
|
throw new ClientException(_m('No such RSVP.'));
|
2011-03-09 17:28:25 +00:00
|
|
|
}
|
|
|
|
|
2016-01-19 00:41:06 +00:00
|
|
|
$this->formOpts['rsvp'] = $this->rsvp;
|
|
|
|
}
|
2011-03-09 17:28:25 +00:00
|
|
|
|
2016-01-19 00:41:06 +00:00
|
|
|
protected function doPost()
|
|
|
|
{
|
|
|
|
$this->event = Happening::getKV('uri', $this->rsvp->event_uri);
|
2011-03-09 17:28:25 +00:00
|
|
|
if (empty($this->event)) {
|
2011-04-07 13:01:40 +01:00
|
|
|
// TRANS: Client exception thrown when referring to a non-existing event.
|
2011-03-30 21:30:23 +01:00
|
|
|
throw new ClientException(_m('No such event.'));
|
2011-03-09 17:28:25 +00:00
|
|
|
}
|
|
|
|
|
2016-01-19 00:41:06 +00:00
|
|
|
$notice = $this->rsvp->getNotice();
|
|
|
|
// NB: this will delete the rsvp, too
|
|
|
|
if (!empty($notice)) {
|
|
|
|
common_log(LOG_DEBUG, "Deleting notice...");
|
|
|
|
$notice->deleteAs($this->scoped);
|
2011-03-09 17:28:25 +00:00
|
|
|
} else {
|
2016-01-19 00:41:06 +00:00
|
|
|
common_log(LOG_DEBUG, "Deleting RSVP alone...");
|
|
|
|
$this->rsvp->delete();
|
2011-03-09 17:28:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|