]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/shownotice.php
Properly unlink all old avatars when deleting/uploading a new
[quix0rs-gnu-social.git] / actions / shownotice.php
index 5501a0af42b0c6f38f566dda03b84f3cb8e2892e..6a026d2d364ea63c55f5b40712b719ac3673c921 100644 (file)
@@ -100,9 +100,13 @@ class ShownoticeAction extends Action
             return false;
         }
 
-        $this->user = User::staticGet('id', $this->profile->id);
+        $this->user = User::getKV('id', $this->profile->id);
 
-        $this->avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
+        try {
+            $this->avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
+        } catch (Exception $e) {
+            $this->avatar = null;
+        }
 
         return true;
     }
@@ -117,11 +121,11 @@ class ShownoticeAction extends Action
     {
         $id = $this->arg('notice');
 
-        $notice = Notice::staticGet('id', $id);
+        $notice = Notice::getKV('id', $id);
 
         if (empty($notice)) {
             // Did we used to have it, and it got deleted?
-            $deleted = Deleted_notice::staticGet($id);
+            $deleted = Deleted_notice::getKV($id);
             if (!empty($deleted)) {
                 // TRANS: Client error displayed trying to show a deleted notice.
                 $this->clientError(_('Notice deleted.'), 410);
@@ -214,7 +218,7 @@ class ShownoticeAction extends Action
         if ($this->boolean('ajax')) {
             $this->showAjax();
         } else {
-            if ($this->notice->is_local == Notice::REMOTE_OMB) {
+            if ($this->notice->is_local == Notice::REMOTE) {
                 if (!empty($this->notice->url)) {
                     $target = $this->notice->url;
                 } else if (!empty($this->notice->uri) && preg_match('/^https?:/', $this->notice->uri)) {
@@ -250,9 +254,7 @@ class ShownoticeAction extends Action
 
     function showAjax()
     {
-        header('Content-Type: text/xml;charset=utf-8');
-        $this->xw->startDocument('1.0', 'UTF-8');
-        $this->elementStart('html');
+        $this->startHTML('text/xml;charset=utf-8');
         $this->elementStart('head');
         // TRANS: Title for page that shows a notice.
         $this->element('title', null, _m('TITLE','Notice'));
@@ -261,7 +263,7 @@ class ShownoticeAction extends Action
         $nli = new NoticeListItem($this->notice, $this);
         $nli->show();
         $this->elementEnd('body');
-        $this->elementEnd('html');
+        $this->endHTML();
     }
 
     /**
@@ -290,7 +292,7 @@ class ShownoticeAction extends Action
      */
     function extraHead()
     {
-        $user = User::staticGet($this->profile->id);
+        $user = User::getKV($this->profile->id);
 
         if (!$user) {
             return;
@@ -319,10 +321,7 @@ class ShownoticeAction extends Action
             'title'=>'oEmbed'),null);
 
         // Extras to aid in sharing notices to Facebook
-        $avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
-        $avatarUrl = ($avatar) ?
-                     $avatar->displayUrl() :
-                     Avatar::defaultImage(AVATAR_PROFILE_SIZE);
+        $avatarUrl = $this->profile->avatarUrl(AVATAR_PROFILE_SIZE);
         $this->element('meta', array('property' => 'og:image',
                                      'content' => $avatarUrl));
         $this->element('meta', array('property' => 'og:description',