]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/shownotice.php
Handle selfLink in ActivityObject
[quix0rs-gnu-social.git] / actions / shownotice.php
index 1d01244cc145b845efb01a9ebe3e1f7194291596..b2385ec1d7b71edcbe3f1ffbf07a0309ec1b412b 100644 (file)
@@ -70,14 +70,15 @@ class ShownoticeAction extends ManagedAction
     {
         parent::prepare($args);
         if ($this->boolean('ajax')) {
-            StatusNet::setApi(true);
+            GNUsocial::setApi(true);
         }
 
         $this->notice = $this->getNotice();
+        $this->target = $this->notice;
 
         if (!$this->notice->inScope($this->scoped)) {
             // TRANS: Client exception thrown when trying a view a notice the user has no access to.
-            throw new ClientException(_('Not available.'), 403);
+            throw new ClientException(_('Access restricted.'), 403);
         }
 
         $this->profile = $this->notice->getProfile();
@@ -113,20 +114,22 @@ class ShownoticeAction extends ManagedAction
     {
         $id = $this->arg('notice');
 
-        $notice = Notice::getKV('id', $id);
-        if ($notice instanceof Notice) {
+        $notice = null;
+        try {
+            $notice = Notice::getByID($id);
             // Alright, got it!
             return $notice;
-        }
-
-        // Did we use to have it, and it got deleted?
-        $deleted = Deleted_notice::getKV('id', $id);
-        if ($deleted instanceof Deleted_notice) {
-            // TRANS: Client error displayed trying to show a deleted notice.
-            $this->clientError(_('Notice deleted.'), 410);
+        } catch (NoResultException $e) {
+            // Hm, not found.
+            $deleted = null;
+            Event::handle('IsNoticeDeleted', array($id, &$deleted));
+            if ($deleted === true) {
+                // TRANS: Client error displayed trying to show a deleted notice.
+                throw new ClientException(_('Notice deleted.'), 410);
+            }
         }
         // TRANS: Client error displayed trying to show a non-existing notice.
-        $this->clientError(_('No such notice.'), 404);
+        throw new ClientException(_('No such notice.'), 404);
     }
 
     /**
@@ -211,36 +214,35 @@ class ShownoticeAction extends ManagedAction
     {
     }
 
-    /**
-     * Don't show aside
-     *
-     * @return void
-     */
-    function showAside() {
+    function getFeeds()
+    {
+        return array(new Feed(Feed::JSON,
+                              common_local_url('ApiStatusesShow',
+                                               array(
+                                                    'id' => $this->target->getID(),
+                                                    'format' => 'json')),
+                              // TRANS: Title for link to single notice representation.
+                              // TRANS: %s is a user nickname.
+                              sprintf(_('Single notice (JSON)'))),
+                     new Feed(Feed::ATOM,
+                              common_local_url('ApiStatusesShow',
+                                               array(
+                                                    'id' => $this->target->getID(),
+                                                    'format' => 'atom')),
+                              // TRANS: Title for link to notice feed.
+                              // TRANS: %s is a user nickname.
+                              sprintf(_('Single notice (Atom)'))));
     }
 
     /**
      * Extra <head> content
      *
-     * We show the microid(s) for the author, if any.
+     * Facebook OpenGraph metadata.
      *
      * @return void
      */
     function extraHead()
     {
-        $user = User::getKV($this->profile->id);
-
-        if (!$user instanceof User) {
-            return;
-        }
-
-        if ($user->emailmicroid && $user->email && $this->notice->uri) {
-            $id = new Microid('mailto:'. $user->email,
-                              $this->notice->uri);
-            $this->element('meta', array('name' => 'microid',
-                                         'content' => $id->toString()));
-        }
-
         // Extras to aid in sharing notices to Facebook
         $avatarUrl = $this->profile->avatarUrl(AVATAR_PROFILE_SIZE);
         $this->element('meta', array('property' => 'og:image',