summaryrefslogtreecommitdiffstats
path: root/frontends/php
diff options
context:
space:
mode:
authorartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-02-26 12:33:26 +0000
committerartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-02-26 12:33:26 +0000
commitc228c7b2c9ea0b4d0e65295e47992b1e559447fc (patch)
tree7ec77efdc12a83d823f7116d9708769caaa5018d /frontends/php
parent401c0e953a8ad1bb7c7cedb5221cc29af76edd20 (diff)
- [DEV-116] added option to remember user login (Artem)
git-svn-id: svn://svn.zabbix.com/trunk@5406 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php')
-rw-r--r--frontends/php/dashboard.php42
-rw-r--r--frontends/php/include/blocks.inc.php13
-rw-r--r--frontends/php/include/forms.inc.php9
-rw-r--r--frontends/php/include/locales/en_gb.inc.php3
-rw-r--r--frontends/php/include/perm.inc.php2
-rw-r--r--frontends/php/include/users.inc.php55
-rw-r--r--frontends/php/js/dashboard.js3
-rw-r--r--frontends/php/profile.php7
-rw-r--r--frontends/php/users.php5
9 files changed, 89 insertions, 50 deletions
diff --git a/frontends/php/dashboard.php b/frontends/php/dashboard.php
index 6b84402d..2ecb5b6e 100644
--- a/frontends/php/dashboard.php
+++ b/frontends/php/dashboard.php
@@ -30,13 +30,8 @@ $page["file"] = "dashboard.php";
$page['hist_arg'] = array();
$page['scripts'] = array('prototype.js','json.js','dashboard.js');
-
$page['type'] = detect_page_type(PAGE_TYPE_HTML);
-if(PAGE_TYPE_HTML == $page['type'])
- define('ZBX_PAGE_DO_REFRESH', 1);
-
-
include_once "include/page_header.php";
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
@@ -92,6 +87,7 @@ include_once "include/page_header.php";
if('set_rf_rate' == $_REQUEST['favobj']){
if(in_array($_REQUEST['favid'],array('hat_syssum','hat_stszbx','hat_lastiss','hat_webovr'))){
update_profile('web.dahsboard.rf_rate.'.$_REQUEST['favid'],$_REQUEST['favcnt']);
+ $_REQUEST['favcnt'] = get_profile('web.dahsboard.rf_rate.'.$_REQUEST['favid'],60);
echo get_refresh_obj_script($_REQUEST['favid'],$_REQUEST['favcnt']);
$menu = array();
@@ -268,8 +264,8 @@ include_once "include/page_header.php";
make_sysmap_menu($menu,$submenu);
make_screen_menu($menu,$submenu);
- make_refresh_menu('hat_syssum',get_profile('web.dahsboard.rf_rate.hat_syssum',120),$menu,$submenu);
- make_refresh_menu('hat_stszbx',get_profile('web.dahsboard.rf_rate.hat_stszbx',120),$menu,$submenu);
+ make_refresh_menu('hat_syssum',get_profile('web.dahsboard.rf_rate.hat_syssum',60),$menu,$submenu);
+ make_refresh_menu('hat_stszbx',get_profile('web.dahsboard.rf_rate.hat_stszbx',60),$menu,$submenu);
make_refresh_menu('hat_lastiss',get_profile('web.dahsboard.rf_rate.hat_lastiss',60),$menu,$submenu);
make_refresh_menu('hat_webovr',get_profile('web.dahsboard.rf_rate.hat_webovr',60),$menu,$submenu);
@@ -322,11 +318,23 @@ include_once "include/page_header.php";
// Refresh tab
$refresh_tab = array(
- 'hat_syssum' => get_profile('web.dahsboard.rf_rate.hat_syssum',120),
- 'hat_stszbx' => get_profile('web.dahsboard.rf_rate.hat_stszbx',120),
- 'hat_lastiss' => get_profile('web.dahsboard.rf_rate.hat_lastiss',60),
- 'hat_webovr' => get_profile('web.dahsboard.rf_rate.hat_webovr',60)
- );
+ array('id' => 'hat_syssum',
+ 'interval' => get_profile('web.dahsboard.rf_rate.hat_syssum',120)
+ ),
+ array('id' => 'hat_stszbx',
+ 'interval' => get_profile('web.dahsboard.rf_rate.hat_stszbx',120)
+ ),
+ array('id' => 'hat_lastiss',
+ 'interval' => get_profile('web.dahsboard.rf_rate.hat_lastiss',60)
+ ),
+ array('id' => 'hat_webovr',
+ 'interval' => get_profile('web.dahsboard.rf_rate.hat_webovr',60)
+ )
+/* array('id' => 'hat_custom',
+ 'interval' => get_profile('web.dahsboard.rf_rate.hat_custom',60),
+ 'url'=> 'charts.php?groupid=4&hostid=10017&graphid=5&output=html&fullscreen=1'
+ )*/
+ );
add_refresh_objects($refresh_tab);
$refresh_menu = new CDiv(SPACE,'menuplus');
@@ -372,7 +380,15 @@ include_once "include/page_header.php";
'hat_webovr',
get_profile('web.dashboard.hats.hat_webovr.state',1)
));
-
+/*
+ $right_tab->AddRow(create_hat(
+ S_GRAPH,
+ null,//make_webmon_overview(),
+ null,
+ 'hat_custom',
+ get_profile('web.dashboard.hats.hat_custom.state',1)
+ ));
+*/
$td_l = new CCol($left_tab);
$td_l->AddOption('valign','top');
diff --git a/frontends/php/include/blocks.inc.php b/frontends/php/include/blocks.inc.php
index 0f97ea4a..8e3819b6 100644
--- a/frontends/php/include/blocks.inc.php
+++ b/frontends/php/include/blocks.inc.php
@@ -722,15 +722,18 @@ return $screenids;
function add_refresh_objects($ref_tab){
$min = PHP_INT_MAX;
- foreach($ref_tab as $id => $interval){
- $min = ($min < $interval)?$min:$interval;
- zbx_add_post_js(get_refresh_obj_script($id,$interval));
+ foreach($ref_tab as $id => $obj){
+ $obj['interval'] = (isset($obj['interval']))?$obj['interval']:60;
+
+ $min = ($min < $obj['interval'])?$min:$obj['interval'];
+ zbx_add_post_js(get_refresh_obj_script($obj));
}
zbx_add_post_js('updater.interval = 10; updater.check4Update();');
}
-function get_refresh_obj_script($id,$interval){
- return 'updater.setObj4Update("'.$id.'","dashboard.php?output=html",{"favobj": "refresh", "favid": "'.$id.'"}, '.$interval.');';
+function get_refresh_obj_script($obj){
+ $obj['url'] = (isset($obj['url']))?$obj['url']:'dashboard.php?output=html';
+return 'updater.setObj4Update("'.$obj['id'].'",'.$obj['interval'].',"'.$obj['url'].'",{"favobj": "refresh", "favid": "'.$obj['id'].'"});';
}
function make_refresh_menu($id,$cur_interval,&$menu,&$submenu){
diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php
index ba346f19..421966ba 100644
--- a/frontends/php/include/forms.inc.php
+++ b/frontends/php/include/forms.inc.php
@@ -681,10 +681,10 @@
# Insert form for User
function insert_user_form($userid,$profile=0){
global $ZBX_LOCALES;
-
+ global $USER_DETAILS;
+
$frm_title = S_USER;
if(isset($userid)){
- global $USER_DETAILS;
/* if(bccomp($userid,$USER_DETAILS['userid'])==0) $profile = 1;*/
$user=get_user_by_userid($userid);
@@ -699,6 +699,7 @@
$password1 = null;
$password2 = null;
$url = $user["url"];
+ $autologin = $user["autologin"];
$autologout = $user["autologout"];
$lang = $user["lang"];
$theme = $user['theme'];
@@ -740,6 +741,7 @@
$password1 = get_request("password1", null);
$password2 = get_request("password2", null);
$url = get_request("url","");
+ $autologin = get_request("autologin",0);
$autologout = get_request("autologout",900);
$lang = get_request("lang","en_gb");
$theme = get_request('theme','default.css');
@@ -886,7 +888,8 @@
$frmUser->AddRow(S_THEME, $cmbTheme);
- $frmUser->AddRow(S_AUTO_LOGOUT_IN_SEC, new CNumericBox("autologout",$autologout,4));
+ $frmUser->AddRow(S_AUTO_LOGIN, new CCheckBox("autologin",$autologin,null,1));
+ $frmUser->AddRow(S_AUTO_LOGOUT, array(new CNumericBox("autologout",$autologout,4),S_SECONDS));
$frmUser->AddRow(S_URL_AFTER_LOGIN, new CTextBox("url",$url,50));
$frmUser->AddRow(S_SCREEN_REFRESH, new CNumericBox("refresh",$refresh,4));
diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php
index a2444c29..50ea6aca 100644
--- a/frontends/php/include/locales/en_gb.inc.php
+++ b/frontends/php/include/locales/en_gb.inc.php
@@ -1364,7 +1364,8 @@
'S_CHANGE_PASSWORD'=> 'Change password',
'S_PASSWORD_ONCE_AGAIN'=> 'Password (once again)',
'S_URL_AFTER_LOGIN'=> 'URL (after login)',
- 'S_AUTO_LOGOUT_IN_SEC'=> 'Auto-logout (in sec=>0 - disable)',
+ 'S_AUTO_LOGIN'=> 'Auto-login (1 month)',
+ 'S_AUTO_LOGOUT'=> 'Auto-logout (0-disable)',
'S_SCREEN_REFRESH'=> 'Refresh (in seconds)',
'S_CREATE_USER'=> 'Create User',
'S_CREATE_GROUP'=> 'Create Group',
diff --git a/frontends/php/include/perm.inc.php b/frontends/php/include/perm.inc.php
index 83a3e767..f6510d83 100644
--- a/frontends/php/include/perm.inc.php
+++ b/frontends/php/include/perm.inc.php
@@ -73,7 +73,7 @@
}
if($login){
- zbx_setcookie("zbx_sessionid",$sessionid);
+ zbx_setcookie("zbx_sessionid",$sessionid,$USER_DETAILS['autologin']?(time()+86400*31):0); //1 month
DBexecute("update sessions set lastaccess=".time()." where sessionid=".zbx_dbstr($sessionid));
}
else{
diff --git a/frontends/php/include/users.inc.php b/frontends/php/include/users.inc.php
index 50771ba8..99af8c1a 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,$theme,$refresh,$user_type,$user_groups,$user_medias)
+ function add_user($name,$surname,$alias,$passwd,$url,$autologin,$autologout,$lang,$theme,$refresh,$user_type,$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,theme,refresh,type)'.
+ $result = DBexecute('insert into users (userid,name,surname,alias,passwd,url,autologin,autologout,lang,theme,refresh,type)'.
' values ('.$userid.','.zbx_dbstr($name).','.zbx_dbstr($surname).','.zbx_dbstr($alias).','.
- zbx_dbstr(md5($passwd)).','.zbx_dbstr($url).','.$autologout.','.zbx_dbstr($lang).','.zbx_dbstr($theme).','.$refresh.','.$user_type.')');
+ zbx_dbstr(md5($passwd)).','.zbx_dbstr($url).','.$autologin.','.$autologout.','.zbx_dbstr($lang).','.zbx_dbstr($theme).','.$refresh.','.$user_type.')');
if($result)
{
@@ -86,34 +86,37 @@
# Update User definition
- function update_user($userid,$name,$surname,$alias,$passwd, $url,$autologout,$lang,$theme,$refresh,$user_type,$user_groups,$user_medias)
+ function update_user($userid,$name,$surname,$alias,$passwd,$url,$autologin,$autologout,$lang,$theme,$refresh,$user_type,$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)))))
- {
+ if(DBfetch(DBselect("select * from users where alias=".zbx_dbstr($alias)." and userid<>$userid and ".DBin_node('userid', get_current_nodeid(false))))){
error("User '$alias' already exists");
return 0;
}
- $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).",theme=".zbx_dbstr($theme).",refresh=$refresh,".
- "type=$user_type".
- " where userid=$userid");
-
- if($result)
- {
+ $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).
+ ' ,autologin='.$autologin.
+ ' ,autologout='.$autologout.
+ ' ,lang='.zbx_dbstr($lang).
+ ' ,theme='.zbx_dbstr($theme).
+ ' ,refresh='.$refresh.
+ ' ,type='.$user_type.
+ ' WHERE userid='.$userid);
+
+ if($result){
DBexecute('delete from users_groups where userid='.$userid);
- foreach($user_groups as $groupid => $grou_pname)
- {
+ foreach($user_groups as $groupid => $grou_pname){
$users_groups_id = get_dbid("users_groups","id");
$result = DBexecute('insert into users_groups (id,usrgrpid,userid)'.
'values('.$users_groups_id.','.$groupid.','.$userid.')');
if(!$result) break;
}
- if($result)
- {
+ if($result){
DBexecute('delete from media where userid='.$userid);
foreach($user_medias as $mediaid => $media_data)
{
@@ -134,7 +137,7 @@
# Update User definition
- function update_user_profile($userid,$passwd, $url,$autologout,$lang,$theme,$refresh)
+ function update_user_profile($userid,$passwd,$url,$autologin,$autologout,$lang,$theme,$refresh)
{
global $USER_DETAILS;
@@ -143,9 +146,15 @@
access_deny();
}
- return DBexecute("update users set url=".zbx_dbstr($url).",autologout=$autologout,lang=".zbx_dbstr($lang).",theme=".zbx_dbstr($theme).
- (isset($passwd) ? (',passwd='.zbx_dbstr(md5($passwd))) : '').
- ",refresh=$refresh where userid=$userid");
+ return DBexecute('update users set '.
+ ' url='.zbx_dbstr($url).
+ ' ,autologin='.$autologin.
+ ' ,autologout='.$autologout.
+ ' ,lang='.zbx_dbstr($lang).
+ ' ,theme='.zbx_dbstr($theme).
+ (isset($passwd) ? (' ,passwd='.zbx_dbstr(md5($passwd))) : '').
+ ' ,refresh='.$refresh.
+ ' where userid='.$userid);
}
# Delete User definition
diff --git a/frontends/php/js/dashboard.js b/frontends/php/js/dashboard.js
index 7702f388..2d3d62a6 100644
--- a/frontends/php/js/dashboard.js
+++ b/frontends/php/js/dashboard.js
@@ -135,7 +135,7 @@ objlist: new Array(), // list of objects
optlist : new Array(), // object params, list
interval: 10, // update interval in sec
-setObj4Update: function(id,url,params,frequency){
+setObj4Update: function(id,frequency,url,params){
var obj = document.getElementById(id);
if(!isset(obj)) return false;
@@ -175,6 +175,7 @@ update: function(obj4update,time){
{
method: 'post',
'parameters': obj4update.params,
+ 'evalScripts': true,
'onSuccess': function(resp){ obj4update.lastupdate = time;},
'onFailure': function(){ document.location = 'dashboard.php?'+Object.toQueryString(obj4update.params); }
});
diff --git a/frontends/php/profile.php b/frontends/php/profile.php
index 8f3a8c75..b5725b38 100644
--- a/frontends/php/profile.php
+++ b/frontends/php/profile.php
@@ -43,6 +43,7 @@ include_once "include/page_header.php";
"password2"=> array(T_ZBX_STR, O_OPT, null, null, 'isset({save})&&isset({form})&&({form}!="update")&&isset({change_password})'),
"lang"=> array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, 'isset({save})'),
"theme"=> array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, 'isset({save})'),
+ 'autologin'=> array(T_ZBX_INT, O_OPT, null, IN('0,1'), null),
"autologout"=> array(T_ZBX_INT, O_OPT, null, BETWEEN(0,3600),'isset({save})'),
"url"=> array(T_ZBX_STR, O_OPT, null, null, 'isset({save})'),
"refresh"=> array(T_ZBX_INT, O_OPT, null, BETWEEN(0,3600),'isset({save})'),
@@ -74,7 +75,11 @@ include_once "include/page_header.php";
}
elseif($_REQUEST["password1"]==$_REQUEST["password2"])
{
- $result=update_user_profile($USER_DETAILS["userid"],$_REQUEST["password1"],$_REQUEST["url"],$_REQUEST["autologout"],$_REQUEST["lang"],$_REQUEST['theme'],$_REQUEST["refresh"]);
+ $result=update_user_profile($USER_DETAILS["userid"],$_REQUEST["password1"],
+ $_REQUEST["url"],get_request("autologin",0),$_REQUEST["autologout"],
+ $_REQUEST["lang"],$_REQUEST['theme'],$_REQUEST["refresh"]
+ );
+
show_messages($result, S_USER_UPDATED, S_CANNOT_UPDATE_USER);
if($result)
add_audit(AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_USER,
diff --git a/frontends/php/users.php b/frontends/php/users.php
index 2c00544e..be27c208 100644
--- a/frontends/php/users.php
+++ b/frontends/php/users.php
@@ -62,6 +62,7 @@ include_once "include/page_header.php";
'disable_media'=>array(T_ZBX_INT, O_OPT,null, null, null),
'lang'=> array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, '(isset({config})&&({config}==0))&&isset({save})'),
'theme'=> array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, '(isset({config})&&({config}==0))&&isset({save})'),
+ 'autologin'=> array(T_ZBX_INT, O_OPT, null, IN('0,1'), null),
'autologout'=> array(T_ZBX_INT, O_OPT, null, BETWEEN(0,3600),'(isset({config})&&({config}==0))&&isset({save})'),
'url'=> array(T_ZBX_STR, O_OPT, null, null, '(isset({config})&&({config}==0))&&isset({save})'),
'refresh'=> array(T_ZBX_INT, O_OPT, null, BETWEEN(0,3600),'(isset({config})&&({config}==0))&&isset({save})'),
@@ -178,7 +179,7 @@ include_once "include/page_header.php";
$action = AUDIT_ACTION_UPDATE;
$result=update_user($_REQUEST["userid"],
$_REQUEST["name"],$_REQUEST["surname"],$_REQUEST["alias"],
- $_REQUEST["password1"],$_REQUEST["url"],$_REQUEST["autologout"],
+ $_REQUEST["password1"],$_REQUEST["url"],get_request("autologin",0),$_REQUEST["autologout"],
$_REQUEST["lang"],$_REQUEST['theme'],$_REQUEST["refresh"],$_REQUEST["user_type"],
$user_groups, $user_medias);
@@ -187,7 +188,7 @@ include_once "include/page_header.php";
$action = AUDIT_ACTION_ADD;
$result=add_user(
$_REQUEST["name"],$_REQUEST["surname"],$_REQUEST["alias"],
- $_REQUEST["password1"],$_REQUEST["url"],$_REQUEST["autologout"],
+ $_REQUEST["password1"],$_REQUEST["url"],get_request("autologin",0),$_REQUEST["autologout"],
$_REQUEST["lang"],$_REQUEST['theme'],$_REQUEST["refresh"],$_REQUEST["user_type"],
$user_groups, $user_medias);