From d1233b47b0d96df364a1b5c043cabedc74d5eb01 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Thu, 21 Apr 2016 11:19:10 +0200 Subject: [PATCH] use PUT to update user settings Signed-off-by: Roeland Jago Douma --- settings/Controller/UsersController.php | 4 +++- settings/js/federationsettingsview.js | 5 +++-- settings/js/usersettings.js | 3 +++ settings/routes.php | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/settings/Controller/UsersController.php b/settings/Controller/UsersController.php index f06eabf6f96..7529cedd196 100644 --- a/settings/Controller/UsersController.php +++ b/settings/Controller/UsersController.php @@ -500,6 +500,7 @@ class UsersController extends Controller { * @PasswordConfirmationRequired * * @param string $userId + * @param string $avatarScope * @param string $displayname * @param string $displaynameScope * @param string $phone @@ -512,7 +513,7 @@ class UsersController extends Controller { * @param string $addressScope * @return DataResponse */ - public function saveUserSettings($userId, + public function saveUserSettings($userId, $avatarScope, $displayname, $displaynameScope, $phone, $phoneScope, $email, $emailScope, @@ -524,6 +525,7 @@ class UsersController extends Controller { 'status' => 'success', 'data' => array( 'userId' => $userId, + 'avatarScope' => $avatarScope, 'displayname' => $displayname, 'displaynameScope' => 'public', // force value for test purposes 'email' => $email, diff --git a/settings/js/federationsettingsview.js b/settings/js/federationsettingsview.js index 997f4fef3f1..9921ff64691 100644 --- a/settings/js/federationsettingsview.js +++ b/settings/js/federationsettingsview.js @@ -51,7 +51,7 @@ }); } self.listenTo(self._config, 'change:' + field + 'Scope', function () { - self._onScopeChanged(field, self._config.get(field + 'Scope')); + self._setFieldScopeIcon(field, self._config.get(field + 'Scope')); }); }); @@ -77,7 +77,8 @@ var pos = ($heading.width() - $heading.find('label').width()) - diff; scopeMenu.$el.css('right', pos); - self._onScopeChanged(field, self._config.get(field + 'Scope')); + // Restore initial state + self._setFieldScopeIcon(field, self._config.get(field + 'Scope')); }); }, diff --git a/settings/js/usersettings.js b/settings/js/usersettings.js index d8d089f83de..fcfe556b1d9 100644 --- a/settings/js/usersettings.js +++ b/settings/js/usersettings.js @@ -17,6 +17,9 @@ */ var UserSettings = OC.Backbone.Model.extend({ url: OC.generateUrl('/settings/users/{id}/settings', {id: OC.currentUser}), + isNew: function() { + return false; // Force PUT on .save() + }, parse: function(data) { if (_.isUndefined(data)) { return null; diff --git a/settings/routes.php b/settings/routes.php index ac4ade4f14a..d4286cd56ff 100644 --- a/settings/routes.php +++ b/settings/routes.php @@ -50,7 +50,7 @@ $application->registerRoutes($this, [ ['name' => 'AppSettings#viewApps', 'url' => '/settings/apps', 'verb' => 'GET'], ['name' => 'AppSettings#listApps', 'url' => '/settings/apps/list', 'verb' => 'GET'], ['name' => 'SecuritySettings#trustedDomains', 'url' => '/settings/admin/security/trustedDomains', 'verb' => 'POST'], - ['name' => 'Users#saveUserSettings', 'url' => '/settings/users/{username}/settings', 'verb' => 'POST'], + ['name' => 'Users#saveUserSettings', 'url' => '/settings/users/{username}/settings', 'verb' => 'PUT'], ['name' => 'Users#stats', 'url' => '/settings/users/stats', 'verb' => 'GET'], ['name' => 'LogSettings#setLogLevel', 'url' => '/settings/admin/log/level', 'verb' => 'POST'], ['name' => 'LogSettings#getEntries', 'url' => '/settings/admin/log/entries', 'verb' => 'GET'], -- 2.39.5