From: Luke Fitzgerald Date: Sat, 24 Jul 2010 14:54:09 +0000 (-0700) Subject: Handle the case where confirmation is cancelled X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9f0eea69ff9cd67b638e70c42d887c7bb45c4ffd;p=quix0rs-gnu-social.git Handle the case where confirmation is cancelled --- diff --git a/plugins/Irc/extlib/phergie/Phergie/Plugin/Statusnet.php b/plugins/Irc/extlib/phergie/Phergie/Plugin/Statusnet.php index 459fe1312c..f2b7bcdab7 100644 --- a/plugins/Irc/extlib/phergie/Phergie/Plugin/Statusnet.php +++ b/plugins/Irc/extlib/phergie/Phergie/Plugin/Statusnet.php @@ -95,11 +95,11 @@ class Phergie_Plugin_Statusnet extends Phergie_Plugin_Abstract { if ($event->getNick() == 'NickServ') { $message = $event->getArgument(1); if (preg_match($this->unregRegexp, $message, $groups)) { - $nick = $groups[1]; - call_user_func($this->regCallback, array('nick' => $nick, 'registered' => false)); + $screenname = $groups[1]; + call_user_func($this->regCallback, array('screenname' => $screenname, 'registered' => false)); } elseif (preg_match($this->regRegexp, $message, $groups)) { - $nick = $groups[1]; - call_user_func($this->regCallback, array('nick' => $nick, 'registered' => true)); + $screenname = $groups[1]; + call_user_func($this->regCallback, array('screenname' => $screenname, 'registered' => true)); } } } diff --git a/plugins/Irc/ircmanager.php b/plugins/Irc/ircmanager.php index 93513df861..40888e4137 100644 --- a/plugins/Irc/ircmanager.php +++ b/plugins/Irc/ircmanager.php @@ -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; } }