summaryrefslogtreecommitdiffstats
path: root/frontends/php
diff options
context:
space:
mode:
authorartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-04-10 09:34:21 +0000
committerartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-04-10 09:34:21 +0000
commitfcc91decd3db84a94505ac2147be987867dcfb41 (patch)
treeec0ba6b36bf92051aca7b5fbcc4e2d4e9a792c9b /frontends/php
parentd53a7572a565383d4680361388063acb0a864aaa (diff)
downloadzabbix-fcc91decd3db84a94505ac2147be987867dcfb41.tar.gz
zabbix-fcc91decd3db84a94505ac2147be987867dcfb41.tar.xz
zabbix-fcc91decd3db84a94505ac2147be987867dcfb41.zip
- merged rev. 5602:5604 of branches/1.4 (Artem) [fixed empty cells for IE]
- fixes permissions SQL for different DBs (Artem) git-svn-id: svn://svn.zabbix.com/trunk@5605 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php')
-rw-r--r--frontends/php/config.php7
-rw-r--r--frontends/php/exp_imp.php42
-rw-r--r--frontends/php/hosts.php55
-rw-r--r--frontends/php/include/classes/ctable.inc.php1
-rw-r--r--frontends/php/include/hosts.inc.php31
-rw-r--r--frontends/php/include/perm.inc.php5
-rw-r--r--frontends/php/items.php8
7 files changed, 79 insertions, 70 deletions
diff --git a/frontends/php/config.php b/frontends/php/config.php
index b4b15306..c01fc4ed 100644
--- a/frontends/php/config.php
+++ b/frontends/php/config.php
@@ -404,8 +404,8 @@ include_once "include/page_header.php";
$mappings_row = array();
$db_maps = DBselect("select * from mappings".
" where valuemapid=".$db_valuemap["valuemapid"]);
- while($db_map = DBfetch($db_maps))
- {
+
+ while($db_map = DBfetch($db_maps)){
array_push($mappings_row,
$db_map["value"],
SPACE.RARR.SPACE,
@@ -416,7 +416,8 @@ include_once "include/page_header.php";
new CLink($db_valuemap["name"],"config.php?form=update&".
"valuemapid=".$db_valuemap["valuemapid"].url_param("config"),
"action"),
- $mappings_row));
+ empty($mappings_row)?SPACE:$mappings_row
+ ));
}
$table->Show();
diff --git a/frontends/php/exp_imp.php b/frontends/php/exp_imp.php
index dd766d58..b0f05aae 100644
--- a/frontends/php/exp_imp.php
+++ b/frontends/php/exp_imp.php
@@ -262,8 +262,7 @@ include_once "include/page_header.php";
$table->ShowEnd();
}
- else
- {
+ else{
/* table HOSTS */
$form = new CForm(null,'post');
$form->SetName('hosts');
@@ -272,17 +271,18 @@ include_once "include/page_header.php";
$cmbGroups = new CComboBox("groupid",get_request("groupid",0),"submit()");
$cmbGroups->AddItem(0,S_ALL_SMALL);
- $result=DBselect("select distinct g.groupid,g.name from groups g,hosts_groups hg,hosts h".
- " where h.hostid in (".$available_hosts.") ".
- " and g.groupid=hg.groupid and h.hostid=hg.hostid".
- " order by g.name");
- while($row=DBfetch($result))
- {
+ $result=DBselect('select distinct g.groupid,g.name '.
+ ' from groups g,hosts_groups hg,hosts h'.
+ ' where h.hostid in ('.$available_hosts.') '.
+ ' and g.groupid=hg.groupid '.
+ ' and h.hostid=hg.hostid '.
+ ' order by g.name');
+ while($row=DBfetch($result)){
$cmbGroups->AddItem($row["groupid"],$row["name"]);
if((bccomp($row["groupid"] , $_REQUEST["groupid"])==0)) $correct_host = 1;
}
- if(!isset($correct_host))
- {
+
+ if(!isset($correct_host)){
unset($_REQUEST["groupid"]);
$cmbGroups->SetValue(0);
}
@@ -329,8 +329,8 @@ include_once "include/page_header.php";
$result=DBselect($sql);
- while($row=DBfetch($result))
- {
+ while($row=DBfetch($result)){
+
$host=new CCol(array(
new CCheckBox('hosts['.$row['hostid'].']',
isset($hosts[$row['hostid']]) || !isset($update),
@@ -358,15 +358,13 @@ include_once "include/page_header.php";
/* calculate items */
$item_cnt = DBfetch(DBselect('select count(itemid) as cnt from items where hostid='.$row['hostid']));
- if($item_cnt['cnt'] > 0)
- {
+ if($item_cnt['cnt'] > 0){
$item_cnt = array(new CCheckBox('items['.$row['hostid'].']',
isset($items[$row['hostid']]) || !isset($update),
NULL,true),
$item_cnt['cnt']);
}
- else
- {
+ else{
$item_cnt = '-';
}
@@ -407,21 +405,19 @@ include_once "include/page_header.php";
/* $screens = 0; */
- if($row["status"] == HOST_STATUS_TEMPLATE)
- {
+ if($row["status"] == HOST_STATUS_TEMPLATE){
$ip = $dns = $port = '-';
}
- else
- {
- $ip = $row["ip"];
- $dns = $row["dns"];
+ else{
+ $ip = (empty($row["ip"]))?'-':$row["ip"];
+ $dns = (empty($row["dns"]))?'-':$row["dns"];
if($row["useip"]==1)
$ip = bold($ip);
else
$dns = bold($dns);
- $port = $row["port"];
+ $port = (empty($row["port"]))?'-':$row["port"];
}
$table->AddRow(array(
diff --git a/frontends/php/hosts.php b/frontends/php/hosts.php
index 4645bfe8..448f3219 100644
--- a/frontends/php/hosts.php
+++ b/frontends/php/hosts.php
@@ -797,9 +797,9 @@ include_once "include/page_header.php";
$error = NULL;
}
else{
- $dns = $row['dns'];
- $ip = $row['ip'];
- $port = $row["port"];
+ $dns = empty($row['dns'])?'-':$row['dns'];
+ $ip = empty($row['ip'])?'-':$row['ip'];
+ $port = empty($row['port'])?'-':$row["port"];
if(1 == $row['useip'])
$ip = bold($ip);
@@ -833,6 +833,12 @@ include_once "include/page_header.php";
if($row['error'] == '') $error = new CCol(SPACE,'off');
else $error = new CCol($row['error'],'on');
+ $row["error"] = trim($row["error"]);
+ if(empty($row["error"]))
+ $error = new CCol('-',"off");
+ else
+ $error = new CCol($row["error"],"on");
+
}
$popup_menu_actions = array(
@@ -842,11 +848,13 @@ include_once "include/page_header.php";
array(S_GRAPHS, 'graphs.php?hostid='.$row['hostid'], array('tw'=>'_blank')),
);
- $db_groups = DBselect('select g.groupid, g.name from groups g left join hosts_groups hg '.
- ' on g.groupid=hg.groupid and hg.hostid='.$row['hostid'].
- ' where '.DBin_node('g.groupid').' AND hg.hostid is NULL order by g.name,g.groupid');
-
- while($group_data = DBfetch($db_groups)){
+ $db_groups = DBselect('SELECT g.groupid, g.name '.
+ ' FROM groups g '.
+ ' LEFT JOIN hosts_groups hg on g.groupid=hg.groupid and hg.hostid='.$row['hostid'].
+ ' WHERE hostid is NULL '.
+ ' ORDER BY g.name,g.groupid');
+ while($group_data = DBfetch($db_groups))
+ {
$add_to[] = array($group_data['name'], '?'.
url_param($group_data['groupid'], false, 'add_to_group').
url_param($row['hostid'], false, 'hostid')
@@ -888,7 +896,7 @@ include_once "include/page_header.php";
$dns,
$ip,
$port,
- implode(', ',$templates),
+ empty($templates)?'-':implode(', ',$templates),
$status,
$available,
$error,
@@ -912,12 +920,12 @@ include_once "include/page_header.php";
}
}
- elseif($_REQUEST["config"]==1)
- {
+ elseif($_REQUEST["config"]==1){
if(isset($_REQUEST["form"]))
{
insert_hostgroups_form(get_request("groupid",NULL));
- } else {
+ }
+ else {
show_table_header(S_HOST_GROUPS_BIG);
$form = new CForm('hosts.php');
@@ -974,7 +982,7 @@ include_once "include/page_header.php";
url_param("config"),'action')
),
$count,
- $hosts
+ empty($hosts)?'-':$hosts
));
}
$table->SetFooter(new CCol(array(
@@ -989,8 +997,7 @@ include_once "include/page_header.php";
$form->Show();
}
}
- elseif($_REQUEST["config"]==2)
- {
+ elseif($_REQUEST["config"]==2){
show_table_header(S_TEMPLATE_LINKAGE_BIG);
$table = new CTableInfo(S_NO_LINKAGES);
@@ -1021,18 +1028,17 @@ include_once "include/page_header.php";
}
$table->AddRow(array(
new CSpan($template["host"],"unknown"),
- $host_list
+ empty($host_list)?'-':$host_list
));
}
$table->Show();
}
- elseif($_REQUEST["config"]==4)
- {
- if(isset($_REQUEST["form"]))
- {
+ else if($_REQUEST["config"]==4){
+ if(isset($_REQUEST["form"])){
insert_application_form();
- } else {
+ }
+ else {
// Table HEADER
$form = new CForm();
$form->SetMethod('get');
@@ -1074,8 +1080,7 @@ include_once "include/page_header.php";
$cmbHosts = new CComboBox("hostid",$_REQUEST["hostid"],"submit();");
$result=DBselect($sql);
- while($row=DBfetch($result))
- {
+ while($row=DBfetch($result)){
$cmbHosts->AddItem($row["hostid"],$row["host"]);
}
@@ -1126,9 +1131,7 @@ include_once "include/page_header.php";
$table->AddRow(array(
- array(new CCheckBox("applications[]",NULL,NULL,$db_app["applicationid"]),
- SPACE,
- $name),
+ array(new CCheckBox("applications[]",NULL,NULL,$db_app["applicationid"]),SPACE,$name),
array(new CLink(S_ITEMS,"items.php?hostid=".$db_app["hostid"],"action"),
SPACE."($rows)")
));
diff --git a/frontends/php/include/classes/ctable.inc.php b/frontends/php/include/classes/ctable.inc.php
index 1ef4957d..53c60763 100644
--- a/frontends/php/include/classes/ctable.inc.php
+++ b/frontends/php/include/classes/ctable.inc.php
@@ -23,6 +23,7 @@
/* public */
function CCol($item=NULL,$class=NULL){
parent::CTag("td","yes");
+
$this->AddItem($item);
$this->SetClass($class);
}
diff --git a/frontends/php/include/hosts.inc.php b/frontends/php/include/hosts.inc.php
index 2b120406..468b3b3e 100644
--- a/frontends/php/include/hosts.inc.php
+++ b/frontends/php/include/hosts.inc.php
@@ -195,10 +195,11 @@ require_once "include/items.inc.php";
}
- if(DBfetch(DBselect(
- "select * from hosts where host=".zbx_dbstr($host).
- ' and '.DBin_node('hostid', get_current_nodeid(false)).
- (isset($hostid) ? ' and hostid<>'.$hostid : '')
+ if(DBfetch(DBselect('SELECT h.host '.
+ ' FROM hosts h '.
+ ' WHERE h.host='.zbx_dbstr($host).
+ ' AND '.DBin_node('h.hostid', get_current_nodeid(false)).
+ (isset($hostid)?' AND h.hostid<>'.$hostid:'')
)))
{
error("Host '$host' already exists");
@@ -207,25 +208,29 @@ require_once "include/items.inc.php";
if(is_null($hostid)){
$hostid = get_dbid("hosts","hostid");
- $result = DBexecute("insert into hosts".
- " (hostid,proxy_hostid,host,port,status,useip,dns,ip,disable_until,available)".
- " values ($hostid,$proxy_hostid,".zbx_dbstr($host).",$port,$status,$useip,".zbx_dbstr($dns).",".zbx_dbstr($ip).",0,"
- .HOST_AVAILABLE_UNKNOWN.")");
+ $result = DBexecute('insert into hosts '.
+ ' (hostid,proxy_hostid,host,port,status,useip,dns,ip,disable_until,available) '.
+ ' values ('.$hostid.','.$proxy_hostid.','.zbx_dbstr($host).','.$port.','.$status.','.$useip.','.zbx_dbstr($dns).','.zbx_dbstr($ip).',0,'
+ .HOST_AVAILABLE_UNKNOWN.')');
}
else{
if(check_circle_host_link($hostid, $templates)){
error("Circle link can't be created");
return false;
}
-
- $result = DBexecute("update hosts set proxy_hostid=$proxy_hostid,host=".zbx_dbstr($host).",".
- "port=$port,useip=$useip,dns=".zbx_dbstr($dns).",ip=".zbx_dbstr($ip)." where hostid=$hostid");
+ $result = DBexecute('UPDATE hosts SET proxy_hostid='.$proxy_hostid.
+ ',host='.zbx_dbstr($host).
+ ',port='.$port.
+ ',status='.$status.
+ ',useip='.$useip.
+ ',dns='.zbx_dbstr($dns).
+ ',ip='.zbx_dbstr($ip).
+ ' WHERE hostid='.$hostid);
update_host_status($hostid, $status);
}
- foreach($templates as $id => $name)
- {
+ foreach($templates as $id => $name){
$hosttemplateid = get_dbid('hosts_templates', 'hosttemplateid');
if(!($result = DBexecute('insert into hosts_templates values ('.$hosttemplateid.','.$hostid.','.$id.')')))
break;
diff --git a/frontends/php/include/perm.inc.php b/frontends/php/include/perm.inc.php
index e96b77bc..4c15b0f5 100644
--- a/frontends/php/include/perm.inc.php
+++ b/frontends/php/include/perm.inc.php
@@ -185,6 +185,7 @@
}
function get_accessible_hosts_by_user(&$user_data,$perm,$perm_mode=null,$perm_res=null,$nodeid=null,$cache=1){
+ global $DB_TYPE;
static $available_hosts;
if(is_null($perm_res)) $perm_res = PERM_RES_STRING_LINE;
@@ -228,6 +229,8 @@ COpt::counter_up('perm');
$where = ' where '.implode(' and ',$where);
else
$where = '';
+
+ $sortorder = (isset($DB_TYPE) && (($DB_TYPE == 'MYSQL') || ($DB_TYPE == 'SQLITE3')))?' DESC ':'';
$sql = 'SELECT DISTINCT n.nodeid,n.name as node_name,h.hostid,h.host, min(r.permission) as permission,ug.userid '.
' FROM hosts h '.
@@ -238,7 +241,7 @@ COpt::counter_up('perm');
' LEFT JOIN nodes n ON '.DBid2nodeid('h.hostid').'=n.nodeid '.
$where.
' GROUP BY h.hostid,n.nodeid,n.name,h.host,ug.userid '.
- ' ORDER BY n.name,n.nodeid, h.host, permission desc, userid desc';
+ ' ORDER BY n.name,n.nodeid, h.host, permission '.$sortorder.', userid '.$sortorder;
$db_hosts = DBselect($sql);
diff --git a/frontends/php/items.php b/frontends/php/items.php
index bb609d17..c06212da 100644
--- a/frontends/php/items.php
+++ b/frontends/php/items.php
@@ -793,9 +793,9 @@ include_once "include/page_header.php";
"&group_task=".($db_item["status"] ? "Activate+selected" : "Disable+selected"),
item_status2style($db_item["status"])));
- if($db_item["error"] == "")
+ if($db_item["error"] == '')
{
- $error=new CCol(SPACE,"off");
+ $error=new CCol('-',"off");
}
else
{
@@ -803,7 +803,7 @@ include_once "include/page_header.php";
}
$applications = $show_applications ? implode(', ', get_applications_by_itemid($db_item["itemid"], 'name')) : null;
-
+
$chkBox = new CCheckBox("group_itemid[]",null,null,$db_item["itemid"]);
//if($db_item["templateid"] > 0) $chkBox->SetEnabled(false);
$table->AddRow(array(
@@ -815,7 +815,7 @@ include_once "include/page_header.php";
$db_item["trends"],
item_type2str($db_item['type']),
$status,
- $applications,
+ ('' == $applications)?'-':$applications,
$error
));
}