]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge remote-tracking branch 'gitorious/1.0.x' into 1.0.x
authorEvan Prodromou <evan@status.net>
Tue, 19 Apr 2011 00:19:25 +0000 (20:19 -0400)
committerEvan Prodromou <evan@status.net>
Tue, 19 Apr 2011 00:19:25 +0000 (20:19 -0400)
Conflicts:
plugins/EmailRegistration/emailregister.php

actions/all.php
actions/recoverpassword.php
classes/Avatar.php
classes/Notice.php
classes/Profile.php
classes/User.php
lib/inboxnoticestream.php
lib/stompqueuemanager.php
plugins/Blacklist/BlacklistPlugin.php
plugins/EmailRegistration/emailregister.php
plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php

index 96f688f72083dbf9a94b9ee95f27647458a42fe7..24d8f6ec09501b2ccc47bb092b03fea49f9ef6fc 100644 (file)
@@ -59,9 +59,7 @@ class AllAction extends ProfileAction
         $stream = new ThreadingInboxNoticeStream($this->user, Profile::current());
 
         $this->notice = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE,
-                                            NOTICES_PER_PAGE + 1,
-                                            null,
-                                            null);
+                                            NOTICES_PER_PAGE + 1);
 
         if ($this->page > 1 && $this->notice->N == 0) {
             // TRANS: Server error when page not found (404).
index 71f673bd3bd659cb0826efbe0fca0f0924ade9ea..47a947dc0c786dc77df89581262fdaf149f1830c 100644 (file)
@@ -440,4 +440,18 @@ class RecoverpasswordAction extends Action
         $this->success = true;
         $this->showPage();
     }
+
+    /**
+     * A local menu
+     *
+     * Shows different login/register actions.
+     *
+     * @return void
+     */
+
+    function showLocalNav()
+    {
+        $nav = new LoginGroupNav($this);
+        $nav->show();
+    }
 }
index 34ec4a3cafc6cd8ecdfe42a82972a4d03c00738e..0b5141ba53965420a4de1c9070118888c717fbd5 100644 (file)
@@ -102,7 +102,7 @@ class Avatar extends Memcached_DataObject
     function displayUrl()
     {
         $server = common_config('avatar', 'server');
-        if ($server) {
+        if ($server && !empty($this->filename)) {
             return Avatar::url($this->filename);
         } else {
             return $this->url;
index bcd84501ec18fd2c2330a9b4b6c478fd7434d82c..71d4d4ff23bff6f225a9eec6d4e2c507b840f63a 100644 (file)
@@ -2407,4 +2407,22 @@ class Notice extends Memcached_DataObject
         }
         return $this->_original;
     }
+
+    /**
+     * Magic function called at serialize() time.
+     *
+     * We use this to drop a couple process-specific references
+     * from DB_DataObject which can cause trouble in future
+     * processes.
+     *
+     * @return array of variable names to include in serialization.
+     */
+
+    function __sleep()
+    {
+        $vars = parent::__sleep();
+        $skip = array('_original', '_profile');
+        return array_diff($vars, $skip);
+    }
+
 }
index 16484fbe6ebfbbca38d6eaabb67cd72a4f4410aa..2638f745f71227598cc9af97b2369470bafd1b16 100644 (file)
@@ -1353,4 +1353,21 @@ class Profile extends Memcached_DataObject
         }
         return $profile;
     }
+
+    /**
+     * Magic function called at serialize() time.
+     *
+     * We use this to drop a couple process-specific references
+     * from DB_DataObject which can cause trouble in future
+     * processes.
+     *
+     * @return array of variable names to include in serialization.
+     */
+
+    function __sleep()
+    {
+        $vars = parent::__sleep();
+        $skip = array('_user');
+        return array_diff($vars, $skip);
+    }
 }
index d8f813c765911ba9b433c97bcf03520b25ae6d31..8642c78c273c15308b4f2c5c2f32c597656edadd 100644 (file)
@@ -983,4 +983,21 @@ class User extends Memcached_DataObject
 
         return $apps;
     }
+
+    /**
+     * Magic function called at serialize() time.
+     *
+     * We use this to drop a couple process-specific references
+     * from DB_DataObject which can cause trouble in future
+     * processes.
+     *
+     * @return array of variable names to include in serialization.
+     */
+
+    function __sleep()
+    {
+        $vars = parent::__sleep();
+        $skip = array('_profile');
+        return array_diff($vars, $skip);
+    }
 }
index 3250351d17aea2fc865a94d1f5b4ee2822df7ccb..5517cef1137b4bcfddb3033a59c0611efc5dbb9c 100644 (file)
@@ -20,7 +20,7 @@
  * You should have received a copy of the GNU Affero General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
- * @category  Cache
+ * @category  NoticeStream
  * @package   StatusNet
  * @author    Evan Prodromou <evan@status.net>
  * @copyright 2011 StatusNet, Inc.
index 1d9a5ad207ef4846aa7e8caf05d08dc9054fd1d1..7dd3e6961e005857bf5bbb729a2d4d11cf8ccf2f 100644 (file)
@@ -480,6 +480,13 @@ class StompQueueManager extends QueueManager
     {
         $host = $this->cons[$this->defaultIdx]->getServer();
         $message = unserialize($frame->body);
+
+        if ($message === false) {
+            $this->_log(LOG_ERR, "Can't unserialize frame: {$frame->body}");
+            $this->_log(LOG_ERR, "Unserializable frame length: " . strlen($frame->body));
+            return false;
+        }
+
         $site = $message['site'];
         $queue = $message['handler'];
 
index 92202dfb2e8349528fe99045a88c903e5b059c29..babf7031313e22565e0a0b366a009940834e585d 100644 (file)
@@ -141,9 +141,9 @@ class BlacklistPlugin extends Plugin
      *
      * @return boolean hook value
      */
-    function onStartRegistrationTry($action)
+    function onStartRegisterUser(&$user, &$profile)
     {
-        $homepage = strtolower($action->trimmed('homepage'));
+        $homepage = strtolower($profile->homepage);
 
         if (!empty($homepage)) {
             if (!$this->_checkUrl($homepage)) {
@@ -154,7 +154,7 @@ class BlacklistPlugin extends Plugin
             }
         }
 
-        $nickname = strtolower($action->trimmed('nickname'));
+        $nickname = strtolower($profile->nickname);
 
         if (!empty($nickname)) {
             if (!$this->_checkNickname($nickname)) {
index 5577fbd964b16070c2b88c04dc49da719ecbca3b..f6d0ec9b3c4de3e4bec187e4025bfbf10a4ae62e 100644 (file)
@@ -270,72 +270,70 @@ class EmailregisterAction extends Action
 
     function setPassword()
     {
-        if (Event::handle('StartRegistrationTry', array($this))) {
-            if (!empty($this->invitation)) {
-                $email = $this->invitation->address;
-            } else if (!empty($this->confirmation)) {
-                $email = $this->confirmation->address;
-            } else {
-                // TRANS: Exception.
-                throw new Exception('No confirmation thing.');
-            }
-
-            if (!$this->tos) {
-                // TRANS: Error text when trying to register without accepting TOS and privacy policy.
-                $this->error = _m('You must accept the terms of service and privacy policy to register.');
-                return;
-            } else if (empty($this->password1)) {
-                // TRANS: Error text when trying to register without a password.
-                $this->error = _m('You must set a password.');
-            } else if (strlen($this->password1) < 6) {
-                // TRANS: Error text when trying to register with too short a password.
-                $this->error = _m('Password must be 6 or more characters.');
-            } else if ($this->password1 != $this->password2) {
-                $this->error = _m('Passwords do not match.');
-            }
+        if (!empty($this->invitation)) {
+            $email = $this->invitation->address;
+        } else if (!empty($this->confirmation)) {
+            $email = $this->confirmation->address;
+        } else {
+            throw new Exception('No confirmation thing.');
+        }
 
-            if (!empty($this->error)) {
-                $nickname = $this->nicknameFromEmail($email);
-                $this->form = new ConfirmRegistrationForm($this, $nickname, $this->email, $this->code);
-                $this->showPage();
-                return;
-            }
+        if (!$this->tos) {
+            $this->error = _('You must accept the terms of service and privacy policy to register.');
+            return;
+        } else if (empty($this->password1)) {
+            $this->error = _('You must set a password');
+        } else if (strlen($this->password1) < 6) {
+            $this->error = _('Password must be 6 or more characters.');
+        } else if ($this->password1 != $this->password2) {
+            $this->error = _('Passwords do not match.');
+        }
 
+        if (!empty($this->error)) {
             $nickname = $this->nicknameFromEmail($email);
+            $this->form = new ConfirmRegistrationForm($this, $nickname, $this->email, $this->code);
+            $this->showPage();
+            return;
+        }
 
+        $nickname = $this->nicknameFromEmail($email);
+
+        try {
             $this->user = User::register(array('nickname' => $nickname,
                                                'email' => $email,
                                                'password' => $this->password1,
                                                'email_confirmed' => true));
+        } catch (ClientException $e) {
+            $this->error = $e->getMessage();
+            $nickname = $this->nicknameFromEmail($email);
+            $this->form = new ConfirmRegistrationForm($this, $nickname, $this->email, $this->code);
+            $this->showPage();
+            return;
+        }
 
-            if (empty($this->user)) {
-                // TRANS: Exception thrown when user registration fails.
-                throw new Exception('Failed to register user.');
-            }
-
-            common_set_user($this->user);
-            // this is a real login
-            common_real_login(true);
+        if (empty($this->user)) {
+            throw new Exception("Failed to register user.");
+        }
 
-            // Re-init language env in case it changed (not yet, but soon)
-            common_init_language();
+        common_set_user($this->user);
+        // this is a real login
+        common_real_login(true);
 
-            if (!empty($this->invitation)) {
-                $inviter = User::staticGet('id', $this->invitation->user_id);
-                if (!empty($inviter)) {
-                    Subscription::start($inviter->getProfile(),
-                                        $this->user->getProfile());
-                }
+        // Re-init language env in case it changed (not yet, but soon)
+        common_init_language();
 
-                $this->invitation->delete();
-            } else if (!empty($this->confirmation)) {
-                $this->confirmation->delete();
-            } else {
-                // TRANS: Exception.
-                throw new Exception('No confirmation thing.');
+        if (!empty($this->invitation)) {
+            $inviter = User::staticGet('id', $this->invitation->user_id);
+            if (!empty($inviter)) {
+                Subscription::start($inviter->getProfile(),
+                                    $this->user->getProfile());
             }
 
-            Event::handle('EndRegistrationTry', array($this));
+            $this->invitation->delete();
+        } else if (!empty($this->confirmation)) {
+            $this->confirmation->delete();
+        } else {
+            throw new Exception('No confirmation thing.');
         }
 
         common_redirect(common_local_url('doc', array('title' => 'welcome')),
index b6bd6f7e5fbeae4bc8c47ca44e22652c2e8fd181..0d4bc4da16db8f648e1cb1623e46c0999fad28d4 100644 (file)
@@ -147,6 +147,26 @@ class RequireValidatedEmailPlugin extends Plugin
         return true;
     }
 
+    /**
+     * Event handler for registration attempts; rejects the registration
+     * if email field is missing.
+     *
+     * @param Action $action Action being executed
+     *
+     * @return bool hook result code
+     */
+
+    function onStartRegisterUser(&$user, &$profile)
+    {
+        $email = $user->email;
+
+        if (empty($email)) {
+            throw new ClientException(_m('You must provide an email address to register.'));
+        }
+
+        return true;
+    }
+
     /**
      * Check if a user has a validated email address or has been
      * otherwise grandfathered in.