]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
utility function for getting a profile URI
authorEvan Prodromou <evan@prodromou.name>
Wed, 16 Jul 2008 15:25:11 +0000 (11:25 -0400)
committerEvan Prodromou <evan@prodromou.name>
Wed, 16 Jul 2008 15:25:11 +0000 (11:25 -0400)
I added a utility function for getting a profile URI. At some point we
need to push commonalities between Remote_profile and User into the
Profile class; single-table inheritance. We do a lot of switching
around for no good reason on users and profiles.

darcs-hash:20080716152511-84dde-6f73d947d11083e7235756fde635e145f02e2483.gz

lib/rssaction.php
lib/util.php

index ee37f3aa7fe19be60d1d2f400d39d79eabc0fade..5a6a8313d596e12d2f24e7cbb7053aa352df421a 100644 (file)
@@ -117,12 +117,7 @@ class Rss10Action extends Action {
        function show_item($notice) {
                $profile = Profile::staticGet($notice->profile_id);
                $nurl = common_local_url('shownotice', array('notice' => $notice->id));
-               $user = User::staticGet($profile->id);
-               if ($user) {
-                       $creator_url = $user->uri;
-               } else {
-                       $creator_url = $profile->profile_url;
-               }
+               $creator_uri = common_profile_uri($profile);
                common_element_start('item', array('rdf:about' => $notice->uri));
                $title = $profile->nickname . ': ' . $notice->content;
                common_element('title', NULL, $title);
@@ -133,7 +128,7 @@ class Rss10Action extends Action {
                common_element('sioc:has_creator', array('rdf:resource' => $creator_url));
                common_element('cc:licence', array('rdf:resource' => common_config('license', 'url')));
                common_element_end('item');
-               $this->creators[$creator_url] = $profile;
+               $this->creators[$creator_uri] = $profile;
        }
 
        function show_creators() {
index 1b672561fce85c30a81f030d045f9f2ed48eb7c9..997f32430b00490c68d54db2809502f224af414b 100644 (file)
@@ -1292,4 +1292,20 @@ function common_profile_avatar_url($profile, $size=AVATAR_PROFILE_SIZE) {
                return common_default_avatar($size);
        }
 }
-       
\ No newline at end of file
+
+function common_profile_uri($profile) {
+       if (!$profile) {
+               return NULL;
+       }
+       $user = User::staticGet($profile->id);
+       if ($user) {
+               return $user->uri;
+       }
+       
+       $remote = Remote_profile::staticGet($profile->id);
+       if ($remote) {
+               return $remote->uri;
+       }
+       # XXX: this is a very bad profile!
+       return NULL;
+}
\ No newline at end of file