]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Handle the case where confirmation is cancelled
authorLuke Fitzgerald <lw.fitzgerald@googlemail.com>
Sat, 24 Jul 2010 14:54:09 +0000 (07:54 -0700)
committerLuke Fitzgerald <lw.fitzgerald@googlemail.com>
Sat, 24 Jul 2010 14:54:09 +0000 (07:54 -0700)
plugins/Irc/extlib/phergie/Phergie/Plugin/Statusnet.php
plugins/Irc/ircmanager.php

index 459fe1312cbba100e71fb0caa75568224327a888..f2b7bcdab7e26449ae180923e9f8bd7fabc66143 100644 (file)
@@ -95,11 +95,11 @@ class Phergie_Plugin_Statusnet extends Phergie_Plugin_Abstract {
         if ($event->getNick() == 'NickServ') {\r
             $message = $event->getArgument(1);\r
             if (preg_match($this->unregRegexp, $message, $groups)) {\r
-                $nick = $groups[1];\r
-                call_user_func($this->regCallback, array('nick' => $nick, 'registered' => false));\r
+                $screenname = $groups[1];\r
+                call_user_func($this->regCallback, array('screenname' => $screenname, 'registered' => false));\r
             } elseif (preg_match($this->regRegexp, $message, $groups)) {\r
-                $nick = $groups[1];\r
-                call_user_func($this->regCallback, array('nick' => $nick, 'registered' => true));\r
+                $screenname = $groups[1];\r
+                call_user_func($this->regCallback, array('screenname' => $screenname, 'registered' => true));\r
             }\r
         }\r
     }\r
index 93513df861a6a99316a04877755c9f6999f4ff20..40888e413732a9b030994d8e3f9a331dbcfc7da4 100644 (file)
@@ -151,36 +151,40 @@ class IrcManager extends ImManager {
     */
     public function handle_reg_response($data) {
         // Retrieve data
-        $nickdata = $this->regchecks[$data['nick']];
-
-        if ($data['registered']) {
-            // Send message
-            $this->plugin->send_confirmation_code($nickdata['screenname'], $nickdata['code'], $nickdata['user'], true);
-        } else {
-            $this->plugin->send_message($nickdata['screenname'], _m('Your nickname is not registered so IRC connectivity cannot be enabled'));
-
-            $confirm = new Confirm_address();
-
-            $confirm->user_id      = $user->id;
-            $confirm->address_type = $this->plugin->transport;
-
-            if ($confirm->find(true)) {
-                $result = $confirm->delete();
-
-                if (!$result) {
-                    common_log_db_error($confirm, 'DELETE', __FILE__);
-                    // TRANS: Server error thrown on database error canceling IM address confirmation.
-                    $this->serverError(_('Couldn\'t delete confirmation.'));
-                    return;
+        $screenname = $data['screenname'];
+        $nickdata = $this->regchecks[$screenname];
+        $usernick = $nickdata['user']->nickname;
+
+        if (isset($this->regchecksLookup[$usernick])) {
+            if ($data['registered']) {
+                // Send message
+                $this->plugin->send_confirmation_code($screenname, $nickdata['code'], $nickdata['user'], true);
+            } else {
+                $this->plugin->send_message($screenname, _m('Your nickname is not registered so IRC connectivity cannot be enabled'));
+
+                $confirm = new Confirm_address();
+
+                $confirm->user_id      = $user->id;
+                $confirm->address_type = $this->plugin->transport;
+
+                if ($confirm->find(true)) {
+                    $result = $confirm->delete();
+
+                    if (!$result) {
+                        common_log_db_error($confirm, 'DELETE', __FILE__);
+                        // TRANS: Server error thrown on database error canceling IM address confirmation.
+                        $this->serverError(_('Couldn\'t delete confirmation.'));
+                        return;
+                    }
                 }
             }
-        }
 
-        // Unset lookup value
-        unset($this->regchecksLookup[$nickdata['screenname']]);
+            // Unset lookup value
+            unset($this->regchecksLookup[$usernick]);
 
-        // Unset data
-        unset($this->regchecks[$data['nick']]);
+            // Unset data
+            unset($this->regchecks[$screename]);
+        }
     }
 
     /**
@@ -194,14 +198,20 @@ class IrcManager extends ImManager {
         if (!$this->conn) {
             return false;
         }
+
         if ($data['type'] != 'message') {
             // Nick checking
-            $screenname = $data['nickdata']['screenname'];
-            if (isset($this->regchecksLookup[$user->nickname])) {
+            $nickdata = $data['nickdata'];
+            $usernick = $nickdata['user']->nickname;
+            $screenname = $nickdata['screenname'];
 
+            // Cancel any existing checks for this user
+            if (isset($this->regchecksLookup[$usernick])) {
+                unset($this->regchecks[$this->regchecksLookup[$usernick]]);
             }
-            $this->regchecks[$screenname] = $data['nickdata'];
-            $this->regchecksLookup[$user->nickname] = $screenname;
+
+            $this->regchecks[$screenname] = $nickdata;
+            $this->regchecksLookup[$usernick] = $screenname;
         }
 
         try {
@@ -210,6 +220,7 @@ class IrcManager extends ImManager {
             $this->conn->reconnect();
             return false;
         }
+
         return true;
     }
 }