$res = CHost::get(array('real_hosts' => 1, 'hostids' => $_REQUEST['hostid']));
    if (empty($res)) {
        access_deny();
    }
}
$_REQUEST['prof_type'] = get_request('prof_type', 0);
$hostprof_wdgt = new CWidget();
$profile_form = new CForm(null, 'get');
$cmbProf = new CComboBox('prof_type', $_REQUEST['prof_type'], 'javascript: submit();');
$cmbProf->additem(0, S_NORMAL);
$cmbProf->additem(1, S_EXTENDED);
$profile_form->addItem(array(SPACE . S_HOST_PROFILES . SPACE, $cmbProf));
$hostprof_wdgt->addPageHeader(S_HOST_PROFILES_BIG, $profile_form);
if ($_REQUEST['hostid'] > 0) {
    if ($_REQUEST['prof_type']) {
        $hostprof_wdgt->addItem(insert_host_profile_ext_form());
    } else {
        $hostprof_wdgt->addItem(insert_host_profile_form());
    }
} else {
    $sortfield = getPageSortField('host');
    $sortorder = getPageSortOrder();
    $options = array('extendoutput' => 1, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'select_profile' => 1, 'select_groups' => 1, 'limit' => $config['search_limit'] + 1);
    if ($pageFilter->groupsSelected) {
        if ($pageFilter->groupid > 0) {
            $options['groupids'] = $pageFilter->groupid;
        }
    } else {
        $options['groupids'] = array();
    }
    $hosts = CHost::get($options);
Example #2
0
        $prof_type = get_request('prof_type', 0);
        $cmbProf = new CComboBox('prof_type', $prof_type, 'javascript: submit();');
        $cmbProf->additem(0, S_NORMAL);
        $cmbProf->additem(1, S_EXTENDED);
        $r_form->addItem(array(SPACE . S_HOST_PROFILES . SPACE, $cmbProf));
        break;
}
/// --- --- ///
show_table_header(S_HOST_PROFILES_BIG, $r_form);
?>

<?php 
if (isset($_REQUEST['hostid']) && $_REQUEST['hostid'] > 0) {
    echo SBR;
    if ($prof_type) {
        insert_host_profile_ext_form();
    } else {
        insert_host_profile_form();
    }
} else {
    $table = new CTableInfo();
    if ($prof_type) {
        $table->setHeader(array(is_show_all_nodes() ? make_sorting_link(S_NODE, 'h.hostid') : null, make_sorting_link(S_HOST, 'h.host'), $_REQUEST['groupid'] > 0 ? null : make_sorting_link(S_GROUP, 'g.name'), make_sorting_link(S_DEVICE_OS_SHORT, 'hpe.device_os_short'), make_sorting_link(S_DEVICE_HW_ARCH, 'hpe.device_hw_arch'), make_sorting_link(S_DEVICE_TYPE, 'hpe.device_type'), make_sorting_link(S_DEVICE_STATUS, 'hpe.device_status')));
        $sql_where = '';
        if ($_REQUEST['groupid'] > 0) {
            $sql_where = ' AND hg.groupid=' . $_REQUEST['groupid'];
        }
        $sql = 'SELECT DISTINCT g.name, h.hostid,h.host,hpe.device_os_short,hpe.device_hw_arch,hpe.device_type,hpe.device_status' . ' FROM hosts h,hosts_profiles_ext hpe,hosts_groups hg,groups g ' . ' WHERE h.hostid=hpe.hostid ' . ' AND h.hostid=hg.hostid ' . ' AND g.groupid=hg.groupid ' . ' AND ' . DBcondition('h.hostid', $PAGE_HOSTS['hostids']) . $sql_where . order_by('h.host,h.hostid,g.name,hpe.device_os_short,hpe.device_hw_arch,hpe.device_type,hpe.device_status');
        $result = DBselect($sql);
        while ($row = DBfetch($result)) {
            $table->AddRow(array(get_node_name_by_elid($row['hostid']), new CLink($row["host"], "?hostid=" . $row["hostid"] . url_param("groupid") . '&prof_type=' . $prof_type, "action"), $_REQUEST["groupid"] > 0 ? null : $row["name"], $row["device_os_short"], $row["device_hw_arch"], $row["device_type"], $row["device_status"]));