コード例 #1
0
ファイル: services.php プロジェクト: phedders/zabbix
    empty($row['serviceupid']) ? $row['serviceupid'] = '0' : '';
    empty($row['triggerid']) ? $row['description'] = 'None' : ($row['description'] = expand_trigger_description($row['triggerid']));
    if (isset($services[$row['serviceid']])) {
        $services[$row['serviceid']] = array_merge($services[$row['serviceid']], $row);
    } else {
        $services[$row['serviceid']] = $row;
    }
    if (isset($row['serviceupid'])) {
        $services[$row['serviceupid']]['childs'][] = array('id' => $row['serviceid'], 'soft' => 0, 'linkid' => 0);
    }
    if (isset($row['servicedownid'])) {
        $services[$row['serviceid']]['childs'][] = array('id' => $row['servicedownid'], 'soft' => 1, 'linkid' => $row['linkid']);
    }
}
$treeServ = array();
createServiceTree($services, $treeServ);
//return into $treeServ parametr
//permission issue
$treeServ = del_empty_nodes($treeServ);
//----
if (isset($_REQUEST['msg']) && !empty($_REQUEST['msg'])) {
    show_messages(true, $_REQUEST['msg']);
}
//show_table_header(S_IT_SERVICES_BIG);
$tree = new CTree('service_conf_tree', $treeServ, array('caption' => bold(S_SERVICE), 'algorithm' => bold(S_STATUS_CALCULATION), 'description' => bold(S_TRIGGER)));
if ($tree) {
    $serv_wdgt = new CWidget();
    $serv_wdgt->addHeader(S_IT_SERVICES_BIG, SPACE);
    $serv_wdgt->addItem($tree->getHTML());
    $serv_wdgt->show();
} else {
コード例 #2
0
ファイル: services.inc.php プロジェクト: phedders/zabbix
function createServiceTree(&$services, &$temp, $id = 0, $serviceupid = 0, $parentid = 0, $soft = 0, $linkid = '')
{
    $rows = $services[$id];
    if ($rows['serviceid'] > 0 && $rows['caption'] != 'root') {
        $rows['algorithm'] = algorithm2str($rows['algorithm']);
    }
    //---------------------------- if not leaf -----------------------------
    $rows['parentid'] = $parentid;
    if ($soft == 0) {
        $rows['caption'] = new CLink($rows['caption'], '#', null, 'javascript: call_menu(event, ' . zbx_jsvalue($rows['serviceid']) . ',' . zbx_jsvalue($rows['caption']) . '); return false;');
        $temp[$rows['serviceid']] = $rows;
        if (isset($rows['childs'])) {
            foreach ($rows['childs'] as $cid => $nodeid) {
                if (!isset($services[$nodeid['id']])) {
                    continue;
                }
                if (isset($services[$nodeid['id']]['serviceupid'])) {
                    createServiceTree($services, $temp, $nodeid['id'], $services[$nodeid['id']]['serviceupid'], $rows['serviceid'], $nodeid['soft'], $nodeid['linkid']);
                }
            }
        }
    } else {
        $rows['caption'] = new CSpan($rows['caption'], 'unknown');
        $temp[$rows['serviceid'] . '.' . $linkid] = $rows;
    }
    return;
}