From 222a61c2225363eb5451e408687837d49228ad06 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 11 Jun 2013 12:04:29 +0400 Subject: [PATCH] user editor: use dojo stuff --- classes/pref/users.php | 42 ++++++++++++------------- js/prefs.js | 70 ++++++++++++++++-------------------------- 2 files changed, 45 insertions(+), 67 deletions(-) diff --git a/classes/pref/users.php b/classes/pref/users.php index 914491e4..db6dc0d6 100644 --- a/classes/pref/users.php +++ b/classes/pref/users.php @@ -12,7 +12,7 @@ class Pref_Users extends Handler_Protected { } function csrf_ignore($method) { - $csrf_ignored = array("index"); + $csrf_ignored = array("index", "edit"); return array_search($method, $csrf_ignored) !== false; } @@ -102,11 +102,11 @@ class Pref_Users extends Handler_Protected { global $access_level_names; $id = $this->dbh->escape_string($_REQUEST["id"]); - print "
"; + print ""; - print ""; - print ""; - print ""; + print ""; + print ""; + print ""; $result = $this->dbh->query("SELECT * FROM ttrss_users WHERE id = '$id'"); @@ -120,16 +120,14 @@ class Pref_Users extends Handler_Protected { print "
"; if ($sel_disabled) { - print ""; - print ""; - } else { - print ""; + print ""; } + print ""; + print "
"; print "
".__("Authentication")."
"; @@ -139,17 +137,16 @@ class Pref_Users extends Handler_Protected { if (!$sel_disabled) { print_select_hash("access_level", $access_level, $access_level_names, - $sel_disabled); + "dojoType=\"dijit.form.Select\" $sel_disabled"); } else { print_select_hash("", $access_level, $access_level_names, - $sel_disabled); - print ""; + "dojoType=\"dijit.form.Select\" $sel_disabled"); + print ""; } - print "
"; + print "
"; - print __('Change password to') . - " "; print ""; @@ -157,8 +154,7 @@ class Pref_Users extends Handler_Protected { print "
".__("Options")."
"; print "
"; - print __('E-mail: '). - " "; print "
"; @@ -168,9 +164,9 @@ class Pref_Users extends Handler_Protected { print "
"; print "
- -
"; return; diff --git a/js/prefs.js b/js/prefs.js index e226459f..b4d55269 100644 --- a/js/prefs.js +++ b/js/prefs.js @@ -85,15 +85,34 @@ function editUser(id, event) { try { notify_progress("Loading, please wait..."); - var query = "?op=pref-users&method=edit&id=" + + var query = "backend.php?op=pref-users&method=edit&id=" + param_escape(id); - new Ajax.Request("backend.php", { - parameters: query, - onComplete: function(transport) { - infobox_callback2(transport, __("User Editor")); - document.forms['user_edit_form'].login.focus(); - } }); + if (dijit.byId("userEditDlg")) + dijit.byId("userEditDlg").destroyRecursive(); + + dialog = new dijit.Dialog({ + id: "userEditDlg", + title: __("User Editor"), + style: "width: 600px", + execute: function() { + if (this.validate()) { + + notify_progress("Saving data...", true); + + var query = dojo.formToQuery("user_edit_form"); + + new Ajax.Request("backend.php", { + parameters: query, + onComplete: function(transport) { + dialog.hide(); + updateUsersList(); + }}); + } + }, + href: query}); + + dialog.show(); } catch (e) { exception_error("editUser", e); @@ -463,43 +482,6 @@ function purgeSelectedFeeds() { return false; } -function userEditCancel() { - closeInfoBox(); - return false; -} - -function userEditSave() { - - try { - - var login = document.forms["user_edit_form"].login.value; - - if (login.length == 0) { - alert(__("Login field cannot be blank.")); - return; - } - - notify_progress("Saving user..."); - - closeInfoBox(); - - var query = Form.serialize("user_edit_form"); - - new Ajax.Request("backend.php", { - parameters: query, - onComplete: function(transport) { - updateUsersList(); - } }); - - } catch (e) { - exception_error("userEditSave", e); - } - - return false; - -} - - function editSelectedUser() { var rows = getSelectedUsers();