/**
  * Process screen.
  *
  * @return CDiv (screen inside container)
  */
 public function get()
 {
     $image = new CImg('map.php?noedit=1&sysmapid=' . $this->screenitem['resourceid'] . '&width=' . $this->screenitem['width'] . '&height=' . $this->screenitem['height'] . '&curtime=' . time());
     $image->setAttribute('id', 'map_' . $this->screenitem['screenitemid']);
     if ($this->mode == SCREEN_MODE_PREVIEW) {
         $sysmap = API::Map()->get(array('sysmapids' => $this->screenitem['resourceid'], 'output' => API_OUTPUT_EXTEND, 'selectSelements' => API_OUTPUT_EXTEND, 'selectLinks' => API_OUTPUT_EXTEND, 'expandUrls' => true, 'nopermissions' => true, 'preservekeys' => true));
         $sysmap = reset($sysmap);
         $actionMap = getActionMapBySysmap($sysmap);
         $image->setMap($actionMap->getName());
         $output = array($actionMap, $image);
     } elseif ($this->mode == SCREEN_MODE_EDIT) {
         $output = array($image, BR(), new CLink(_('Change'), $this->action));
     } else {
         $output = array($image);
     }
     $this->insertFlickerfreeJs();
     $div = new CDiv($output, 'map-container flickerfreescreen', $this->getScreenId());
     $div->setAttribute('data-timestamp', $this->timestamp);
     $div->addStyle('position: relative;');
     return $div;
 }
Beispiel #2
0
             $checked = uint_in_array($node['nodeid'], $ZBX_VIEWED_NODES['nodeids']);
             $combo_select_node = new CCheckbox('selected_nodes[' . $node['nodeid'] . ']', $checked, null, $node['nodeid']);
             // If not exist parent for node, link it to root (0)
             if (!isset($available_nodes[$node['masterid']])) {
                 $node['masterid'] = 0;
             }
             $node_tree[$node['nodeid']] = array('id' => $node['nodeid'], 'caption' => $node['name'], 'combo_select_node' => $combo_select_node, 'parentid' => $node['masterid']);
         }
         $node_tree_captions = array('caption' => bold(S_NODE), 'combo_select_node' => SPACE);
         $node_tree = new CTree('nodes', $node_tree, $node_tree_captions);
         // --- ---
         $div_node_tree = new CDiv();
         $div_node_tree->additem($node_tree->getHTML());
         $div_node_tree->additem(new CButton('select_nodes', S_SELECT, "javascript: " . " hidePopupDiv('select_iframe');" . " \$('div_node_tree').setStyle({display:'none'});"));
         $div_node_tree->setAttribute('id', 'div_node_tree');
         $div_node_tree->addStyle('display: none');
         if (!is_null($combo_node_list)) {
             $node_form->addItem(array(new CSpan(S_CURRENT_NODE, 'textcolorstyles'), $combo_node_list));
         }
         $node_form->addItem($button_show_tree);
         $node_form->addItem($div_node_tree);
         unset($combo_node_list);
     }
 }
 // 1st level menu
 $table = new CTable();
 $table->setCellSpacing(0);
 $table->setCellPadding(0);
 $table->setAttribute('style', 'width: 100%;');
 $r_col = new CCol($node_form);
 $r_col->setAttribute('align', 'right');
Beispiel #3
0
/**
 * Create DIV with latest problem triggers.
 *
 * If no sortfield and sortorder are defined, the sort indicater in the column name will not be displayed.
 *
 * @param array  $filter['screenid']
 * @param array  $filter['groupids']
 * @param array  $filter['hostids']
 * @param array  $filter['maintenance']
 * @param int    $filter['extAck']
 * @param int    $filter['severity']
 * @param int    $filter['limit']
 * @param string $filter['sortfield']
 * @param string $filter['sortorder']
 * @param string $filter['backUrl']
 *
 * @return CDiv
 */
function make_latest_issues(array $filter = array())
{
    // hide the sort indicator if no sortfield and sortorder are given
    $showSortIndicator = isset($filter['sortfield']) || isset($filter['sortorder']);
    if (!isset($filter['sortfield'])) {
        $filter['sortfield'] = 'lastchange';
    }
    if (!isset($filter['sortorder'])) {
        $filter['sortorder'] = ZBX_SORT_DOWN;
    }
    $options = array('groupids' => $filter['groupids'], 'hostids' => isset($filter['hostids']) ? $filter['hostids'] : null, 'monitored' => true, 'maintenance' => $filter['maintenance'], 'filter' => array('priority' => $filter['severity'], 'value' => TRIGGER_VALUE_TRUE));
    $triggers = API::Trigger()->get(array_merge($options, array('withLastEventUnacknowledged' => isset($filter['extAck']) && $filter['extAck'] == EXTACK_OPTION_UNACK ? true : null, 'skipDependent' => true, 'output' => array('triggerid', 'state', 'error', 'url', 'expression', 'description', 'priority', 'lastchange'), 'selectHosts' => array('hostid', 'name'), 'selectLastEvent' => array('eventid', 'acknowledged', 'objectid', 'clock', 'ns'), 'sortfield' => $filter['sortfield'], 'sortorder' => $filter['sortorder'], 'limit' => isset($filter['limit']) ? $filter['limit'] : DEFAULT_LATEST_ISSUES_CNT)));
    // don't use withLastEventUnacknowledged and skipDependent because of performance issues
    $triggersTotalCount = API::Trigger()->get(array_merge($options, array('countOutput' => true)));
    // get acknowledges
    $eventIds = array();
    foreach ($triggers as $trigger) {
        if ($trigger['lastEvent']) {
            $eventIds[] = $trigger['lastEvent']['eventid'];
        }
    }
    if ($eventIds) {
        $eventAcknowledges = API::Event()->get(array('eventids' => $eventIds, 'select_acknowledges' => API_OUTPUT_EXTEND, 'preservekeys' => true));
    }
    foreach ($triggers as $tnum => $trigger) {
        // if trigger is lost (broken expression) we skip it
        if (empty($trigger['hosts'])) {
            unset($triggers[$tnum]);
            continue;
        }
        $host = reset($trigger['hosts']);
        $trigger['hostid'] = $host['hostid'];
        $trigger['hostname'] = $host['name'];
        if ($trigger['lastEvent']) {
            $trigger['lastEvent']['acknowledges'] = isset($eventAcknowledges[$trigger['lastEvent']['eventid']]) ? $eventAcknowledges[$trigger['lastEvent']['eventid']]['acknowledges'] : null;
        }
        $triggers[$tnum] = $trigger;
    }
    $hostIds = zbx_objectValues($triggers, 'hostid');
    // get hosts
    $hosts = API::Host()->get(array('hostids' => $hostIds, 'output' => array('hostid', 'name', 'status', 'maintenance_status', 'maintenance_type', 'maintenanceid'), 'selectScreens' => API_OUTPUT_COUNT, 'preservekeys' => true));
    // actions
    $actions = getEventActionsStatHints($eventIds);
    // ack params
    $ackParams = isset($filter['screenid']) ? array('screenid' => $filter['screenid']) : array();
    $config = select_config();
    // indicator of sort field
    if ($showSortIndicator) {
        $sortDiv = new CDiv(SPACE, $filter['sortorder'] === ZBX_SORT_DOWN ? 'icon_sortdown default_cursor' : 'icon_sortup default_cursor');
        $sortDiv->addStyle('float: left');
        $hostHeaderDiv = new CDiv(array(_('Host'), SPACE));
        $hostHeaderDiv->addStyle('float: left');
        $issueHeaderDiv = new CDiv(array(_('Issue'), SPACE));
        $issueHeaderDiv->addStyle('float: left');
        $lastChangeHeaderDiv = new CDiv(array(_('Time'), SPACE));
        $lastChangeHeaderDiv->addStyle('float: left');
    }
    $table = new CTableInfo(_('No events found.'));
    $table->setHeader(array(is_show_all_nodes() ? _('Node') : null, $showSortIndicator && $filter['sortfield'] === 'hostname' ? array($hostHeaderDiv, $sortDiv) : _('Host'), $showSortIndicator && $filter['sortfield'] === 'priority' ? array($issueHeaderDiv, $sortDiv) : _('Issue'), $showSortIndicator && $filter['sortfield'] === 'lastchange' ? array($lastChangeHeaderDiv, $sortDiv) : _('Last change'), _('Age'), _('Info'), $config['event_ack_enable'] ? _('Ack') : null, _('Actions')));
    $scripts = API::Script()->getScriptsByHosts($hostIds);
    // triggers
    foreach ($triggers as $trigger) {
        $host = $hosts[$trigger['hostid']];
        $hostName = new CSpan($host['name'], 'link_menu');
        $hostName->setMenuPopup(getMenuPopupHost($host, $scripts[$host['hostid']]));
        // add maintenance icon with hint if host is in maintenance
        $maintenanceIcon = null;
        if ($host['maintenance_status']) {
            $maintenanceIcon = new CDiv(null, 'icon-maintenance-abs');
            // get maintenance
            $maintenances = API::Maintenance()->get(array('maintenanceids' => $host['maintenanceid'], 'output' => API_OUTPUT_EXTEND, 'limit' => 1));
            if ($maintenance = reset($maintenances)) {
                $hint = $maintenance['name'] . ' [' . ($host['maintenance_type'] ? _('Maintenance without data collection') : _('Maintenance with data collection')) . ']';
                if (isset($maintenance['description'])) {
                    // double quotes mandatory
                    $hint .= "\n" . $maintenance['description'];
                }
                $maintenanceIcon->setHint($hint);
                $maintenanceIcon->addClass('pointer');
            }
            $hostName->addClass('left-to-icon-maintenance-abs');
        }
        $hostDiv = new CDiv(array($hostName, $maintenanceIcon), 'maintenance-abs-cont');
        // unknown triggers
        $unknown = SPACE;
        if ($trigger['state'] == TRIGGER_STATE_UNKNOWN) {
            $unknown = new CDiv(SPACE, 'status_icon iconunknown');
            $unknown->setHint($trigger['error'], '', 'on');
        }
        // trigger has events
        if ($trigger['lastEvent']) {
            // description
            $description = CMacrosResolverHelper::resolveEventDescription(zbx_array_merge($trigger, array('clock' => $trigger['lastEvent']['clock'], 'ns' => $trigger['lastEvent']['ns'])));
            // ack
            $ack = getEventAckState($trigger['lastEvent'], empty($filter['backUrl']) ? true : $filter['backUrl'], true, $ackParams);
        } else {
            // description
            $description = CMacrosResolverHelper::resolveEventDescription(zbx_array_merge($trigger, array('clock' => $trigger['lastchange'], 'ns' => '999999999')));
            // ack
            $ack = new CSpan(_('No events'), 'unknown');
        }
        // description
        if (!zbx_empty($trigger['url'])) {
            $description = new CLink($description, resolveTriggerUrl($trigger), null, null, true);
        } else {
            $description = new CSpan($description, 'pointer');
        }
        $description = new CCol($description, getSeverityStyle($trigger['priority']));
        if ($trigger['lastEvent']) {
            $description->setHint(make_popup_eventlist($trigger['triggerid'], $trigger['lastEvent']['eventid']), '', '', false);
        }
        // clock
        $clock = new CLink(zbx_date2str(_('d M Y H:i:s'), $trigger['lastchange']), 'events.php?triggerid=' . $trigger['triggerid'] . '&source=0&show_unknown=1&nav_time=' . $trigger['lastchange']);
        // actions
        $actionHint = $trigger['lastEvent'] && isset($actions[$trigger['lastEvent']['eventid']]) ? $actions[$trigger['lastEvent']['eventid']] : SPACE;
        $table->addRow(array(get_node_name_by_elid($trigger['triggerid']), $hostDiv, $description, $clock, zbx_date2age($trigger['lastchange']), $unknown, $ack, $actionHint));
    }
    // initialize blinking
    zbx_add_post_js('jqBlink.blink();');
    $script = new CJSScript(get_js("jQuery('#hat_lastiss_footer').html('" . _s('Updated: %s', zbx_date2str(_('H:i:s'))) . "')"));
    $infoDiv = new CDiv(_n('%1$d of %2$d issue is shown', '%1$d of %2$d issues are shown', count($triggers), $triggersTotalCount));
    $infoDiv->addStyle('text-align: right; padding-right: 3px;');
    return new CDiv(array($table, $infoDiv, $script));
}
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
**/
include 'include/views/js/administration.general.triggerSeverity.js.php';
$severityTab = new CFormList('scriptsTab');
$headerDiv = new CDiv(_('Custom severity'), 'inlineblock');
$headerDiv->addStyle('width: 16.3em; margin-left: 3px; zoom:1; *display: inline;');
$severityTab->addRow(SPACE, array($headerDiv, _('Colour')));
$severityNameTB0 = new CTextBox('severity_name_0', $this->data['config']['severity_name_0']);
$severityNameTB0->addStyle('width: 15em;');
$severityNameTB0->setAttribute('maxlength', 32);
$severityColorTB0 = new CColor('severity_color_0', $this->data['config']['severity_color_0']);
$severityTab->addRow(_('Not classified'), array($severityNameTB0, SPACE, $severityColorTB0));
$severityNameTB1 = new CTextBox('severity_name_1', $this->data['config']['severity_name_1']);
$severityNameTB1->addStyle('width: 15em;');
$severityNameTB1->setAttribute('maxlength', 32);
$severityColorTB1 = new CColor('severity_color_1', $this->data['config']['severity_color_1']);
$severityTab->addRow(_('Information'), array($severityNameTB1, SPACE, $severityColorTB1));
$severityNameTB2 = new CTextBox('severity_name_2', $this->data['config']['severity_name_2']);
$severityNameTB2->addStyle('width: 15em;');
$severityNameTB2->setAttribute('maxlength', 32);
$severityColorTB2 = new CColor('severity_color_2', $this->data['config']['severity_color_2']);
            $input->setAttribute('disabled', 'disabled');
        }
    } else {
        $populatingItemCell = '';
    }
    $input->addStyle('float: left;');
    $populatingItem = new CSpan($populatingItemCell, 'populating_item');
    if ($inventory_mode != HOST_INVENTORY_AUTOMATIC) {
        // those links are visible only in automatic mode
        $populatingItem->addStyle('display: none');
    }
    $inventoryFormList->addRow($inventoryInfo['title'], array($input, $populatingItem));
}
// clearing the float
$clearFixDiv = new CDiv();
$clearFixDiv->addStyle('clear: both;');
$inventoryFormList->addRow('', $clearFixDiv);
$divTabs->addTab('inventoryTab', _('Host inventory'), $inventoryFormList);
$frmHost->addItem($divTabs);
/*
 * footer
 */
$others = array();
// do not display the clone and delete buttons for clone forms and new host forms
if (getRequest('hostid') && !in_array(getRequest('form'), array('clone', 'full_clone'))) {
    $others[] = new CSubmit('clone', _('Clone'));
    $others[] = new CSubmit('full_clone', _('Full clone'));
    $others[] = new CButtonDelete(_('Delete selected host?'), url_param('form') . url_param('hostid') . url_param('groupid'));
}
$others[] = new CButtonCancel(url_param('groupid'));
$frmHost->addItem(makeFormFooter(new CSubmit('save', _('Save')), $others));
$exprTable->setFooter(new CButton('add', _('Add'), null, 'link_menu exprAdd'));
$exprTab->addRow(_('Expressions'), new CDiv($exprTable, 'inlineblock border_dotted objectgroup'));
$exprForm = new CTable(null, 'formElementTable');
$exprForm->addRow(array(_('Expression'), new CTextBox('expressionNew', null, ZBX_TEXTBOX_STANDARD_SIZE)));
$exprForm->addRow(array(_('Expression type'), new CComboBox('typeNew', null, null, expression_type2str())));
$exprForm->addRow(array(_('Delimiter'), new CComboBox('delimiterNew', null, null, expressionDelimiters())), null, 'delimiterNewRow');
$exprForm->addRow(array(_('Case sensitive'), new CCheckBox('case_sensitiveNew')));
$exprFormFooter = array(new CButton('saveExpression', _('Add'), null, 'link_menu'), SPACE, new CButton('cancelExpression', _('Cancel'), null, 'link_menu'));
$exprTab->addRow(null, new CDiv(array($exprForm, $exprFormFooter), 'objectgroup inlineblock border_dotted'), true, 'exprForm');
/*
 * Test tab
 */
$testTab = new CFormList('testTab');
$testTab->addRow(_('Test string'), new CTextArea('test_string', $this->get('test_string')));
$preloaderDiv = new CDiv(null, 'preloader', 'testPreloader');
$preloaderDiv->addStyle('display: none');
$testTab->addRow(SPACE, array(new CButton('testExpression', _('Test expressions')), $preloaderDiv));
$tabExp = new CTableInfo(null);
$tabExp->attr('id', 'testResultTable');
$tabExp->setHeader(array(_('Expression'), _('Expression type'), _('Result')));
$testTab->addRow(_('Result'), $tabExp);
$regExpView = new CTabView();
if (!$this->data['form_refresh']) {
    $regExpView->setSelected(0);
}
$regExpView->addTab('expr', _('Expressions'), $exprTab);
$regExpView->addTab('test', _('Test'), $testTab);
$form->addItem($regExpView);
// footer
if (isset($this->data['regexpid'])) {
    $form->addItem(makeFormFooter(new CSubmit('update', _('Update')), array(new CButton('clone', _('Clone')), new CButtonDelete(_('Delete regular expression?'), url_param('regexpid') . url_param('regexp.massdelete', false, 'action')), new CButtonCancel())));
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
**/
include 'include/views/js/administration.general.triggerDisplayOptions.js.php';
$triggerDOFormList = new CFormList('scriptsTab');
$headerDiv = new CDiv(_('Colour'), 'inlineblock trigger_displaying_form_col');
$headerDiv->addStyle('margin-left: 2px;');
$triggerDOFormList->addRow(SPACE, array($headerDiv, _('Blinking')));
// Unacknowledged problem events
$triggerDOFormList->addRow(_('Unacknowledged PROBLEM events'), array(new CDiv(new CColor('problem_unack_color', $this->data['problem_unack_color']), 'inlineblock trigger_displaying_form_col'), new CCheckBox('problem_unack_style', $this->data['problem_unack_style'] == 1, null, 1)));
// Acknowledged problem events
$triggerDOFormList->addRow(_('Acknowledged PROBLEM events'), array(new CDiv(new CColor('problem_ack_color', $this->data['problem_ack_color']), 'inlineblock trigger_displaying_form_col'), new CCheckBox('problem_ack_style', $this->data['problem_ack_style'] == 1, null, 1)));
// Unacknowledged recovery events
$triggerDOFormList->addRow(_('Unacknowledged OK events'), array(new CDiv(new CColor('ok_unack_color', $this->data['ok_unack_color']), 'inlineblock trigger_displaying_form_col'), new CCheckBox('ok_unack_style', $this->data['ok_unack_style'] == 1, null, 1)));
// Acknowledged recovery events
$triggerDOFormList->addRow(_('Acknowledged OK events'), array(new CDiv(new CColor('ok_ack_color', $this->data['ok_ack_color']), 'inlineblock trigger_displaying_form_col'), new CCheckBox('ok_ack_style', $this->data['ok_ack_style'] == 1, null, 1)));
// some air between the sections
$triggerDOFormList->addRow(BR());
// Display OK triggers
$okPeriodTextBox = new CTextBox('ok_period', $this->data['ok_period']);
$okPeriodTextBox->addStyle('width: 4em;');
$okPeriodTextBox->setAttribute('maxlength', '6');
Beispiel #8
0
 /**
  * Get enveloped screen inside container.
  *
  * @param object	$item
  * @param boolean	$insertFlickerfreeJs
  * @param array		$flickerfreeData
  *
  * @return CDiv
  */
 public function getOutput($item = null, $insertFlickerfreeJs = true, $flickerfreeData = array())
 {
     if ($insertFlickerfreeJs) {
         $this->insertFlickerfreeJs($flickerfreeData);
     }
     if ($this->mode == SCREEN_MODE_EDIT) {
         $div = new CDiv(array($item, BR(), new CLink(_('Change'), $this->action)), 'flickerfreescreen', $this->getScreenId());
     } else {
         $div = new CDiv($item, 'flickerfreescreen', $this->getScreenId());
     }
     $div->setAttribute('data-timestamp', $this->timestamp);
     $div->addStyle('position: relative;');
     return $div;
 }
Beispiel #9
0
 // Draw type selector
 $cmbDrawType = new CComboBox('draw_type', $draw_type);
 foreach (graph_item_drawtypes() as $dt) {
     $cmbDrawType->addItem($dt, graph_item_drawtype2str($dt));
 }
 // Yaxisside selector
 $cmbYaxisside = new CComboBox('yaxisside', $yaxisside);
 foreach (array(0, 1) as $side) {
     $cmbYaxisside->addItem($side, $side == 0 ? _('Left') : _('Right'));
 }
 $graph_params_w = new CWidget();
 $graph_params_w->setClass('header');
 $graph_params_w->addHeader(_('Graphs'));
 $graph_params_div = new CDiv();
 $graph_params_div->setAttribute("id", "graphparams");
 $graph_params_div->addStyle("width: {$right_widget_width};");
 $graph_params_tbl = new CTable();
 $graph_params_tbl->attr('class', 'formtable');
 $graph_params_tbl->addStyle("width: 100%; align: left; border-width: 0 0 0 0;");
 $graph_params_tbl->setCellPadding(0);
 $graph_params_tbl->setCellSpacing(0);
 $graph_params_tbl1 = new CTable();
 $graph_params_tbl1->attr('class', 'formtable');
 $graph_params_tbl1->addStyle("width: 100%; align: left; border-width: 0 0 0 0;");
 $graph_params_tbl1->addRow(array(_('Create graph'), $graphCreate, _('Name') . ':', $graphName, _('Width') . ':', $graphWidth, _('Height') . ':', $graphHeight, _('Graph type') . ':', $cmbGraphType));
 $graph_params_tbl2 = new CTable();
 $graph_params_tbl2->attr('class', 'formtable');
 $graph_params_tbl2->addStyle("width: 100%; align: left; border-width: 0 0 0 0;");
 $graph_params_tbl2->addRow(array(_('Function') . ':', $cmbGraphFunc, _('Draw style') . ':', $cmbDrawType, _('Y axis side') . ':', $cmbYaxisside));
 $graph_params_tbl->addRow($graph_params_tbl1);
 $graph_params_tbl->addRow($graph_params_tbl2);
Beispiel #10
0
function insert_mass_update_host_form()
{
    //$elements_array_name){
    global $USER_DETAILS;
    $visible = get_request('visible', array());
    $groups = get_request('groups', array());
    $newgroup = get_request('newgroup', '');
    $host = get_request('host', '');
    $port = get_request('port', CProfile::get('HOST_PORT', 10050));
    $status = get_request('status', HOST_STATUS_MONITORED);
    $useip = get_request('useip', 1);
    $dns = get_request('dns', '');
    $ip = get_request('ip', '0.0.0.0');
    $proxy_hostid = get_request('proxy_hostid', '');
    $useipmi = get_request('useipmi', 'no');
    $ipmi_ip = get_request('ipmi_ip', '');
    $ipmi_port = get_request('ipmi_port', 623);
    $ipmi_authtype = get_request('ipmi_authtype', -1);
    $ipmi_privilege = get_request('ipmi_privilege', 2);
    $ipmi_username = get_request('ipmi_username', '');
    $ipmi_password = get_request('ipmi_password', '');
    $useprofile = get_request('useprofile', 'no');
    $host_profile = get_request('host_profile', array());
    $profile_fields = array('devicetype' => S_DEVICE_TYPE, 'name' => S_NAME, 'os' => S_OS, 'serialno' => S_SERIALNO, 'tag' => S_TAG, 'macaddress' => S_MACADDRESS, 'hardware' => S_HARDWARE, 'software' => S_SOFTWARE, 'contact' => S_CONTACT, 'location' => S_LOCATION, 'notes' => S_NOTES);
    foreach ($profile_fields as $field => $caption) {
        if (!isset($host_profile[$field])) {
            $host_profile[$field] = '';
        }
    }
    // BEGIN: HOSTS PROFILE EXTENDED Section
    $useprofile_ext = get_request('useprofile_ext', 'no');
    $ext_host_profiles = get_request('ext_host_profiles', array());
    $ext_profiles_fields = array('device_alias' => S_DEVICE_ALIAS, 'device_type' => S_DEVICE_TYPE, 'device_chassis' => S_DEVICE_CHASSIS, 'device_os' => S_DEVICE_OS, 'device_os_short' => S_DEVICE_OS_SHORT, 'device_hw_arch' => S_DEVICE_HW_ARCH, 'device_serial' => S_DEVICE_SERIAL, 'device_model' => S_DEVICE_MODEL, 'device_tag' => S_DEVICE_TAG, 'device_vendor' => S_DEVICE_VENDOR, 'device_contract' => S_DEVICE_CONTRACT, 'device_who' => S_DEVICE_WHO, 'device_status' => S_DEVICE_STATUS, 'device_app_01' => S_DEVICE_APP_01, 'device_app_02' => S_DEVICE_APP_02, 'device_app_03' => S_DEVICE_APP_03, 'device_app_04' => S_DEVICE_APP_04, 'device_app_05' => S_DEVICE_APP_05, 'device_url_1' => S_DEVICE_URL_1, 'device_url_2' => S_DEVICE_URL_2, 'device_url_3' => S_DEVICE_URL_3, 'device_networks' => S_DEVICE_NETWORKS, 'device_notes' => S_DEVICE_NOTES, 'device_hardware' => S_DEVICE_HARDWARE, 'device_software' => S_DEVICE_SOFTWARE, 'ip_subnet_mask' => S_IP_SUBNET_MASK, 'ip_router' => S_IP_ROUTER, 'ip_macaddress' => S_IP_MACADDRESS, 'oob_ip' => S_OOB_IP, 'oob_subnet_mask' => S_OOB_SUBNET_MASK, 'oob_router' => S_OOB_ROUTER, 'date_hw_buy' => S_DATE_HW_BUY, 'date_hw_install' => S_DATE_HW_INSTALL, 'date_hw_expiry' => S_DATE_HW_EXPIRY, 'date_hw_decomm' => S_DATE_HW_DECOMM, 'site_street_1' => S_SITE_STREET_1, 'site_street_2' => S_SITE_STREET_2, 'site_street_3' => S_SITE_STREET_3, 'site_city' => S_SITE_CITY, 'site_state' => S_SITE_STATE, 'site_country' => S_SITE_COUNTRY, 'site_zip' => S_SITE_ZIP, 'site_rack' => S_SITE_RACK, 'site_notes' => S_SITE_NOTES, 'poc_1_name' => S_POC_1_NAME, 'poc_1_email' => S_POC_1_EMAIL, 'poc_1_phone_1' => S_POC_1_PHONE_1, 'poc_1_phone_2' => S_POC_1_PHONE_2, 'poc_1_cell' => S_POC_1_CELL, 'poc_1_screen' => S_POC_1_SCREEN, 'poc_1_notes' => S_POC_1_NOTES, 'poc_2_name' => S_POC_2_NAME, 'poc_2_email' => S_POC_2_EMAIL, 'poc_2_phone_1' => S_POC_2_PHONE_1, 'poc_2_phone_2' => S_POC_2_PHONE_2, 'poc_2_cell' => S_POC_2_CELL, 'poc_2_screen' => S_POC_2_SCREEN, 'poc_2_notes' => S_POC_2_NOTES);
    foreach ($ext_profiles_fields as $field => $caption) {
        if (!isset($ext_host_profiles[$field])) {
            $ext_host_profiles[$field] = '';
        }
    }
    // END:   HOSTS PROFILE EXTENDED Section
    $templates = get_request('templates', array());
    natsort($templates);
    $frm_title = S_HOST . SPACE . S_MASS_UPDATE;
    $frmHost = new CFormTable($frm_title, 'hosts.php');
    $frmHost->setHelp('web.hosts.host.php');
    $frmHost->addVar('go', 'massupdate');
    $hosts = $_REQUEST['hosts'];
    foreach ($hosts as $id => $hostid) {
        $frmHost->addVar('hosts[' . $hostid . ']', $hostid);
    }
    //		$frmItem->addRow(array( new CVisibilityBox('visible[type]', isset($visible['type']), 'type', S_ORIGINAL),S_TYPE), $cmbType);
    $frmHost->addRow(S_NAME, S_ORIGINAL);
    $grp_tb = new CTweenBox($frmHost, 'groups', $groups, 6);
    $options = array('output' => API_OUTPUT_EXTEND, 'editable' => 1);
    $all_groups = CHostGroup::get($options);
    order_result($all_groups, 'name');
    foreach ($all_groups as $grp) {
        $grp_tb->addItem($grp['groupid'], $grp['name']);
    }
    $frmHost->addRow(array(new CVisibilityBox('visible[groups]', isset($visible['groups']), $grp_tb->getName(), S_ORIGINAL), S_GROUPS), $grp_tb->get(S_IN . SPACE . S_GROUPS, S_OTHER . SPACE . S_GROUPS));
    $frmHost->addRow(array(new CVisibilityBox('visible[newgroup]', isset($visible['newgroup']), 'newgroup', S_ORIGINAL), S_NEW_GROUP), new CTextBox('newgroup', $newgroup), 'new');
    // onchange does not work on some browsers: MacOS, KDE browser
    $frmHost->addRow(array(new CVisibilityBox('visible[dns]', isset($visible['dns']), 'dns', S_ORIGINAL), S_DNS_NAME), new CTextBox('dns', $dns, '40'));
    $frmHost->addRow(array(new CVisibilityBox('visible[ip]', isset($visible['ip']), 'ip', S_ORIGINAL), S_IP_ADDRESS), new CTextBox('ip', $ip, defined('ZBX_HAVE_IPV6') ? 39 : 15));
    $cmbConnectBy = new CComboBox('useip', $useip);
    $cmbConnectBy->addItem(0, S_DNS_NAME);
    $cmbConnectBy->addItem(1, S_IP_ADDRESS);
    $frmHost->addRow(array(new CVisibilityBox('visible[useip]', isset($visible['useip']), 'useip', S_ORIGINAL), S_CONNECT_TO), $cmbConnectBy);
    $frmHost->addRow(array(new CVisibilityBox('visible[port]', isset($visible['port']), 'port', S_ORIGINAL), S_AGENT_PORT), new CNumericBox('port', $port, 5));
    //Proxy
    $cmbProxy = new CComboBox('proxy_hostid', $proxy_hostid);
    $cmbProxy->addItem(0, S_NO_PROXY);
    $sql = 'SELECT hostid,host ' . ' FROM hosts ' . ' WHERE status IN (' . HOST_STATUS_PROXY_ACTIVE . ',' . HOST_STATUS_PROXY_PASSIVE . ') ' . ' AND ' . DBin_node('hostid') . ' ORDER BY host';
    $db_proxies = DBselect($sql);
    while ($db_proxy = DBfetch($db_proxies)) {
        $cmbProxy->addItem($db_proxy['hostid'], $db_proxy['host']);
    }
    $frmHost->addRow(array(new CVisibilityBox('visible[proxy_hostid]', isset($visible['proxy_hostid']), 'proxy_hostid', S_ORIGINAL), S_MONITORED_BY_PROXY), $cmbProxy);
    //----------
    $cmbStatus = new CComboBox('status', $status);
    $cmbStatus->addItem(HOST_STATUS_MONITORED, S_MONITORED);
    $cmbStatus->addItem(HOST_STATUS_NOT_MONITORED, S_NOT_MONITORED);
    $frmHost->addRow(array(new CVisibilityBox('visible[status]', isset($visible['status']), 'status', S_ORIGINAL), S_STATUS), $cmbStatus);
    // LINK TEMPLATES {{{
    $template_table = new CTable();
    $template_table->setAttribute('name', 'template_table');
    $template_table->setAttribute('id', 'template_table');
    $template_table->setCellPadding(0);
    $template_table->setCellSpacing(0);
    foreach ($templates as $id => $temp_name) {
        $frmHost->addVar('templates[' . $id . ']', $temp_name);
        $template_table->addRow(array(new CCheckBox('templates_rem[' . $id . ']', 'no', null, $id), $temp_name));
    }
    $template_table->addRow(array(new CButton('add_template', S_ADD, "return PopUp('popup.php?dstfrm=" . $frmHost->getName() . "&dstfld1=new_template&srctbl=templates&srcfld1=hostid&srcfld2=host" . url_param($templates, false, 'existed_templates') . "',450,450)"), new CButton('unlink', S_REMOVE)));
    $vbox = new CVisibilityBox('visible[template_table]', isset($visible['template_table']), 'template_table', S_ORIGINAL);
    $vbox->setAttribute('id', 'cb_tpladd');
    if (isset($visible['template_table_r'])) {
        $vbox->setAttribute('disabled', 'disabled');
    }
    $action = $vbox->getAttribute('onclick');
    $action .= 'if($("cb_tplrplc").disabled) $("cb_tplrplc").enable(); else $("cb_tplrplc").disable();';
    $vbox->setAttribute('onclick', $action);
    $frmHost->addRow(array($vbox, S_LINK_ADDITIONAL_TEMPLATES), $template_table, 'T');
    // }}} LINK TEMPLATES
    // RELINK TEMPLATES {{{
    $template_table_r = new CTable();
    $template_table_r->setAttribute('name', 'template_table_r');
    $template_table_r->setAttribute('id', 'template_table_r');
    $template_table_r->setCellPadding(0);
    $template_table_r->setCellSpacing(0);
    foreach ($templates as $id => $temp_name) {
        $frmHost->addVar('templates[' . $id . ']', $temp_name);
        $template_table_r->addRow(array(new CCheckBox('templates_rem[' . $id . ']', 'no', null, $id), $temp_name));
    }
    $template_table_r->addRow(array(new CButton('add_template', S_ADD, "return PopUp('popup.php?dstfrm=" . $frmHost->getName() . "&dstfld1=new_template&srctbl=templates&srcfld1=hostid&srcfld2=host" . url_param($templates, false, 'existed_templates') . "',450,450)"), new CButton('unlink', S_REMOVE)));
    $vbox = new CVisibilityBox('visible[template_table_r]', isset($visible['template_table_r']), 'template_table_r', S_ORIGINAL);
    $vbox->setAttribute('id', 'cb_tplrplc');
    if (isset($visible['template_table'])) {
        $vbox->setAttribute('disabled', 'disabled');
    }
    $action = $vbox->getAttribute('onclick');
    $action .= <<<JAVASCRIPT
if(\$("cb_tpladd").disabled){
\t\$("cb_tpladd").enable();
}
else{
\t\$("cb_tpladd").disable();
}
\$("clrcbdiv").toggle();
JAVASCRIPT;
    $vbox->setAttribute('onclick', $action);
    $clear_cb = new CCheckBox('mass_clear_tpls', get_request('mass_clear_tpls', false));
    $div = new CDiv(array($clear_cb, S_CLEAR_WHEN_UNLINKING));
    $div->setAttribute('id', 'clrcbdiv');
    $div->addStyle('margin-left: 20px;');
    if (!isset($visible['template_table_r'])) {
        $div->addStyle('display: none;');
    }
    $frmHost->addRow(array($vbox, S_RELINK_TEMPLATES, $div), $template_table_r, 'T');
    // }}} RELINK TEMPLATES
    $frmHost->addRow(array(new CVisibilityBox('visible[useipmi]', isset($visible['useipmi']), 'useipmi', S_ORIGINAL), S_USEIPMI), new CCheckBox('useipmi', $useipmi, 'submit()'));
    if ($useipmi == 'yes') {
        $frmHost->addRow(array(new CVisibilityBox('visible[ipmi_ip]', isset($visible['ipmi_ip']), 'ipmi_ip', S_ORIGINAL), S_IPMI_IP_ADDRESS), new CTextBox('ipmi_ip', $ipmi_ip, defined('ZBX_HAVE_IPV6') ? 39 : 15));
        $frmHost->addRow(array(new CVisibilityBox('visible[ipmi_port]', isset($visible['ipmi_port']), 'ipmi_port', S_ORIGINAL), S_IPMI_PORT), new CNumericBox('ipmi_port', $ipmi_port, 15));
        $cmbIPMIAuthtype = new CComboBox('ipmi_authtype', $ipmi_authtype);
        $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_DEFAULT, S_AUTHTYPE_DEFAULT);
        $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_NONE, S_AUTHTYPE_NONE);
        $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_MD2, S_AUTHTYPE_MD2);
        $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_MD5, S_AUTHTYPE_MD5);
        $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_STRAIGHT, S_AUTHTYPE_STRAIGHT);
        $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_OEM, S_AUTHTYPE_OEM);
        $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_RMCP_PLUS, S_AUTHTYPE_RMCP_PLUS);
        $frmHost->addRow(array(new CVisibilityBox('visible[ipmi_authtype]', isset($visible['ipmi_authtype']), 'ipmi_authtype', S_ORIGINAL), S_IPMI_AUTHTYPE), $cmbIPMIAuthtype);
        $cmbIPMIPrivilege = new CComboBox('ipmi_privilege', $ipmi_privilege);
        $cmbIPMIPrivilege->addItem(IPMI_PRIVILEGE_CALLBACK, S_PRIVILEGE_CALLBACK);
        $cmbIPMIPrivilege->addItem(IPMI_PRIVILEGE_USER, S_PRIVILEGE_USER);
        $cmbIPMIPrivilege->addItem(IPMI_PRIVILEGE_OPERATOR, S_PRIVILEGE_OPERATOR);
        $cmbIPMIPrivilege->addItem(IPMI_PRIVILEGE_ADMIN, S_PRIVILEGE_ADMIN);
        $cmbIPMIPrivilege->addItem(IPMI_PRIVILEGE_OEM, S_PRIVILEGE_OEM);
        $frmHost->addRow(array(new CVisibilityBox('visible[ipmi_privilege]', isset($visible['ipmi_privilege']), 'ipmi_privilege', S_ORIGINAL), S_IPMI_PRIVILEGE), $cmbIPMIPrivilege);
        $frmHost->addRow(array(new CVisibilityBox('visible[ipmi_username]', isset($visible['ipmi_username']), 'ipmi_username', S_ORIGINAL), S_IPMI_USERNAME), new CTextBox('ipmi_username', $ipmi_username, 16));
        $frmHost->addRow(array(new CVisibilityBox('visible[ipmi_password]', isset($visible['ipmi_password']), 'ipmi_password', S_ORIGINAL), S_IPMI_PASSWORD), new CTextBox('ipmi_password', $ipmi_password, 20));
    }
    $frmHost->addRow(array(new CVisibilityBox('visible[useprofile]', isset($visible['useprofile']), 'useprofile', S_ORIGINAL), S_USE_PROFILE), new CCheckBox('useprofile', $useprofile, 'submit()'));
    // BEGIN: HOSTS PROFILE EXTENDED Section
    $frmHost->addRow(array(new CVisibilityBox('visible[useprofile_ext]', isset($visible['useprofile_ext']), 'useprofile_ext', S_ORIGINAL), S_USE_EXTENDED_PROFILE), new CCheckBox('useprofile_ext', $useprofile_ext, 'submit()'));
    // END:   HOSTS PROFILE EXTENDED Section
    if ($useprofile === 'yes') {
        if ($useprofile === 'yes') {
            foreach ($profile_fields as $field => $caption) {
                $frmHost->addRow(array(new CVisibilityBox('visible[' . $field . ']', isset($visible[$field]), 'host_profile[' . $field . ']', S_ORIGINAL), $caption), new CTextBox('host_profile[' . $field . ']', $host_profile[$field], 80));
            }
        } else {
            foreach ($profile_fields as $field => $caption) {
                $frmHost->addVar('host_profile[' . $field . ']', $host_profile[$field]);
            }
        }
    }
    // BEGIN: HOSTS PROFILE EXTENDED Section
    if ($useprofile_ext == 'yes') {
        foreach ($ext_profiles_fields as $prof_field => $caption) {
            $frmHost->addRow(array(new CVisibilityBox('visible[' . $prof_field . ']', isset($visible[$prof_field]), 'ext_host_profiles[' . $prof_field . ']', S_ORIGINAL), $caption), new CTextBox('ext_host_profiles[' . $prof_field . ']', $ext_host_profiles[$prof_field], 80));
        }
    } else {
        foreach ($ext_profiles_fields as $prof_field => $caption) {
            $frmHost->addVar('ext_host_profiles[' . $prof_field . ']', $ext_host_profiles[$prof_field]);
        }
    }
    // END:   HOSTS PROFILE EXTENDED Section
    $frmHost->addItemToBottomRow(new CButton('masssave', S_SAVE));
    $frmHost->addItemToBottomRow(SPACE);
    $frmHost->addItemToBottomRow(new CButtonCancel(url_param('config') . url_param('groupid')));
    return $frmHost;
}
Beispiel #11
0
 //Oidview
 $oid_view_w = new CWidget();
 $oid_view_w->setClass('header');
 $oid_view_w->addHeader(array("Oid View - click to view as table:", new CCheckBox('viewtype', 'no', 'onViewType()', 1)));
 $oid_view_div = new CDiv();
 $oid_view_div->setAttribute("id", "oidview");
 $oid_view_div->addStyle("overflow: auto; max-height: 250px; width: 800px");
 $oid_view_w->addItem($oid_view_div);
 $right_tab->addRow($oid_view_w);
 //Itemlist
 $item_list_w = new CWidget();
 $item_list_w->setClass('header');
 $item_list_w->addHeader("Item List");
 $item_list_div = new CDiv();
 $item_list_div->setAttribute("id", "itemlist");
 $item_list_div->addStyle("overflow: auto; max-height: 150px; width: 800px");
 $item_list_w->addItem($item_list_div);
 $right_tab->addRow($item_list_w);
 //Action srow
 $action_w = new CWidget();
 $action_w->setClass('header');
 $action_w->addHeader(array(new CButton('save', 'Save', 'javascript: onSaveItems()'), SPACE, new CButton('clear', 'Clear List', 'javascript: onClearItems()')));
 //$action_div = new CDiv();
 //$action_w->addItem($action_div);
 $right_tab->addRow($action_w);
 // Left panel
 $td_l = new CCol($left_tab);
 $td_l->setAttribute('valign', 'top');
 $td_l->setAttribute('width', '300px');
 //Right panel
 $td_r = new CCol($right_tab);