+ $jabber = jabber_normalize_jid($jabber);
+
+ if (!$jabber) {
+ $this->show_form(_('Cannot normalize that Jabber ID'));
+ return;
+ }
+ if (!jabber_valid_base_jid($jabber)) {
+ $this->show_form(_('Not a valid Jabber ID'));
+ return;
+ } else if ($user->jabber == $jabber) {
+ $this->show_form(_('That is already your Jabber ID.'));
+ return;
+ } else if ($this->jabber_exists($jabber)) {
+ $this->show_form(_('Jabber ID already belongs to another user.'));
+ return;
+ }
+
+ $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(_('Couldn\'t insert confirmation code.'));
+ return;
+ }
+
+ if (!common_config('queue', 'enabled')) {
+ jabber_confirm_address($confirm->code,
+ $user->nickname,
+ $jabber);
+ }
+
+ $msg = sprintf(_('A confirmation code was sent to the IM address you added. You must approve %s for sending messages to you.'), jabber_daemon_address());
+
+ $this->show_form($msg, TRUE);
+ }
+
+ function cancel_confirmation() {
+ $jabber = $this->arg('jabber');
+ $confirm = $this->get_confirmation();
+ if (!$confirm) {
+ $this->show_form(_('No pending confirmation to cancel.'));
+ return;
+ }
+ if ($confirm->address != $jabber) {
+ $this->show_form(_('That is the wrong IM address.'));
+ return;
+ }
+
+ $result = $confirm->delete();
+
+ if (!$result) {
+ common_log_db_error($confirm, 'DELETE', __FILE__);
+ $this->server_error(_('Couldn\'t delete email confirmation.'));
+ return;
+ }
+
+ $this->show_form(_('Confirmation cancelled.'), TRUE);
+ }
+
+ function remove_address() {
+
+ $user = common_current_user();
+ $jabber = $this->arg('jabber');
+
+ # Maybe an old tab open...?
+