]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Profile.php
More sensical profile::getUri()
[quix0rs-gnu-social.git] / classes / Profile.php
index ab05bb8546bfe83d22ce66ce6164e509d32b6bc4..494c697e425fab0fa9726cba9bf0aac41635e2ff 100644 (file)
@@ -769,7 +769,7 @@ class Profile extends Memcached_DataObject
 
         $xs->elementStart('author');
         $xs->element('name', null, $this->nickname);
-        $xs->element('uri', null, $this->profileurl);
+        $xs->element('uri', null, $this->getUri());
         $xs->elementEnd('author');
 
         return $xs->getString();
@@ -810,10 +810,7 @@ class Profile extends Memcached_DataObject
         $xs->element(
             'id',
             null,
-            common_local_url(
-                'userbyid',
-                array('id' => $this->id)
-                )
+            $this->getUri()
             );
         $xs->element('title', null, $this->getBestName());
 
@@ -822,6 +819,7 @@ class Profile extends Memcached_DataObject
         $xs->element(
             'link', array(
                 'type' => empty($avatar) ? 'image/png' : $avatar->mediatype,
+                'rel'  => 'avatar',
                 'href' => empty($avatar)
                 ? Avatar::defaultImage(AVATAR_PROFILE_SIZE)
                 : $avatar->displayUrl()
@@ -834,9 +832,40 @@ class Profile extends Memcached_DataObject
         return $xs->getString();
     }
 
-    function getAcctUri()
+    /**
+     * Returns the best URI for a profile. Plugins may override.
+     *
+     * @return string $uri
+     */
+    function getUri()
     {
-        return $this->nickname . '@' . common_config('site', 'server');
+        $uri = null;
+
+        // check for a local user first
+        $user = User::staticGet('id', $this->id);
+
+        if (!empty($user)) {
+            $uri = common_local_url(
+                'userbyid',
+                array('id' => $user->id)
+            );
+        } else {
+
+            // give plugins a chance to set the URI
+            if (Event::handle('StartGetProfileUri', array($this, &$uri))) {
+
+                // return OMB profile if any
+                $remote = Remote_profile::staticGet('id', $this->id);
+
+                if (!empty($remote)) {
+                    $uri = $remote->uri;
+                }
+
+                Event::handle('EndGetProfileUri', array($this, &$uri));
+            }
+        }
+
+        return $uri;
     }
 
 }