]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Fallback for RSVP display when Event is deleted
authorEvan Prodromou <evan@status.net>
Thu, 24 Mar 2011 02:10:44 +0000 (22:10 -0400)
committerEvan Prodromou <evan@status.net>
Thu, 24 Mar 2011 02:16:00 +0000 (22:16 -0400)
plugins/Event/RSVP.php

index 7b61cc34adb84beca36de9cf965bf6ff186dee9b..beb377c5bc74ef0022f29a2bfd848e510e56a434 100644 (file)
@@ -294,15 +294,19 @@ class RSVP extends Managed_DataObject
 
     function asHTML()
     {
+        $event = Happening::staticGet('id', $this->event_id);
+
         return self::toHTML($this->getProfile(),
-                            $this->getEvent(),
+                            $event,
                             $this->response);
     }
 
     function asString()
     {
+        $event = Happening::staticGet('id', $this->event_id);
+
         return self::toString($this->getProfile(),
-                              $this->getEvent(),
+                              $event,
                               $this->response);
     }
 
@@ -310,8 +314,6 @@ class RSVP extends Managed_DataObject
     {
         $fmt = null;
 
-        $notice = $event->getNotice();
-
         switch ($response) {
         case 'Y':
             $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;
         }
 
+        if (empty($event)) {
+            $eventUrl = '#';
+            $eventTitle = _('an unknown event');
+        } else {
+            $notice = $event->getNotice();
+            $eventUrl = $notice->bestUrl();
+            $eventTitle = $event->title;
+        }
+
         return sprintf($fmt,
                        htmlspecialchars($profile->profileurl),
                        htmlspecialchars($profile->getBestName()),
-                       htmlspecialchars($notice->bestUrl()),
-                       htmlspecialchars($event->title));
+                       htmlspecialchars($eventUrl),
+                       htmlspecialchars($eventTitle));
     }
 
     static function toString($profile, $event, $response)
     {
         $fmt = null;
 
-        $notice = $event->getNotice();
-
         switch ($response) {
         case 'Y':
             $fmt = _("%1s is attending %2s.");
@@ -355,8 +364,15 @@ class RSVP extends Managed_DataObject
             break;
         }
 
+        if (empty($event)) {
+            $eventTitle = _('an unknown event');
+        } else {
+            $notice = $event->getNotice();
+            $eventTitle = $event->title;
+        }
+
         return sprintf($fmt,
                        $profile->getBestName(),
-                       $event->title);
+                       $eventTitle);
     }
 }