]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/shownotice.php
Redirect non-SSL hits to login & register actions to SSL if 'always' or 'sometimes...
[quix0rs-gnu-social.git] / actions / shownotice.php
index 6d8d540510cff182d49fa2929b62e76975005c53..7be9618f864f7bc99f9e7199d4b9bf2c82101fa0 100644 (file)
  *
  * @category  Personal
  * @package   StatusNet
- * @author    Evan Prodromou <evan@controlyourself.ca>
+ * @author    Evan Prodromou <evan@status.net>
  * @copyright 2008-2009 StatusNet, Inc.
  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link      http://laconi.ca/
+ * @link      http://status.net/
  */
 
-if (!defined('LACONICA')) {
+if (!defined('STATUSNET') && !defined('LACONICA')) {
     exit(1);
 }
 
@@ -40,9 +40,9 @@ require_once INSTALLDIR.'/lib/feedlist.php';
  *
  * @category Personal
  * @package  StatusNet
- * @author   Evan Prodromou <evan@controlyourself.ca>
+ * @author   Evan Prodromou <evan@status.net>
  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link     http://laconi.ca/
+ * @link     http://status.net/
  */
 
 class ShownoticeAction extends OwnerDesignAction
@@ -84,24 +84,25 @@ class ShownoticeAction extends OwnerDesignAction
         $this->notice = Notice::staticGet($id);
 
         if (empty($this->notice)) {
-            $this->clientError(_('No such notice.'), 404);
+            // Did we used to have it, and it got deleted?
+            $deleted = Deleted_notice::staticGet($id);
+            if (!empty($deleted)) {
+                $this->clientError(_('Notice deleted.'), 410);
+            } else {
+                $this->clientError(_('No such notice.'), 404);
+            }
             return false;
         }
 
         $this->profile = $this->notice->getProfile();
 
         if (empty($this->profile)) {
-            $this->serverError(_('Notice has no profile'), 500);
+            $this->serverError(_('Notice has no profile.'), 500);
             return false;
         }
 
         $this->user = User::staticGet('id', $this->profile->id);
 
-        if (! $this->notice->is_local) {
-            common_redirect($this->notice->uri);
-            return false;
-        }
-
         $this->avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
 
         return true;
@@ -166,9 +167,9 @@ class ShownoticeAction extends OwnerDesignAction
     function title()
     {
         if (!empty($this->profile->fullname)) {
-            $base = $this->profile->fullname . ' (' . $this->user->nickname . ') ';
+            $base = $this->profile->fullname . ' (' . $this->profile->nickname . ') ';
         } else {
-            $base = $this->user->nickname;
+            $base = $this->profile->nickname;
         }
 
         return sprintf(_('%1$s\'s status on %2$s'),
@@ -192,13 +193,20 @@ class ShownoticeAction extends OwnerDesignAction
 
         if ($this->notice->is_local == Notice::REMOTE_OMB) {
             if (!empty($this->notice->url)) {
-                common_redirect($this->notice->url, 301);
+                $target = $this->notice->url;
             } else if (!empty($this->notice->uri) && preg_match('/^https?:/', $this->notice->uri)) {
-                common_redirect($this->notice->uri, 301);
+                // Old OMB posts saved the remote URL only into the URI field.
+                $target = $this->notice->uri;
+            } else {
+                // Shouldn't happen.
+                $target = false;
+            }
+            if ($target && $target != $this->selfUrl()) {
+                common_redirect($target, 301);
+                return false;
             }
-        } else {
-            $this->showPage();
         }
+        $this->showPage();
     }
 
     /**