]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge branch '0.7.x' into 0.8.x
authorEvan Prodromou <evan@controlyourself.ca>
Fri, 3 Apr 2009 19:36:16 +0000 (15:36 -0400)
committerEvan Prodromou <evan@controlyourself.ca>
Fri, 3 Apr 2009 19:36:16 +0000 (15:36 -0400)
actions/foaf.php
actions/public.php
actions/publictagcloud.php
lib/util.php

index 3a99835b4aaef16a9a86c827886635ec09e47a0c..416935b1b724316daefc046172b9f567bedc6754 100644 (file)
@@ -33,7 +33,24 @@ class FoafAction extends Action
     function prepare($args)
     {
         parent::prepare($args);
-        $this->nickname = $this->trimmed('nickname');
+
+        $nickname_arg = $this->arg('nickname');
+
+        if (empty($nickname_arg)) {
+            $this->clientError(_('No such user.'), 404);
+            return false;
+        }
+
+        $this->nickname = common_canonical_nickname($nickname_arg);
+
+        // Permanent redirect on non-canonical nickname
+
+        if ($nickname_arg != $this->nickname) {
+            common_redirect(common_local_url('foaf',
+                                             array('nickname' => $this->nickname)),
+                            301);
+            return false;
+        }
 
         $this->user = User::staticGet('nickname', $this->nickname);
 
@@ -122,20 +139,30 @@ class FoafAction extends Action
 
         if ($sub->find()) {
             while ($sub->fetch()) {
-                if ($sub->token) {
+                if (!empty($sub->token)) {
                     $other = Remote_profile::staticGet('id', $sub->subscribed);
                 } else {
                     $other = User::staticGet('id', $sub->subscribed);
                 }
-                if (!$other) {
+                if (empty($other)) {
                     common_debug('Got a bad subscription: '.print_r($sub,true));
                     continue;
                 }
                 $this->element('knows', array('rdf:resource' => $other->uri));
-                $person[$other->uri] = array(LISTENEE, $other);
+                $person[$other->uri] = array(LISTENEE,
+                                             $other->id,
+                                             $other->nickname,
+                                             (empty($sub->token)) ? 'User' : 'Remote_profile');
+                $other->free();
+                $other = null;
+                unset($other);
             }
         }
 
+        $sub->free();
+        $sub = null;
+        unset($sub);
+
         // Get people who subscribe to user
 
         $sub = new Subscription();
@@ -156,25 +183,36 @@ class FoafAction extends Action
                 if (array_key_exists($other->uri, $person)) {
                     $person[$other->uri][0] = BOTH;
                 } else {
-                    $person[$other->uri] = array(LISTENER, $other);
+                    $person[$other->uri] = array(LISTENER,
+                                                 $other->id,
+                                                 $other->nickname,
+                                                 (empty($sub->token)) ? 'User' : 'Remote_profile');
                 }
+                $other->free();
+                $other = null;
+                unset($other);
             }
         }
 
+        $sub->free();
+        $sub = null;
+        unset($sub);
+
         $this->elementEnd('Person');
 
         foreach ($person as $uri => $p) {
             $foaf_url = null;
-            if ($p[1] instanceof User) {
-                $foaf_url = common_local_url('foaf', array('nickname' => $p[1]->nickname));
+            list($type, $id, $nickname, $cls) = $p;
+            if ($cls == 'User') {
+                $foaf_url = common_local_url('foaf', array('nickname' => $nickname));
             }
-            $this->profile = Profile::staticGet($p[1]->id);
+            $profile = Profile::staticGet($id);
             $this->elementStart('Person', array('rdf:about' => $uri));
-            if ($p[0] == LISTENER || $p[0] == BOTH) {
+            if ($type == LISTENER || $type == BOTH) {
                 $this->element('knows', array('rdf:resource' => $this->user->uri));
             }
-            $this->showMicrobloggingAccount($this->profile, ($p[1] instanceof User) ?
-                                              common_root_url() : null);
+            $this->showMicrobloggingAccount($profile, ($cls == 'User') ?
+                                            common_root_url() : null);
             if ($foaf_url) {
                 $this->element('rdfs:seeAlso', array('rdf:resource' => $foaf_url));
             }
@@ -182,6 +220,9 @@ class FoafAction extends Action
             if ($foaf_url) {
                 $this->showPpd($foaf_url, $uri);
             }
+            $profile->free();
+            $profile = null;
+            unset($profile);
         }
 
         $this->elementEnd('rdf:RDF');
index 96c766a57d946f9ecb2af9acaf19e5e245884b5a..fca90488fee4223f1ec04beaee7488eeb8130fb4 100644 (file)
@@ -184,25 +184,9 @@ class PublicAction extends Action
 
         if (common_logged_in()) {
             $message .= _('Be the first to post!');
-/*
-                sprintf(_('You are logged in... %%%%site.name%%%% groups let you find and talk with ' .
-                    'people of similar interests. After you join a group ' .
-                    'you can send messages to all other members using the ' .
-                    'syntax "!groupname". Don\'t see a group you like? Try ' .
-                    '[searching for one](%%%%action.groupsearch%%%%) or ' .
-                    '[start your own!](%%%%action.newgroup%%%%)'));
-*/
         }
         else {
             $message .= _('Why not [register an account](%%action.register%%) and be the first to post!');
-/*
-                sprintf(_('You are not logged in... %%%%site.name%%%% groups let you find and talk with ' .
-                    'people of similar interests. After you join a group ' .
-                    'you can send messages to all other members using the ' .
-                    'syntax "!groupname". Don\'t see a group you like? Try ' .
-                    '[searching for one](%%%%action.groupsearch%%%%) or ' .
-                    '[start your own!](%%%%action.newgroup%%%%)'));
-*/
         }
 
         $this->elementStart('div', 'blankfiller');
index 6f5fc7541392ba2c72ff474cadabf39fd1a6dbb9..5322372b2a12baa7fb65b98973f2452d3643f566 100644 (file)
@@ -62,6 +62,24 @@ class PublictagcloudAction extends Action
         $this->element('p', 'instructions',
                        sprintf(_('These are most popular recent tags on %s '),
                                common_config('site', 'name')));
+
+        $tags = new Notice_tag();
+        if ($tags->count()) {
+            return;
+        }
+
+        $message = _('Noone has posted a notice with a [hashtag](%%doc.tags%%) yet.') . ' ';
+
+        if (common_logged_in()) {
+            $message .= _('Be the first to post one!');
+        }
+        else {
+            $message .= _('Why not [register an account](%%action.register%%) and be the first to post one!');
+        }
+
+        $this->elementStart('div', 'blankfiller');
+        $this->raw(common_markup_to_html($message));
+        $this->elementEnd('div');
     }
 
     function showLocalNav()
index b0d1174551ebd09f03e23d3e9d93c55d6ccc1ebf..ad1044fa23fc405cf2f21558b8d27cad9578a954 100644 (file)
@@ -723,7 +723,7 @@ function common_local_url($action, $args=null, $params=null, $fragment=null)
 {
     static $sensitive = array('login', 'register', 'passwordsettings',
                               'twittersettings', 'finishopenidlogin',
-                              'api');
+                              'finishaddopenid', 'api');
 
     $r = Router::get();
     $path = $r->build($action, $args, $params, $fragment);