user editor: use dojo stuff

This commit is contained in:
Andrew Dolgov 2013-06-11 12:04:29 +04:00
parent 10e1b51798
commit 222a61c222
2 changed files with 45 additions and 67 deletions

View File

@ -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 "<form id=\"user_edit_form\" onsubmit='return false'>";
print "<form id=\"user_edit_form\" onsubmit='return false' dojoType=\"dijit.form.Form\">";
print "<input type=\"hidden\" name=\"id\" value=\"$id\">";
print "<input type=\"hidden\" name=\"op\" value=\"pref-users\">";
print "<input type=\"hidden\" name=\"method\" value=\"editSave\">";
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"id\" value=\"$id\">";
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-users\">";
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"editSave\">";
$result = $this->dbh->query("SELECT * FROM ttrss_users WHERE id = '$id'");
@ -120,15 +120,13 @@ class Pref_Users extends Handler_Protected {
print "<div class=\"dlgSecCont\">";
if ($sel_disabled) {
print "<input type=\"hidden\" name=\"login\" value=\"$login\">";
print "<input size=\"30\" style=\"font-size : 16px\"
onkeypress=\"return filterCR(event, userEditSave)\" $sel_disabled
value=\"$login\">";
} else {
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"login\" value=\"$login\">";
}
print "<input size=\"30\" style=\"font-size : 16px\"
dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"
onkeypress=\"return filterCR(event, userEditSave)\" $sel_disabled
name=\"login\" value=\"$login\">";
}
print "</div>";
@ -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 "<input type=\"hidden\" name=\"access_level\" value=\"$access_level\">";
"dojoType=\"dijit.form.Select\" $sel_disabled");
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"access_level\" value=\"$access_level\">";
}
print "<br/>";
print "<hr/>";
print __('Change password to') .
" <input type=\"password\" size=\"20\" onkeypress=\"return filterCR(event, userEditSave)\"
print "<input dojoType=\"dijit.form.TextBox\" type=\"password\" size=\"20\" onkeypress=\"return filterCR(event, userEditSave)\" placeholder=\"Change password to\"
name=\"password\">";
print "</div>";
@ -157,8 +154,7 @@ class Pref_Users extends Handler_Protected {
print "<div class=\"dlgSec\">".__("Options")."</div>";
print "<div class=\"dlgSecCont\">";
print __('E-mail: ').
" <input size=\"30\" name=\"email\" onkeypress=\"return filterCR(event, userEditSave)\"
print "<input dojoType=\"dijit.form.TextBox\" size=\"30\" name=\"email\" onkeypress=\"return filterCR(event, userEditSave)\" placeholder=\"Email\"
value=\"$email\">";
print "</div>";
@ -168,9 +164,9 @@ class Pref_Users extends Handler_Protected {
print "</form>";
print "<div class=\"dlgButtons\">
<button onclick=\"return userEditSave()\">".
<button dojoType=\"dijit.form.Button\" type=\"submit\">".
__('Save')."</button>
<button onclick=\"return userEditCancel()\">".
<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('userEditDlg').hide()\">".
__('Cancel')."</button></div>";
return;

View File

@ -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);
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) {
infobox_callback2(transport, __("User Editor"));
document.forms['user_edit_form'].login.focus();
} });
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();