本文整理汇总了PHP中order_result函数的典型用法代码示例。如果您正苦于以下问题:PHP order_result函数的具体用法?PHP order_result怎么用?PHP order_result使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了order_result函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doAction
protected function doAction()
{
$data = ['sid' => $this->getUserSID(), 'eventids' => $this->getInput('eventids'), 'message' => $this->getInput('message', ''), 'acknowledge_type' => $this->getInput('acknowledge_type', ZBX_ACKNOWLEDGE_SELECTED), 'backurl' => $this->getInput('backurl', 'tr_status.php'), 'unack_problem_events_count' => 0, 'unack_events_count' => 0];
if (count($this->getInput('eventids')) == 1) {
$events = API::Event()->get(['output' => [], 'eventids' => $this->getInput('eventids'), 'source' => EVENT_SOURCE_TRIGGERS, 'object' => EVENT_OBJECT_TRIGGER, 'select_acknowledges' => ['clock', 'message', 'alias', 'name', 'surname']]);
if ($events) {
$data['event'] = ['acknowledges' => $events[0]['acknowledges']];
order_result($data['acknowledges'], 'clock', ZBX_SORT_DOWN);
}
}
$events = API::Event()->get(['output' => ['objectid', 'acknowledged', 'value'], 'eventids' => $this->getInput('eventids'), 'source' => EVENT_SOURCE_TRIGGERS, 'object' => EVENT_OBJECT_TRIGGER]);
$triggerids = [];
foreach ($events as $event) {
if ($event['acknowledged'] == EVENT_ACKNOWLEDGED) {
$data['unack_problem_events_count']++;
$data['unack_events_count']++;
} elseif ($event['value'] == TRIGGER_VALUE_FALSE) {
$data['unack_problem_events_count']++;
}
$triggerids[$event['objectid']] = true;
}
$triggerids = array_keys($triggerids);
$data['unack_problem_events_count'] += API::Event()->get(['countOutput' => true, 'source' => EVENT_SOURCE_TRIGGERS, 'object' => EVENT_OBJECT_TRIGGER, 'objectids' => $triggerids, 'filter' => ['acknowledged' => EVENT_NOT_ACKNOWLEDGED, 'value' => TRIGGER_VALUE_TRUE]]);
$data['unack_events_count'] += API::Event()->get(['countOutput' => true, 'source' => EVENT_SOURCE_TRIGGERS, 'object' => EVENT_OBJECT_TRIGGER, 'objectids' => $triggerids, 'filter' => ['acknowledged' => EVENT_NOT_ACKNOWLEDGED]]);
$response = new CControllerResponseData($data);
$response->setTitle(_('Alarm acknowledgements'));
$this->setResponse($response);
}
示例2: doAction
protected function doAction()
{
$sortField = $this->getInput('sort', CProfile::get('web.proxies.php.sort', 'host'));
$sortOrder = $this->getInput('sortorder', CProfile::get('web.proxies.php.sortorder', ZBX_SORT_UP));
CProfile::update('web.proxies.php.sort', $sortField, PROFILE_TYPE_STR);
CProfile::update('web.proxies.php.sortorder', $sortOrder, PROFILE_TYPE_STR);
$config = select_config();
$data = ['uncheck' => $this->hasInput('uncheck'), 'sort' => $sortField, 'sortorder' => $sortOrder, 'config' => ['max_in_table' => $config['max_in_table']]];
$data['proxies'] = API::Proxy()->get(['output' => ['proxyid', 'host', 'status', 'lastaccess', 'tls_connect', 'tls_accept'], 'selectHosts' => ['hostid', 'name', 'status'], 'sortfield' => $sortField, 'limit' => $config['search_limit'] + 1, 'editable' => true, 'preservekeys' => true]);
// sorting & paging
order_result($data['proxies'], $sortField, $sortOrder);
$url = (new CUrl('zabbix.php'))->setArgument('action', 'proxy.list');
$data['paging'] = getPagingLine($data['proxies'], $sortOrder, $url);
foreach ($data['proxies'] as &$proxy) {
order_result($proxy['hosts'], 'name');
}
unset($proxy);
// get proxy IDs for a *selected* page
$proxyIds = array_keys($data['proxies']);
if ($proxyIds) {
// calculate performance
$dbPerformance = DBselect('SELECT h.proxy_hostid,SUM(1.0/i.delay) AS qps' . ' FROM hosts h,items i' . ' WHERE h.hostid=i.hostid' . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND i.delay<>0' . ' AND i.flags<>' . ZBX_FLAG_DISCOVERY_PROTOTYPE . ' AND ' . dbConditionInt('h.proxy_hostid', $proxyIds) . ' GROUP BY h.proxy_hostid');
while ($performance = DBfetch($dbPerformance)) {
$data['proxies'][$performance['proxy_hostid']]['perf'] = round($performance['qps'], 2);
}
// get items
$items = API::Item()->get(['proxyids' => $proxyIds, 'groupCount' => true, 'countOutput' => true, 'webitems' => true, 'monitored' => true]);
foreach ($items as $item) {
$data['proxies'][$item['proxy_hostid']]['item_count'] = $item['rowscount'];
}
}
$response = new CControllerResponseData($data);
$response->setTitle(_('Configuration of proxies'));
$this->setResponse($response);
}
示例3: doAction
protected function doAction()
{
$sortField = $this->getInput('sort', CProfile::get('web.media_types.php.sort', 'description'));
$sortOrder = $this->getInput('sortorder', CProfile::get('web.media_types.php.sortorder', ZBX_SORT_UP));
CProfile::update('web.media_type.php.sort', $sortField, PROFILE_TYPE_STR);
CProfile::update('web.media_types.php.sortorder', $sortOrder, PROFILE_TYPE_STR);
$config = select_config();
$data = ['uncheck' => $this->hasInput('uncheck'), 'sort' => $sortField, 'sortorder' => $sortOrder];
// get media types
$data['mediatypes'] = API::Mediatype()->get(['output' => ['mediatypeid', 'description', 'type', 'smtp_server', 'smtp_helo', 'smtp_email', 'exec_path', 'gsm_modem', 'username', 'status'], 'limit' => $config['search_limit'] + 1, 'editable' => true, 'preservekeys' => true]);
if ($data['mediatypes']) {
// get media types used in actions
$actions = API::Action()->get(['output' => ['actionid', 'name'], 'selectOperations' => ['operationtype', 'opmessage'], 'mediatypeids' => array_keys($data['mediatypes'])]);
foreach ($data['mediatypes'] as &$mediaType) {
$mediaType['typeid'] = $mediaType['type'];
$mediaType['type'] = media_type2str($mediaType['type']);
$mediaType['listOfActions'] = [];
foreach ($actions as $action) {
foreach ($action['operations'] as $operation) {
if ($operation['operationtype'] == OPERATION_TYPE_MESSAGE && $operation['opmessage']['mediatypeid'] == $mediaType['mediatypeid']) {
$mediaType['listOfActions'][$action['actionid']] = ['actionid' => $action['actionid'], 'name' => $action['name']];
}
}
}
order_result($mediaType['listOfActions'], 'name');
}
unset($mediaType);
order_result($data['mediatypes'], $sortField, $sortOrder);
}
$url = (new CUrl('zabbix.php'))->setArgument('action', 'mediatype.list');
$data['paging'] = getPagingLine($data['mediatypes'], $sortOrder, $url);
$response = new CControllerResponseData($data);
$response->setTitle(_('Configuration of media types'));
$this->setResponse($response);
}
示例4: doAction
protected function doAction()
{
$sortField = $this->getInput('sort', CProfile::get('web.scripts.php.sort', 'name'));
$sortOrder = $this->getInput('sortorder', CProfile::get('web.scripts.php.sortorder', ZBX_SORT_UP));
CProfile::update('web.scripts.php.sort', $sortField, PROFILE_TYPE_STR);
CProfile::update('web.scripts.php.sortorder', $sortOrder, PROFILE_TYPE_STR);
$config = select_config();
$data = ['uncheck' => $this->hasInput('uncheck'), 'sort' => $sortField, 'sortorder' => $sortOrder];
// list of scripts
$data['scripts'] = API::Script()->get(['output' => ['scriptid', 'name', 'command', 'host_access', 'usrgrpid', 'groupid', 'type', 'execute_on'], 'editable' => true, 'limit' => $config['search_limit'] + 1]);
// sorting & paging
order_result($data['scripts'], $sortField, $sortOrder);
$url = (new CUrl('zabbix.php'))->setArgument('action', 'script.list');
$data['paging'] = getPagingLine($data['scripts'], $sortOrder, $url);
// find script host group name and user group name. set to '' if all host/user groups used.
$usrgrpids = [];
$groupids = [];
foreach ($data['scripts'] as &$script) {
$script['userGroupName'] = null;
// all user groups
$script['hostGroupName'] = null;
// all host groups
if ($script['usrgrpid'] != 0) {
$usrgrpids[] = $script['usrgrpid'];
}
if ($script['groupid'] != 0) {
$groupids[] = $script['groupid'];
}
}
unset($script);
if ($usrgrpids) {
$userGroups = API::UserGroup()->get(['output' => ['name'], 'usrgrpids' => $usrgrpids, 'preservekeys' => true]);
foreach ($data['scripts'] as &$script) {
if ($script['usrgrpid'] != 0 && array_key_exists($script['usrgrpid'], $userGroups)) {
$script['userGroupName'] = $userGroups[$script['usrgrpid']]['name'];
}
unset($script['usrgrpid']);
}
unset($script);
}
if ($groupids) {
$hostGroups = API::HostGroup()->get(['output' => ['name'], 'groupids' => $groupids, 'preservekeys' => true]);
foreach ($data['scripts'] as &$script) {
if ($script['groupid'] != 0 && array_key_exists($script['groupid'], $hostGroups)) {
$script['hostGroupName'] = $hostGroups[$script['groupid']]['name'];
}
unset($script['groupid']);
}
unset($script);
}
$response = new CControllerResponseData($data);
$response->setTitle(_('Configuration of scripts'));
$this->setResponse($response);
}
示例5: discovery_check_type2str
function discovery_check_type2str($type = null)
{
$discovery_types = array(SVC_SSH => S_SSH, SVC_LDAP => S_LDAP, SVC_SMTP => S_SMTP, SVC_FTP => S_FTP, SVC_HTTP => S_HTTP, SVC_POP => S_POP, SVC_NNTP => S_NNTP, SVC_IMAP => S_IMAP, SVC_TCP => S_TCP, SVC_AGENT => S_ZABBIX_AGENT, SVC_SNMPv1 => S_SNMPV1_AGENT, SVC_SNMPv2 => S_SNMPV2_AGENT, SVC_SNMPv3 => S_SNMPV3_AGENT, SVC_ICMPPING => S_ICMPPING);
if (is_null($type)) {
order_result($discovery_types);
return $discovery_types;
} else {
if (isset($discovery_types[$type])) {
return $discovery_types[$type];
} else {
return S_UNKNOWN;
}
}
}
示例6: doAction
protected function doAction()
{
// default values
$data = ['sid' => $this->getUserSID(), 'scriptid' => 0, 'name' => '', 'type' => ZBX_SCRIPT_TYPE_CUSTOM_SCRIPT, 'execute_on' => ZBX_SCRIPT_EXECUTE_ON_AGENT, 'command' => '', 'commandipmi' => '', 'description' => '', 'usrgrpid' => 0, 'groupid' => 0, 'host_access' => 0, 'confirmation' => '', 'enable_confirmation' => 0, 'hgstype' => 0];
// get values from the dabatase
if ($this->hasInput('scriptid')) {
$scripts = API::Script()->get(['output' => ['scriptid', 'name', 'type', 'execute_on', 'command', 'description', 'usrgrpid', 'groupid', 'host_access', 'confirmation'], 'scriptids' => $this->getInput('scriptid')]);
$script = $scripts[0];
$data['scriptid'] = $script['scriptid'];
$data['name'] = $script['name'];
$data['type'] = $script['type'];
$data['execute_on'] = $script['execute_on'];
$data['command'] = $script['type'] == ZBX_SCRIPT_TYPE_CUSTOM_SCRIPT ? $script['command'] : '';
$data['commandipmi'] = $script['type'] == ZBX_SCRIPT_TYPE_IPMI ? $script['command'] : '';
$data['description'] = $script['description'];
$data['usrgrpid'] = $script['usrgrpid'];
$data['groupid'] = $script['groupid'];
$data['host_access'] = $script['host_access'];
$data['confirmation'] = $script['confirmation'];
$data['enable_confirmation'] = $script['confirmation'] !== '';
$data['hgstype'] = $script['groupid'] != 0 ? 1 : 0;
}
// overwrite with input variables
$this->getInputs($data, ['name', 'type', 'execute_on', 'command', 'commandipmi', 'description', 'usrgrpid', 'groupid', 'host_access', 'confirmation', 'enable_confirmation', 'hgstype']);
// get host group
if ($data['groupid'] == 0) {
$data['hostgroup'] = null;
} else {
$hostgroups = API::HostGroup()->get(['groupids' => [$data['groupid']], 'output' => ['groupid', 'name']]);
$hostgroup = $hostgroups[0];
$data['hostgroup'][] = ['id' => $hostgroup['groupid'], 'name' => $hostgroup['name']];
}
// get list of user groups
$usergroups = API::UserGroup()->get(['output' => ['usrgrpid', 'name']]);
order_result($usergroups, 'name');
$data['usergroups'] = $usergroups;
$response = new CControllerResponseData($data);
$response->setTitle(_('Configuration of scripts'));
$this->setResponse($response);
}
示例7: CTableInfo
$table = new CTableInfo(_('No hosts found.'));
$table->setHeader(array(make_sorting_header($groupFieldTitle === '' ? _('Field') : $groupFieldTitle, 'inventory_field', $sortField, $sortOrder), make_sorting_header(_('Host count'), 'host_count', $sortField, $sortOrder)));
// to show a report, we will need a host group and a field to aggregate
if ($pageFilter->groupsSelected && $groupFieldTitle !== '') {
$options = array('output' => array('hostid', 'name'), 'selectInventory' => array($_REQUEST['groupby']), 'withInventory' => true);
if ($pageFilter->groupid > 0) {
$options['groupids'] = $pageFilter->groupid;
}
$hosts = API::Host()->get($options);
// aggregating data by chosen field value
$report = array();
foreach ($hosts as $host) {
if ($host['inventory'][$_REQUEST['groupby']] !== '') {
// same names with different letter casing are considered the same
$lowerValue = mb_strtolower($host['inventory'][$_REQUEST['groupby']]);
if (!isset($report[$lowerValue])) {
$report[$lowerValue] = array('inventory_field' => $host['inventory'][$_REQUEST['groupby']], 'host_count' => 1);
} else {
$report[$lowerValue]['host_count'] += 1;
}
}
}
order_result($report, $sortField, $sortOrder);
foreach ($report as $rep) {
$row = array(new CSpan(zbx_str2links($rep['inventory_field']), 'pre'), new CLink($rep['host_count'], 'hostinventories.php?filter_field=' . $_REQUEST['groupby'] . '&filter_field_value=' . urlencode($rep['inventory_field']) . '&filter_set=1&filter_exact=1' . url_param('groupid')));
$table->addRow($row);
}
}
$hostinvent_wdgt->addItem($table);
$hostinvent_wdgt->show();
require_once dirname(__FILE__) . '/include/page_footer.php';
示例8: CSpan
$cbFilter = new CSpan(S_DISABLED, 'red underline pointer');
$cbFilter->setAttribute('onclick', "\$('dashform').enable(); create_var('" . $dashForm->getName() . "', 'filterEnable', 1, true);");
}
$dashForm->addRow(S_DASHBOARD_FILTER, $cbFilter);
$dashForm->addVar('groupids', $groupids);
$cmbGroups = new CComboBox('grpswitch', $grpswitch, 'submit();');
$cmbGroups->addItem(0, S_ALL_S);
$cmbGroups->addItem(1, S_SELECTED);
if (!$filterEnable) {
$cmbGroups->setAttribute('disabled', 'disabled');
}
$dashForm->addRow(S_HOST_GROUPS, $cmbGroups);
if ($grpswitch == 1) {
$options = array('nodeids' => get_current_nodeid(true), 'groupids' => $groupids, 'output' => API_OUTPUT_EXTEND);
$groups = CHostGroup::get($options);
order_result($groups, 'name');
$lstGroups = new CListBox('del_groups[]', null, 15);
$lstGroups->setAttribute('style', 'width: 200px;');
foreach ($groups as $gnum => $group) {
$lstGroups->addItem($group['groupid'], get_node_name_by_elid($group['groupid'], true, ':') . $group['name']);
}
if (!$filterEnable) {
$lstGroups->setAttribute('disabled', 'disabled');
}
$addButton = new CButton('add', S_ADD, "return PopUp('popup_right.php?dstfrm=" . $dashForm->getName() . "&permission=" . PERM_READ_WRITE . "',450,450);");
if (!$filterEnable) {
$addButton->setAttribute('disabled', 'disabled');
}
$delButton = new CButton('delete', S_DELETE_SELECTED);
if (!$filterEnable) {
$delButton->setAttribute('disabled', 'disabled');
示例9: CLink
$name[] = new CLink($sourceTemplate['name'], '?parent_discoveryid=' . $hostPrototype['sourceDiscoveryRuleId'], 'unknown');
$name[] = NAME_DELIMITER;
}
$name[] = new CLink($hostPrototype['name'], '?form=update&parent_discoveryid=' . $discoveryRule['itemid'] . '&hostid=' . $hostPrototype['hostid']);
// template list
if (empty($hostPrototype['templates'])) {
$hostTemplates = '-';
} else {
$hostTemplates = array();
order_result($hostPrototype['templates'], 'name');
foreach ($hostPrototype['templates'] as $template) {
$caption = array();
$caption[] = new CLink($template['name'], 'templates.php?form=update&templateid=' . $template['templateid'], 'unknown');
$linkedTemplates = $this->data['linkedTemplates'][$template['templateid']]['parentTemplates'];
if ($linkedTemplates) {
order_result($linkedTemplates, 'name');
$caption[] = ' (';
foreach ($linkedTemplates as $tpl) {
$caption[] = new CLink($tpl['name'], 'templates.php?form=update&templateid=' . $tpl['templateid'], 'unknown');
$caption[] = ', ';
}
array_pop($caption);
$caption[] = ')';
}
$hostTemplates[] = $caption;
$hostTemplates[] = ', ';
}
if ($hostTemplates) {
array_pop($hostTemplates);
}
}
示例10: drawMapLinkLabels
function drawMapLinkLabels(&$im, $map, $mapInfo, $resolveMacros = true)
{
global $colors;
$links = $map['links'];
$selements = $map['selements'];
foreach ($links as $link) {
if (empty($link['label'])) {
continue;
}
$selement1 = $selements[$link['selementid1']];
list($x1, $y1) = get_icon_center_by_selement($selement1, $mapInfo[$link['selementid1']], $map);
$selement2 = $selements[$link['selementid2']];
list($x2, $y2) = get_icon_center_by_selement($selement2, $mapInfo[$link['selementid2']], $map);
if (isset($selement1['elementsubtype']) && $selement1['elementsubtype'] == SYSMAP_ELEMENT_AREA_TYPE_CUSTOM) {
if ($selement1['areatype'] == SYSMAP_ELEMENT_AREA_TYPE_CUSTOM) {
$w = $selement1['width'];
$h = $selement1['height'];
} else {
$w = $map['width'];
$h = $map['height'];
}
list($x1, $y1) = calculateMapAreaLinkCoord($x1, $y1, $w, $h, $x2, $y2);
}
if (isset($selement2['elementsubtype']) && $selement2['elementsubtype'] == SYSMAP_ELEMENT_AREA_TYPE_CUSTOM) {
if ($selement2['areatype'] == SYSMAP_ELEMENT_AREA_TYPE_CUSTOM) {
$w = $selement2['width'];
$h = $selement2['height'];
} else {
$w = $map['width'];
$h = $map['height'];
}
list($x2, $y2) = calculateMapAreaLinkCoord($x2, $y2, $w, $h, $x1, $y1);
}
$drawtype = $link['drawtype'];
$color = convertColor($im, $link['color']);
$linktriggers = $link['linktriggers'];
order_result($linktriggers, 'triggerid');
if (!empty($linktriggers)) {
$max_severity = 0;
$triggers = array();
foreach ($linktriggers as $link_trigger) {
if ($link_trigger['triggerid'] == 0) {
continue;
}
$id = $link_trigger['linktriggerid'];
$triggers[$id] = zbx_array_merge($link_trigger, get_trigger_by_triggerid($link_trigger['triggerid']));
if ($triggers[$id]['status'] == TRIGGER_STATUS_ENABLED && $triggers[$id]['value'] == TRIGGER_VALUE_TRUE) {
if ($triggers[$id]['priority'] >= $max_severity) {
$drawtype = $triggers[$id]['drawtype'];
$color = convertColor($im, $triggers[$id]['color']);
$max_severity = $triggers[$id]['priority'];
}
}
}
}
$label = $link['label'];
$label = str_replace("\r", '', $label);
$strings = explode("\n", $label);
$box_width = 0;
$box_height = 0;
foreach ($strings as $snum => $str) {
$strings[$snum] = $resolveMacros ? CMacrosResolverHelper::resolveMapLabelMacros($str) : $str;
}
foreach ($strings as $str) {
$dims = imageTextSize(8, 0, $str);
$box_width = $box_width > $dims['width'] ? $box_width : $dims['width'];
$box_height += $dims['height'] + 2;
}
$boxX_left = round(($x1 + $x2) / 2 - $box_width / 2 - 6);
$boxX_right = round(($x1 + $x2) / 2 + $box_width / 2 + 6);
$boxY_top = round(($y1 + $y2) / 2 - $box_height / 2 - 4);
$boxY_bottom = round(($y1 + $y2) / 2 + $box_height / 2 + 2);
switch ($drawtype) {
case MAP_LINK_DRAWTYPE_DASHED_LINE:
case MAP_LINK_DRAWTYPE_DOT:
dashedRectangle($im, $boxX_left, $boxY_top, $boxX_right, $boxY_bottom, $color);
break;
case MAP_LINK_DRAWTYPE_BOLD_LINE:
imagerectangle($im, $boxX_left - 1, $boxY_top - 1, $boxX_right + 1, $boxY_bottom + 1, $color);
// break; is not ne
// break; is not ne
case MAP_LINK_DRAWTYPE_LINE:
default:
imagerectangle($im, $boxX_left, $boxY_top, $boxX_right, $boxY_bottom, $color);
}
imagefilledrectangle($im, $boxX_left + 1, $boxY_top + 1, $boxX_right - 1, $boxY_bottom - 1, $colors['White']);
$increasey = 4;
foreach ($strings as $str) {
$dims = imageTextSize(8, 0, $str);
$labelx = ($x1 + $x2) / 2 - $dims['width'] / 2;
$labely = $boxY_top + $increasey;
imagetext($im, 8, 0, $labelx, $labely + $dims['height'], $colors['Black'], $str);
$increasey += $dims['height'] + 2;
}
}
}
示例11: get
//.........这里部分代码省略.........
$result[$dservice['dserviceid']]['drules'] = array();
}
$result[$dservice['dserviceid']]['drules'][] = array('druleid' => $dservice['druleid']);
}
// dhostids
if (isset($dservice['dhostid']) && is_null($options['selectDHosts'])) {
if (!isset($result[$dservice['dserviceid']]['dhosts'])) {
$result[$dservice['dserviceid']]['dhosts'] = array();
}
$result[$dservice['dserviceid']]['dhosts'][] = array('dhostid' => $dservice['dhostid']);
}
// dcheckids
if (isset($dservice['dcheckid']) && is_null($options['selectDChecks'])) {
if (!isset($result[$dservice['dserviceid']]['dchecks'])) {
$result[$dservice['dserviceid']]['dchecks'] = array();
}
$result[$dservice['dserviceid']]['dchecks'][] = array('dcheckid' => $dservice['dcheckid']);
}
$result[$dservice['dserviceid']] += $dservice;
}
}
}
if (!is_null($options['countOutput'])) {
return $result;
}
// Adding Objects
// select_drules
if (!is_null($options['selectDRules'])) {
$objParams = array('nodeids' => $nodeids, 'dserviceids' => $dserviceids, 'preservekeys' => 1);
if (is_array($options['selectDRules']) || str_in_array($options['selectDRules'], $subselectsAllowedOutputs)) {
$objParams['output'] = $options['selectDRules'];
$drules = API::DRule()->get($objParams);
if (!is_null($options['limitSelects'])) {
order_result($drules, 'name');
}
foreach ($drules as $druleid => $drule) {
unset($drules[$druleid]['dservices']);
$count = array();
foreach ($drule['dservices'] as $dnum => $dservice) {
if (!is_null($options['limitSelects'])) {
if (!isset($count[$dservice['dserviceid']])) {
$count[$dservice['dserviceid']] = 0;
}
$count[$dservice['dserviceid']]++;
if ($count[$dservice['dserviceid']] > $options['limitSelects']) {
continue;
}
}
$result[$dservice['dserviceid']]['drules'][] =& $drules[$druleid];
}
}
} elseif (API_OUTPUT_COUNT == $options['selectDRules']) {
$objParams['countOutput'] = 1;
$objParams['groupCount'] = 1;
$drules = API::DRule()->get($objParams);
$drules = zbx_toHash($drules, 'dserviceid');
foreach ($result as $dserviceid => $dservice) {
if (isset($drules[$dserviceid])) {
$result[$dserviceid]['drules'] = $drules[$dserviceid]['rowscount'];
} else {
$result[$dserviceid]['drules'] = 0;
}
}
}
}
// selectDHosts
示例12: navigation_bar_calc
if (getRequest('favobj') === 'timeline' && hasRequest('elementid') && hasRequest('period')) {
navigation_bar_calc('web.hostscreen', getRequest('elementid'), true);
}
if ($page['type'] == PAGE_TYPE_JS || $page['type'] == PAGE_TYPE_HTML_BLOCK) {
require_once dirname(__FILE__) . '/include/page_footer.php';
exit;
}
/*
* Display
*/
$data = array('hostid' => getRequest('hostid', 0), 'fullscreen' => $_REQUEST['fullscreen'], 'screenid' => getRequest('screenid', CProfile::get('web.hostscreen.screenid', null)), 'period' => getRequest('period'), 'stime' => getRequest('stime'));
CProfile::update('web.hostscreen.screenid', $data['screenid'], PROFILE_TYPE_ID);
// get screen list
$data['screens'] = API::TemplateScreen()->get(array('hostids' => $data['hostid'], 'output' => API_OUTPUT_EXTEND));
$data['screens'] = zbx_toHash($data['screens'], 'screenid');
order_result($data['screens'], 'name');
// get screen
$screenid = null;
if (!empty($data['screens'])) {
$screen = !isset($data['screens'][$data['screenid']]) ? reset($data['screens']) : $data['screens'][$data['screenid']];
if (!empty($screen['screenid'])) {
$screenid = $screen['screenid'];
}
}
$data['screen'] = API::TemplateScreen()->get(array('screenids' => $screenid, 'hostids' => $data['hostid'], 'output' => API_OUTPUT_EXTEND, 'selectScreenItems' => API_OUTPUT_EXTEND));
$data['screen'] = reset($data['screen']);
// get host
if (!empty($data['screen']['hostid'])) {
$data['host'] = get_host_by_hostid($data['screen']['hostid']);
}
// render view
示例13: CUrl
$sortLink = new CUrl();
$sortLink->setArgument('parent_discoveryid', $this->data['parent_discoveryid']);
$sortLink = $sortLink->getUrl();
$itemTable->setHeader(array(new CCheckBox('all_items', null, "checkAll('" . $itemForm->getName() . "', 'all_items', 'group_itemid');"), make_sorting_header(_('Name'), 'name', $sortLink), make_sorting_header(_('Key'), 'key_', $sortLink), make_sorting_header(_('Interval'), 'delay', $sortLink), make_sorting_header(_('History'), 'history', $sortLink), make_sorting_header(_('Trends'), 'trends', $sortLink), make_sorting_header(_('Type'), 'type', $sortLink), _('Applications'), make_sorting_header(_('Status'), 'status', $sortLink)));
foreach ($this->data['items'] as $item) {
$description = array();
if (!empty($item['templateid'])) {
$template_host = get_realhost_by_itemid($item['templateid']);
$templateDiscoveryRuleId = get_realrule_by_itemid_and_hostid($this->data['parent_discoveryid'], $template_host['hostid']);
$description[] = new CLink($template_host['name'], '?parent_discoveryid=' . $templateDiscoveryRuleId, 'unknown');
$description[] = NAME_DELIMITER;
}
$description[] = new CLink($item['name_expanded'], '?form=update&itemid=' . $item['itemid'] . '&parent_discoveryid=' . $this->data['parent_discoveryid']);
$status = new CLink(itemIndicator($item['status']), '?group_itemid=' . $item['itemid'] . '&parent_discoveryid=' . $this->data['parent_discoveryid'] . '&go=' . ($item['status'] ? 'activate' : 'disable'), itemIndicatorStyle($item['status']));
if (!empty($item['applications'])) {
order_result($item['applications'], 'name');
$applications = zbx_objectValues($item['applications'], 'name');
$applications = implode(', ', $applications);
if (empty($applications)) {
$applications = '-';
}
} else {
$applications = '-';
}
$itemTable->addRow(array(new CCheckBox('group_itemid[' . $item['itemid'] . ']', null, null, $item['itemid']), $description, $item['key_'], $item['delay'], $item['history'], in_array($item['value_type'], array(ITEM_VALUE_TYPE_STR, ITEM_VALUE_TYPE_LOG, ITEM_VALUE_TYPE_TEXT)) ? '' : $item['trends'], item_type2str($item['type']), new CCol($applications, 'wraptext'), $status));
}
// create go buttons
$goComboBox = new CComboBox('go');
$goOption = new CComboItem('activate', _('Enable selected'));
$goOption->setAttribute('confirm', _('Enable selected item prototypes?'));
$goComboBox->addItem($goOption);
示例14: getTriggersOverview
/**
* Creates and returns the trigger overview table for the given hosts.
*
* @param array $hostIds
* @param string $application name of application to filter
* @param string $pageFile the page where the element is displayed
* @param int $viewMode table display style: either hosts on top, or host on the left side
* @param string $screenId the ID of the screen, that contains the trigger overview table
*
* @return CTableInfo
*/
function getTriggersOverview($hostIds, $application, $pageFile, $viewMode = null, $screenId = null)
{
if (is_null($viewMode)) {
$viewMode = CProfile::get('web.overview.view.style', STYLE_TOP);
}
// get application ids
$applicationIds = null;
if ($application !== '') {
$dbApplications = API::Application()->get(array('hostids' => $hostIds, 'filter' => array('name' => $application), 'output' => array('applicationid')));
$applicationIds = zbx_objectValues($dbApplications, 'applicationid');
$hostIds = null;
}
// get triggers
$dbTriggers = API::Trigger()->get(array('hostids' => $hostIds, 'applicationids' => $applicationIds, 'monitored' => true, 'skipDependent' => true, 'output' => API_OUTPUT_EXTEND, 'selectHosts' => array('hostid', 'name'), 'sortfield' => 'description'));
// get hosts
$hostIds = array();
foreach ($dbTriggers as $trigger) {
$host = reset($trigger['hosts']);
$hostIds[$host['hostid']] = $host['hostid'];
}
$hosts = API::Host()->get(array('output' => array('name', 'hostid', 'status'), 'hostids' => $hostIds, 'preservekeys' => true, 'selectScreens' => $viewMode == STYLE_LEFT ? API_OUTPUT_COUNT : null));
$triggers = array();
$hostNames = array();
foreach ($dbTriggers as $trigger) {
$host = reset($trigger['hosts']);
$host['name'] = get_node_name_by_elid($host['hostid'], null, NAME_DELIMITER) . $host['name'];
$trigger['description'] = CMacrosResolverHelper::resolveTriggerReference($trigger['expression'], $trigger['description']);
$hostNames[$host['hostid']] = $host['name'];
// a little tricky check for attempt to overwrite active trigger (value=1) with
// inactive or active trigger with lower priority.
if (!isset($triggers[$trigger['description']][$host['name']]) || ($triggers[$trigger['description']][$host['name']]['value'] == TRIGGER_VALUE_FALSE && $trigger['value'] == TRIGGER_VALUE_TRUE || ($triggers[$trigger['description']][$host['name']]['value'] == TRIGGER_VALUE_FALSE || $trigger['value'] == TRIGGER_VALUE_TRUE) && $trigger['priority'] > $triggers[$trigger['description']][$host['name']]['priority'])) {
$triggers[$trigger['description']][$host['name']] = array('hostid' => $host['hostid'], 'triggerid' => $trigger['triggerid'], 'value' => $trigger['value'], 'lastchange' => $trigger['lastchange'], 'priority' => $trigger['priority'], 'flags' => $trigger['flags'], 'url' => $trigger['url'], 'hosts' => array($host));
}
}
$triggerTable = new CTableInfo(_('No triggers found.'));
if (empty($hostNames)) {
return $triggerTable;
}
$triggerTable->makeVerticalRotation();
order_result($hostNames);
if ($viewMode == STYLE_TOP) {
// header
$header = array(new CCol(_('Triggers'), 'center'));
foreach ($hostNames as $hostName) {
$header[] = new CCol($hostName, 'vertical_rotation');
}
$triggerTable->setHeader($header, 'vertical_header');
// data
foreach ($triggers as $description => $triggerHosts) {
$columns = array(nbsp($description));
foreach ($hostNames as $hostName) {
$columns[] = getTriggerOverviewCells(isset($triggerHosts[$hostName]) ? $triggerHosts[$hostName] : null, $pageFile, $screenId);
}
$triggerTable->addRow($columns);
}
} else {
// header
$header = array(new CCol(_('Host'), 'center'));
foreach ($triggers as $description => $triggerHosts) {
$header[] = new CCol($description, 'vertical_rotation');
}
$triggerTable->setHeader($header, 'vertical_header');
// data
$scripts = API::Script()->getScriptsByHosts(zbx_objectValues($hosts, 'hostid'));
foreach ($hostNames as $hostId => $hostName) {
$name = new CSpan($hostName, 'link_menu');
$name->setMenuPopup(getMenuPopupHost($hosts[$hostId], $scripts[$hostId]));
$columns = array($name);
foreach ($triggers as $triggerHosts) {
$columns[] = getTriggerOverviewCells(isset($triggerHosts[$hostName]) ? $triggerHosts[$hostName] : null, $pageFile, $screenId);
}
$triggerTable->addRow($columns);
}
}
return $triggerTable;
}
示例15: mb_strtolower
$haystack = mb_strtolower($data['hosts'][$num]['inventory'][$data['filterField']]);
if ($haystack !== $needle) {
unset($data['hosts'][$num]);
}
}
}
$sort_fields = ['pr_name' => 'name', 'pr_type' => 'type', 'pr_os' => 'os', 'pr_serialno_a' => 'serialno_a', 'pr_tag' => 'tag', 'pr_macaddress_a' => 'macaddress_a'];
if (array_key_exists($sortField, $sort_fields)) {
// copying an inventory field into the upper array level for sorting
foreach ($data['hosts'] as &$host) {
$host[$sortField] = $host['inventory'][$sort_fields[$sortField]];
}
unset($host);
}
$limit = $data['config']['search_limit'] + 1;
order_result($data['hosts'], $sortField, $sortOrder);
if ($sortOrder == ZBX_SORT_UP) {
$data['hosts'] = array_slice($data['hosts'], 0, $limit);
} else {
$data['hosts'] = array_slice($data['hosts'], -$limit, $limit);
}
order_result($data['hosts'], $sortField, $sortOrder);
}
}
$url = (new CUrl('hostinventories.php'))->setArgument('groupid', $data['pageFilter']->groupid);
$data['paging'] = getPagingLine($data['hosts'], $sortOrder, $url);
$hostinventoriesView = new CView('inventory.host.list', $data);
$hostinventoriesView->render();
$hostinventoriesView->show();
}
require_once dirname(__FILE__) . '/include/page_footer.php';