gnu-social/plugins/Event/actions/cancelrsvp.php

90 lines
2.9 KiB
PHP
Raw Normal View History

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-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/
*/
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/
*/
class CancelrsvpAction extends FormAction
2011-03-09 17:28:25 +00:00
{
protected $form = 'CancelRSVP';
2011-03-09 17:28:25 +00:00
function title()
{
// TRANS: Title for RSVP ("please respond") action.
return _m('TITLE','Cancel RSVP');
2011-03-09 17:28:25 +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)) {
// TRANS: Client exception thrown when referring to a non-existing RSVP ("please respond") item.
throw new ClientException(_m('No such RSVP.'));
2011-03-09 17:28:25 +00:00
}
$this->rsvp = RSVP::getKV('id', $rsvpId);
2011-03-09 17:28:25 +00:00
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.'));
2011-03-09 17:28:25 +00:00
}
$this->formOpts['rsvp'] = $this->rsvp;
}
2011-03-09 17:28:25 +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)) {
// TRANS: Client exception thrown when referring to a non-existing event.
throw new ClientException(_m('No such event.'));
2011-03-09 17:28:25 +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 {
common_log(LOG_DEBUG, "Deleting RSVP alone...");
$this->rsvp->delete();
2011-03-09 17:28:25 +00:00
}
}
}