]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge branch '0.7.x' of git@gitorious.org:laconica/dev into 0.7.x
authorEvan Prodromou <evan@controlyourself.ca>
Sat, 21 Feb 2009 15:10:33 +0000 (07:10 -0800)
committerEvan Prodromou <evan@controlyourself.ca>
Sat, 21 Feb 2009 15:10:33 +0000 (07:10 -0800)
18 files changed:
.gitignore
actions/finishopenidlogin.php
actions/grouprss.php
actions/login.php
actions/tagother.php
actions/twitapistatuses.php
actions/userrss.php
classes/User.php
index.php
lib/grouplist.php
lib/noticesection.php
lib/omb.php
lib/openid.php
lib/popularnoticesection.php
lib/profilelist.php
lib/router.php
lib/searchaction.php
lib/util.php

index f2e96d3eb662e89c5938a74382846233c3544726..83a53dfa3fef76899d8cf1316800396452f44961 100644 (file)
@@ -1,8 +1,10 @@
 avatar/*
 files/*
 _darcs/*
+logs/*
 config.php
 .htaccess
+httpd.conf
 *.tmproj
 dataobject.ini
 *~
@@ -10,3 +12,4 @@ dataobject.ini
 *.orig
 *.rej
 .#*
+*.swp
index 1e7b73a7f3a43b756ec787bb66e430b1f916b8a1..6d92cb9aaecb787edcf2f26ac7a8f8d4a13e2005 100644 (file)
@@ -83,7 +83,7 @@ class FinishopenidloginAction extends Action
 
     function showContent()
     {
-        if ($this->message_text) {
+        if (!empty($this->message_text)) {
             $this->element('p', null, $this->message);
             return;
         }
@@ -232,7 +232,8 @@ class FinishopenidloginAction extends Action
             return;
         }
 
-        if ($sreg['country']) {
+        $location = '';
+        if (!empty($sreg['country'])) {
             if ($sreg['postcode']) {
                 # XXX: use postcode to get city and region
                 # XXX: also, store postcode somewhere -- it's valuable!
@@ -242,12 +243,16 @@ class FinishopenidloginAction extends Action
             }
         }
 
-        if ($sreg['fullname'] && mb_strlen($sreg['fullname']) <= 255) {
+        if (!empty($sreg['fullname']) && mb_strlen($sreg['fullname']) <= 255) {
             $fullname = $sreg['fullname'];
+        } else {
+            $fullname = '';
         }
 
-        if ($sreg['email'] && Validate::email($sreg['email'], true)) {
+        if (!empty($sreg['email']) && Validate::email($sreg['email'], true)) {
             $email = $sreg['email'];
+        } else {
+            $email = '';
         }
 
         # XXX: add language
@@ -328,7 +333,7 @@ class FinishopenidloginAction extends Action
 
         # Try the passed-in nickname
 
-        if ($sreg['nickname']) {
+        if (!empty($sreg['nickname'])) {
             $nickname = $this->nicknamize($sreg['nickname']);
             if ($this->isNewNickname($nickname)) {
                 return $nickname;
@@ -337,7 +342,7 @@ class FinishopenidloginAction extends Action
 
         # Try the full name
 
-        if ($sreg['fullname']) {
+        if (!empty($sreg['fullname'])) {
             $fullname = $this->nicknamize($sreg['fullname']);
             if ($this->isNewNickname($fullname)) {
                 return $fullname;
index 1a7b858b1ee0da247f620252597d2abb1a67ae81..de76a59600dbb67d409c44bf434784b3d62e04f0 100644 (file)
@@ -111,13 +111,13 @@ class groupRssAction extends Rss10Action
     {
 
         $group = $this->group;
-        
+
         if (is_null($group)) {
             return null;
         }
-        
+
         $notice = $group->getNotices(0, ($limit == 0) ? NOTICES_PER_PAGE : $limit);
-        
+
         while ($notice->fetch()) {
             $notices[] = clone($notice);
         }
@@ -141,13 +141,4 @@ class groupRssAction extends Rss10Action
     {
         return $this->group->homepage_logo;
     }
-
-    # override parent to add X-SUP-ID URL
-    
-    function initRss($limit=0)
-    {
-        $url = common_local_url('sup', null, $this->group->id);
-        header('X-SUP-ID: '.$url);
-        parent::initRss($limit);
-    }
 }
index 71e4679292c79102dd97f80f6683a655dfef5535..b049791fb1858dac3d79625317efa0ae77bb5bd9 100644 (file)
@@ -108,13 +108,15 @@ class LoginAction extends Action
         $nickname = common_canonical_nickname($this->trimmed('nickname'));
         $password = $this->arg('password');
 
-        if (!common_check_user($nickname, $password)) {
+        $user = common_check_user($nickname, $password);
+
+        if (!$user) {
             $this->showForm(_('Incorrect username or password.'));
             return;
         }
 
         // success!
-        if (!common_set_user($nickname)) {
+        if (!common_set_user($user)) {
             $this->serverError(_('Error setting user.'));
             return;
         }
index 79151c91184a7c7e3642eefea49c48c2fe579c10..0d18945a09e88b2e8d2cc9b2704584cc93184be1 100644 (file)
@@ -135,7 +135,8 @@ class TagotherAction extends Action
                                            'id' => 'form_tag_user',
                                            'class' => 'form_settings',
                                            'name' => 'tagother',
-                                           'action' => $this->selfUrl()));
+                                           'action' => common_local_url('tagother', array('id' => $this->profile->id))));
+
         $this->elementStart('fieldset');
         $this->element('legend', null, _('Tag user'));
         $this->hidden('token', common_session_token());
index 18e24c0f582c1a1781dc09f058510e3c2bd32276..51c2565892976820e5fd98633b932a6da5427896 100644 (file)
@@ -204,7 +204,7 @@ class TwitapistatusesAction extends TwitterapiAction
         # FriendFeed's SUP protocol
         # Also added RSS and Atom feeds
 
-        $suplink = common_local_url('sup', null, $user->id);
+        $suplink = common_local_url('sup', null, null, $user->id);
         header('X-SUP-ID: '.$suplink);
 
         # XXX: since
index 04855cccaded30a05ac67a0789647aae8b7e882f..a3e5a3aab710a05699ef64eeffb5c6084397d35a 100644 (file)
@@ -46,13 +46,13 @@ class UserrssAction extends Rss10Action
     {
 
         $user = $this->user;
-        
+
         if (is_null($user)) {
             return null;
         }
-        
+
         $notice = $user->getNotices(0, ($limit == 0) ? NOTICES_PER_PAGE : $limit);
-        
+
         while ($notice->fetch()) {
             $notices[] = clone($notice);
         }
@@ -87,10 +87,10 @@ class UserrssAction extends Rss10Action
     }
 
     # override parent to add X-SUP-ID URL
-    
+
     function initRss($limit=0)
     {
-        $url = common_local_url('sup', null, $this->user->id);
+        $url = common_local_url('sup', null, null, $this->user->id);
         header('X-SUP-ID: '.$url);
         parent::initRss($limit);
     }
@@ -100,4 +100,3 @@ class UserrssAction extends Rss10Action
         return true;
     }
 }
-
index 495a982360e04c716a2a52708d4f8ff87c197283..40cf18df67406da2e16eb22089a21e328383e1c8 100644 (file)
@@ -183,16 +183,16 @@ class User extends Memcached_DataObject
         $profile->nickname = $nickname;
         $profile->profileurl = common_profile_url($nickname);
 
-        if ($fullname) {
+        if (!empty($fullname)) {
             $profile->fullname = $fullname;
         }
-        if ($homepage) {
+        if (!empty($homepage)) {
             $profile->homepage = $homepage;
         }
-        if ($bio) {
+        if (!empty($bio)) {
             $profile->bio = $bio;
         }
-        if ($location) {
+        if (!empty($location)) {
             $profile->location = $location;
         }
 
@@ -200,7 +200,7 @@ class User extends Memcached_DataObject
 
         $id = $profile->insert();
 
-        if (!$id) {
+        if (empty($id)) {
             common_log_db_error($profile, 'INSERT', __FILE__);
             return false;
         }
@@ -210,13 +210,13 @@ class User extends Memcached_DataObject
         $user->id = $id;
         $user->nickname = $nickname;
 
-        if ($password) { # may not have a password for OpenID users
+        if (!empty($password)) { # may not have a password for OpenID users
             $user->password = common_munge_password($password, $id);
         }
 
         # Users who respond to invite email have proven their ownership of that address
 
-        if ($code) {
+        if (!empty($code)) {
             $invite = Invitation::staticGet($code);
             if ($invite && $invite->address && $invite->address_type == 'email' && $invite->address == $email) {
                 $user->email = $invite->address;
@@ -253,7 +253,7 @@ class User extends Memcached_DataObject
             return false;
         }
 
-        if ($email && !$user->email) {
+        if (!empty($email) && !$user->email) {
 
             $confirm = new Confirm_address();
             $confirm->code = common_confirmation_code(128);
@@ -268,7 +268,7 @@ class User extends Memcached_DataObject
             }
         }
 
-        if ($code && $user->email) {
+        if (!empty($code) && $user->email) {
             $user->emailChanged();
         }
 
index b180e2b653b285f2c54585d83d7558e170f7e74d..914ba5bde1453e2c21122a0766e8fc95fd8ac6cb 100644 (file)
--- a/index.php
+++ b/index.php
@@ -27,12 +27,13 @@ $action = null;
 
 function getPath($req)
 {
-    if (common_config('site', 'fancy')) {
+    if ((common_config('site', 'fancy') || !array_key_exists('PATH_INFO', $_SERVER))
+        && array_key_exists('p', $req)) {
         return $req['p'];
-    } else if ($_SERVER['PATH_INFO']) {
+    } else if (array_key_exists('PATH_INFO', $_SERVER)) {
         return $_SERVER['PATH_INFO'];
     } else {
-        return $req['p'];
+        return null;
     }
 }
 
@@ -115,8 +116,8 @@ function main()
 
         // XXX: find somewhere for this little block to live
 
-        if ($config['db']['mirror'] && $action_obj->isReadOnly()) {
-            if (is_array($config['db']['mirror'])) {
+        if (common_config('db', 'mirror') && $action_obj->isReadOnly()) {
+            if (is_array(common_config('db', 'mirror'))) {
                 // "load balancing", ha ha
                 $k = array_rand($config['db']['mirror']);
 
index 6801ab42617eb40d876fecccba72066c0c2e2ba4..1b854749982198e68f89de742d2c1fd306e3ce1c 100644 (file)
@@ -151,7 +151,7 @@ class GroupList extends Widget
 
         # If we're on a list with an owner (subscriptions or subscribers)...
 
-        if ($user && $user->id == $this->owner->id) {
+        if (!empty($user) && !empty($this->owner) && $user->id == $this->owner->id) {
             $this->showOwnerControls();
         }
 
index 97b51752965c1092c7bf7867e6d0aade184373ea..b31f18744557be91c42975ca0baaef70139271cb 100644 (file)
@@ -96,7 +96,7 @@ class NoticeSection extends Section
         $this->out->elementStart('p', 'entry-content');
         $this->out->raw($notice->rendered);
         $this->out->elementEnd('p');
-        if ($notice->value) {
+        if (!empty($notice->value)) {
             $this->out->elementStart('p');
             $this->out->text($notice->value);
             $this->out->elementEnd('p');
index f2dbef5ba945f97ed10c172cd5e3a5367c844035..29e14c75f76adff6255e62010b3e5e46b999b0d8 100644 (file)
@@ -239,7 +239,7 @@ function omb_broadcast_profile($profile)
         while ($sub->fetch()) {
             $rp = Remote_profile::staticGet('id', $sub->subscriber);
             if ($rp) {
-                if (!$updated[$rp->updateprofileurl]) {
+                if (!array_key_exists($rp->updateprofileurl, $updated)) {
                     if (omb_update_profile($profile, $rp, $sub)) {
                         $updated[$rp->updateprofileurl] = true;
                     }
@@ -295,7 +295,9 @@ function omb_update_profile($profile, $remote_profile, $subscription)
 
     common_debug('Got HTTP result "'.print_r($result,true).'"', __FILE__);
 
-    if ($result->status == 403) { # not authorized, don't send again
+    if (empty($result) || $result) {
+        common_debug("Unable to contact " . $req->get_normalized_http_url());
+    } else if ($result->status == 403) { # not authorized, don't send again
         common_debug('403 result, deleting subscription', __FILE__);
         $subscription->delete();
         return false;
index 8605737026340cebfbc00e2d87ea615398af83e2..5c3d460dafdb7c2e7814663953f54eb7c5788f8f 100644 (file)
@@ -64,6 +64,9 @@ function oid_set_last($openid_url)
 
 function oid_get_last()
 {
+    if (empty($_COOKIE[OPENID_COOKIE_KEY])) {
+        return null;
+    }
     $openid_url = $_COOKIE[OPENID_COOKIE_KEY];
     if ($openid_url && strlen($openid_url) > 0) {
         return $openid_url;
index 5380563b9e70ee48cb8590bc376d39b16cbb20fd..c7c7f02150407a850bbcc8a3172cfd8b05f90dfd 100644 (file)
@@ -31,8 +31,6 @@ if (!defined('LACONICA')) {
     exit(1);
 }
 
-define('NOTICES_PER_SECTION', 5);
-
 /**
  * Base class for sections showing lists of notices
  *
index 8bef49dceeefc0885576274a86e7adc786a0dee1..c2040fbc232a980fa2d926d926abbd6850b67614 100644 (file)
@@ -34,8 +34,6 @@ if (!defined('LACONICA')) {
 
 require_once INSTALLDIR.'/lib/widget.php';
 
-define('PROFILES_PER_PAGE', 20);
-
 /**
  * Widget to show a list of profiles
  *
index 9d0d3a3f0613382fb401fd47922b5ebae107098e..e842604e9a35d11abd55ba1194eaec80b56534f0 100644 (file)
@@ -47,7 +47,7 @@ require_once 'Net/URL/Mapper.php';
 
 class Router
 {
-    static $m = null;
+    var $m = null;
     static $inst = null;
 
     static function get()
@@ -98,12 +98,14 @@ class Router
         $main = array('login', 'logout', 'register', 'subscribe',
                       'unsubscribe', 'confirmaddress', 'recoverpassword',
                       'invite', 'favor', 'disfavor', 'sup',
-                      'tagother', 'block');
+                      'block');
 
         foreach ($main as $a) {
             $m->connect('main/'.$a, array('action' => $a));
         }
 
+        $m->connect('main/tagother/:id', array('action' => 'tagother'));
+
         // these take a code
 
         foreach (array('register', 'confirmaddress', 'recoverpassword') as $c) {
@@ -370,7 +372,7 @@ class Router
         return $match;
     }
 
-    function build($action, $args=null, $fragment=null)
+    function build($action, $args=null, $params=null, $fragment=null)
     {
         $action_arg = array('action' => $action);
 
@@ -380,6 +382,6 @@ class Router
             $args = $action_arg;
         }
 
-        return $this->m->generate($args, null, $fragment);
+        return $this->m->generate($args, $params, $fragment);
     }
 }
\ No newline at end of file
index fdfb8dc5adac4cc57378b9665c9d0744907a8d5a..df6876445992b8c3838f5c3a51d660dc746805b4 100644 (file)
@@ -79,10 +79,11 @@ class SearchAction extends Action
 
     function showTop($arr=null)
     {
+        $error = null;
         if ($arr) {
             $error = $arr[1];
         }
-        if ($error) {
+        if (!empty($error)) {
             $this->element('p', 'error', $error);
         } else {
             $instr = $this->getInstructions();
index 46aa7b9df907b2691f0ce782376a7005da573a98..5345a08bba08346e028a55f164fcf609b416e5fd 100644 (file)
@@ -705,10 +705,10 @@ function common_relative_profile($sender, $nickname, $dt=null)
     return null;
 }
 
-function common_local_url($action, $args=null, $fragment=null)
+function common_local_url($action, $args=null, $params=null, $fragment=null)
 {
     $r = Router::get();
-    $path = $r->build($action, $args, $fragment);
+    $path = $r->build($action, $args, $params, $fragment);
     if ($path) {
     }
     if (common_config('site','fancy')) {