+ if (in_array($type, array('email', 'sms')))
+ {
+ if ($cur->$type == $confirm->address) {
+ // TRANS: Client error for an already confirmed email/jabber/sms address.
+ $this->clientError(_('That address has already been confirmed.'));
+ }
+
+ $orig_user = clone($cur);
+
+ $cur->$type = $confirm->address;
+
+ if ($type == 'sms') {
+ $cur->carrier = ($confirm->address_extra)+0;
+ $carrier = Sms_carrier::getKV($cur->carrier);
+ $cur->smsemail = $carrier->toEmailAddress($cur->sms);
+ }
+
+ $result = $cur->updateKeys($orig_user);
+
+ if (!$result) {
+ common_log_db_error($cur, 'UPDATE', __FILE__);
+ // TRANS: Server error displayed when confirming an e-mail address or IM address fails.
+ $this->serverError(_('Could not update user.'));
+ }
+
+ if ($type == 'email') {
+ $cur->emailChanged();
+ }
+
+ } else {
+
+ $user_im_prefs = new User_im_prefs();
+ $user_im_prefs->transport = $confirm->address_type;
+ $user_im_prefs->user_id = $cur->id;
+ if ($user_im_prefs->find() && $user_im_prefs->fetch()) {
+ if($user_im_prefs->screenname == $confirm->address){
+ // TRANS: Client error for an already confirmed IM address.
+ $this->clientError(_('That address has already been confirmed.'));
+ }
+ $user_im_prefs->screenname = $confirm->address;
+ $result = $user_im_prefs->update();
+
+ if (!$result) {
+ common_log_db_error($user_im_prefs, 'UPDATE', __FILE__);
+ // TRANS: Server error displayed when updating IM preferences fails.
+ $this->serverError(_('Could not update user IM preferences.'));
+ }
+ }else{
+ $user_im_prefs = new User_im_prefs();
+ $user_im_prefs->screenname = $confirm->address;
+ $user_im_prefs->transport = $confirm->address_type;
+ $user_im_prefs->user_id = $cur->id;
+ $result = $user_im_prefs->insert();
+
+ if (!$result) {
+ common_log_db_error($user_im_prefs, 'INSERT', __FILE__);
+ // TRANS: Server error displayed when adding IM preferences fails.
+ $this->serverError(_('Could not insert user IM preferences.'));
+ }
+ }