summaryrefslogtreecommitdiffstats
path: root/frontends/php/include
diff options
context:
space:
mode:
authorartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-01-14 12:16:49 +0000
committerartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-01-14 12:16:49 +0000
commit6d1c51d9ae6e65a0619b6cb9d2ccefb4a972707f (patch)
tree6e6b00f51f858f9ddc84dc469d9f61086acb7961 /frontends/php/include
parent6d47f4278d61e0efde9cafab7d4dd5477f974891 (diff)
downloadzabbix-6d1c51d9ae6e65a0619b6cb9d2ccefb4a972707f.tar.gz
zabbix-6d1c51d9ae6e65a0619b6cb9d2ccefb4a972707f.tar.xz
zabbix-6d1c51d9ae6e65a0619b6cb9d2ccefb4a972707f.zip
- [DEV-95] added user status enabled/disabled (Artem)
git-svn-id: svn://svn.zabbix.com/trunk@5241 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include')
-rw-r--r--frontends/php/include/defines.inc.php5
-rw-r--r--frontends/php/include/forms.inc.php27
-rw-r--r--frontends/php/include/locales/en_gb.inc.php3
-rw-r--r--frontends/php/include/perm.inc.php11
-rw-r--r--frontends/php/include/users.inc.php35
5 files changed, 52 insertions, 29 deletions
diff --git a/frontends/php/include/defines.inc.php b/frontends/php/include/defines.inc.php
index 86f0b7cc..46cfd8d2 100644
--- a/frontends/php/include/defines.inc.php
+++ b/frontends/php/include/defines.inc.php
@@ -81,6 +81,8 @@
define('AUDIT_ACTION_DELETE', 2);
define('AUDIT_ACTION_LOGIN', 3);
define('AUDIT_ACTION_LOGOUT', 4);
+ define('AUDIT_ACTION_ENABLE', 5);
+ define('AUDIT_ACTION_DISABLE', 6);
define('AUDIT_RESOURCE_USER', 0);
// define('AUDIT_RESOURCE_ZABBIX', 1);
@@ -336,6 +338,9 @@
define('USER_TYPE_ZABBIX_ADMIN', 2);
define('USER_TYPE_SUPER_ADMIN', 3);
+ define('USER_STATUS_DISABLED', 1);
+ define('USER_STATUS_ENABLED', 0);
+
define('PERM_MAX', 3);
define('PERM_READ_WRITE', 3);
define('PERM_READ_ONLY', 2);
diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php
index 35b9d034..ad6b9faf 100644
--- a/frontends/php/include/forms.inc.php
+++ b/frontends/php/include/forms.inc.php
@@ -682,13 +682,9 @@
}
# Insert form for User
- function insert_user_form($userid,$profile=0)
- {
- global $_REQUEST;
-
+ function insert_user_form($userid,$profile=0){
$frm_title = S_USER;
- if(isset($userid))
- {
+ if(isset($userid)){
global $USER_DETAILS;
/* if(bccomp($userid,$USER_DETAILS['userid'])==0) $profile = 1;*/
@@ -696,8 +692,7 @@
$frm_title = S_USER." \"".$user["alias"]."\"";
}
- if(isset($userid) && (!isset($_REQUEST["form_refresh"]) || isset($_REQUEST["register"])))
- {
+ if(isset($userid) && (!isset($_REQUEST["form_refresh"]) || isset($_REQUEST["register"]))){
$alias = $user["alias"];
$name = $user["name"];
$surname = $user["surname"];
@@ -708,6 +703,7 @@
$autologout = $user["autologout"];
$lang = $user["lang"];
$refresh = $user["refresh"];
+ $status = $user["status"];
$user_type = $user["type"];
$user_groups = array();
@@ -716,8 +712,7 @@
$db_user_groups = DBselect('SELECT g.* FROM usrgrp g, users_groups ug'.
' WHERE ug.usrgrpid=g.usrgrpid AND ug.userid='.$userid);
- while($db_group = DBfetch($db_user_groups))
- {
+ while($db_group = DBfetch($db_user_groups)){
$user_groups[$db_group['usrgrpid']] = $db_group['name'];
}
@@ -746,9 +741,10 @@
$password1 = get_request("password1", null);
$password2 = get_request("password2", null);
$url = get_request("url","");
- $autologout = get_request("autologout","900");
+ $autologout = get_request("autologout",900);
$lang = get_request("lang","en_gb");
- $refresh = get_request("refresh","30");
+ $refresh = get_request("refresh",30);
+ $status = get_request('status',0);
$user_type = get_request("user_type",USER_TYPE_ZABBIX_USER);;
$user_groups = get_request("user_groups",array());
$change_password = get_request("change_password", null);
@@ -893,7 +889,12 @@
$frmUser->AddRow(S_AUTO_LOGOUT_IN_SEC, new CNumericBox("autologout",$autologout,4));
$frmUser->AddRow(S_URL_AFTER_LOGIN, new CTextBox("url",$url,50));
$frmUser->AddRow(S_SCREEN_REFRESH, new CNumericBox("refresh",$refresh,4));
-
+
+ $cmbStat = new CComboBox('status',$status);
+ $cmbStat->AddItem(USER_STATUS_ENABLED,S_ENABLED);
+ $cmbStat->AddItem(USER_STATUS_DISABLED,S_DISABLED);
+
+ $frmUser->AddRow(S_STATUS, $cmbStat);
if($profile==0)
{
diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php
index 56e5d1bc..a0906ac9 100644
--- a/frontends/php/include/locales/en_gb.inc.php
+++ b/frontends/php/include/locales/en_gb.inc.php
@@ -1195,6 +1195,8 @@
'S_EXPRESSION'=> 'Expression',
'S_DISABLED'=> 'Disabled',
'S_ENABLED'=> 'Enabled',
+ 'S_DISABLE'=> 'Disable',
+ 'S_ENABLE'=> 'Enable',
'S_DISABLE_SELECTED'=> 'Disable selected',
'S_ENABLE_SELECTED'=> 'Enable selected',
'S_ENABLE_SELECTED_TRIGGERS_Q'=> 'Enable selected triggers?',
@@ -1261,6 +1263,7 @@
'S_USER_TYPE'=> 'User type',
'S_USERS'=> 'Users',
'S_USER_ADDED'=> 'User added',
+ 'S_CANNOT'=> 'Cannot',
'S_CANNOT_ADD_USER'=> 'Cannot add user',
'S_CANNOT_ADD_USER_BOTH_PASSWORDS_MUST'=>'Cannot add user. Both passwords must be equal.',
'S_USER_DELETED'=> 'User deleted',
diff --git a/frontends/php/include/perm.inc.php b/frontends/php/include/perm.inc.php
index 060739f8..bf1381a7 100644
--- a/frontends/php/include/perm.inc.php
+++ b/frontends/php/include/perm.inc.php
@@ -42,7 +42,6 @@
global $page;
global $PHP_AUTH_USER,$PHP_AUTH_PW;
global $USER_DETAILS;
- global $_REQUEST;
global $ZBX_LOCALNODEID;
$USER_DETAILS = NULL;
@@ -51,10 +50,12 @@
if( !is_null($sessionid))
{
- if(!($USER_DETAILS = DBfetch(DBselect("select u.*,s.* from sessions s,users u".
- " where s.sessionid=".zbx_dbstr($sessionid)." and s.userid=u.userid".
- " and ((s.lastaccess+u.autologout>".time().") or (u.autologout=0))".
- " and ".DBin_node('u.userid', $ZBX_LOCALNODEID)))))
+ if(!($USER_DETAILS = DBfetch(DBselect('SELECT u.*,s.* FROM sessions s,users u'.
+ ' WHERE s.sessionid='.zbx_dbstr($sessionid).
+ ' AND s.userid=u.userid'.
+ ' AND ((s.lastaccess+u.autologout>'.time().') OR (u.autologout=0))'.
+ ' AND '.DBin_node('u.userid', $ZBX_LOCALNODEID).
+ ' AND status='.USER_STATUS_ENABLED))))
{
zbx_unsetcookie('zbx_sessionid');
DBexecute("delete from sessions where sessionid=".zbx_dbstr($sessionid));
diff --git a/frontends/php/include/users.inc.php b/frontends/php/include/users.inc.php
index 2f34b7bf..49bdf322 100644
--- a/frontends/php/include/users.inc.php
+++ b/frontends/php/include/users.inc.php
@@ -33,7 +33,7 @@
# Add User definition
- function add_user($name,$surname,$alias,$passwd,$url,$autologout,$lang,$refresh,$user_type,$user_groups,$user_medias)
+ function add_user($name,$surname,$alias,$passwd,$url,$autologout,$lang,$refresh,$user_type,$status,$user_groups,$user_medias)
{
global $USER_DETAILS;
@@ -50,9 +50,9 @@
$userid = get_dbid("users","userid");
- $result = DBexecute('insert into users (userid,name,surname,alias,passwd,url,autologout,lang,refresh,type)'.
+ $result = DBexecute('insert into users (userid,name,surname,alias,passwd,url,autologout,lang,refresh,type,status)'.
' 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.')');
+ zbx_dbstr(md5($passwd)).','.zbx_dbstr($url).','.$autologout.','.zbx_dbstr($lang).','.$refresh.','.$user_type.','.$status.')');
if($result)
{
@@ -86,7 +86,7 @@
# Update User definition
- function update_user($userid,$name,$surname,$alias,$passwd, $url,$autologout,$lang,$refresh,$user_type,$user_groups,$user_medias)
+ function update_user($userid,$name,$surname,$alias,$passwd, $url,$autologout,$lang,$refresh,$user_type,$status,$user_groups,$user_medias)
{
if(DBfetch(DBselect("select * from users where alias=".zbx_dbstr($alias).
" and userid<>$userid and ".DBin_node('userid', get_current_nodeid(false)))))
@@ -96,9 +96,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 where userid=$userid");
+ (isset($passwd) ? (',passwd='.zbx_dbstr(md5($passwd))) : '').
+ ",url=".zbx_dbstr($url).","."autologout=$autologout,lang=".zbx_dbstr($lang).",refresh=$refresh,".
+ "type=$user_type,status=$status".
+ " where userid=$userid");
if($result)
{
@@ -175,16 +176,28 @@
}
- function get_user_by_userid($userid)
- {
- if($row = DBfetch(DBselect("select * from users where userid=$userid")))
- {
+ function get_user_by_userid($userid){
+ if($row = DBfetch(DBselect('select * from users where userid='.zbx_dbstr($userid)))){
return $row;
}
/* error("No user with id [$userid]"); */
return false;
}
+ 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;
+ }
+
+ $res = DBexecute('UPDATE users SET status='.$status.' WHERE userid='.zbx_dbstr($userid));
+ }
+ return $res;
+ }
+
/**************************
USER GROUPS