Skip to content
Snippets Groups Projects
Commit 3e68c136 authored by Robert Anderson's avatar Robert Anderson
Browse files

Update/Add user password for Admin Users Control panel

parent d274f410
No related branches found
No related tags found
No related merge requests found
......@@ -793,6 +793,7 @@
$res->setID('ID');
$res->addField('ID','int');
$res->addField('Username','string');
$res->addField('Password','string');
$res->addField('Disabled','boolean');
$res->parseHash($rawData);
......
......@@ -56,6 +56,17 @@ function getAdminUser($params) {
$resultArray['Username'] = $row->username;
$resultArray['Disabled'] = $row->disabled;
$res = DBSelect("SELECT Value FROM user_attributes WHERE Name = ? AND UserID = ?",
array('User-Password',$params[0])
);
if (!is_object($res)) {
return $res;
}
$row = $res->fetchObject();
$resultArray['Password'] = $row->value;
return $resultArray;
}
......@@ -78,7 +89,7 @@ function removeAdminUser($params) {
if ($res !== FALSE) {
$res = DBDo("DELETE FROM users_to_groups WHERE UserID = ?",array($params[0]));
}
# Delete user
if ($res !== FALSE) {
$res = DBDo("DELETE FROM users WHERE ID = ?",array($params[0]));
......@@ -100,9 +111,27 @@ function removeAdminUser($params) {
function createAdminUser($params) {
global $db;
DBBegin();
$res = DBDo("INSERT INTO users (Username) VALUES (?)",array($params[0]['Username']));
if (!is_numeric($res)) {
if ($res !== FALSE) {
$lastInsertID = DBLastInsertID();
if (isset($lastInsertID)) {
$res = DBDo("INSERT INTO user_attributes (UserID,Name,Operator,Value) VALUES (?,?,?,?)",
array($lastInsertID,'User-Password','==',$params[0]['Password'])
);
} else {
$res = 0;
}
}
# Commit and return if successful
if ($res !== FALSE) {
DBCommit();
return $res;
# Else rollback database
} else {
DBRollback();
}
return NULL;
......@@ -112,9 +141,22 @@ function createAdminUser($params) {
function updateAdminUser($params) {
global $db;
DBBegin();
$res = DBDo("UPDATE users SET Username = ? WHERE ID = ?",array($params[0]['Username'],$params[0]['ID']));
if (!is_numeric($res)) {
if ($res !== FALSE) {
$res = DBDo("UPDATE user_attributes SET Value = ? WHERE Name = ? AND UserID = ?",
array($params[0]['Password'],'User-Password',$params[0]['ID'])
);
}
# Commit and return if successful
if ($res !== FALSE) {
DBCommit();
return $res;
# Else rollback database
} else {
DBRollback();
}
return NULL;
......
......@@ -252,7 +252,9 @@ function showAdminUserAddEditWindow(id) {
SOAPFunction: 'updateAdminUser',
SOAPParams:
'0:ID,'+
'0:Username'
'0:Username,'+
'0:Password'
};
// We doing an Add
......@@ -260,7 +262,8 @@ function showAdminUserAddEditWindow(id) {
submitAjaxConfig = {
SOAPFunction: 'createAdminUser',
SOAPParams:
'0:Username'
'0:Username,'+
'0:Password'
};
}
......@@ -271,10 +274,10 @@ function showAdminUserAddEditWindow(id) {
title: "User Information",
width: 310,
height: 113,
height: 142,
minWidth: 310,
minHeight: 113
minHeight: 142
},
// Form panel config
{
......@@ -293,6 +296,11 @@ function showAdminUserAddEditWindow(id) {
maskRe: usernamePartRe,
allowBlank: false,
},
{
fieldLabel: 'Password',
name: 'Password',
allowBlank: false,
},
],
},
// Submit button config
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment