}
}
- /**
- * Turn a Notice into an activity object
- *
- * @param Notice $notice
- *
- * @return ActivityObject
- */
- function activityObjectFromNotice(Notice $notice)
+ function activityObjectFromNotice(Notice $stored)
{
$happening = null;
switch (true) {
- case ActivityUtils::compareVerbs($notice->verb, array(ActivityVerb::POST)) &&
- ActivityUtils::compareTypes($notice->object_type, array(Happening::OBJECT_TYPE)):
- $happening = Happening::fromStored($notice);
+ case ActivityUtils::compareVerbs($stored->verb, array(ActivityVerb::POST)) &&
+ ActivityUtils::compareTypes($stored->object_type, array(Happening::OBJECT_TYPE)):
+ $happening = Happening::fromStored($stored);
break;
// FIXME: Why are these object_type??
case ActivityUtils::compareTypes($stored->object_type, array(RSVP::POSITIVE, RSVP::NEGATIVE, RSVP::POSSIBLE)):
- $rsvp = RSVP::fromNotice($notice);
+ $rsvp = RSVP::fromNotice($stored);
$happening = $rsvp->getEvent();
break;
default:
throw new Exception(_m('Unknown object type.'));
}
- // This is a bit weird, if it's a Notice for a Happening. We should only do this for RSVP.
- $notice = $happening->getNotice();
-
$obj = new ActivityObject();
$obj->id = $happening->getUri();
$obj->type = Happening::OBJECT_TYPE;
$obj->title = $happening->title;
$obj->summary = $happening->description;
- $obj->link = $notice->getUrl();
-
- // XXX: how to get this stuff into JSON?!
+ $obj->link = $happening->getStored()->getUrl();
$obj->extra[] = array('dtstart',
array('xmlns' => 'urn:ietf:params:xml:ns:xcal'),
$obj->extra[] = array('location', false, $happening->location);
$obj->extra[] = array('url', false, $happening->url);
- // XXX: probably need other stuff here
-
- common_debug('EVENTDEBUG: activity object from notice: '._ve($obj));
return $obj;
}
switch ($notice->object_type) {
case Happening::OBJECT_TYPE:
common_log(LOG_DEBUG, "Deleting event from notice...");
- $happening = Happening::fromStored($notice);
- $happening->delete();
+ try {
+ $happening = Happening::fromStored($notice);
+ $happening->delete();
+ } catch (NoResultException $e) {
+ // already gone
+ }
break;
case RSVP::POSITIVE:
case RSVP::NEGATIVE:
function onStartAddNoticeReply($nli, $parent, $child)
{
- // Filter out any poll responses
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 showNoticeItemNotice(NoticeListItem $nli)
- {
- $nli->showAuthor();
- $nli->showContent();
- }
-
protected function showNoticeContent(Notice $stored, HTMLOutputter $out, Profile $scoped=null)
{
switch (true) {
+++ /dev/null
-<?php
-/**
- * StatusNet - the distributed open-source microblogging tool
- * Copyright (C) 2011, StatusNet, Inc.
- *
- * Show a single 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);
-}
-
-/**
- * Show a single event, with associated information
- *
- * @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 ShoweventAction extends ShownoticeAction
-{
- protected $id = null;
- protected $event = null;
-
- function getNotice()
- {
- $this->id = $this->trimmed('id');
-
- $this->event = Happening::getKV('id', $this->id);
-
- 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->event->getNotice();
-
- if (empty($notice)) {
- // Did we used to have it, and it got deleted?
- // TRANS: Client exception thrown when referring to a non-existing event.
- throw new ClientException(_m('No such event.'), 404);
- }
-
- return $notice;
- }
-
- /**
- * Title of the page
- *
- * Used by Action class for layout.
- *
- * @return string page tile
- */
- function title()
- {
- return $this->event->title;
- }
-}
return $this->uri;
}
- public function getNotice()
+ public function getStored()
{
return Notice::getByKeys(array('uri'=>$this->getUri()));
}
function saveNew($profile, $event, $verb, $options=array())
{
- $eventNotice = $event->getNotice();
+ $eventNotice = $event->getStored();
$options = array_merge(array('source' => 'web'), $options);
$act = new Activity();
static function fromNotice(Notice $notice)
{
$rsvp = new RSVP();
- $rsvp->uri = $notice->uri;
+ $rsvp->uri = $notice->getUri();
if (!$rsvp->find(true)) {
throw new NoResultException($rsvp);
}
// TRANS: Used as: Username [is [not ] attending|might attend] an unknown event.
$eventTitle = _m('an unknown event');
} else {
- $notice = $event->getNotice();
- $eventUrl = $notice->getUrl();
+ $eventUrl = $event->getStored()->getUrl();
$eventTitle = $event->title;
}
// TRANS: Used as: Username [is [not ] attending|might attend] an unknown event.
$eventTitle = _m('an unknown event');
} else {
- $notice = $event->getNotice();
$eventTitle = $event->title;
}