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

84 lines
2.4 KiB
PHP
Raw Normal View History

2011-03-09 01:15:17 +09:00
<?php
/**
2011-03-10 02:28:25 +09:00
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2011, StatusNet, Inc.
2011-03-09 01:15:17 +09:00
*
2011-03-10 02:28:25 +09:00
* RSVP for an event
*
2011-03-09 01:15:17 +09: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/>.
2011-03-10 02:28:25 +09:00
*
* @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-03-09 01:15:17 +09:00
*/
if (!defined('GNUSOCIAL')) { exit(1); }
2011-03-09 01:15:17 +09:00
/**
2011-03-10 02:28:25 +09:00
* RSVP for an event
2011-03-09 01:15:17 +09:00
*
2011-03-10 02:28:25 +09:00
* @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-03-09 01:15:17 +09:00
*/
class NewrsvpAction extends FormAction
2011-03-09 01:15:17 +09:00
{
protected $form = 'RSVP';
protected $event;
2011-03-09 01:15:17 +09:00
2011-03-10 02:28:25 +09:00
function title()
{
// TRANS: Title for RSVP ("please respond") action.
return _m('TITLE','New RSVP');
2011-03-10 02:28:25 +09:00
}
protected function doPreparation()
2011-03-09 01:15:17 +09:00
{
$this->event = Happening::getByKeys(['uri'=>$this->trimmed('event')]);
2011-03-09 01:15:17 +09:00
$this->formOpts['event'] = $this->event;
2011-03-09 01:15:17 +09:00
}
protected function doPost()
2011-03-09 01:15:17 +09:00
{
$verb = RSVP::verbFor(strtolower($this->trimmed('submitvalue')));
2011-03-10 02:28:25 +09:00
$options = array('source' => 'web');
2011-03-10 02:28:25 +09:00
$act = new Activity();
$act->id = UUID::gen();
$act->verb = $verb;
$act->time = time();
$act->title = _m('RSVP');
$act->actor = $this->scoped->asActivityObject();
$act->target = $this->event->getStored()->asActivityObject();
$act->objects = array(clone($act->target));
$act->content = RSVP::toHTML($this->scoped, $this->event, RSVP::codeFor($verb));
2011-03-10 02:28:25 +09:00
$stored = Notice::saveActivity($act, $this->scoped, $options);
2011-03-09 01:15:17 +09:00
return _m('Saved RSVP');
2011-03-09 01:15:17 +09:00
}
}