Fallback for RSVP display when Event is deleted

This commit is contained in:
Evan Prodromou 2011-03-23 22:10:44 -04:00
parent 2b901894c2
commit bd11d11bfc

View File

@ -294,15 +294,19 @@ class RSVP extends Managed_DataObject
function asHTML() function asHTML()
{ {
$event = Happening::staticGet('id', $this->event_id);
return self::toHTML($this->getProfile(), return self::toHTML($this->getProfile(),
$this->getEvent(), $event,
$this->response); $this->response);
} }
function asString() function asString()
{ {
$event = Happening::staticGet('id', $this->event_id);
return self::toString($this->getProfile(), return self::toString($this->getProfile(),
$this->getEvent(), $event,
$this->response); $this->response);
} }
@ -310,8 +314,6 @@ class RSVP extends Managed_DataObject
{ {
$fmt = null; $fmt = null;
$notice = $event->getNotice();
switch ($response) { switch ($response) {
case 'Y': case 'Y':
$fmt = _("<span class='automatic event-rsvp'><a href='%1s'>%2s</a> is attending <a href='%3s'>%4s</a>.</span>"); $fmt = _("<span class='automatic event-rsvp'><a href='%1s'>%2s</a> is attending <a href='%3s'>%4s</a>.</span>");
@ -327,19 +329,26 @@ class RSVP extends Managed_DataObject
break; break;
} }
if (empty($event)) {
$eventUrl = '#';
$eventTitle = _('an unknown event');
} else {
$notice = $event->getNotice();
$eventUrl = $notice->bestUrl();
$eventTitle = $event->title;
}
return sprintf($fmt, return sprintf($fmt,
htmlspecialchars($profile->profileurl), htmlspecialchars($profile->profileurl),
htmlspecialchars($profile->getBestName()), htmlspecialchars($profile->getBestName()),
htmlspecialchars($notice->bestUrl()), htmlspecialchars($eventUrl),
htmlspecialchars($event->title)); htmlspecialchars($eventTitle));
} }
static function toString($profile, $event, $response) static function toString($profile, $event, $response)
{ {
$fmt = null; $fmt = null;
$notice = $event->getNotice();
switch ($response) { switch ($response) {
case 'Y': case 'Y':
$fmt = _("%1s is attending %2s."); $fmt = _("%1s is attending %2s.");
@ -355,8 +364,15 @@ class RSVP extends Managed_DataObject
break; break;
} }
if (empty($event)) {
$eventTitle = _('an unknown event');
} else {
$notice = $event->getNotice();
$eventTitle = $event->title;
}
return sprintf($fmt, return sprintf($fmt,
$profile->getBestName(), $profile->getBestName(),
$event->title); $eventTitle);
} }
} }