summaryrefslogtreecommitdiffstats
path: root/frontends/php/include/users.inc.php
diff options
context:
space:
mode:
authorartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-01-14 14:45:56 +0000
committerartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-01-14 14:45:56 +0000
commit8c131d6804ff7f8b8d30ec2405671a14a7ec84f9 (patch)
treec03a1511056dbd3c66f674162006c5b9764620ee /frontends/php/include/users.inc.php
parent3ee8a188032fbd4f0d112ba7a7af55e1cfb0e50c (diff)
downloadzabbix-8c131d6804ff7f8b8d30ec2405671a14a7ec84f9.tar.gz
zabbix-8c131d6804ff7f8b8d30ec2405671a14a7ec84f9.tar.xz
zabbix-8c131d6804ff7f8b8d30ec2405671a14a7ec84f9.zip
- [DEV-96] added availability to disable default user "guest" (Artem)
git-svn-id: svn://svn.zabbix.com/trunk@5246 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include/users.inc.php')
-rw-r--r--frontends/php/include/users.inc.php33
1 files changed, 16 insertions, 17 deletions
diff --git a/frontends/php/include/users.inc.php b/frontends/php/include/users.inc.php
index 49bdf322..3bac4b30 100644
--- a/frontends/php/include/users.inc.php
+++ b/frontends/php/include/users.inc.php
@@ -50,10 +50,12 @@
$userid = get_dbid("users","userid");
- $result = DBexecute('insert into users (userid,name,surname,alias,passwd,url,autologout,lang,refresh,type,status)'.
+ $result = DBexecute('insert into users (userid,name,surname,alias,passwd,url,autologout,lang,refresh,type)'.
' values ('.$userid.','.zbx_dbstr($name).','.zbx_dbstr($surname).','.zbx_dbstr($alias).','.
- zbx_dbstr(md5($passwd)).','.zbx_dbstr($url).','.$autologout.','.zbx_dbstr($lang).','.$refresh.','.$user_type.','.$status.')');
-
+ zbx_dbstr(md5($passwd)).','.zbx_dbstr($url).','.$autologout.','.zbx_dbstr($lang).','.$refresh.','.$user_type.')');
+
+ $result &= change_user_status($userid,$status);
+
if($result)
{
DBexecute('delete from users_groups where userid='.$userid);
@@ -98,8 +100,10 @@
$result = DBexecute("update users set name=".zbx_dbstr($name).",surname=".zbx_dbstr($surname).","."alias=".zbx_dbstr($alias).
(isset($passwd) ? (',passwd='.zbx_dbstr(md5($passwd))) : '').
",url=".zbx_dbstr($url).","."autologout=$autologout,lang=".zbx_dbstr($lang).",refresh=$refresh,".
- "type=$user_type,status=$status".
+ "type=$user_type".
" where userid=$userid");
+
+ $result &= change_user_status($userid,$status);
if($result)
{
@@ -150,15 +154,12 @@
# Delete User definition
- function delete_user($userid)
- {
-
- if(DBfetch(DBselect('select * from users where userid='.$userid.' and alias='.zbx_dbstr(ZBX_GUEST_USER))))
- {
- error("Cannot delete user '".ZBX_GUEST_USER."'");
+ function delete_user($userid){
+ if(DBfetch(DBselect('select * from users where userid='.$userid.' and alias='.zbx_dbstr(ZBX_GUEST_USER)))){
+ error(S_CANNOT_DELETE_USER.SPACE."'".ZBX_GUEST_USER."'");
return false;
}
-
+
DBexecute('delete from operations where object='.OPERATION_OBJECT_USER.' and objectid='.$userid);
$result = DBexecute('delete from media where userid='.$userid);
@@ -187,12 +188,10 @@
function change_user_status($userid,$status){
global $USER_DETAILS;
$res = false;
- if(bccomp($USER_DETAILS['userid'],$userid) != 0){
- if(DBfetch(DBselect('select * from users where userid='.$userid.' and alias='.zbx_dbstr(ZBX_GUEST_USER)))){
- error("Cannot disable user '".ZBX_GUEST_USER."'");
- return $res;
- }
-
+ if((bccomp($USER_DETAILS['userid'],$userid) == 0) && ($status==USER_STATUS_DISABLED)){
+ show_error_message(S_USER_CANNOT_DISABLE_ITSELF);
+ }
+ else{
$res = DBexecute('UPDATE users SET status='.$status.' WHERE userid='.zbx_dbstr($userid));
}
return $res;