X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fsmssettings.php;h=ec8841281d2bf07c544910080002aacd7181e556;hb=4de125dd843359c8a705c7c76eb2aa5f74efce68;hp=cdf99a56d9da6a2bfd728ceabbe85eeeb0c32bad;hpb=27ef3b1d905cdf8f47b47293a757624dda88fdc7;p=quix0rs-gnu-social.git diff --git a/actions/smssettings.php b/actions/smssettings.php index cdf99a56d9..ec8841281d 100644 --- a/actions/smssettings.php +++ b/actions/smssettings.php @@ -120,7 +120,7 @@ class SmssettingsAction extends SettingsAction } else { $confirm = $this->getConfirmation(); if ($confirm) { - $carrier = Sms_carrier::staticGet($confirm->address_extra); + $carrier = Sms_carrier::getKV($confirm->address_extra); $this->element('p', 'form_unconfirmed', $confirm->address . ' (' . $carrier->name . ')'); $this->element('p', 'form_guide', @@ -246,6 +246,7 @@ class SmssettingsAction extends SettingsAction $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { + // TRANS: Client error displayed when the session token does not match or is not given. $this->showForm(_('There was a problem with your session token. '. 'Try again, please.')); return; @@ -298,7 +299,6 @@ class SmssettingsAction extends SettingsAction common_log_db_error($user, 'UPDATE', __FILE__); // TRANS: Server error thrown on database error updating SMS preferences. $this->serverError(_('Could not update user.')); - return; } $user->query('COMMIT'); @@ -362,10 +362,9 @@ class SmssettingsAction extends SettingsAction common_log_db_error($confirm, 'INSERT', __FILE__); // TRANS: Server error thrown on database error adding SMS confirmation code. $this->serverError(_('Could not insert confirmation code.')); - return; } - $carrier = Sms_carrier::staticGet($carrier_id); + $carrier = Sms_carrier::getKV($carrier_id); mail_confirm_sms($confirm->code, $user->nickname, @@ -409,8 +408,7 @@ class SmssettingsAction extends SettingsAction if (!$result) { common_log_db_error($confirm, 'DELETE', __FILE__); // TRANS: Server error thrown on database error canceling SMS phone number confirmation. - $this->serverError(_('Could not delete email confirmation.')); - return; + $this->serverError(_('Could not delete SMS confirmation.')); } // TRANS: Message given after successfully canceling SMS phone number confirmation. @@ -438,22 +436,14 @@ class SmssettingsAction extends SettingsAction return; } - $user->query('BEGIN'); - $original = clone($user); $user->sms = null; $user->carrier = null; $user->smsemail = null; - $result = $user->updateKeys($original); - if (!$result) { - common_log_db_error($user, 'UPDATE', __FILE__); - // TRANS: Server error thrown on database error removing a registered SMS phone number. - $this->serverError(_('Could not update user.')); - return; - } - $user->query('COMMIT'); + // Throws exception on failure. Also performs it within a transaction. + $user->updateWithKeys($original); // TRANS: Message given after successfully removing a registered SMS phone number. $this->showForm(_('The SMS phone number was removed.'), true); @@ -472,7 +462,7 @@ class SmssettingsAction extends SettingsAction { $user = common_current_user(); - $other = User::staticGet('sms', $sms); + $other = User::getKV('sms', $sms); if (!$other) { return false; @@ -559,11 +549,8 @@ class SmssettingsAction extends SettingsAction $user->incomingemail = null; - if (!$user->updateKeys($orig)) { - common_log_db_error($user, 'UPDATE', __FILE__); - // TRANS: Server error displayed when the user could not be updated in SMS settings. - $this->serverError(_('Could not update user record.')); - } + // Throws exception on failure. Also performs it within a transaction. + $user->updateWithKeys($orig); // TRANS: Confirmation text after updating SMS settings. $this->showForm(_('Incoming email address removed.'), true); @@ -584,11 +571,8 @@ class SmssettingsAction extends SettingsAction $user->incomingemail = mail_new_incoming_address(); - if (!$user->updateKeys($orig)) { - common_log_db_error($user, 'UPDATE', __FILE__); - // TRANS: Server error displayed when the user could not be updated in SMS settings. - $this->serverError(_('Could not update user record.')); - } + // Throws exception on failure. Also performs it within a transaction. + $user->updateWithKeys($orig); // TRANS: Confirmation text after updating SMS settings. $this->showForm(_('New incoming email address added.'), true);