code:
<?php
/**
 * StatusNet - the distributed open-source microblogging tool
 * Copyright (C) 2011, StatusNet, Inc.
 *
 * Microapp plugin for event invitations and RSVPs
 *
 * 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); }

/**
 * Event plugin
 *
 * @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 EventPlugin extends ActivityVerbHandlerPlugin
{
    const PLUGIN_VERSION = '2.0.0';

    /**
     * Set up our tables (event and rsvp)
     *
     * @see Schema
     * @see ColumnDef
     *
     * @return boolean hook value; true means continue processing, false means stop.
     */
    function onCheckSchema()
    {
        $schema = Schema::get();

        $schema->ensureTable('happening', Happening::schemaDef());
        $schema->ensureTable('rsvp', RSVP::schemaDef());

        return true;
    }

    public function onBeforePluginCheckSchema()
    {
        RSVP::beforeSchemaUpdate();
        return true;
    }

    /**
     * Map URLs to actions
     *
     * @param URLMapper $m path-to-action mapper
     *
     * @return boolean hook value; true means continue processing, false means stop.
     */
    public function onRouterInitialized(URLMapper $m)
    {
        $m->connect('main/event/new',
                    ['action' => 'newevent']);
        $m->connect('main/event/rsvp',
                    ['action' => 'rsvp']);
        $m->connect('main/event/rsvp/:rsvp',    // this will probably change to include event notice id
                    ['action' => 'rsvp'],
                    ['rsvp'   => '[a-z]+']);
        $m->connect('event/:id',
                    ['action' => 'showevent'],
                    ['id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}']);
        $m->connect('rsvp/:id',
                    ['action' => 'showrsvp'],
                    ['id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}']);
        $m->connect('main/event/updatetimes',
                    ['action' => 'timelist']);

        $m->connect(':nickname/events',
                    ['action' => 'events'],
                    ['nickname' => Nickname::DISPLAY_FMT]);
        return true;
    }

    function onPluginVersion(array &$versions)
    {
        $versions[] = array('name' => 'Event',
                            'version' => self::PLUGIN_VERSION,
                            'author' => 'Evan Prodromou',
                            'homepage' => 'https://git.gnu.io/gnu/gnu-social/tree/master/plugins/Event',
                            'description' =>
                            // TRANS: Plugin description.
                            _m('Event invitations and RSVPs.'));
        return true;
    }

    function appTitle() {
        // TRANS: Title for event application.
        return _m('TITLE','Event');
    }

    function tag() {
        return 'event';
    }

    function types() {
        return array(Happening::OBJECT_TYPE);
    }

    function verbs() {
        return array(ActivityVerb::POST,
                     RSVP::POSITIVE,
                     RSVP::NEGATIVE,
                     RSVP::POSSIBLE);
    }

    function isMyNotice(Notice $notice) {
        if (!empty($notice->object_type)) {
            return parent::isMyNotice($notice);
        }
        return $this->isMyVerb($notice->verb);
    }

    public function newFormAction() {
        // such as 'newbookmark' or 'newevent' route
        return 'new'.$this->tag();
    }

    function onStartShowEntryForms(&$tabs)
    {
        $tabs[$this->tag()] = array('title' => $this->appTitle(),
                                    'href'  => common_local_url($this->newFormAction()),
                                   );
        return true;
    }

    function onStartMakeEntryForm($tag, $out, &$form)
    {
        if ($tag == $this->tag()) {
            $form = $this->entryForm($out);
            return false;
        }

        return true;
    }

    protected function getActionTitle(ManagedAction $action, $verb, Notice $target, Profile $scoped)
    {
        return $verb;
    }

    protected function doActionPreparation(ManagedAction $action, $verb, Notice $target, Profile $scoped)
    {
        return true;
    }

    protected function doActionPost(ManagedAction $action, $verb, Notice $target, Profile $scoped)
    {
        throw new ServerException('Event does not handle doActionPost yet', 501);
    }

    protected function getActivityForm(ManagedAction $action, $verb, Notice $target, Profile $scoped)
    {
        return new RSVPForm(Happening::fromStored($target), $action);
    }

    protected function saveObjectFromActivity(Activity $act, Notice $stored, array $options=array())
    {
        switch (true) {
        case ActivityUtils::compareVerbs($stored->getVerb(), [ActivityVerb::POST]):
            return Happening::saveActivityObject($act, $stored);
            break;

        case ActivityUtils::compareVerbs($stored->getVerb(), [RSVP::POSITIVE, RSVP::NEGATIVE, RSVP::POSSIBLE]):
            return RSVP::saveActivityObject($act, $stored);
            break;
        }
        return null;
    }

    function activityObjectFromNotice(Notice $stored)
    {
        $happening = null;

        switch (true) {
        case $stored->isVerb([ActivityVerb::POST]) && $stored->isObjectType([Happening::OBJECT_TYPE]):
            $obj = Happening::fromStored($stored)->asActivityObject();
            break;
        // isObjectType here is because we had the verb stored in object_type previously for unknown reasons
        case $stored->isObjectType([RSVP::POSITIVE, RSVP::NEGATIVE, RSVP::POSSIBLE]):
        case $stored->isVerb([RSVP::POSITIVE, RSVP::NEGATIVE, RSVP::POSSIBLE]):
            $obj = RSVP::fromStored($stored)->asActivityObject();
            break;
        default:
            // TRANS: Exception thrown when event plugin comes across a unknown object type.
            throw new Exception(_m('Unknown object type.'));
        }

        return $obj;
    }

    /**
     * Form for our app
     *
     * @param HTMLOutputter $out
     * @return Widget
     */
    function entryForm($out)
    {
        return new EventForm($out);
    }

    function deleteRelated(Notice $stored)
    {
        switch (true) {
        case $stored->isObjectType([Happening::OBJECT_TYPE]):
            common_log(LOG_DEBUG, "Deleting event from notice...");
            try {
                $happening = Happening::fromStored($stored);
                $happening->delete();
            } catch (NoResultException $e) {
                // already gone
            }
            break;
        // isObjectType here is because we had the verb stored in object_type previously for unknown reasons
        case $stored->isObjectType([RSVP::POSITIVE, RSVP::NEGATIVE, RSVP::POSSIBLE]):
        case $stored->isVerb([RSVP::POSITIVE, RSVP::NEGATIVE, RSVP::POSSIBLE]):
            common_log(LOG_DEBUG, "Deleting rsvp from notice...");
            try {
                $rsvp = RSVP::fromStored($stored);
                $rsvp->delete();
            } catch (NoResultException $e) {
                // already gone
            }
            break;
        }
    }

    function onEndShowScripts($action)
    {
        $action->script($this->path('js/event.js'));
    }

    function onEndShowStyles($action)
    {
        $action->cssLink($this->path('css/event.css'));
        return true;
    }

    function onStartAddNoticeReply($nli, $parent, $child)
    {
        if (($parent->object_type == Happening::OBJECT_TYPE) &&
            in_array($child->object_type, array(RSVP::POSITIVE, RSVP::NEGATIVE, RSVP::POSSIBLE))) {
            return false;
        }
        return true;
    }

    protected function showNoticeContent(Notice $stored, HTMLOutputter $out, Profile $scoped=null)
    {
        switch (true) {
        case ActivityUtils::compareTypes($stored->verb, array(ActivityVerb::POST)) &&
                ActivityUtils::compareTypes($stored->object_type, array(Happening::OBJECT_TYPE)):
            $this->showEvent($stored, $out, $scoped);
            break;
        case ActivityUtils::compareVerbs($stored->verb, array(RSVP::POSITIVE, RSVP::NEGATIVE, RSVP::POSSIBLE)):
            $this->showRSVP($stored, $out, $scoped);
            break;
        default:
            throw new ServerException('This is not an Event notice');
        }
        return true;
    }

    protected function showEvent(Notice $stored, HTMLOutputter $out, Profile $scoped=null)
    {
        $profile = $stored->getProfile();
        $event   = Happening::fromStored($stored);

        $out->elementStart('div', 'h-event');

        $out->elementStart('h3', 'p-summary p-name');

        try {
            $out->element('a', array('href' => $event->getUrl()), $event->title);
        } catch (InvalidUrlException $e) {
            $out->text($event->title);
        }

        $out->elementEnd('h3');

        $now       = new DateTime();
        $startDate = new DateTime($event->start_time);
        $endDate   = new DateTime($event->end_time);
        $userTz    = new DateTimeZone(common_timezone());

        // Localize the time for the observer
        $now->setTimeZone($userTz);
        $startDate->setTimezone($userTz);
        $endDate->setTimezone($userTz);

        $thisYear  = $now->format('Y');
        $startYear = $startDate->format('Y');
        $endYear   = $endDate->format('Y');

        $dateFmt = 'D, F j, '; // e.g.: Mon, Aug 31

        if ($startYear != $thisYear || $endYear != $thisYear) {
            $dateFmt .= 'Y,'; // append year if we need to think about years
        }

        $startDateStr = $startDate->format($dateFmt);
        $endDateStr = $endDate->format($dateFmt);

        $timeFmt = 'g:ia';

        $startTimeStr = $startDate->format($timeFmt);
        $endTimeStr = $endDate->format("{$timeFmt} (T)");

        $out->elementStart('div', 'event-times'); // VEVENT/EVENT-TIMES IN

        // TRANS: Field label for event description.
        $out->element('strong', null, _m('Time:'));

        $out->element('time', array('class' => 'dt-start',
                                    'datetime' => common_date_iso8601($event->start_time)),
                      $startDateStr . ' ' . $startTimeStr);
        $out->text(' – ');
        $out->element('time', array('class' => 'dt-end',
                                    'datetime' => common_date_iso8601($event->end_time)),
                      $startDateStr != $endDateStr
                                    ? "$endDateStr $endTimeStr"
                                    :  $endTimeStr);

        $out->elementEnd('div'); // VEVENT/EVENT-TIMES OUT

        if (!empty($event->location)) {
            $out->elementStart('div', 'event-location');
            // TRANS: Field label for event description.
            $out->element('strong', null, _m('Location:'));
            $out->element('span', 'p-location', $event->location);
            $out->elementEnd('div');
        }

        if (!empty($event->description)) {
            $out->elementStart('div', 'event-description');
            // TRANS: Field label for event description.
            $out->element('strong', null, _m('Description:'));
            $out->element('div', 'p-description', $event->description);
            $out->elementEnd('div');
        }

        $rsvps = $event->getRSVPs();

        $out->elementStart('div', 'event-rsvps');

        // TRANS: Field label for event description.
        $out->element('strong', null, _m('Attending:'));
        $out->elementStart('ul', 'attending-list');

        foreach ($rsvps as $verb => $responses) {
            $out->elementStart('li', 'rsvp-list');
            switch ($verb) {
            case RSVP::POSITIVE:
                $out->text(_('Yes:'));
                break;
            case RSVP::NEGATIVE:
                $out->text(_('No:'));
                break;
            case RSVP::POSSIBLE:
                $out->text(_('Maybe:'));
                break;
            }
            $ids = array();
            foreach ($responses as $response) {
                $ids[] = $response->profile_id;
            }
            $ids = array_slice($ids, 0, ProfileMiniList::MAX_PROFILES + 1);
            $minilist = new ProfileMiniList(Profile::multiGet('id', $ids), $out);
            $minilist->show();

            $out->elementEnd('li');
        }

        $out->elementEnd('ul');
        $out->elementEnd('div');

        if ($scoped instanceof Profile) {
            $form = new RSVPForm($out, array('event'=>$event, 'scoped'=>$scoped));
            $form->show();
        }
        $out->elementEnd('div');
    }

    protected function showRSVP(Notice $stored, HTMLOutputter $out, Profile $scoped=null)
    {
        try {
            $rsvp = RSVP::fromStored($stored)->asHTML();
        } catch (NoResultException $e) {
            // 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);
        $out->elementEnd('div');
    }

    function onEndPersonalGroupNav(Menu $menu, Profile $target, Profile $scoped=null)
    {
        $menu->menuItem(common_local_url('events', array('nickname' => $target->getNickname())),
                          // TRANS: Menu item in sample plugin.
                          _m('Happenings'),
                          // TRANS: Menu item title in sample plugin.
                          _m('A list of your events'), false, 'nav_timeline_events');
        return true;
    }
}


code:
The Event plugin adds event invitations and RSVPs types of notices.

Installation
============
This plugin is enabled by default

Settings
========
none

path: plugins/Event/README

license: mit


code:
<?php
/**
 * List events
 */

if (!defined('GNUSOCIAL')) { exit(1); }

class EventsAction extends ShowstreamAction
{
    public function getStream()
    {
                                     /* whose events */   /* are these the user's own events? */
        $stream = new EventsNoticeStream($this->target, $this->scoped);
        return $stream;
    }

    function title()
    {
        // TRANS: Page title for sample plugin. %s is a user nickname.
        return sprintf(_m('%s\'s happenings'), $this->target->getNickname());
    }

    function getFeeds()
    {
        return array(
                    );
    }

    function showEmptyList() {
        $message = sprintf(_('This is %1$s\'s event stream, but %1$s hasn\'t received any events yet.'), $this->target->getNickname()) . ' ';

        $this->elementStart('div', 'guide');
        $this->raw(common_markup_to_html($message));
        $this->elementEnd('div');
    }

    /**
     * Return true if read only.
     *
     * Some actions only read from the database; others read and write.
     * The simple database load-balancer built into StatusNet will
     * direct read-only actions to database mirrors (if they are configured),
     * and read-write actions to the master database.
     *
     * This defaults to false to avoid data integrity issues, but you
     * should make sure to overload it for performance gains.
     *
     * @param array $args other arguments, if RO/RW status depends on them.
     *
     * @return boolean is read only action?
     */
    function isReadOnly($args)
    {
        return true;
    }
}


code:
<?php
/**
 * StatusNet - the distributed open-source microblogging tool
 * Copyright (C) 2011, StatusNet, Inc.
 *
 * Add a new event
 *
 * 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); }

/**
 * Add a new 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 NeweventAction extends FormAction
{
    protected $form = 'Event';

    /**
     * Returns the title of the action
     *
     * @return string Action title
     */
    function title()
    {
        // TRANS: Title for new event form.
        return _m('TITLE','New event');
    }

    protected function doPost()
    {
        // HUMAN TEXT DATA
        $title = $this->trimmed('title');
        if (empty($title)) {
            // TRANS: Client exception thrown when trying to post an event without providing a title.
            throw new ClientException(_m('Event must have a title.'));
        }
        $description = $this->trimmed('description');

        // TIME PARSING
        $tz          = $this->trimmed('tz');

        $startDate = $this->trimmed('startdate');
        if (empty($startDate)) {
            // TRANS: Client exception thrown when trying to post an event without providing a start date.
            throw new ClientException(_m('Start date required.'));
        }
        $startTime = $this->trimmed('event-starttime');
        if (empty($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.'));
        }
        $start_str = sprintf('%s %s %s', $startDate, $startTime, $tz);
        $start = strtotime($start_str);
        if ($start === false) {
            // TRANS: Client exception thrown when trying to post an event with a date that cannot be processed.
            // TRANS: %s is the data that could not be processed.
            throw new ClientException(sprintf(_m('Could not parse date %s.'), _ve($start_str)));
        }

        $endDate = $this->trimmed('enddate');
        if (empty($endDate)) {
            // TRANS: Client exception thrown when trying to post an event without providing an end date.
            throw new ClientException(_m('End date required.'));
        }
        $endTime = $this->trimmed('event-endtime');
        if (empty($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.'));
        }
        $end_str   = sprintf('%s %s %s', $endDate, $endTime, $tz);
        $end = strtotime($end_str);
        if ($end === false) {
            // TRANS: Client exception thrown when trying to post an event with a date that cannot be processed.
            // TRANS: %s is the data that could not be processed.
            throw new ClientException(sprintf(_m('Could not parse date %s.'), _ve($end_str)));
        }

        $url         = $this->trimmed('url');
        if (!empty($url) && !common_valid_http_url($url)) {
            // TRANS: Client exception thrown when trying to post an event with an invalid (non-empty) URL.
            throw new ClientException(_m('An event URL must be a valid HTTP/HTTPS link.'));
        }

        // LOCATION DATA
        $location    = $this->trimmed('location');

        $options = [ 'source' => 'web' ];

        $act = new Activity();
        $act->verb = ActivityVerb::POST;
        $act->time = time();
        $act->actor = $this->scoped->asActivityObject();

        $act->context = new ActivityContext();
        // FIXME: Add location here? Let's make it possible to include current location with less code...

        $actobj = new ActivityObject();
        $actobj->id = UUID::gen();
        $actobj->type = Happening::OBJECT_TYPE;
        $actobj->title = $title;
        $actobj->summary = $description;
        $actobj->extra[] = array('dtstart',
                                array('xmlns' => 'urn:ietf:params:xml:ns:xcal'),
                                common_date_iso8601($start_str));
        $actobj->extra[] = array('dtend',
                                array('xmlns' => 'urn:ietf:params:xml:ns:xcal'),
                                common_date_iso8601($end_str));
        $actobj->extra[] = array('location',
                                array('xmlns' => 'urn:ietf:params:xml:ns:xcal'),
                                $location);
        $actobj->extra[] = array('url',
                                array('xmlns' => 'urn:ietf:params:xml:ns:xcal'),
                                $url);

        /* We don't use these ourselves, but we add them to be nice RSS/XML citizens */
        $actobj->extra[] = array('startdate',
                                array('xmlns' => 'http://purl.org/rss/1.0/modules/event/'),
                                common_date_iso8601($start_str));
        $actobj->extra[] = array('enddate',
                                array('xmlns' => 'http://purl.org/rss/1.0/modules/event/'),
                                common_date_iso8601($end_str));
        $actobj->extra[] = array('location',
                                array('xmlns' => 'http://purl.org/rss/1.0/modules/event/'),
                                $location);

        $act->objects = array($actobj);

        $stored = Notice::saveActivity($act, $this->scoped, $options);

        return _m('Saved the event.');
    }
}


code:
<?php
/**
 * StatusNet - the distributed open-source microblogging tool
 * Copyright (C) 2011, StatusNet, Inc.
 *
 * RSVP for an event
 *
 * 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); }

/**
 * 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 RsvpAction extends FormAction
{
    protected $form = 'RSVP';

    protected $event = null;

    function title()
    {
        // TRANS: Title for RSVP ("please respond") action.
        return _m('TITLE','New RSVP');
    }

    protected function doPreparation()
    {
        if ($this->trimmed('notice')) {
            $stored = Notice::getByID($this->trimmed('notice'));
            $this->event = Happening::fromStored($stored);
        } else {
            $this->event = Happening::getByKeys(['uri'=>$this->trimmed('event')]);
        }

        $this->formOpts['event'] = $this->event;
    }

    protected function doPost()
    {
        if ($this->trimmed('rsvp') === 'cancel') {
            $rsvp = RSVP::byEventAndActor($this->event, $this->scoped);
            try {
                $notice = $rsvp->getStored();
                $notice->deleteAs($this->scoped);
            } catch (NoResultException $e) {
                // Notice already gone
                $rsvp->delete();
            } catch (Exception $e) {
                // emergency cleanup in case database is screwed up
                $rsvp->delete();
            }
            return _m('Cancelled RSVP');
        }

        $verb = RSVP::verbFor(strtolower($this->trimmed('rsvp')));
        $options = array('source' => 'web');

        $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));

        $act->context = new ActivityContext();
        $act->context->replyToID = $this->event->getUri();

        $stored = Notice::saveActivity($act, $this->scoped, $options);

        return _m('Saved RSVP');
    }
}


code:
<?php
/**
 * StatusNet - the distributed open-source microblogging tool
 * Copyright (C) 2010, StatusNet, Inc.
 *
 * Show a single RSVP
 *
 * 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  RSVP
 * @package   StatusNet
 * @author    Evan Prodromou <evan@status.net>
 * @copyright 2010 StatusNet, Inc.
 * @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.
    exit(1);
}

/**
 * Show a single RSVP, with associated information
 *
 * @category  RSVP
 * @package   StatusNet
 * @author    Evan Prodromou <evan@status.net>
 * @copyright 2010 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
 * @link      http://status.net/
 */
class ShowrsvpAction extends ShownoticeAction
{
    protected $rsvp = null;
    protected $event = null;

    function getNotice()
    {
        $this->id = $this->trimmed('id');

        $this->rsvp = RSVP::getKV('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;
    }

    /**
     * Title of the page
     *
     * Used by Action class for layout.
     *
     * @return string page tile
     */
    function title()
    {
        // TRANS: Title for event.
	// TRANS: %1$s is a user nickname, %2$s is an event title.
        return sprintf(_m('%1$s\'s RSVP for "%2$s"'),
                       $this->user->nickname,
                       $this->event->title);
    }
}


code:
<?php
/**
 * StatusNet - the distributed open-source microblogging tool
 * Copyright (C) 2011, StatusNet, Inc.
 *
 * 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    Zach Copley <zach@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('STATUSNET')) {
    exit(1);
}

/**
 * Callback handler to populate end time dropdown
 */
class TimelistAction extends Action {
    private $start;
    private $duration;

    /**
     * Get ready
     *
     * @param array $args misc. arguments
     *
     * @return boolean true
     */
    function prepare(array $args = array()) {
        parent::prepare($args);
        $this->start = $this->arg('start');
        $this->duration = $this->boolean('duration', false);
        return true;
    }

    /**
     * Handle input and ouput something
     *
     * @param array $args $_REQUEST arguments
     *
     * @return void
     */
    function handle()
    {
        parent::handle();

        if (!common_logged_in()) {
            // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
            $this->clientError(_m('Not logged in.'));
        }

        if (!empty($this->start)) {
            $times = EventTimeList::getTimes($this->start, $this->duration);
        } else {
            // TRANS: Client error when submitting a form with unexpected information.
            $this->clientError(_m('Unexpected form submission.'));
        }

        if ($this->boolean('ajax')) {
            header('Content-Type: application/json; charset=utf-8');
            print json_encode($times);
        } else {
            // TRANS: Client error displayed when using an action in a non-AJAX way.
            $this->clientError(_m('This action is AJAX only.'));
        }
    }

    /**
     * Override the regular error handler to show something more
     * ajaxy
     *
     * @param string $msg   error message
     * @param int    $code  error code
     */
    function clientError($msg, $code = 400) {
        if ($this->boolean('ajax')) {
            header('Content-Type: application/json; charset=utf-8');
            print json_encode(
                array(
                    'success' => false,
                    'code'    => $code,
                    'message' => $msg
                )
            );
        } else {
            parent::clientError($msg, $code);
        }
    }
}


code:
<?php
/**
 * Data class for happenings
 *
 * PHP version 5
 *
 * @category Data
 * @package  StatusNet
 * @author   Evan Prodromou <evan@status.net>
 * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
 * @link     http://status.net/
 *
 * StatusNet - the distributed open-source microblogging tool
 * Copyright (C) 2011, StatusNet, Inc.
 *
 * 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/>.
 */

if (!defined('GNUSOCIAL')) { exit(1); }

/**
 * Data class for happenings
 *
 * There's already an Event class in lib/event.php, so we couldn't
 * call this an Event without causing a hole in space-time.
 *
 * "Happening" seemed good enough.
 *
 * @category Event
 * @package  StatusNet
 * @author   Evan Prodromou <evan@status.net>
 * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
 * @link     http://status.net/
 *
 * @see      Managed_DataObject
 */
class Happening extends Managed_DataObject
{
    const OBJECT_TYPE = 'http://activitystrea.ms/schema/1.0/event';

    public $__table = 'happening'; // table name
    public $id;                    // varchar(36) UUID
    public $uri;                   // varchar(191)   not 255 because utf8mb4 takes more space
    public $profile_id;            // int
    public $start_time;            // datetime
    public $end_time;              // datetime
    public $title;                 // varchar(191)   not 255 because utf8mb4 takes more space
    public $location;              // varchar(191)   not 255 because utf8mb4 takes more space
    public $url;                   // varchar(191)   not 255 because utf8mb4 takes more space
    public $description;           // text
    public $created;               // datetime

    /**
     * The One True Thingy that must be defined and declared.
     */
    public static function schemaDef()
    {
        return array(
            'description' => 'A real-world happening',
            'fields' => array(
                'id' => array('type' => 'char',
                              'length' => 36,
                              'not null' => true,
                              'description' => 'UUID'),
                'uri' => array('type' => 'varchar',
                               'length' => 191,
                               'not null' => true),
                'profile_id' => array('type' => 'int', 'not null' => true),
                'start_time' => array('type' => 'datetime', 'not null' => true),
                'end_time' => array('type' => 'datetime', 'not null' => true),
                'title' => array('type' => 'varchar',
                                 'length' => 191,
                                 'not null' => true),
                'location' => array('type' => 'varchar',
                                    'length' => 191),
                'url' => array('type' => 'varchar',
                               'length' => 191),
                'description' => array('type' => 'text'),
                'created' => array('type' => 'datetime',
                                   'not null' => true),
            ),
            'primary key' => array('id'),
            'unique keys' => array(
                'happening_uri_key' => array('uri'),
            ),
            'foreign keys' => array('happening_profile_id__key' => array('profile', array('profile_id' => 'id')),
                                    'happening_uri__key' => array('notice', array('uri' => 'uri'))),
            'indexes' => array('happening_created_idx' => array('created'),
                               'happening_start_end_idx' => array('start_time', 'end_time')),
        );
    }

    public static function saveActivityObject(Activity $act, Notice $stored)
    {
        if (count($act->objects) !== 1) {
            // TRANS: Exception thrown when there are too many activity objects.
            throw new Exception(_m('Too many activity objects.'));
        }
        $actobj = $act->objects[0];
        if (!ActivityUtils::compareTypes($actobj->type, [Happening::OBJECT_TYPE])) {
            // TRANS: Exception thrown when event plugin comes across a non-event type object.
            throw new Exception(_m('Wrong type for object.'));
        }

        try {
            $other = Happening::getByKeys(['uri' => $actobj->id]);
            throw AlreadyFulfilledException('Happening already exists.');
        } catch (NoResultException $e) {
            // alright, let's save this
        }

        $dtstart = null;
        $dtend = null;
        $location = null;
        $url = null;

        foreach ($actobj->extra as $extra) {
            switch ($extra[0]) {
            case 'dtstart':
                $dtstart = $extra[2];
            case 'dtend':
                $dtend = $extra[2];
                break;
            case 'location':
                // location is optional
                $location = $extra[2];
                break;
            case 'url':
                // url is optional
                $url = $extra[2];
            }
        }
        if(empty($dtstart)) {
            // TRANS: Exception thrown when has no start date
            throw new Exception(_m('No start date for event.'));
        }
        if(empty($dtend)) {
            // TRANS: Exception thrown when has no end date
            throw new Exception(_m('No end date for event.'));
        }

        // convert RFC3339 dates delivered in Activity Stream to MySQL DATETIME date format
        $start_time = new DateTime($dtstart);
        $start_time->setTimezone(new DateTimeZone('UTC'));
        $start_time = $start_time->format('Y-m-d H:i:s');
        $end_time = new DateTime($dtend);
        $end_time->setTimezone(new DateTimeZone('UTC'));
        $end_time = $end_time->format('Y-m-d H:i:s');

        $ev = new Happening();

        $ev->id          = UUID::gen();
        $ev->uri         = $actobj->id;
        $ev->profile_id  = $stored->getProfile()->getID();
        $ev->start_time  = $start_time;
        $ev->end_time    = $end_time;
        $ev->title       = $actobj->title;
        $ev->location    = $location;
        $ev->description = $stored->getContent();
        $ev->url         = $url;
        $ev->created     = $stored->getCreated();

        $ev->insert();
        return $ev;
    }

    public function insert()
    {
        $result = parent::insert();
        if ($result === false) {
            common_log_db_error($this, 'INSERT', __FILE__);
            throw new ServerException(_('Failed to insert '._ve(get_called_class()).' into database'));
        }
        return $result;
    }

    /**
     * Returns the profile's canonical url, not necessarily a uri/unique id
     *
     * @return string $url
     */
    public function getUrl()
    {
        if (empty($this->url) ||
                !filter_var($this->url, FILTER_VALIDATE_URL)) {
            throw new InvalidUrlException($this->url);
        }
        return $this->url;
    }

    public function getUri()
    {
        return $this->uri;
    }

    public function getStored()
    {
        return Notice::getByKeys(array('uri'=>$this->getUri()));
    }

    static function fromStored(Notice $stored)
    {
        if (!ActivityUtils::compareTypes($stored->getObjectType(), [self::OBJECT_TYPE])) {
            throw new ServerException('Notice is not of type '.self::OBJECT_TYPE);
        }
        return self::getByKeys(array('uri'=>$stored->getUri()));
    }

    function getRSVPs()
    {
        return RSVP::forEvent($this);
    }

    function getRSVP($profile)
    {
        return RSVP::pkeyGet(array('profile_id' => $profile->getID(),
                                   'event_uri' => $this->getUri()));
    }

    static public function getObjectType()
    {
        return self::OBJECT_TYPE;
    }

    public function asActivityObject()
    {
        $actobj = new ActivityObject();
        $actobj->id = $this->getUri();
        $actobj->type = self::getObjectType();
        $actobj->title = $this->title;
        $actobj->summary = $this->description;
        $actobj->extra[] = array('dtstart',
                                array('xmlns' => 'urn:ietf:params:xml:ns:xcal'),
                                common_date_iso8601($this->start_time));
        $actobj->extra[] = array('dtend',
                                array('xmlns' => 'urn:ietf:params:xml:ns:xcal'),
                                common_date_iso8601($this->end_time));
        $actobj->extra[] = array('location',
                                array('xmlns' => 'urn:ietf:params:xml:ns:xcal'),
                                $this->location);
        try {
            $actobj->extra[] = array('url',
                                    array('xmlns' => 'urn:ietf:params:xml:ns:xcal'),
                                    $this->getUrl());
        } catch (InvalidUrlException $e) {
            // oh well, no URL for you!
        }

        /* We don't use these ourselves, but we add them to be nice RSS/XML citizens */
        $actobj->extra[] = array('startdate',
                                array('xmlns' => 'http://purl.org/rss/1.0/modules/event/'),
                                common_date_iso8601($this->start_time));
        $actobj->extra[] = array('enddate',
                                array('xmlns' => 'http://purl.org/rss/1.0/modules/event/'),
                                common_date_iso8601($this->end_time));
        $actobj->extra[] = array('location',
                                array('xmlns' => 'http://purl.org/rss/1.0/modules/event/'),
                                $this->location);

        return $actobj;
    }
}


code:
<?php
/**
 * Data class for event RSVPs
 *
 * PHP version 5
 *
 * @category Data
 * @package  StatusNet
 * @author   Evan Prodromou <evan@status.net>
 * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
 * @link     http://status.net/
 *
 * StatusNet - the distributed open-source microblogging tool
 * Copyright (C) 2011, StatusNet, Inc.
 *
 * 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/>.
 */

if (!defined('GNUSOCIAL')) { exit(1); }

/**
 * Data class for event RSVPs
 *
 * @category Event
 * @package  StatusNet
 * @author   Evan Prodromou <evan@status.net>
 * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
 * @link     http://status.net/
 *
 * @see      Managed_DataObject
 */
class RSVP extends Managed_DataObject
{
    const POSITIVE = 'http://activitystrea.ms/schema/1.0/rsvp-yes';
    const POSSIBLE = 'http://activitystrea.ms/schema/1.0/rsvp-maybe';
    const NEGATIVE = 'http://activitystrea.ms/schema/1.0/rsvp-no';

    public $__table = 'rsvp'; // table name
    public $id;                // varchar(36) UUID
    public $uri;               // varchar(191)   not 255 because utf8mb4 takes more space
    public $profile_id;        // int
    public $event_uri;         // varchar(191)   not 255 because utf8mb4 takes more space
    public $response;            // tinyint
    public $created;           // datetime

    /**
     * The One True Thingy that must be defined and declared.
     */
    public static function schemaDef()
    {
        return array(
            'description' => 'Plan to attend event',
            'fields' => array(
                'id' => array('type' => 'char',
                              'length' => 36,
                              'not null' => true,
                              'description' => 'UUID'),
                'uri' => array('type' => 'varchar',
                               'length' => 191,
                               'not null' => true),
                'profile_id' => array('type' => 'int'),
                'event_uri' => array('type' => 'varchar',
                              'length' => 191,
                              'not null' => true,
                              'description' => 'Event URI'),
                'response' => array('type' => 'char',
                                  'length' => '1',
                                  'description' => 'Y, N, or ? for three-state yes, no, maybe'),
                'created' => array('type' => 'datetime',
                                   'not null' => true),
            ),
            'primary key' => array('id'),
            'unique keys' => array(
                'rsvp_uri_key' => array('uri'),
                'rsvp_profile_event_key' => array('profile_id', 'event_uri'),
            ),
            'foreign keys' => array('rsvp_event_uri_key' => array('happening', array('event_uri' => 'uri')),
                                    'rsvp_profile_id__key' => array('profile', array('profile_id' => 'id'))),
            'indexes' => array('rsvp_created_idx' => array('created')),
        );
    }

    static public function beforeSchemaUpdate()
    {
        $table = strtolower(get_called_class());
        $schema = Schema::get();
        $schemadef = $schema->getTableDef($table);

        // 2015-12-31 RSVPs refer to Happening by event_uri now, not event_id. Let's migrate!
        if (isset($schemadef['fields']['event_uri'])) {
            // We seem to have already migrated, good!
            return;
        }

        // this is a "normal" upgrade from StatusNet for example
        echo "\nFound old $table table, upgrading it to add 'event_uri' field...";

        $schemadef['fields']['event_uri'] = array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'Event URI');
        $schemadef['fields']['uri']['length'] = 191;    // we likely don't have to discover too long keys here
        $schema->ensureTable($table, $schemadef);

        $rsvp = new RSVP();
        $rsvp->find();
        while ($rsvp->fetch()) {
            $event = Happening::getKV('id', $rsvp->event_id);
            if (!$event instanceof Happening) {
                $rsvp->delete();
                continue;
            }
            $orig = clone($rsvp);
            $rsvp->event_uri = $event->uri;
            $rsvp->updateWithKeys($orig);
        }
        print "DONE.\n";
        print "Resuming core schema upgrade...";
    }

    static function saveActivityObject(Activity $act, Notice $stored)
    {
        $target = Notice::getByKeys(array('uri'=>$act->target->id));
        if (!ActivityUtils::compareTypes($target->getObjectType(), [ Happening::OBJECT_TYPE ])) {
            throw new ClientException('RSVP not aimed at a Happening');
        }

        // FIXME: Maybe we need some permission handling here, though I think it's taken care of in saveActivity?

        try {
            $other = RSVP::getByKeys( [ 'profile_id' => $stored->getProfile()->getID(),
                                        'event_uri' => $target->getUri(),
                                      ] );
            // TRANS: Client exception thrown when trying to save an already existing RSVP ("please respond").
            throw new AlreadyFulfilledException(_m('RSVP already exists.'));
        } catch (NoResultException $e) {
            // No previous RSVP, so go ahead and add.
        }

        $rsvp = new RSVP();
        $rsvp->id          = UUID::gen();   // remove this
        $rsvp->uri         = $stored->getUri();
        $rsvp->profile_id  = $stored->getProfile()->getID();
        $rsvp->event_uri   = $target->getUri();
        $rsvp->response    = self::codeFor($stored->getVerb());
        $rsvp->created     = $stored->getCreated();

        $rsvp->insert();

        self::blow('rsvp:for-event:%s', $target->getUri());

        return $rsvp;
    }

    static public function getObjectType()
    {
        return ActivityObject::ACTIVITY;
    }

    public function asActivityObject()
    {
        $happening = $this->getEvent();

        $actobj = new ActivityObject();
        $actobj->id = $this->getUri();
        $actobj->type = self::getObjectType();
        $actobj->title = $this->asString();
        $actobj->content = $this->asString();
        $actobj->target = array($happening->asActivityObject());

        return $actobj;
    }

    static function codeFor($verb)
    {
        switch (true) {
        case ActivityUtils::compareVerbs($verb, [RSVP::POSITIVE]):
            return 'Y';
            break;
        case ActivityUtils::compareVerbs($verb, [RSVP::NEGATIVE]):
            return 'N';
            break;
        case ActivityUtils::compareVerbs($verb, [RSVP::POSSIBLE]):
            return '?';
            break;
        default:
            // TRANS: Exception thrown when requesting an undefined verb for RSVP.
            throw new Exception(sprintf(_m('Unknown verb "%s".'),$verb));
        }
    }

    static function verbFor($code)
    {
        switch ($code) {
        case 'Y':
        case 'yes':
            return RSVP::POSITIVE;
            break;
        case 'N':
        case 'no':
            return RSVP::NEGATIVE;
            break;
        case '?':
        case 'maybe':
            return RSVP::POSSIBLE;
            break;
        default:
            // TRANS: Exception thrown when requesting an undefined code for RSVP.
            throw new ClientException(sprintf(_m('Unknown code "%s".'), $code));
        }
    }

    public function getUri()
    {
        return $this->uri;
    }

    public function getEventUri()
    {
        return $this->event_uri;
    }

    public function getStored()
    {
        return Notice::getByKeys(['uri' => $this->getUri()]);
    }

    static function fromStored(Notice $stored)
    {
        return self::getByKeys(['uri' => $stored->getUri()]);
    }

    static function byEventAndActor(Happening $event, Profile $actor)
    {
        return self::getByKeys(['event_uri' => $event->getUri(),
                                'profile_id' => $actor->getID()]);
    }

    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;
    }

    function getProfile()
    {
        return Profile::getByID($this->profile_id);
    }

    function getEvent()
    {
        return Happening::getByKeys(['uri' => $this->getEventUri()]);
    }

    function asHTML()
    {
        return self::toHTML($this->getProfile(),
                            $this->getEvent(),
                            $this->response);
    }

    function asString()
    {
        return self::toString($this->getProfile(),
                              $this->getEvent(),
                              $this->response);
    }

    static function toHTML(Profile $profile, Happening $event, $response)
    {
        $fmt = null;

        switch ($response) {
        case 'Y':
            // TRANS: HTML version of an RSVP ("please respond") status for a user.
            // TRANS: %1$s is a profile URL, %2$s a profile name,
            // TRANS: %3$s is an event URL, %4$s an event title.
            $fmt = _m("%2\$s is attending %4\$s.");
            break;
        case 'N':
            // TRANS: HTML version of an RSVP ("please respond") status for a user.
            // TRANS: %1$s is a profile URL, %2$s a profile name,
            // TRANS: %3$s is an event URL, %4$s an event title.
            $fmt = _m("%2\$s is not attending %4\$s.");
            break;
        case '?':
            // TRANS: HTML version of an RSVP ("please respond") status for a user.
            // TRANS: %1$s is a profile URL, %2$s a profile name,
            // TRANS: %3$s is an event URL, %4$s an event title.
            $fmt = _m("%2\$s might attend %4\$s.");
            break;
        default:
            // TRANS: Exception thrown when requesting a user's RSVP status for a non-existing response code.
            // TRANS: %s is the non-existing response code.
            throw new Exception(sprintf(_m('Unknown response code %s.'),$response));
        }

        if (empty($event)) {
            $eventUrl = '#';
            // TRANS: Used as event title when not event title is available.
            // TRANS: Used as: Username [is [not ] attending|might attend] an unknown event.
            $eventTitle = _m('an unknown event');
        } else {
            $eventUrl = $event->getStored()->getUrl();
            $eventTitle = $event->title;
        }

        return sprintf($fmt,
                       htmlspecialchars($profile->getUrl()),
                       htmlspecialchars($profile->getBestName()),
                       htmlspecialchars($eventUrl),
                       htmlspecialchars($eventTitle));
    }

    static function toString($profile, $event, $response)
    {
        $fmt = null;

        switch ($response) {
        case 'Y':
            // TRANS: Plain text version of an RSVP ("please respond") status for a user.
            // TRANS: %1$s is a profile name, %2$s is an event title.
            $fmt = _m('%1$s is attending %2$s.');
            break;
        case 'N':
            // TRANS: Plain text version of an RSVP ("please respond") status for a user.
            // TRANS: %1$s is a profile name, %2$s is an event title.
            $fmt = _m('%1$s is not attending %2$s.');
            break;
        case '?':
            // TRANS: Plain text version of an RSVP ("please respond") status for a user.
            // TRANS: %1$s is a profile name, %2$s is an event title.
            $fmt = _m('%1$s might attend %2$s.');
            break;
        default:
            // TRANS: Exception thrown when requesting a user's RSVP status for a non-existing response code.
            // TRANS: %s is the non-existing response code.
            throw new Exception(sprintf(_m('Unknown response code %s.'),$response));
            break;
        }

        if (empty($event)) {
            // TRANS: Used as event title when not event title is available.
            // TRANS: Used as: Username [is [not ] attending|might attend] an unknown event.
            $eventTitle = _m('an unknown event');
        } else {
            $eventTitle = $event->title;
        }

        return sprintf($fmt,
                       $profile->getBestName(),
                       $eventTitle);
    }

    public function delete($useWhere=false)
    {
        self::blow('rsvp:for-event:%s', $this->id);
        return parent::delete($useWhere);
    }

    public function insert()
    {
        $result = parent::insert();
        if ($result === false) {
            common_log_db_error($this, 'INSERT', __FILE__);
            throw new ServerException(_('Failed to insert '._ve(get_called_class()).' into database'));
        }
        return $result;
    }
}


code:
<?php
/**
 * StatusNet - the distributed open-source microblogging tool
 * Copyright (C) 2011, StatusNet, Inc.
 *
 * Form for entering an event
 *
 * 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('STATUSNET')) {
    // This check helps protect against security problems;
    // your code file can't be executed directly from the web.
    exit(1);
}

/**
 * Form for adding 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 EventForm extends Form
{
    /**
     * ID of the form
     *
     * @return int ID of the form
     */
    function id()
    {
        return 'form_new_event';
    }

    /**
     * class of the form
     *
     * @return string class of the form
     */
    function formClass()
    {
        return 'form_settings ajax-notice';
    }

    /**
     * Action of the form
     *
     * @return string URL of the action
     */
    function action()
    {
        return common_local_url('newevent');
    }

    /**
     * Data elements of the form
     *
     * @return void
     */
    function formData()
    {
        $this->out->elementStart('fieldset', array('id' => 'new_event_data'));

        // Passing in the URL of the Ajax action that the .js for this form hits
        // when selecting event start and end times. JavaScript will try to
        // use a relative path, unless explicitely told where an action is,
        // and that's a bit difficult to calculate since the event form is on
        // so many pages with different paths. It might be worth solving this
        // globally by putting the base site path in the Identifier-URL meta tag
        // or something similar, so it would be easy to calculate the exact path
        // for actions and other things in JavaScripts. -z
        $this->out->hidden('timelist_action_url', common_local_url('timelist'));

        $this->out->elementStart('ul', 'form_data');

        $this->li();
        $this->out->input('event-title',
                          // TRANS: Field label on event form.
                          _m('LABEL','Title'),
                          null,
                          // TRANS: Field title on event form.
                          _m('Title of the event.'),
                          'title',
                          true);    // HTML5 "required" attribute
        $this->unli();

        $this->li();

        $today = new DateTime('now');
        $today->setTimezone(new DateTimeZone(common_timezone()));

        $this->out->input('event-startdate',
                          // TRANS: Field label on event form.
                          _m('LABEL','Start date'),
                          $today->format('m/d/Y'),
                          // TRANS: Field title on event form.
                          _m('Date the event starts.'),
                          'startdate');
        $this->unli();

        $this->li();

        $times = EventTimeList::getTimes($today->format('m/d/Y 12:00') . ' am ' . $today->format('T'));
        $start = EventTimeList::nearestHalfHour($today->format('c'));
        $start->setTimezone(new DateTimeZone(common_timezone()));

        $this->out->dropdown(
            'event-starttime',
            // TRANS: Field label on event form.
            _m('LABEL','Start time'),
            $times,
            // TRANS: Field title on event form. %s is the abbreviated timezone
            sprintf(_m("Time the event starts (%s)."), $today->format('T')),
            false,
            $start->format('g:ia')
        );

        // Need to keep JavaScript TZ in sync with PHP TZ
        $this->out->hidden('tz', $today->format('T'));
        $this->out->hidden('now', $today->format('F d, Y H:i:s T'));

        $this->unli();

        $this->li();
        $this->out->input('event-enddate',
                          // TRANS: Field label on event form.
                          _m('LABEL','End date'),
                          $today->format('m/d/Y'),
                          // TRANS: Field title on event form.
                          _m('Date the event ends.'),
                          'enddate');
        $this->unli();

        $this->li();

        $this->out->dropdown(
            'event-endtime',
            // TRANS: Field label on event form.
            _m('LABEL','End time'),
            EventTimeList::getTimes($start->format('c'), true),
            // TRANS: Field title on event form.
            _m('Time the event ends.'),
            false,
            null
        );
        $this->unli();

        $this->li();
        $this->out->input('event-location',
                          // TRANS: Field label on event form.
                          _m('LABEL','Where?'),
                          null,
                          // TRANS: Field title on event form.
                          _m('Event location.'),
                          'location');
        $this->unli();

        $this->li();
        $this->out->input('event-url',
                          // TRANS: Field label on event form.
                          _m('LABEL','URL'),
                          null,
                          // TRANS: Field title on event form.
                          _m('URL for more information.'),
                          'url');
        $this->unli();

        $this->li();
        $this->out->input('event-description',
                          // TRANS: Field label on event form.
                          _m('LABEL','Description'),
                          null,
                          // TRANS: Field title on event form.
                          _m('Description of the event.'),
                          'description',
                          true);    // HTML5 "required" attribute
        $this->unli();

        $this->out->elementEnd('ul');

        $toWidget = new ToSelector($this->out,
                                   common_current_user(),
                                   null);
        $toWidget->show();

        $this->out->elementEnd('fieldset');
    }

    /**
     * Action elements
     *
     * @return void
     */
    function formActions()
    {
        // TRANS: Button text to save an event..
        $this->out->submit('event-submit', _m('BUTTON', 'Save'), 'submit', 'submit');
    }
}


code:
<?php
/**
 * StatusNet - the distributed open-source microblogging tool
 * Copyright (C) 2011, StatusNet, Inc.
 *
 * Form to RSVP for an event
 *
 * 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); }

/**
 * A form to RSVP for an event
 *
 * @category  General
 * @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 RSVPForm extends Form
{
    protected $event = null;

    function __construct($out=null, array $formOpts=array())
    {
        parent::__construct($out);
        if (!isset($formOpts['event'])) {
            throw new ServerException('You must set the "event" form option for RSVPForm.');
        } elseif (!$formOpts['event'] instanceof Happening) {
            throw new ServerException('The "event" form option for RSVPForm must be a Happening object.');
        }
        $this->event = $formOpts['event'];
    }

    /**
     * ID of the form
     *
     * @return int ID of the form
     */
    function id()
    {
        return 'form_event_rsvp';
    }

    /**
     * class of the form
     *
     * @return string class of the form
     */
    function formClass()
    {
        return 'ajax';
    }

    /**
     * Action of the form
     *
     * @return string URL of the action
     */
    function action()
    {
        return common_local_url('rsvp');
    }

    /**
     * Data elements of the form
     *
     * @return void
     */
    function formData()
    {
        $this->out->elementStart('fieldset', array('id' => 'new_rsvp_data'));

        // TRANS: Field label on form to RSVP ("please respond") for an event.
        $this->out->text(_m('RSVP:'));

        $this->out->hidden('notice', $this->event->getStored()->getID(), 'event');
        $this->out->hidden('event', $this->event->getUri(), 'event');   // not used
        $this->out->hidden('rsvp', '');

        $this->out->elementEnd('fieldset');
    }

    /**
     * Action elements
     *
     * @return void
     */
    function formActions()
    {
        try {
            $rsvp = RSVP::byEventAndActor($this->event, $this->scoped);
            $this->submitButton('cancel', _m('BUTTON', 'Cancel'));
        } catch (NoResultException $e) {
            // TRANS: Button text for RSVP ("please respond") reply to confirm attendence.
            $this->submitButton('yes', _m('BUTTON', 'Yes'));
            // TRANS: Button text for RSVP ("please respond") reply to deny attendence.
            $this->submitButton('no', _m('BUTTON', 'No'));
            // TRANS: Button text for RSVP ("please respond") reply to indicate one might attend.
            $this->submitButton('maybe', _m('BUTTON', 'Maybe'));
        }
    }

    function submitButton($answer, $label)
    {
        $this->out->element(
            'input',
                array(
                    'type'    => 'submit',
                    'id'      => 'rsvp-submit-'.$answer,
                    'name'    => $answer,
                    'class'   => 'submit',
                    'value'   => $label,
                    'title'   => $label,
                    'onClick' => 'this.form.rsvp.value = this.name; return true;'
            )
        );
    }
}


code:
<?php

if (!defined('GNUSOCIAL')) { exit(1); }

class RawEventsNoticeStream extends NoticeStream
{
    function getNoticeIds($offset, $limit, $since_id, $max_id)
    {
        $notice = new Notice();
        $qry = null;

        $qry =  'SELECT notice.* FROM notice ';
        $qry .= 'INNER JOIN happening ON happening.uri = notice.uri ';
        $qry .= 'AND notice.is_local != ' . Notice::GATEWAY . ' ';

        if ($since_id != 0) {
            $qry .= 'AND notice.id > ' . $since_id . ' ';
        }

        if ($max_id != 0) {
            $qry .= 'AND notice.id <= ' . $max_id . ' ';
        }

        // NOTE: we sort by event time, not by notice time!
        $qry .= 'ORDER BY happening.created DESC ';
        if (!is_null($offset)) {
            $qry .= "LIMIT $limit OFFSET $offset";
        }

        $notice->query($qry);
        $ids = array();
        while ($notice->fetch()) {
            $ids[] = $notice->id;
        }

        $notice->free();
        unset($notice);
        return $ids;
    }
}

class EventsNoticeStream extends ScopingNoticeStream
{
    // possible values of RSVP in our database
    protected $rsvp = ['Y', 'N', '?'];
    protected $target = null;

    function __construct(Profile $target, Profile $scoped=null, array $rsvp=array())
    {
        $stream = new RawEventsNoticeStream();

        if ($target->sameAs($scoped)) {
            $key = 'happening:ids_for_user_own:'.$target->getID();
        } else {
            $key = 'happening:ids_for_user:'.$target->getID();
        }

        // Match RSVP against our possible values, given in the class variable
        // and if no RSVPs are given is empty, assume we want all events, even
        // without RSVPs from this profile.
        $this->rsvp = array_intersect($this->rsvp, $rsvp);
        $this->target = $target;

        parent::__construct(new CachingNoticeStream($stream, $key), $scoped);
    }

    protected function filter(Notice $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;
    }
}


code:
<?php
/**
 * Helper class for calculating and displaying event times
 *
 * PHP version 5
 *
 * @category Data
 * @package  StatusNet
 * @author   Zach Copley <zach@status.net>
 * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
 * @link     http://status.net/
 *
 * StatusNet - the distributed open-source microblogging tool
 * Copyright (C) 2011, StatusNet, Inc.
 *
 * 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/>.
 */

/**
 *  Class to get fancy times for the dropdowns on the new event form
 */
class EventTimeList {
    /**
     * Round up to the nearest half hour
     *
     * @param string $time the time to round (date/time string)
     * @return DateTime    the rounded time
     */
    public static function nearestHalfHour($time)
    {
        $startd = new DateTime($time);

        $minutes = $startd->format('i');
        $hour    = $startd->format('H');

        if ($minutes >= 30) {
            $minutes = '00';
            $hour++;
        } else {
            $minutes = '30';
        }

        $startd->setTime($hour, $minutes, 0);

        return $startd;
    }

    /**
     * Output a list of times in half-hour intervals
     *
     * @param string  $start       Time to start with (date string, usually a ts)
     * @param boolean $duration    Whether to include the duration of the event
     *                             (from the start)
     * @return array  $times (localized 24 hour time string => fancy time string)
     */
    public static function getTimes($start = 'now', $duration = false)
    {
        $newTime = new DateTime($start);
        $times   = array();
        $len     = 0;

        $newTime->setTimezone(new DateTimeZone(common_timezone()));

        for ($i = 0; $i < 47; $i++) {

            $localTime = $newTime->format("g:ia");

            // pretty up the end-time option list a bit
            if ($duration) {
                $hours = $len / 60;
                switch ($hours) {
                case 0:
                    // TRANS: 0 minutes abbreviated. Used in a list.
                    $total = ' ' . _m('(0 min)');
                    break;
                case .5:
                    // TRANS: 30 minutes abbreviated. Used in a list.
                    $total = ' ' . _m('(30 min)');
                    break;
                case 1:
                    // TRANS: 1 hour. Used in a list.
                    $total = ' ' . _m('(1 hour)');
                    break;
                default:
                    // TRANS: Number of hours (%.1f and %d). Used in a list.
                    $format = is_float($hours)
                        ? _m('(%.1f hours)')
                        : _m('(%d hours)');
                    $total = ' ' . sprintf($format, $hours);
                    break;
                }
                $localTime .= $total;
                $len += 30;
            }

            $times[$newTime->format('g:ia')] = $localTime;
            $newTime->modify('+30min'); // 30 min intervals
        }

        return $times;
    }
}


code:
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-06-08 18:20+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

#. TRANS: 0 minutes abbreviated. Used in a list.
#: lib/eventtimelist.php:85
msgid "(0 min)"
msgstr ""

#. TRANS: 30 minutes abbreviated. Used in a list.
#: lib/eventtimelist.php:89
msgid "(30 min)"
msgstr ""

#. TRANS: 1 hour. Used in a list.
#: lib/eventtimelist.php:93
msgid "(1 hour)"
msgstr ""

#: lib/eventtimelist.php:98
#, php-format
msgid "(%.1f hours)"
msgstr ""

#: lib/eventtimelist.php:99
#, php-format
msgid "(%d hours)"
msgstr ""

#. TRANS: Title for new event form.
#: actions/newevent.php:55
msgctxt "TITLE"
msgid "New event"
msgstr ""

#. TRANS: Client exception thrown when trying to post an event without providing a title.
#: actions/newevent.php:64
msgid "Event must have a title."
msgstr ""

#. TRANS: Client exception thrown when trying to post an event without providing a start date.
#: actions/newevent.php:75
msgid "Start date required."
msgstr ""

#. TRANS: Client exception thrown when trying to post an event without providing a start time.
#: actions/newevent.php:80
msgid "Event must have a start time."
msgstr ""

#. TRANS: Client exception thrown when trying to post an event with a date that cannot be processed.
#. TRANS: %s is the data that could not be processed.
#: actions/newevent.php:87 actions/newevent.php:105
#, php-format
msgid "Could not parse date %s."
msgstr ""

#. TRANS: Client exception thrown when trying to post an event without providing an end date.
#: actions/newevent.php:93
msgid "End date required."
msgstr ""

#. TRANS: Client exception thrown when trying to post an event without providing an end time.
#: actions/newevent.php:98
msgid "Event must have an end time."
msgstr ""

#. TRANS: Client exception thrown when trying to post an event with an invalid (non-empty) URL.
#: actions/newevent.php:111
msgid "An event URL must be a valid HTTP/HTTPS link."
msgstr ""

#: actions/newevent.php:164
msgid "Saved the event."
msgstr ""

#. TRANS: Page title for sample plugin. %s is a user nickname.
#: actions/events.php:20
#, php-format
msgid "%s's happenings"
msgstr ""

#. TRANS: Error message displayed when trying to perform an action that requires a logged in user.
#: actions/timelist.php:65
msgid "Not logged in."
msgstr ""

#. TRANS: Client error when submitting a form with unexpected information.
#: actions/timelist.php:72
msgid "Unexpected form submission."
msgstr ""

#. TRANS: Client error displayed when using an action in a non-AJAX way.
#: actions/timelist.php:80
msgid "This action is AJAX only."
msgstr ""

#. TRANS: Client exception thrown when referring to a non-existing RSVP.
#. TRANS: RSVP stands for "Please reply".
#: actions/showrsvp.php:61 actions/showrsvp.php:77
msgid "No such RSVP."
msgstr ""

#. TRANS: Client exception thrown when referring to a non-existing event.
#: actions/showrsvp.php:68
msgid "No such event."
msgstr ""

#. TRANS: Title for event.
#. TRANS: %1$s is a user nickname, %2$s is an event title.
#: actions/showrsvp.php:94
#, php-format
msgid "%1$s's RSVP for \"%2$s\""
msgstr ""

#. TRANS: Title for RSVP ("please respond") action.
#: actions/rsvp.php:52
msgctxt "TITLE"
msgid "New RSVP"
msgstr ""

#: actions/rsvp.php:81
msgid "Cancelled RSVP"
msgstr ""

#: actions/rsvp.php:91
msgid "RSVP"
msgstr ""

#: actions/rsvp.php:102
msgid "Saved RSVP"
msgstr ""

#. TRANS: Exception thrown when there are too many activity objects.
#: classes/Happening.php:108
msgid "Too many activity objects."
msgstr ""

#. TRANS: Exception thrown when event plugin comes across a non-event type object.
#: classes/Happening.php:113
msgid "Wrong type for object."
msgstr ""

#. TRANS: Exception thrown when has no start date
#: classes/Happening.php:146
msgid "No start date for event."
msgstr ""

#. TRANS: Exception thrown when has no end date
#: classes/Happening.php:150
msgid "No end date for event."
msgstr ""

#. TRANS: Client exception thrown when trying to save an already existing RSVP ("please respond").
#: classes/RSVP.php:143
msgid "RSVP already exists."
msgstr ""

#. TRANS: Exception thrown when requesting an undefined verb for RSVP.
#: classes/RSVP.php:196
#, php-format
msgid "Unknown verb \"%s\"."
msgstr ""

#. TRANS: Exception thrown when requesting an undefined code for RSVP.
#: classes/RSVP.php:217
#, php-format
msgid "Unknown code \"%s\"."
msgstr ""

#. TRANS: HTML version of an RSVP ("please respond") status for a user.
#. TRANS: %1$s is a profile URL, %2$s a profile name,
#. TRANS: %3$s is an event URL, %4$s an event title.
#: classes/RSVP.php:321
#, php-format
msgid ""
"%2$s is attending %4$s."
msgstr ""

#. TRANS: HTML version of an RSVP ("please respond") status for a user.
#. TRANS: %1$s is a profile URL, %2$s a profile name,
#. TRANS: %3$s is an event URL, %4$s an event title.
#: classes/RSVP.php:327
#, php-format
msgid ""
"%2$s is not attending "
"%4$s."
msgstr ""

#. TRANS: HTML version of an RSVP ("please respond") status for a user.
#. TRANS: %1$s is a profile URL, %2$s a profile name,
#. TRANS: %3$s is an event URL, %4$s an event title.
#: classes/RSVP.php:333
#, php-format
msgid ""
"%2$s might attend %4$s."
msgstr ""

#. TRANS: Exception thrown when requesting a user's RSVP status for a non-existing response code.
#. TRANS: %s is the non-existing response code.
#: classes/RSVP.php:338 classes/RSVP.php:381
#, php-format
msgid "Unknown response code %s."
msgstr ""

#. TRANS: Used as event title when not event title is available.
#. TRANS: Used as: Username [is [not ] attending|might attend] an unknown event.
#: classes/RSVP.php:345 classes/RSVP.php:388
msgid "an unknown event"
msgstr ""

#. TRANS: Plain text version of an RSVP ("please respond") status for a user.
#. TRANS: %1$s is a profile name, %2$s is an event title.
#: classes/RSVP.php:366
#, php-format
msgid "%1$s is attending %2$s."
msgstr ""

#. TRANS: Plain text version of an RSVP ("please respond") status for a user.
#. TRANS: %1$s is a profile name, %2$s is an event title.
#: classes/RSVP.php:371
#, php-format
msgid "%1$s is not attending %2$s."
msgstr ""

#. TRANS: Plain text version of an RSVP ("please respond") status for a user.
#. TRANS: %1$s is a profile name, %2$s is an event title.
#: classes/RSVP.php:376
#, php-format
msgid "%1$s might attend %2$s."
msgstr ""

#. TRANS: Plugin description.
#: EventPlugin.php:110
msgid "Event invitations and RSVPs."
msgstr ""

#. TRANS: Title for event application.
#: EventPlugin.php:116
msgctxt "TITLE"
msgid "Event"
msgstr ""

#. TRANS: Exception thrown when event plugin comes across a unknown object type.
#: EventPlugin.php:213
msgid "Unknown object type."
msgstr ""

#. TRANS: Field label for event description.
#: EventPlugin.php:340
msgid "Time:"
msgstr ""

#. TRANS: Field label for event description.
#: EventPlugin.php:357
msgid "Location:"
msgstr ""

#. TRANS: Field label for event description.
#: EventPlugin.php:365
msgid "Description:"
msgstr ""

#. TRANS: Field label for event description.
#: EventPlugin.php:375
msgid "Attending:"
msgstr ""

#. TRANS: Content for a deleted RSVP list item (RSVP stands for "please respond").
#: EventPlugin.php:418
msgid "Deleted."
msgstr ""

#. TRANS: Menu item in sample plugin.
#: EventPlugin.php:431
msgid "Happenings"
msgstr ""

#. TRANS: Menu item title in sample plugin.
#: EventPlugin.php:433
msgid "A list of your events"
msgstr ""

#. TRANS: Field label on event form.
#: forms/event.php:103
msgctxt "LABEL"
msgid "Title"
msgstr ""

#. TRANS: Field title on event form.
#: forms/event.php:106
msgid "Title of the event."
msgstr ""

#. TRANS: Field label on event form.
#: forms/event.php:118
msgctxt "LABEL"
msgid "Start date"
msgstr ""

#. TRANS: Field title on event form.
#: forms/event.php:121
msgid "Date the event starts."
msgstr ""

#. TRANS: Field label on event form.
#: forms/event.php:134
msgctxt "LABEL"
msgid "Start time"
msgstr ""

#. TRANS: Field title on event form. %s is the abbreviated timezone
#: forms/event.php:137
#, php-format
msgid "Time the event starts (%s)."
msgstr ""

#. TRANS: Field label on event form.
#: forms/event.php:151
msgctxt "LABEL"
msgid "End date"
msgstr ""

#. TRANS: Field title on event form.
#: forms/event.php:154
msgid "Date the event ends."
msgstr ""

#. TRANS: Field label on event form.
#: forms/event.php:163
msgctxt "LABEL"
msgid "End time"
msgstr ""

#. TRANS: Field title on event form.
#: forms/event.php:166
msgid "Time the event ends."
msgstr ""

#. TRANS: Field label on event form.
#: forms/event.php:175
msgctxt "LABEL"
msgid "Where?"
msgstr ""

#. TRANS: Field title on event form.
#: forms/event.php:178
msgid "Event location."
msgstr ""

#. TRANS: Field label on event form.
#: forms/event.php:185
msgctxt "LABEL"
msgid "URL"
msgstr ""

#. TRANS: Field title on event form.
#: forms/event.php:188
msgid "URL for more information."
msgstr ""

#. TRANS: Field label on event form.
#: forms/event.php:195
msgctxt "LABEL"
msgid "Description"
msgstr ""

#. TRANS: Field title on event form.
#: forms/event.php:198
msgid "Description of the event."
msgstr ""

#. TRANS: Button text to save an event..
#: forms/event.php:221
msgctxt "BUTTON"
msgid "Save"
msgstr ""

#. TRANS: Field label on form to RSVP ("please respond") for an event.
#: forms/rsvp.php:98
msgid "RSVP:"
msgstr ""

#: forms/rsvp.php:116
msgctxt "BUTTON"
msgid "Cancel"
msgstr ""

#. TRANS: Button text for RSVP ("please respond") reply to confirm attendence.
#: forms/rsvp.php:119
msgctxt "BUTTON"
msgid "Yes"
msgstr ""

#. TRANS: Button text for RSVP ("please respond") reply to deny attendence.
#: forms/rsvp.php:121
msgctxt "BUTTON"
msgid "No"
msgstr ""

#. TRANS: Button text for RSVP ("please respond") reply to indicate one might attend.
#: forms/rsvp.php:123
msgctxt "BUTTON"
msgid "Maybe"
msgstr ""


code:
# Translation file for GNU social - the free software social networking platform
# Copyright (C) 2015 - 2019 Free Software Foundation, Inc http://www.fsf.org
# This file is under https://www.gnu.org/licenses/agpl v3 or later
#
# Translators:
msgid ""
msgstr ""
"Project-Id-Version: GNU social\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-02-02 17:47+0100\n"
"PO-Revision-Date: 2015-02-05 16:12+0000\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: Afrikaans (http://www.transifex.com/gnu-social/gnu-social/language/af/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: af\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#. TRANS: Possible status for RSVP ("please respond") item.
#: forms/cancelrsvp.php:101
msgid "You will attend this event."
msgstr ""

#. TRANS: Possible status for RSVP ("please respond") item.
#: forms/cancelrsvp.php:105
msgid "You will not attend this event."
msgstr ""

#. TRANS: Possible status for RSVP ("please respond") item.
#: forms/cancelrsvp.php:109
msgid "You might attend this event."
msgstr ""

#. TRANS: Button text to cancel responding to an RSVP ("please respond") item.
#: forms/cancelrsvp.php:124
msgctxt "BUTTON"
msgid "Cancel"
msgstr "Kanselleer"

#. TRANS: Field label on form to RSVP ("please respond") for an event.
#: forms/rsvp.php:97
msgid "RSVP:"
msgstr ""

#. TRANS: Button text for RSVP ("please respond") reply to confirm attendence.
#: forms/rsvp.php:113
msgctxt "BUTTON"
msgid "Yes"
msgstr "Ja"

#. TRANS: Button text for RSVP ("please respond") reply to deny attendence.
#: forms/rsvp.php:115
msgctxt "BUTTON"
msgid "No"
msgstr "Nee"

#. TRANS: Button text for RSVP ("please respond") reply to indicate one might
#. attend.
#: forms/rsvp.php:117
msgctxt "BUTTON"
msgid "Maybe"
msgstr ""

#. TRANS: Field label on event form.
#: forms/event.php:103
msgctxt "LABEL"
msgid "Title"
msgstr ""

#. TRANS: Field title on event form.
#: forms/event.php:106
msgid "Title of the event."
msgstr ""

#. TRANS: Field label on event form.
#: forms/event.php:118
msgctxt "LABEL"
msgid "Start date"
msgstr ""

#. TRANS: Field title on event form.
#: forms/event.php:121
msgid "Date the event starts."
msgstr ""

#. TRANS: Field label on event form.
#: forms/event.php:134
msgctxt "LABEL"
msgid "Start time"
msgstr ""

#. TRANS: Field title on event form. %s is the abbreviated timezone
#: forms/event.php:137
#, php-format
msgid "Time the event starts (%s)."
msgstr ""

#. TRANS: Field label on event form.
#: forms/event.php:151
msgctxt "LABEL"
msgid "End date"
msgstr ""

#. TRANS: Field title on event form.
#: forms/event.php:154
msgid "Date the event ends."
msgstr ""

#. TRANS: Field label on event form.
#: forms/event.php:163
msgctxt "LABEL"
msgid "End time"
msgstr ""

#. TRANS: Field title on event form.
#: forms/event.php:166
msgid "Time the event ends."
msgstr ""

#. TRANS: Field label on event form.
#: forms/event.php:175
msgctxt "LABEL"
msgid "Where?"
msgstr ""

#. TRANS: Field title on event form.
#: forms/event.php:178
msgid "Event location."
msgstr ""

#. TRANS: Field label on event form.
#: forms/event.php:185
msgctxt "LABEL"
msgid "URL"
msgstr ""

#. TRANS: Field title on event form.
#: forms/event.php:188
msgid "URL for more information."
msgstr ""

#. TRANS: Field label on event form.
#: forms/event.php:195
msgctxt "LABEL"
msgid "Description"
msgstr "Beskrywing"

#. TRANS: Field title on event form.
#: forms/event.php:198
msgid "Description of the event."
msgstr ""

#. TRANS: Button text to save an event..
#: forms/event.php:221
msgctxt "BUTTON"
msgid "Save"
msgstr "Stoor"

#. TRANS: Title for new event form.
#: actions/newevent.php:66
msgctxt "TITLE"
msgid "New event"
msgstr ""

#. TRANS: Client exception thrown when trying to post an event while not
#. logged in.
#: actions/newevent.php:84
msgid "Must be logged in to post a event."
msgstr ""

#. TRANS: Client exception thrown when trying to post an event without
#. providing a title.
#: actions/newevent.php:98
msgid "Title required."
msgstr ""

#. TRANS: Client exception thrown when trying to post an event without
#. providing a start date.
#: actions/newevent.php:110
msgid "Start date required."
msgstr ""

#. TRANS: Client exception thrown when trying to post an event without
#. providing an end date.
#: actions/newevent.php:123
msgid "End date required."
msgstr ""

#. TRANS: Client exception thrown when trying to post an event with a date
#. that cannot be processed.
#. TRANS: %s is the data that could not be processed.
#: actions/newevent.php:141 actions/newevent.php:148
#, php-format
msgid "Could not parse date \"%s\"."
msgstr ""

#. TRANS: Client exception thrown when trying to post an event without
#. providing a title.
#: actions/newevent.php:196
msgid "Event must have a title."
msgstr ""

#. TRANS: Client exception thrown when trying to post an event without
#. providing a start time.
#: actions/newevent.php:201
msgid "Event must have a start time."
msgstr ""

#. TRANS: Client exception thrown when trying to post an event without
#. providing an end time.
#: actions/newevent.php:206
msgid "Event must have an end time."
msgstr ""

#. TRANS: Client exception thrown when trying to post an event with an invalid
#. URL.
#: actions/newevent.php:211
msgid "URL must be valid."
msgstr ""

#. TRANS: Page title after sending a notice.
#. TRANS: Page title after creating an event.
#: actions/newevent.php:250 actions/cancelrsvp.php:156 actions/newrsvp.php:161
msgid "Event saved"
msgstr ""

#. TRANS: Title for RSVP ("please respond") action.
#: actions/cancelrsvp.php:61
msgctxt "TITLE"
msgid "Cancel RSVP"
msgstr ""

#. TRANS: Client exception thrown when referring to a non-existing RSVP
#. ("please respond") item.
#. TRANS: Client exception thrown when referring to a non-existing RSVP.
#. TRANS: RSVP stands for "Please reply".
#: actions/cancelrsvp.php:82 actions/cancelrsvp.php:89 actions/showrsvp.php:61
#: actions/showrsvp.php:77
msgid "No such RSVP."
msgstr ""

#. TRANS: Client exception thrown when referring to a non-existing event.
#: actions/cancelrsvp.php:96 actions/showevent.php:60 actions/showevent.php:68
#: actions/newrsvp.php:82 actions/newrsvp.php:89 actions/showrsvp.php:68
msgid "No such event."
msgstr ""

#. TRANS: Client exception thrown when trying tp RSVP ("please respond") while
#. not logged in.
#. TRANS: Client exception thrown when trying to RSVP ("please respond") while
#. not logged in.
#: actions/cancelrsvp.php:103 actions/newrsvp.php:96
msgid "You must be logged in to RSVP for an event."
msgstr ""

#. TRANS: Title for RSVP ("please respond") action.
#: actions/newrsvp.php:61
msgctxt "TITLE"
msgid "New RSVP"
msgstr ""

#. TRANS: Client exception thrown when using an invalid value for RSVP
#. ("please respond").
#: actions/newrsvp.php:113
msgid "Unknown submit value."
msgstr ""

#. TRANS: Title for event.
#. TRANS: %1$s is a user nickname, %2$s is an event title.
#: actions/showrsvp.php:94
#, php-format
msgid "%1$s's RSVP for \"%2$s\""
msgstr ""

#. TRANS: Error message displayed when trying to perform an action that
#. requires a logged in user.
#: actions/timelist.php:65
msgid "Not logged in."
msgstr "Nie aangeteken nie."

#. TRANS: Client error when submitting a form with unexpected information.
#: actions/timelist.php:72
msgid "Unexpected form submission."
msgstr "Die vorm is onverwags ingestuur."

#. TRANS: Client error displayed when using an action in a non-AJAX way.
#: actions/timelist.php:80
msgid "This action is AJAX only."
msgstr ""

#. TRANS: Client exception thrown when trying to create an event that already
#. exists.
#: classes/Happening.php:111
msgid "Event already exists."
msgstr ""

#. TRANS: Event description. %1$s is a title, %2$s is start time, %3$s is end
#. time,
#. TRANS: %4$s is location, %5$s is a description.
#: classes/Happening.php:145
#, php-format
msgid "\"%1$s\" %2$s - %3$s (%4$s): %5$s"
msgstr ""

#. TRANS: Rendered microformats2 tagged event description.
#. TRANS: %1$s is a title, %2$s is start time, %3$s is start time,
#. TRANS: %4$s is end time, %5$s is end time, %6$s is location, %7$s is
#. description.
#. TRANS: Class names should not be translated.
#: classes/Happening.php:156
#, php-format
msgid ""
"

%1$s
 <time class"
"=\"dt-start\" datetime=\"%2$s\">%3$s</time> - <time class=\"dt-end\" "
"datetime=\"%4$s\">%5$s</time> (%6$s):
%7$s

"
msgstr ""

#. TRANS: Client exception thrown when trying to save an already existing RSVP
#. ("please respond").
#: classes/RSVP.php:116 classes/RSVP.php:125
msgid "RSVP already exists."
msgstr ""

#. TRANS: Exception thrown when requesting an undefined verb for RSVP.
#: classes/RSVP.php:194
#, php-format
msgid "Unknown verb \"%s\"."
msgstr ""

#. TRANS: Exception thrown when requesting an undefined code for RSVP.
#: classes/RSVP.php:212
#, php-format
msgid "Unknown code \"%s\"."
msgstr ""

#. TRANS: Server exception thrown when requesting a non-exsting notice for an
#. RSVP ("please respond").
#. TRANS: %s is the RSVP with the missing notice.
#: classes/RSVP.php:222
#, php-format
msgid "RSVP %s does not correspond to a notice in the database."
msgstr ""

#. TRANS: Exception thrown when requesting a non-existing profile.
#. TRANS: %s is the ID of the non-existing profile.
#: classes/RSVP.php:284
#, php-format
msgid "No profile with ID %s."
msgstr ""

#. TRANS: Exception thrown when requesting a non-existing event.
#. TRANS: %s is the ID of the non-existing event.
#: classes/RSVP.php:295
#, php-format
msgid "No event with ID %s."
msgstr ""

#. TRANS: HTML version of an RSVP ("please respond") status for a user.
#. TRANS: %1$s is a profile URL, %2$s a profile name,
#. TRANS: %3$s is an event URL, %4$s an event title.
#: classes/RSVP.php:327
#, php-format
msgid ""
"%2$s is attending %4$s."
msgstr ""

#. TRANS: HTML version of an RSVP ("please respond") status for a user.
#. TRANS: %1$s is a profile URL, %2$s a profile name,
#. TRANS: %3$s is an event URL, %4$s an event title.
#: classes/RSVP.php:333
#, php-format
msgid ""
"%2$s is not attending "
"%4$s."
msgstr ""

#. TRANS: HTML version of an RSVP ("please respond") status for a user.
#. TRANS: %1$s is a profile URL, %2$s a profile name,
#. TRANS: %3$s is an event URL, %4$s an event title.
#: classes/RSVP.php:339
#, php-format
msgid ""
"%2$s might attend %4$s."
msgstr ""

#. TRANS: Exception thrown when requesting a user's RSVP status for a non-
#. existing response code.
#. TRANS: %s is the non-existing response code.
#: classes/RSVP.php:344 classes/RSVP.php:388
#, php-format
msgid "Unknown response code %s."
msgstr ""

#. TRANS: Used as event title when not event title is available.
#. TRANS: Used as: Username [is [not ] attending|might attend] an unknown
#. event.
#: classes/RSVP.php:351 classes/RSVP.php:395
msgid "an unknown event"
msgstr ""

#. TRANS: Plain text version of an RSVP ("please respond") status for a user.
#. TRANS: %1$s is a profile name, %2$s is an event title.
#: classes/RSVP.php:373
#, php-format
msgid "%1$s is attending %2$s."
msgstr ""

#. TRANS: Plain text version of an RSVP ("please respond") status for a user.
#. TRANS: %1$s is a profile name, %2$s is an event title.
#: classes/RSVP.php:378
#, php-format
msgid "%1$s is not attending %2$s."
msgstr ""

#. TRANS: Plain text version of an RSVP ("please respond") status for a user.
#. TRANS: %1$s is a profile name, %2$s is an event title.
#: classes/RSVP.php:383
#, php-format
msgid "%1$s might attend %2$s."
msgstr ""

#. TRANS: Plugin description.
#: EventPlugin.php:101
msgid "Event invitations and RSVPs."
msgstr ""

#. TRANS: Title for event application.
#: EventPlugin.php:107
msgctxt "TITLE"
msgid "Event"
msgstr ""

#. TRANS: Exception thrown when there are too many activity objects.
#: EventPlugin.php:135
msgid "Too many activity objects."
msgstr ""

#. TRANS: Exception thrown when event plugin comes across a non-event type
#. object.
#: EventPlugin.php:142
msgid "Wrong type for object."
msgstr ""

#. TRANS: Exception thrown when trying to RSVP for an unknown event.
#: EventPlugin.php:166
msgid "RSVP for unknown event."
msgstr ""

#. TRANS: Exception thrown when event plugin comes across a undefined verb.
#: EventPlugin.php:172
msgid "Unknown verb for events."
msgstr ""

#. TRANS: Exception thrown when event plugin comes across a unknown object
#. type.
#: EventPlugin.php:203
msgid "Unknown object type."
msgstr ""

#. TRANS: Exception thrown when referring to a notice that is not an event an
#. in event context.
#: EventPlugin.php:210
msgid "Unknown event notice."
msgstr ""

#. TRANS: Content for a deleted RSVP list item (RSVP stands for "please
#. respond").
#: EventPlugin.php:342 EventPlugin.php:474
msgid "Deleted."
msgstr ""

#. TRANS: Field label for event description.
#: EventPlugin.php:389
msgid "Time:"
msgstr ""

#. TRANS: Field label for event description.
#: EventPlugin.php:406
msgid "Location:"
msgstr ""

#. TRANS: Field label for event description.
#: EventPlugin.php:414
msgid "Description:"
msgstr ""

#. TRANS: Field label for event description.
#: EventPlugin.php:424
msgid "Attending:"
msgstr ""

#. TRANS: 0 minutes abbreviated. Used in a list.
#: lib/eventtimelist.php:85
msgid "(0 min)"
msgstr ""

#. TRANS: 30 minutes abbreviated. Used in a list.
#: lib/eventtimelist.php:89
msgid "(30 min)"
msgstr ""

#. TRANS: 1 hour. Used in a list.
#: lib/eventtimelist.php:93
msgid "(1 hour)"
msgstr ""

#: lib/eventtimelist.php:98
#, php-format
msgid "(%.1f hours)"
msgstr ""

#: lib/eventtimelist.php:99
#, php-format
msgid "(%d hours)"
msgstr ""