I didn't know this is a new feature or a bug, because little people report this problem.
but “move from left to right” really works in zabbix 1.6.
so I write a patch try to fix this problem, but I know nothing about php, so i don't want to commit it as a 'patch'
. hope this will help ur guys
iam laneovcc , thx for reading this thread...
but “move from left to right” really works in zabbix 1.6.
so I write a patch try to fix this problem, but I know nothing about php, so i don't want to commit it as a 'patch'
. hope this will help ur guysiam laneovcc , thx for reading this thread...
Code:
diff -rupN php/hostgroups.php php_new/hostgroups.php
--- php/hostgroups.php 2009-12-08 03:43:57.000000000 +0800
+++ php_new/hostgroups.php 2010-06-12 15:39:20.000000000 +0800
@@ -74,30 +74,101 @@
$_REQUEST['form'] = 'clone';
}
else if(isset($_REQUEST['save'])){
-
+
$objects = get_request('hosts', array());
+ $twb_groupid = get_request('twb_groupid', 0);
+ $groupid = get_request('groupid', 0);
+ //print_r($objects);
+ //print $_REQUEST['groupid'];
+ //print_r(get_request('twb_groupid' , array()));
+ $params = array(
+ 'groupids' => $groupid,
+ 'templated_hosts' => 1,
+ 'sortfield' => 'host',
+ 'editable' => 1,
+ 'extendoutput' => 0);
+ $db_hosts = CHost::get($params);
+ //print_r($db_hosts);
+ foreach($db_hosts as $hostt ){
+ $hosts_ori[$hostt['hostid']]=$hostt['hostid'];
+ }
+ //print_r($hosts_ori);
+ //get twb_hosts
+ $params = array(
+ 'groupids' => $twb_groupid,
+ 'templated_hosts' => 1,
+ 'sortfield' => 'host',
+ 'editable' => 1,
+ 'extendoutput' => 0);
+ $db_hosts = CHost::get($params);
+ //print_r($db_hosts);
+ foreach($db_hosts as $twbhostt ){
+ $twb_hosts[$twbhostt['hostid']]=$twbhostt['hostid'];
+ }
+ //print_r($twb_hosts);
+ $hosts = CHost::get(array('hostids' => $objects, 'editable' => 1));
+ $templates = CTemplate::get(array('templateids' => $objects, 'editable' => 1));
+
+//start
+ //print_r($hosts);
+ foreach($hosts as $hosts_i){
+ $flag=0;
+ foreach( $hosts_ori as $hosts_ori_i ){
+ //echo $hosts_i['hostid'];
+ //echo $hosts_ori_i;
+ if ( $hosts_i['hostid'] == $hosts_ori_i ){
+ $flag=1;
+ //echo $hosts_i $hosts_ori_i;
+ }
+ }
+ if($flag == 0) unset($twb_hosts[$hosts_i['hostid']]);
+ }
- $hosts = CHost::get(array('hostids' => $objects, 'output' => API_OUTPUT_SHORTEN));
- $templates = CTemplate::get(array('templateids' => $objects, 'output' => API_OUTPUT_SHORTEN));
+
+ foreach($hosts_ori as $hosts_ori_i){
+ $flag=0;
+ foreach( $hosts as $hosts_i ){
+ if ( $hosts_i['hostid'] == $hosts_ori_i ){
+ $flag=1;
+ //echo 2;
+ }
+ }
+ if($flag == 0)
+ {
+ //print($hosts_ori_i);
+ //print($hosts_i['hostid'] . '<br>' );
+ $twb_hosts[$hosts_ori_i]=$hosts_ori_i;
+ }
+ }
+//stop
+
+ //repack $twb_hosts
+ $i = 0 ;
+ foreach($twb_hosts as $twb_hosts_i){
+ $twb_hosts_re[$i]['hostid'] = $twb_hosts_i ;
+ $i++;
+ }
+ //get twb_groups name
+ $twb_group_row = get_hostgroup_by_groupid($twb_groupid);
+ $twb_group_name = $twb_group_row ['name'];
+ echo $twb_group_name;
if(isset($_REQUEST['groupid'])){
+
+ print $_REQUEST['groupid'];
DBstart();
- $result = CHostGroup::update(array('groupid' => $_REQUEST['groupid'], 'name' => $_REQUEST['gname']));
+ $result = CHostgroup::update(array('groupid' => $_REQUEST['groupid'], 'name' => $_REQUEST['gname'])) ;
+ $result2 = CHostgroup::update(array('groupid' => $twb_groupid, 'name' =>$twb_group_name) );
+ //echo "Result:";
+ //print_r($result);
+ //echo "<br>";
+
+ $groups = CHostGroup::get(array('groupids' => $result['groupids'],'output' => API_OUTPUT_EXTEND));
+
+
if($result === false) error(CHostGroup::resetErrors());
- if($result){
- $options = array(
- 'groupids' => $result['groupids'],
- 'output' => API_OUTPUT_EXTEND
- );
- $groups = CHostGroup::get($options);
-
- $data = array(
- 'hosts' => $hosts,
- 'templates' => $templates,
- 'groups' => $groups
- );
- $result = CHostGroup::massUpdate($data);
- }
+ if($result) $result = CHostGroup::massUpdate(array('hosts' => $hosts, 'templates' => $templates, 'groups' => CHostGroup::get(array('groupids' => $result['groupids'],'output' => API_OUTPUT_EXTEND)) )) ;
+ if($result2) $result2 = CHostGroup::massUpdate(array('hosts' => $twb_hosts_re, 'templates' => $templates, 'groups' => CHostGroup::get(array('groupids' => $result2['groupids'],'output' => API_OUTPUT_EXTEND)) ));
if($result === false) error(CHostGroup::resetErrors());
$result = ($result) ? true : false;
$result = DBend($result);
diff -rupN php/include/hosts.inc.php php_new/include/hosts.inc.php
--- php/include/hosts.inc.php 2009-12-08 03:43:57.000000000 +0800
+++ php_new/include/hosts.inc.php 2010-06-12 15:36:11.000000000 +0800
@@ -2099,7 +2099,7 @@ return $result;
' WHERE hostgroupid>0 '.
$sql_where.
' GROUP BY hg.hostid '.
- ' HAVING count(hg.groupid) > 1';
+ ' HAVING count(hg.groupid) > 0';
$res = DBselect($sql);
while($host = DBfetch($res)){
$unlnk_hostids[$host['hostid']] = $host['hostid'];
Comment