X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fimsettings.php;h=0aa7631dc2c2fc59314ce269aad42cf65a4985cb;hb=4f3d1e93e97365deac2366bfe422e8301d773a25;hp=f4c6a3e3a9cc3c2199f9528393a434805f273bbc;hpb=87b494f1ebbe7640d194ef322af12fdf378295df;p=quix0rs-gnu-social.git diff --git a/actions/imsettings.php b/actions/imsettings.php index f4c6a3e3a9..0aa7631dc2 100644 --- a/actions/imsettings.php +++ b/actions/imsettings.php @@ -25,9 +25,7 @@ require_once(INSTALLDIR.'/lib/jabber.php'); class ImsettingsAction extends SettingsAction { function get_instructions() { - return _('You can send and receive notices through '. - 'Jabber/GTalk [instant messages](%%doc.im%%). Configure '. - 'your address and settings below.'); + return _('You can send and receive notices through Jabber/GTalk [instant messages](%%doc.im%%). Configure your address and settings below.'); } function show_form($msg=NULL, $success=false) { @@ -37,6 +35,7 @@ class ImsettingsAction extends SettingsAction { 'id' => 'imsettings', 'action' => common_local_url('imsettings'))); + common_hidden('token', common_session_token()); common_element('h2', NULL, _('Address')); @@ -54,19 +53,14 @@ class ImsettingsAction extends SettingsAction { common_element_start('p'); common_element('span', 'address unconfirmed', $confirm->address); common_element('span', 'input_instructions', - sprintf(_('Awaiting confirmation on this address. Check your ' . - 'Jabber/GTalk account for a message with further ' . - 'instructions. (Did you add %s to your buddy list?)', - jabber_daemon_address()))); + sprintf(_('Awaiting confirmation on this address. Check your Jabber/GTalk account for a message with further instructions. (Did you add %s to your buddy list?)'), jabber_daemon_address())); common_hidden('jabber', $confirm->address); common_element_end('p'); common_submit('cancel', _('Cancel')); } else { common_input('jabber', _('IM Address'), ($this->arg('jabber')) ? $this->arg('jabber') : NULL, - sprintf(_('Jabber or GTalk address, like "UserName@example.org". ' . - 'First, make sure to add %s' . - ' to your buddy list in your IM client or on GTalk.'), jabber_daemon_address())); + sprintf(_('Jabber or GTalk address, like "UserName@example.org". First, make sure to add %s to your buddy list in your IM client or on GTalk.'), jabber_daemon_address())); common_submit('add', _('Add')); } } @@ -79,6 +73,12 @@ class ImsettingsAction extends SettingsAction { common_checkbox('updatefrompresence', _('Post a notice when my Jabber/GTalk status changes.'), $user->updatefrompresence); + common_checkbox('jabberreplies', + _('Send me replies through Jabber/GTalk from people I\'m not subscribed to.'), + $user->jabberreplies); + common_checkbox('jabbermicroid', + _('Publish a MicroID for my Jabber/GTalk address.'), + $user->jabbermicroid); common_submit('save', _('Save')); common_element_end('form'); @@ -99,6 +99,13 @@ class ImsettingsAction extends SettingsAction { function handle_post() { + # CSRF protection + $token = $this->trimmed('token'); + if (!$token || $token != common_session_token()) { + $this->show_form(_('There was a problem with your session token. Try again, please.')); + return; + } + if ($this->arg('save')) { $this->save_preferences(); } else if ($this->arg('add')) { @@ -116,6 +123,8 @@ class ImsettingsAction extends SettingsAction { $jabbernotify = $this->boolean('jabbernotify'); $updatefrompresence = $this->boolean('updatefrompresence'); + $jabberreplies = $this->boolean('jabberreplies'); + $jabbermicroid = $this->boolean('jabbermicroid'); $user = common_current_user(); @@ -127,12 +136,14 @@ class ImsettingsAction extends SettingsAction { $user->jabbernotify = $jabbernotify; $user->updatefrompresence = $updatefrompresence; + $user->jabberreplies = $jabberreplies; + $user->jabbermicroid = $jabbermicroid; $result = $user->update($original); if ($result === FALSE) { common_log_db_error($user, 'UPDATE', __FILE__); - common_server_error(_('Couldnt update user.')); + common_server_error(_('Couldn\'t update user.')); return; } @@ -181,7 +192,7 @@ class ImsettingsAction extends SettingsAction { if ($result === FALSE) { common_log_db_error($confirm, 'INSERT', __FILE__); - common_server_error(_('Couldnt insert confirmation code.')); + common_server_error(_('Couldn\'t insert confirmation code.')); return; } @@ -190,12 +201,8 @@ class ImsettingsAction extends SettingsAction { $user->nickname, $jabber); } - - # XXX: I18N - $msg = 'A confirmation code was sent to the IM address you added. ' . - ' You must approve ' . jabber_daemon_address() . - ' for sending messages to you.'; + $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); } @@ -241,7 +248,7 @@ class ImsettingsAction extends SettingsAction { $result = $user->updateKeys($original); if (!$result) { common_log_db_error($user, 'UPDATE', __FILE__); - common_server_error(_('Couldnt update user.')); + common_server_error(_('Couldn\'t update user.')); return; } $user->query('COMMIT');