diff options
author | Evan Prodromou <evan@controlezvous.ca> | 2008-06-23 21:32:03 -0400 |
---|---|---|
committer | Evan Prodromou <evan@controlezvous.ca> | 2008-06-23 21:32:03 -0400 |
commit | d1e55b3777fe5c988c6ec605987d5c616cbdbc06 (patch) | |
tree | db34ad29948c042a723f7f44336a2cbe71f40adf /actions/imsettings.php | |
parent | 63dcbe1e6e4dc49de9ce9be82421c043cc751007 (diff) |
jabber send and confirmation code
darcs-hash:20080624013203-34904-fe87dc6b3b991e9753512b8b7cc192f7610eb1dc.gz
Diffstat (limited to 'actions/imsettings.php')
-rw-r--r-- | actions/imsettings.php | 62 |
1 files changed, 51 insertions, 11 deletions
diff --git a/actions/imsettings.php b/actions/imsettings.php index d8680c98b..2fa74514a 100644 --- a/actions/imsettings.php +++ b/actions/imsettings.php @@ -82,12 +82,11 @@ class ImsettingsAction extends SettingsAction { $user->query('BEGIN'); $original = clone($user); - - $user->jabber = $jabber; + $user->jabbernotify = $jabbernotify; $user->updatefrompresence = $updatefrompresence; - $result = $user->updateKeys($original); # For key columns + $result = $user->update($original); # For key columns if ($result === FALSE) { common_log_db_error($user, 'UPDATE', __FILE__); @@ -95,17 +94,58 @@ class ImsettingsAction extends SettingsAction { return; } - $result = $user->update($original); # For non-key columns - - if ($result === FALSE) { - common_log_db_error($user, 'UPDATE', __FILE__); - common_server_error(_t('Couldnt update user.')); - return; + $confirmation_sent = false; + + if ($user->jabber != $jabber) { + + if ($jabber) { + $confirm = new Confirm_address(); + $confirm->address = $jabber; + $confirm->address_type = 'jabber'; + $confirm->user_id = $user->id; + $confirm->code = common_confirmation_code(64); + + $result = $confirm->insert(); + + if ($result === FALSE) { + common_log_db_error($confirm, 'INSERT', __FILE__); + common_server_error(_t('Couldnt insert confirmation code.')); + return; + } + + # XXX: optionally queue for offline sending + + jabber_confirm_address($confirm->code, + $user->nickname, + $jabber); + + if ($result === FALSE) { + common_log_db_error($confirm, 'INSERT', __FILE__); + common_server_error(_t('Couldnt insert confirmation code.')); + return; + } + + $confirmation_sent = false; + } else { + # Clearing the ID is free + $user->jabber = NULL; + $result = $user->updateKeys($original); + if ($result === FALSE) { + common_log_db_error($user, 'UPDATE', __FILE__); + common_server_error(_t('Couldnt update user.')); + return; + } + } } - + $user->query('COMMIT'); - $this->show_form(_t('Settings saved.'), TRUE); + $msg = ($confirmation_sent) ? + _t('Settings saved. A confirmation code was ' . + ' sent to the IM address you added. ') : + _t('Settings saved.'); + + $this->show_form($msg, TRUE); } function jabber_exists($jabber) { |