diff options
| author | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-06-20 08:42:25 +0000 |
|---|---|---|
| committer | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-06-20 08:42:25 +0000 |
| commit | 3f8cf5f0da75fa8312c173e9e2c1e1e843811091 (patch) | |
| tree | 1cb9f4841cb20bc2fd65a696181e70cbdf2cfb88 /frontends/php/include | |
| parent | 2804bdc7c298f114802a93d7c3312370c8602ba0 (diff) | |
| download | zabbix-3f8cf5f0da75fa8312c173e9e2c1e1e843811091.tar.gz zabbix-3f8cf5f0da75fa8312c173e9e2c1e1e843811091.tar.xz zabbix-3f8cf5f0da75fa8312c173e9e2c1e1e843811091.zip | |
- [DEV-137] changes in users profile system (Artem)
git-svn-id: svn://svn.zabbix.com/trunk@5782 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include')
| -rw-r--r-- | frontends/php/include/config.inc.php | 4 | ||||
| -rw-r--r-- | frontends/php/include/db.inc.php | 1 | ||||
| -rw-r--r-- | frontends/php/include/defines.inc.php | 12 | ||||
| -rw-r--r-- | frontends/php/include/discovery.inc.php | 2 | ||||
| -rw-r--r-- | frontends/php/include/graphs.inc.php | 4 | ||||
| -rw-r--r-- | frontends/php/include/html.inc.php | 19 | ||||
| -rw-r--r-- | frontends/php/include/httptest.inc.php | 9 | ||||
| -rw-r--r-- | frontends/php/include/import.inc.php | 6 | ||||
| -rw-r--r-- | frontends/php/include/page_header.php | 2 | ||||
| -rw-r--r-- | frontends/php/include/perm.inc.php | 5 | ||||
| -rw-r--r-- | frontends/php/include/profiles.inc.php | 335 |
11 files changed, 231 insertions, 168 deletions
diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php index 7ea70118..9011da62 100644 --- a/frontends/php/include/config.inc.php +++ b/frontends/php/include/config.inc.php @@ -216,7 +216,7 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!! $ZBX_NODES_IDS = array(); $ZBX_NODES = array(); if(!defined('ZBX_PAGE_NO_AUTHERIZATION') && ZBX_DISTRIBUTED){ - +//SDI($_REQUEST); $ZBX_CURRENT_NODEID = get_cookie('zbx_current_nodeid', $ZBX_LOCALNODEID); // Selected node $ZBX_WITH_SUBNODES = get_cookie('zbx_with_subnodes', false); // Show elements from subnodes @@ -285,7 +285,7 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!! $result = ( is_show_subnodes($forse_with_subnodes) ? $ZBX_CURRENT_SUBNODES : $ZBX_CURRENT_NODEID ); if(!is_null($perm)){ - $result = get_accessible_nodes_by_user($USER_DETAILS, PERM_READ_ONLY); + $result = get_accessible_nodes_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY, $ZBX_CURRENT_SUBNODES); } return $result; diff --git a/frontends/php/include/db.inc.php b/frontends/php/include/db.inc.php index 38e412c4..31f018c3 100644 --- a/frontends/php/include/db.inc.php +++ b/frontends/php/include/db.inc.php @@ -736,7 +736,6 @@ else { function DBcondition($fieldname, &$array, $notin=false){ global $DB; - $condition = ''; $in = $notin?' NOT IN ':' IN '; diff --git a/frontends/php/include/defines.inc.php b/frontends/php/include/defines.inc.php index 0e7024a8..b217c340 100644 --- a/frontends/php/include/defines.inc.php +++ b/frontends/php/include/defines.inc.php @@ -320,12 +320,14 @@ define('MARK_COLOR_GREEN', 2); define('MARK_COLOR_BLUE', 3); - define('PROFILE_TYPE_UNKNOWN', 0); - define('PROFILE_TYPE_ARRAY', 1); + define('PROFILE_TYPE_UNKNOWN', 0); + define('PROFILE_TYPE_ID', 1); + define('PROFILE_TYPE_INT', 2); + define('PROFILE_TYPE_STR', 3); + define('PROFILE_TYPE_ARRAY_ID', 4); + define('PROFILE_TYPE_ARRAY_INT', 5); + define('PROFILE_TYPE_ARRAY_STR', 6); - define('PROFILE_TYPE_MULTI', 2); - define('PROFILE_TYPE_MULTI_ARRAY', 3); - define('CALC_FNC_MIN', 1); define('CALC_FNC_AVG', 2); define('CALC_FNC_MAX', 4); diff --git a/frontends/php/include/discovery.inc.php b/frontends/php/include/discovery.inc.php index f0e7b5cf..e1410565 100644 --- a/frontends/php/include/discovery.inc.php +++ b/frontends/php/include/discovery.inc.php @@ -25,7 +25,7 @@ global $USER_DETAILS; if( $USER_DETAILS['type'] >= USER_TYPE_ZABBIX_ADMIN ){ - if(count(get_accessible_nodes_by_user($USER_DETAILS, $permission, PERM_RES_IDS_ARRAY, get_current_nodeid()))) + if(count(get_accessible_nodes_by_user($USER_DETAILS, $permission, PERM_RES_IDS_ARRAY))) return true; } return false; diff --git a/frontends/php/include/graphs.inc.php b/frontends/php/include/graphs.inc.php index 0251b177..dae343fd 100644 --- a/frontends/php/include/graphs.inc.php +++ b/frontends/php/include/graphs.inc.php @@ -198,7 +198,7 @@ $perm_res = PERM_RES_STRING_LINE; $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, $perm, null, $nodeid); - + $denied_graphs = array(); $result = array(); @@ -233,7 +233,7 @@ else $result = implode(',',$result); } - + return $result; } diff --git a/frontends/php/include/html.inc.php b/frontends/php/include/html.inc.php index 5771e868..db6d95f4 100644 --- a/frontends/php/include/html.inc.php +++ b/frontends/php/include/html.inc.php @@ -36,33 +36,28 @@ return $str; } - function bfirst($str) // mark first symbol of string as bold - { + function bfirst($str){ +// mark first symbol of string as bold $res = bold($str[0]); for($i=1,$max=strlen($str); $i<$max; $i++) $res .= $str[$i]; $str = $res; return $str; } - function nbsp($str) - { + function nbsp($str){ return str_replace(" ",SPACE,$str); } - function url1_param($parameter) - { - if(isset($_REQUEST[$parameter])) - { + function url1_param($parameter){ + if(isset($_REQUEST[$parameter])){ return "$parameter=".$_REQUEST[$parameter]; } - else - { + else{ return ""; } } - function prepare_url(&$var, $varname=null) - { + function prepare_url(&$var, $varname=null){ $result = ""; if(is_array($var)){ diff --git a/frontends/php/include/httptest.inc.php b/frontends/php/include/httptest.inc.php index a0282034..57855b65 100644 --- a/frontends/php/include/httptest.inc.php +++ b/frontends/php/include/httptest.inc.php @@ -45,16 +45,13 @@ return $status; } - function db_save_step($hostid, $applicationid, $httptestid, $testname, $name, $no, $timeout, $url, $posts, $required, $status_codes, $delay, $history, $trends) - { - if( $no <= 0 ) - { + function db_save_step($hostid, $applicationid, $httptestid, $testname, $name, $no, $timeout, $url, $posts, $required, $status_codes, $delay, $history, $trends){ + if( $no <= 0 ){ error('Scenario step number can\'t be less then 1'); return false; } - if (!eregi('^([0-9a-zA-Z\_\.[.-.]\$ ]+)$', $name)) - { + if (!eregi('^([0-9a-zA-Z\_\.[.-.]\$ ]+)$', $name)) { error("Scenario step name should contain '0-9a-zA-Z_ .$'- characters only"); return false; } diff --git a/frontends/php/include/import.inc.php b/frontends/php/include/import.inc.php index 8329f5a8..84389754 100644 --- a/frontends/php/include/import.inc.php +++ b/frontends/php/include/import.inc.php @@ -34,11 +34,11 @@ $this->trigger = array('exist' => 0, 'missed' => 0); $this->graph = array('exist' => 0, 'missed' => 0); - $this->available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_WRITE, PERM_RES_IDS_ARRAY, get_current_nodeid()); + $this->available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_WRITE, PERM_RES_IDS_ARRAY); - $this->available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_WRITE, PERM_RES_IDS_ARRAY, get_current_nodeid()); + $this->available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_WRITE, PERM_RES_IDS_ARRAY); - $this->available_nodes = get_accessible_nodes_by_user($USER_DETAILS, PERM_READ_WRITE, PERM_RES_IDS_ARRAY, get_current_nodeid()); + $this->available_nodes = get_accessible_nodes_by_user($USER_DETAILS, PERM_READ_WRITE, PERM_RES_IDS_ARRAY); } function CharacterData($parser, $data) { diff --git a/frontends/php/include/page_header.php b/frontends/php/include/page_header.php index ec92dc94..87526d15 100644 --- a/frontends/php/include/page_header.php +++ b/frontends/php/include/page_header.php @@ -324,7 +324,7 @@ COpt::profiling_start("page"); if(isset($menu_url)){ /* active menu */ $class = 'active'; - update_profile('web.menu.'.$label.'.last', $menu_url); + update_profile('web.menu.'.$label.'.last', $menu_url, PROFILE_TYPE_STR); if(isset($deny)){ $denyed_page_requested = true; diff --git a/frontends/php/include/perm.inc.php b/frontends/php/include/perm.inc.php index 17299831..65bcf4c1 100644 --- a/frontends/php/include/perm.inc.php +++ b/frontends/php/include/perm.inc.php @@ -399,8 +399,9 @@ COpt::counter_up('perm'); function get_accessible_nodes_by_user(&$user_data,$perm,$perm_res=null,$nodeid=null){ global $ZBX_LOCALNODEID, $ZBX_NODES_IDS; - + if(is_null($nodeid)) $nodeid = $ZBX_NODES_IDS; + if(!is_array($nodeid)) $nodeid = array($nodeid); if(is_null($perm_res)) $perm_res=PERM_RES_STRING_LINE; $userid =& $user_data['userid']; @@ -414,7 +415,7 @@ function get_accessible_nodes_by_user(&$user_data,$perm,$perm_res=null,$nodeid=n //COpt::counter_up('perm'); if(USER_TYPE_SUPER_ADMIN == $user_type){ - $nodes = DBselect('SELECT nodeid FROM nodes WHERE '.DBcondition('nodeid',$nodeid)); + $nodes = DBselect('SELECT nodeid FROM nodes WHERE '.DBcondition('nodeid', $nodeid)); while($node = DBfetch($nodes)){ $node_data[$node['nodeid']] = $node; $node_data[$node['nodeid']]['permission'] = PERM_READ_WRITE; diff --git a/frontends/php/include/profiles.inc.php b/frontends/php/include/profiles.inc.php index c2be5fc3..929b8527 100644 --- a/frontends/php/include/profiles.inc.php +++ b/frontends/php/include/profiles.inc.php @@ -22,32 +22,38 @@ /********** USER PROFILE ***********/ //---------- GET USER VALUE ------------- -function get_profile($idx,$default_value=null,$type=PROFILE_TYPE_UNKNOWN,$source=null){ + +function get_profile($idx,$default_value=null,$type=PROFILE_TYPE_UNKNOWN,$idx2=null,$source=null){ global $USER_DETAILS; $result = $default_value; if($USER_DETAILS["alias"]!=ZBX_GUEST_USER){ - $sql = 'SELECT value, valuetype '. + $sql_cond = ''; + if(ctype_digit($idx2)) $sql_cond = ' AND idx2='.$idx2.' AND '.DBin_node('idx2'); + if(!is_null($source)) $sql_cond.= ' AND source='.zbx_dbstr($source); + + $sql = 'SELECT value_id, value_int, value_str, type '. ' FROM profiles '. ' WHERE userid='.$USER_DETAILS["userid"]. ' AND idx='.zbx_dbstr($idx). - (is_null($source)?'':' AND source='.zbx_dbstr($source)). + $sql_cond. ' ORDER BY profileid ASC'; $db_profiles = DBselect($sql); if($profile=DBfetch($db_profiles)){ - if(PROFILE_TYPE_UNKNOWN == $type) $type = $profile["valuetype"]; - - if(PROFILE_TYPE_ARRAY == $type){ - $result[] = $profile['value']; + if(PROFILE_TYPE_UNKNOWN == $type) $type = $profile['type']; + $value_type = profile_field_by_type($type); + + if(profile_type_array($type)){ + $result[] = $profile[$value_type]; while($profile=DBfetch($db_profiles)){ - $result[] = $profile['value']; + $result[] = $profile[$value_type]; } } else{ - $result = strval($profile["value"]); + $result = $profile[$value_type]; } } } @@ -57,36 +63,43 @@ return $result; // multi value -function get_multi_profile($idx,$default_value=array(),$type=PROFILE_TYPE_UNKNOWN,$source=null){ +function get_source_profile($idx,$default_value=array(),$type=PROFILE_TYPE_UNKNOWN,$idx2=null,$source=null){ global $USER_DETAILS; - $result = $default_value; + $result = array(); if($USER_DETAILS["alias"]!=ZBX_GUEST_USER){ - $sql = 'SELECT value,value2,source,valuetype '. + $sql_cond = ''; + if(ctype_digit($idx2)) $sql_cond.= ' AND idx2='.$idx2.' AND '.DBin_node('idx2'); + if(!is_null($source)) $sql_cond.= ' AND source='.zbx_dbstr($source); + + $sql = 'SELECT value_id,value_int,value_str,source,type '. ' FROM profiles '. ' WHERE userid='.$USER_DETAILS["userid"]. ' AND idx='.zbx_dbstr($idx). - (is_null($source)?'':' AND source='.zbx_dbstr($source)). + $sql_cond. ' ORDER BY profileid ASC'; - $db_profiles = DBselect($sql); + $db_profiles = DBselect($sql); if($profile=DBfetch($db_profiles)){ - - if(PROFILE_TYPE_UNKNOWN == $type) $type = $profile["valuetype"]; - - if(PROFILE_TYPE_MULTI_ARRAY == $type){ - $result[] = $profile; + if(PROFILE_TYPE_UNKNOWN == $type) $type = $profile['type']; + $value_type = profile_field_by_type($type); + + if(profile_type_array($type)){ + $result[] = array('value'=>$profile[$value_type], 'source'=>$profile['source']); + while($profile=DBfetch($db_profiles)){ - $result[] = $profile; + $result[] = array('value'=>$profile[$value_type], 'source'=>$profile['source']); } } else{ - $result = $profile; + $result = array('value'=>$profile[$value_type], 'source'=>$profile['source']); } + } } - + $result = count($result)?$result:$default_value; + return $result; } @@ -96,46 +109,72 @@ return (zbx_empty($profile))?$default_value:$profile; } //----------- ADD/EDIT USERPROFILE ------------- -function update_profile($idx,$value,$type=PROFILE_TYPE_UNKNOWN,$source=null){ +function update_profile($idx,$value,$type=PROFILE_TYPE_UNKNOWN,$idx2=null,$source=null){ global $USER_DETAILS; + if($USER_DETAILS["alias"]==ZBX_GUEST_USER) return false; - if($USER_DETAILS["alias"]==ZBX_GUEST_USER){ - return false; - } - - if($type==PROFILE_TYPE_UNKNOWN && is_array($value)) $type = PROFILE_TYPE_ARRAY; - if(($type==PROFILE_TYPE_ARRAY) && !is_array($value)) $value = array($value); + if(PROFILE_TYPE_UNKNOWN == $type) $type = profile_type_by_value($value); + else $value = profile_value_by_type($value,$type); - DBstart(); + if($value === false) return false; + + $sql_cond = ''; + if(ctype_digit($idx2)) $sql_cond = ' AND idx2='.$idx2.' AND '.DBin_node('idx2'); - if(PROFILE_TYPE_ARRAY == $type){ + DBstart(); + if(profile_type_array($type)){ $sql='DELETE FROM profiles '. ' WHERE userid='.$USER_DETAILS["userid"]. - ' AND idx='.zbx_dbstr($idx); - DBExecute($sql); - + ' AND idx='.zbx_dbstr($idx). + $sql_cond; + + DBexecute($sql); foreach($value as $id => $val){ - insert_profile($idx,$val,$type,$source); + insert_profile($idx,$val,$type,$idx2,$source); } } else{ $sql = 'SELECT profileid '. ' FROM profiles '. - ' WHERE userid='.$USER_DETAILS["userid"]. + ' WHERE userid='.$USER_DETAILS['userid']. ' AND idx='.zbx_dbstr($idx). - (is_null($source)?'':' AND source='.zbx_dbstr($source)); + $sql_cond; $row = DBfetch(DBselect($sql)); if(!$row){ - insert_profile($idx,$value,$type,$source); + insert_profile($idx,$value,$type,$idx2,$source); } else{ - $sql='UPDATE profiles SET value='.zbx_dbstr($value).',valuetype='.$type. + $val = array(); + $value_type = profile_field_by_type($type); + + $val['value_id'] = 0; + $val['value_int'] = 0; + $val['value_str'] = ''; + + $val[$value_type] = $value; + + $idx2 = ctype_digit($idx2)?$idx2:0; + $src = is_null($source)?'':$source; + + if(is_array($value)){ + $val[$value_type] = isset($value['value'])?$value['value']:''; + $src = isset($value['source'])?$value['source']:$src; + } + if(is_null($val[$value_type])) return false; + + $sql='UPDATE profiles '. + ' SET value_id='.$val['value_id'].','. + ' value_int='.$val['value_int'].','. + ' value_str='.zbx_dbstr($val['value_str']).','. + ' type='.$type.','. + ' source='.zbx_dbstr($src). ' WHERE userid='.$USER_DETAILS["userid"]. ' AND idx='.zbx_dbstr($idx). - (is_null($source)?'':' AND source='.zbx_dbstr($source)); + $sql_cond; + DBexecute($sql); } } @@ -145,116 +184,146 @@ function update_profile($idx,$value,$type=PROFILE_TYPE_UNKNOWN,$source=null){ return $result; } -function update_multi_profile($idx,$value,$type=PROFILE_TYPE_UNKNOWN,$source=null){ + +// Author: Aly +function insert_profile($idx,$value,$type,$idx2,$source){ global $USER_DETAILS; - if($USER_DETAILS["alias"]==ZBX_GUEST_USER){ - return false; + $profileid = get_dbid('profiles', 'profileid'); + $value_type = profile_field_by_type($type); + + $val['value_id'] = 0; + $val['value_int'] = 0; + $val['value_str'] = ''; + + $val[$value_type] = $value; + + $idx2 = ctype_digit($idx2)?$idx2:0; + $src = is_null($source)?'':$source; + + if(is_array($value)){ + $val[$value_type] = isset($value['value'])?$value['value']:''; + $src = isset($value['source'])?$value['source']:$src; } - if(empty($value)) $type = PROFILE_TYPE_MULTI_ARRAY; - if(!is_array($value)) $value = array('value' => $value); + if(is_null($val[$value_type])) return false; - if($type==PROFILE_TYPE_UNKNOWN && isset($value['value'])) $type = PROFILE_TYPE_MULTI; - if($type==PROFILE_TYPE_UNKNOWN && isset($value[0]['value'])) $type = PROFILE_TYPE_MULTI_ARRAY; - - if(($type==PROFILE_TYPE_MULTI_ARRAY) && isset($value['value'])) $value = array($value); + $sql='INSERT INTO profiles (profileid,userid,idx,idx2,value_id,value_int,value_str,source,type)'. + ' VALUES ('.$profileid.','. + $USER_DETAILS['userid'].','. + zbx_dbstr($idx).','. + $idx2.','. + $val['value_id'].','. + $val['value_int'].','. + zbx_dbstr($val['value_str']).','. + zbx_dbstr($src).','. + $type.')'; - DBstart(); + $result = DBexecute($sql); + +return $result; +} - if(PROFILE_TYPE_MULTI_ARRAY == $type){ - $sql='DELETE FROM profiles '. - ' WHERE userid='.$USER_DETAILS["userid"]. - ' AND idx='.zbx_dbstr($idx); - DBExecute($sql); +// ----------- MISC PROFILE FUNCTIONS ----------- +function profile_type_array($type){ + return uint_in_array($type,array(PROFILE_TYPE_ARRAY_ID,PROFILE_TYPE_ARRAY_INT,PROFILE_TYPE_ARRAY_STR)); +} - foreach($value as $id => $val){ - insert_profile($idx,$val,$type,$source); - } +function profile_field_by_type($type){ + switch($type){ + case PROFILE_TYPE_INT: + case PROFILE_TYPE_ARRAY_INT: + $field = 'value_int'; + break; + case PROFILE_TYPE_STR: + case PROFILE_TYPE_ARRAY_STR: + $field = 'value_str'; + break; + case PROFILE_TYPE_ID: + case PROFILE_TYPE_ARRAY_ID: + case PROFILE_TYPE_UNKNOWN: + default: + $field = 'value_id'; } - else { - $sql = 'SELECT profileid '. - ' FROM profiles '. - ' WHERE userid='.$USER_DETAILS["userid"]. - ' AND idx='.zbx_dbstr($idx). - (is_null($source)?'':' AND source='.zbx_dbstr($source)); - - $row = DBfetch(DBselect($sql)); +return $field; +} - if(!$row){ - insert_profile($idx,$value,$type,$source); +function profile_type_by_value($value,$type=PROFILE_TYPE_UNKNOWN){ + if(is_array($value)){ + $value = $value[0]; + + if(is_array($value)){ + if(isset($value['value'])) + $type=ctype_digit($value['value'])?PROFILE_TYPE_ARRAY_ID:PROFILE_TYPE_ARRAY_STR; } else{ - $val1 = isset($value['value'])?$value['value']:''; - $val2 = isset($value['value2'])?$value['value2']:''; - $rsrc = isset($value['source'])?$value['source']:(is_null($source)?'':source); - - $sql='UPDATE profiles '. - ' SET value='.zbx_dbstr($val1). - ',value2='.zbx_dbstr($val2). - ',source='.zbx_dbstr($rsrc). - ',valuetype='.$type. - ' WHERE userid='.$USER_DETAILS["userid"]. - ' AND idx='.zbx_dbstr($idx). - (is_null($source)?'':' AND source='.zbx_dbstr($source)); - DBexecute($sql); + $type=ctype_digit($value)?PROFILE_TYPE_ARRAY_ID:PROFILE_TYPE_ARRAY_STR; } } - - $result = DBend(); - -return $result; + else{ + if(ctype_digit($value)) $type = PROFILE_TYPE_ID; + else $type = PROFILE_TYPE_STR; + } +return $type; } - -// Author: Aly -function insert_profile($idx,$value,$type,$source=null){ - global $USER_DETAILS; - - $profileid = get_dbid('profiles', 'profileid'); - - $val1 = $value; - $val2 = ''; - $rsrc = is_null($source)?'':$source; +function profile_value_by_type(&$value,$type){ - if(($type == PROFILE_TYPE_MULTI_ARRAY) || - ($type == PROFILE_TYPE_MULTI) || - is_array($value)) - { - $val1 = isset($value['value'])?$value['value']:''; - $val2 = isset($value['value2'])?$value['value2']:''; - $rsrc = isset($value['source'])?$value['source']:$rsrc; + if(profile_type_array($type)){ + $result = is_array($value)?$value:array($value); + } + else if(is_array($value)){ + if(!isset($value['value'])) return false; + + $result = $value; + switch($type){ + case PROFILE_TYPE_ID: + case PROFILE_TYPE_INT: + if(ctype_digit($value['value'])){ + $result['value'] = intval($value['value']); + } + else{ + $result = false; + } + break; + case PROFILE_TYPE_STR: + $result['value'] = strval($value['value']); + break; + default: + $result = false; + } + } + else{ + switch($type){ + case PROFILE_TYPE_ID: + case PROFILE_TYPE_INT: + $result = ctype_digit($value)?intval($value):false; + break; + case PROFILE_TYPE_STR: + $result = strval($value); + break; + default: + $result = false; + } } - - if(is_null($val1)) return false; - - $sql='INSERT INTO profiles (profileid,userid,idx,value,value2,source,valuetype)'. - ' VALUES ('.$profileid.','. - $USER_DETAILS["userid"].','. - zbx_dbstr($idx).','. - zbx_dbstr($val1).','. - zbx_dbstr($val2).','. - zbx_dbstr($rsrc).','. - $type.')'; - - $result = DBexecute($sql); - return $result; } /***********************************/ + + /************ HISTORY **************/ // Author: Aly function get_user_history(){ $history=array(); $delimiter = new CSpan('»','delimiter'); for($i = 0; $i < ZBX_HISTORY_COUNT; $i++){ - if($rows = get_multi_profile('web.history.'.$i,false,PROFILE_TYPE_MULTI)){ + if($rows = get_source_profile('web.history.'.$i,false)){ if($i>0){ array_push($history,$delimiter); } - $url = new CLink($rows['value'],$rows['value2'],'history'); + $url = new CLink($rows['source'],$rows['value'],'history'); array_push($history,array(SPACE,$url,SPACE)); } } @@ -268,15 +337,15 @@ function get_last_history_page($same_page=false){ $rows=false; for($i = 0; $i < ZBX_HISTORY_COUNT; $i++){ - $new_rows = get_multi_profile('web.history.'.$i,false,PROFILE_TYPE_MULTI); + $new_rows = get_source_profile('web.history.'.$i,false); - if(!$same_page && ($title == $new_rows['value'])) continue; + if(!$same_page && ($title == $new_rows['source'])) continue; $rows = $new_rows; } if(is_array($rows)){ - $rows['page'] = $rows['value']; - $rows['url'] = $rows['value2']; + $rows['page'] = $rows['source']; + $rows['url'] = $rows['value']; } return $rows; @@ -304,28 +373,28 @@ function add_user_history($page){ $curr = 0; $profile = array(); for($i = 0; $i < ZBX_HISTORY_COUNT; $i++){ - if($history = get_multi_profile('web.history.'.$i,false)){ - if($history['value'] != $title){ + if($history = get_source_profile('web.history.'.$i,false)){ + if($history['source'] != $title){ $profile[$curr] = $history; $curr++; } } } - $history = array('value' => $title, - 'value2' => $url); + $history = array('source' => $title, + 'value' => $url); if($curr < ZBX_HISTORY_COUNT){ for($i = 0; $i < $curr; $i++){ - update_multi_profile('web.history.'.$i,$profile[$i]); + update_profile('web.history.'.$i,$profile[$i], PROFILE_TYPE_STR); } - $result = update_multi_profile('web.history.'.$curr,$history); + $result = update_profile('web.history.'.$curr,$history, PROFILE_TYPE_STR); } else { for($i = 1; $i < ZBX_HISTORY_COUNT; $i++){ - update_multi_profile('web.history.'.($i-1),$profile[$i]); + update_profile('web.history.'.($i-1),$profile[$i], PROFILE_TYPE_STR); } - $result = update_multi_profile('web.history.'.(ZBX_HISTORY_COUNT-1),$history); + $result = update_profile('web.history.'.(ZBX_HISTORY_COUNT-1),$history, PROFILE_TYPE_STR); } return $result; @@ -335,7 +404,7 @@ return $result; /********** USER FAVORITES ***********/ // Author: Aly function get_favorites($favobj,$nodeid=null){ - $fav = get_multi_profile($favobj); + $fav = get_source_profile($favobj); if(is_null($nodeid)) $nodeid = get_current_nodeid(); @@ -355,7 +424,7 @@ function add2favorites($favobj,$favid,$source=null){ $favorites[] = array('value' => $favid); - $result = update_multi_profile($favobj,$favorites,PROFILE_TYPE_MULTI_ARRAY,$source); + $result = update_profile($favobj,$favorites,null,null,$source); return $result; } @@ -376,7 +445,7 @@ function rm4favorites($favobj,$favid,$favcnt=null,$source=null){ $favcnt--; } - $result = update_multi_profile($favobj,$favorites,PROFILE_TYPE_MULTI_ARRAY); + $result = update_profile($favobj,$favorites); return $result; } |
