当前位置: 首页>>代码示例>>PHP>>正文


PHP API::Template方法代码示例

本文整理汇总了PHP中API::Template方法的典型用法代码示例。如果您正苦于以下问题:PHP API::Template方法的具体用法?PHP API::Template怎么用?PHP API::Template使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在API的用法示例。


在下文中一共展示了API::Template方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: inherit

 /**
  * Updates the children of the trigger on the given hosts and propagates the inheritance to all child hosts.
  * If the given trigger was assigned to a different template or a host, all of the child triggers, that became
  * obsolete will be deleted.
  *
  * @param array $trigger    the trigger with an exploded expression
  * @param array $hostids
  *
  * @return bool
  */
 protected function inherit(array $trigger, array $hostIds = null)
 {
     $triggerTemplates = API::Template()->get(array('triggerids' => $trigger['triggerid'], 'output' => API_OUTPUT_EXTEND, 'nopermissions' => true));
     if (empty($triggerTemplates)) {
         // nothing to inherit, just exit
         return true;
     }
     if (!isset($trigger['expression']) || !isset($trigger['description'])) {
         $dbTriggers = $this->get(array('triggerids' => $trigger['triggerid'], 'output' => array('expression', 'description'), 'nopermissions' => true));
         $dbTrigger = reset($dbTriggers);
         if (!isset($trigger['description'])) {
             $trigger['description'] = $dbTrigger['description'];
         }
         if (!isset($trigger['expression'])) {
             $trigger['expression'] = explode_exp($dbTrigger['expression']);
         }
     }
     // fetch all of the child hosts
     $childHosts = API::Host()->get(array('templateids' => zbx_objectValues($triggerTemplates, 'templateid'), 'output' => array('hostid', 'host'), 'preservekeys' => true, 'hostids' => $hostIds, 'nopermissions' => true, 'templated_hosts' => true));
     foreach ($childHosts as $childHost) {
         // update the child trigger on the child host
         $newTrigger = $this->inheritOnHost($trigger, $childHost, $triggerTemplates);
         // propagate the trigger inheritance to all child hosts
         $this->inherit($newTrigger);
     }
     return true;
 }
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:37,代码来源:CTriggerGeneral.php

示例2: inherit

 /**
  * Updates the children of the trigger on the given hosts and propagates the inheritance to all child hosts.
  * If the given trigger was assigned to a different template or a host, all of the child triggers, that became
  * obsolete will be deleted.
  *
  * @param array $trigger    the trigger with an exploded expression
  * @param array $hostids
  *
  * @return bool
  */
 protected function inherit(array $trigger, array $hostids = null)
 {
     $triggerTemplates = API::Template()->get(array('triggerids' => $trigger['triggerid'], 'output' => API_OUTPUT_EXTEND, 'nopermissions' => true));
     // fetch the existing child triggers
     $templatedTriggers = $this->get(array('output' => array('triggerid', 'description'), 'filter' => array('templateid' => $trigger['triggerid']), 'selectHosts' => array('name'), 'preservekeys' => true));
     // no templates found, which means, that the trigger is no longer a templated trigger
     if (empty($triggerTemplates)) {
         // delete all of the former child triggers that may exist
         if ($templatedTriggers) {
             foreach ($templatedTriggers as $trigger) {
                 info(_s('Deleted: Trigger "%1$s" on "%2$s".', $trigger['description'], implode(', ', zbx_objectValues($trigger['hosts'], 'name'))));
             }
             $this->deleteByIds(zbx_objectValues($templatedTriggers, 'triggerid'));
         }
         // nothing to inherit, just exit
         return true;
     }
     if (!isset($trigger['expression']) || !isset($trigger['description'])) {
         $options = array('triggerids' => $trigger['triggerid'], 'output' => API_OUTPUT_EXTEND, 'preservekeys' => true, 'nopermissions' => true);
         $dbTrigger = $this->get($options);
         $dbTrigger = reset($dbTrigger);
         if (!isset($trigger['description'])) {
             $trigger['description'] = $dbTrigger['description'];
         }
         if (!isset($trigger['expression'])) {
             $trigger['expression'] = explode_exp($dbTrigger['expression']);
         }
     }
     // fetch all of the child hosts
     $chdHosts = API::Host()->get(array('templateids' => zbx_objectValues($triggerTemplates, 'templateid'), 'output' => array('hostid', 'host'), 'preservekeys' => true, 'hostids' => $hostids, 'nopermissions' => true, 'templated_hosts' => true));
     foreach ($chdHosts as $childHost) {
         // update the child trigger on the child host
         $newTrigger = $this->inheritOnHost($trigger, $childHost, $triggerTemplates);
         // propagate the trigger inheritance to all child hosts
         $this->inherit($newTrigger);
         unset($templatedTriggers[$newTrigger['triggerid']]);
     }
     // if we've updated the children of the trigger on all of the host, and there are still some children left,
     // we must delete them
     if ($templatedTriggers && !$hostids) {
         foreach ($templatedTriggers as $trigger) {
             info(_s('Deleted: Trigger "%1$s" on "%2$s".', $trigger['description'], implode(', ', zbx_objectValues($trigger['hosts'], 'name'))));
         }
         $this->deleteByIds(zbx_objectValues($templatedTriggers, 'triggerid'));
     }
     return true;
 }
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:57,代码来源:CTriggerGeneral.php

示例3: addRelatedObjects

 protected function addRelatedObjects(array $options, array $result)
 {
     $result = parent::addRelatedObjects($options, $result);
     $hostPrototypeIds = array_keys($result);
     // adding discovery rule
     if ($options['selectDiscoveryRule'] !== null && $options['selectDiscoveryRule'] != API_OUTPUT_COUNT) {
         $relationMap = $this->createRelationMap($result, 'hostid', 'parent_itemid', 'host_discovery');
         $discoveryRules = API::DiscoveryRule()->get(['output' => $options['selectDiscoveryRule'], 'itemids' => $relationMap->getRelatedIds(), 'nopermissions' => true, 'preservekeys' => true]);
         $result = $relationMap->mapOne($result, $discoveryRules, 'discoveryRule');
     }
     // adding group links
     if ($options['selectGroupLinks'] !== null && $options['selectGroupLinks'] != API_OUTPUT_COUNT) {
         $groupPrototypes = DBFetchArray(DBselect('SELECT hg.group_prototypeid,hg.hostid' . ' FROM group_prototype hg' . ' WHERE ' . dbConditionInt('hg.hostid', $hostPrototypeIds) . ' AND hg.groupid IS NOT NULL'));
         $relationMap = $this->createRelationMap($groupPrototypes, 'hostid', 'group_prototypeid');
         $groupPrototypes = API::getApiService()->select('group_prototype', ['output' => $options['selectGroupLinks'], 'group_prototypeids' => $relationMap->getRelatedIds(), 'preservekeys' => true]);
         foreach ($groupPrototypes as &$groupPrototype) {
             unset($groupPrototype['name']);
         }
         unset($groupPrototype);
         $result = $relationMap->mapMany($result, $groupPrototypes, 'groupLinks');
     }
     // adding group prototypes
     if ($options['selectGroupPrototypes'] !== null && $options['selectGroupPrototypes'] != API_OUTPUT_COUNT) {
         $groupPrototypes = DBFetchArray(DBselect('SELECT hg.group_prototypeid,hg.hostid' . ' FROM group_prototype hg' . ' WHERE ' . dbConditionInt('hg.hostid', $hostPrototypeIds) . ' AND hg.groupid IS NULL'));
         $relationMap = $this->createRelationMap($groupPrototypes, 'hostid', 'group_prototypeid');
         $groupPrototypes = API::getApiService()->select('group_prototype', ['output' => $options['selectGroupPrototypes'], 'group_prototypeids' => $relationMap->getRelatedIds(), 'preservekeys' => true]);
         foreach ($groupPrototypes as &$groupPrototype) {
             unset($groupPrototype['groupid']);
         }
         unset($groupPrototype);
         $result = $relationMap->mapMany($result, $groupPrototypes, 'groupPrototypes');
     }
     // adding host
     if ($options['selectParentHost'] !== null && $options['selectParentHost'] != API_OUTPUT_COUNT) {
         $relationMap = new CRelationMap();
         $dbRules = DBselect('SELECT hd.hostid,i.hostid AS parent_hostid' . ' FROM host_discovery hd,items i' . ' WHERE ' . dbConditionInt('hd.hostid', $hostPrototypeIds) . ' AND hd.parent_itemid=i.itemid');
         while ($relation = DBfetch($dbRules)) {
             $relationMap->addRelation($relation['hostid'], $relation['parent_hostid']);
         }
         $hosts = API::Host()->get(['output' => $options['selectParentHost'], 'hostids' => $relationMap->getRelatedIds(), 'templated_hosts' => true, 'nopermissions' => true, 'preservekeys' => true]);
         $result = $relationMap->mapOne($result, $hosts, 'parentHost');
     }
     // adding templates
     if ($options['selectTemplates'] !== null) {
         if ($options['selectTemplates'] != API_OUTPUT_COUNT) {
             $relationMap = $this->createRelationMap($result, 'hostid', 'templateid', 'hosts_templates');
             $templates = API::Template()->get(['output' => $options['selectTemplates'], 'templateids' => $relationMap->getRelatedIds(), 'preservekeys' => true]);
             $result = $relationMap->mapMany($result, $templates, 'templates');
         } else {
             $templates = API::Template()->get(['hostids' => $hostPrototypeIds, 'countOutput' => true, 'groupCount' => true]);
             $templates = zbx_toHash($templates, 'hostid');
             foreach ($result as $hostid => $host) {
                 $result[$hostid]['templates'] = isset($templates[$hostid]) ? $templates[$hostid]['rowscount'] : 0;
             }
         }
     }
     // adding inventory
     if ($options['selectInventory'] !== null) {
         $relationMap = $this->createRelationMap($result, 'hostid', 'hostid');
         // only allow to retrieve the hostid and inventory_mode fields
         $output = [];
         if ($this->outputIsRequested('hostid', $options['selectInventory'])) {
             $output[] = 'hostid';
         }
         if ($this->outputIsRequested('inventory_mode', $options['selectInventory'])) {
             $output[] = 'inventory_mode';
         }
         $inventory = API::getApiService()->select('host_inventory', ['output' => $output, 'filter' => ['hostid' => $hostPrototypeIds]]);
         $result = $relationMap->mapOne($result, zbx_toHash($inventory, 'hostid'), 'inventory');
     }
     return $result;
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:72,代码来源:CHostPrototype.php

示例4: inherit

 protected function inherit($graph, $hostids = null)
 {
     $graphTemplates = API::Template()->get(array('itemids' => zbx_objectValues($graph['gitems'], 'itemid'), 'output' => array('templateid'), 'nopermissions' => true));
     if (empty($graphTemplates)) {
         return true;
     }
     $graphTemplate = reset($graphTemplates);
     $chdHosts = API::Host()->get(array('templateids' => $graphTemplate['templateid'], 'output' => array('hostid', 'host'), 'preservekeys' => true, 'hostids' => $hostids, 'nopermissions' => true, 'templated_hosts' => true));
     $graph = $this->get(array('graphids' => $graph['graphid'], 'nopermissions' => true, 'filter' => array('flags' => null), 'selectGraphItems' => API_OUTPUT_EXTEND, 'output' => API_OUTPUT_EXTEND));
     $graph = reset($graph);
     foreach ($chdHosts as $chdHost) {
         $tmpGraph = $graph;
         $tmpGraph['templateid'] = $graph['graphid'];
         $tmpGraph['gitems'] = getSameGraphItemsForHost($tmpGraph['gitems'], $chdHost['hostid']);
         if (!$tmpGraph['gitems']) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _s('Graph "%1$s" cannot inherit. No required items on "%2$s".', $tmpGraph['name'], $chdHost['host']));
         }
         if ($tmpGraph['ymax_itemid'] > 0) {
             $ymaxItemid = getSameGraphItemsForHost(array(array('itemid' => $tmpGraph['ymax_itemid'])), $chdHost['hostid']);
             if (!$ymaxItemid) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _s('Graph "%1$s" cannot inherit. No required items on "%2$s" (Ymax value item).', $tmpGraph['name'], $chdHost['host']));
             }
             $ymaxItemid = reset($ymaxItemid);
             $tmpGraph['ymax_itemid'] = $ymaxItemid['itemid'];
         }
         if ($tmpGraph['ymin_itemid'] > 0) {
             $yminItemid = getSameGraphItemsForHost(array(array('itemid' => $tmpGraph['ymin_itemid'])), $chdHost['hostid']);
             if (!$yminItemid) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _s('Graph "%1$s" cannot inherit. No required items on "%2$s" (Ymin value item).', $tmpGraph['name'], $chdHost['host']));
             }
             $yminItemid = reset($yminItemid);
             $tmpGraph['ymin_itemid'] = $yminItemid['itemid'];
         }
         // check if templated graph exists
         $chdGraphs = $this->get(array('filter' => array('templateid' => $tmpGraph['graphid'], 'flags' => array(ZBX_FLAG_DISCOVERY_PROTOTYPE, ZBX_FLAG_DISCOVERY_NORMAL)), 'output' => API_OUTPUT_EXTEND, 'selectGraphItems' => API_OUTPUT_EXTEND, 'preservekeys' => true, 'hostids' => $chdHost['hostid']));
         if ($chdGraph = reset($chdGraphs)) {
             if ($tmpGraph['name'] !== $chdGraph['name']) {
                 $graphExists = $this->get(array('output' => array('graphid'), 'hostids' => $chdHost['hostid'], 'filter' => array('name' => $tmpGraph['name'], 'flags' => null), 'nopermissions' => true, 'limit' => 1));
                 if ($graphExists) {
                     self::exception(ZBX_API_ERROR_PARAMETERS, _s('Graph "%1$s" already exists on "%2$s".', $tmpGraph['name'], $chdHost['host']));
                 }
             } elseif ($chdGraph['flags'] != $tmpGraph['flags']) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _('Graph with same name but other type exist.'));
             }
             $tmpGraph['graphid'] = $chdGraph['graphid'];
             $this->updateReal($tmpGraph, $chdGraph);
         } else {
             $chdGraph = $this->get(array('filter' => array('name' => $tmpGraph['name'], 'flags' => null), 'output' => API_OUTPUT_EXTEND, 'selectGraphItems' => API_OUTPUT_EXTEND, 'preservekeys' => true, 'nopermissions' => true, 'hostids' => $chdHost['hostid']));
             if ($chdGraph = reset($chdGraph)) {
                 if ($chdGraph['templateid'] != 0) {
                     self::exception(ZBX_API_ERROR_PARAMETERS, _s('Graph "%1$s" already exists on "%2$s" (inherited from another template).', $tmpGraph['name'], $chdHost['host']));
                 } elseif ($chdGraph['flags'] != $tmpGraph['flags']) {
                     self::exception(ZBX_API_ERROR_PARAMETERS, _('Graph with same name but other type exist.'));
                 }
                 $chdGraphItemItems = array();
                 foreach (array(API::Item(), API::ItemPrototype()) as $api) {
                     $chdGraphItemItems += $api->get(array('output' => array('key_', 'hostid', 'itemid'), 'itemids' => zbx_objectValues($chdGraph['gitems'], 'itemid'), 'preservekeys' => true));
                 }
                 if (count($chdGraph['gitems']) == count($tmpGraph['gitems'])) {
                     foreach ($tmpGraph['gitems'] as $gitem) {
                         foreach ($chdGraph['gitems'] as $chdGraphItem) {
                             $chdGraphItemItem = $chdGraphItemItems[$chdGraphItem['itemid']];
                             if ($gitem['key_'] == $chdGraphItemItem['key_'] && bccomp($chdHost['hostid'], $chdGraphItemItem['hostid']) == 0) {
                                 continue 2;
                             }
                         }
                         self::exception(ZBX_API_ERROR_PARAMETERS, _s('Graph "%1$s" already exists on "%2$s" (items are not identical).', $tmpGraph['name'], $chdHost['host']));
                     }
                     $tmpGraph['graphid'] = $chdGraph['graphid'];
                     $this->updateReal($tmpGraph, $chdGraph);
                 } else {
                     self::exception(ZBX_API_ERROR_PARAMETERS, _s('Graph "%1$s" already exists on "%2$s" (items are not identical).', $tmpGraph['name'], $chdHost['host']));
                 }
             } else {
                 $graphid = $this->createReal($tmpGraph);
                 $tmpGraph['graphid'] = $graphid;
             }
         }
         $this->inherit($tmpGraph);
     }
 }
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:81,代码来源:CGraphPrototype.php

示例5: validateUpdate

 /**
  * Validates the input parameters for the update() method.
  *
  * @param array $hosts			hosts data array
  * @param array $db_hosts		db hosts data array
  *
  * @throws APIException if the input is invalid.
  */
 protected function validateUpdate(array $hosts, array $db_hosts)
 {
     $host_db_fields = ['hostid' => null];
     $hosts_full = [];
     foreach ($hosts as $host) {
         // Validate mandatory fields.
         if (!check_db_fields($host_db_fields, $host)) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _s('Wrong fields for host "%1$s".', array_key_exists('host', $host) ? $host['host'] : ''));
         }
         // Validate host permissions.
         if (!array_key_exists($host['hostid'], $db_hosts)) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _('No permissions to referred object or it does not exist!'));
         }
         // Validate "groups" field.
         if (array_key_exists('groups', $host) && (!is_array($host['groups']) || !$host['groups'])) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _s('No groups for host "%1$s".', $db_hosts[$host['hostid']]['host']));
         }
         // Permissions to host groups is validated in massUpdate().
     }
     $inventory_fields = zbx_objectValues(getHostInventories(), 'db_field');
     $status_validator = new CLimitedSetValidator(['values' => [HOST_STATUS_MONITORED, HOST_STATUS_NOT_MONITORED], 'messageInvalid' => _('Incorrect status for host "%1$s".')]);
     $update_discovered_validator = new CUpdateDiscoveredValidator(['allowed' => ['hostid', 'status', 'inventory', 'description'], 'messageAllowedField' => _('Cannot update "%2$s" for a discovered host "%1$s".')]);
     $host_names = [];
     foreach ($hosts as &$host) {
         $db_host = $db_hosts[$host['hostid']];
         $host_name = array_key_exists('host', $host) ? $host['host'] : $db_host['host'];
         if (array_key_exists('status', $host)) {
             $status_validator->setObjectName($host_name);
             $this->checkValidator($host['status'], $status_validator);
         }
         if (array_key_exists('inventory', $host) && $host['inventory']) {
             if (array_key_exists('inventory_mode', $host) && $host['inventory_mode'] == HOST_INVENTORY_DISABLED) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _('Cannot set inventory fields for disabled inventory.'));
             }
             $fields = array_keys($host['inventory']);
             foreach ($fields as $field) {
                 if (!in_array($field, $inventory_fields)) {
                     self::exception(ZBX_API_ERROR_PARAMETERS, _s('Incorrect inventory field "%s".', $field));
                 }
             }
         }
         // cannot update certain fields for discovered hosts
         $update_discovered_validator->setObjectName($host_name);
         $this->checkPartialValidator($host, $update_discovered_validator, $db_host);
         if (array_key_exists('interfaces', $host)) {
             if (!is_array($host['interfaces']) || !$host['interfaces']) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _s('No interfaces for host "%s".', $host['host']));
             }
         }
         if (array_key_exists('host', $host)) {
             if (!preg_match('/^' . ZBX_PREG_HOST_FORMAT . '$/', $host['host'])) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _s('Incorrect characters used for host name "%s".', $host['host']));
             }
             if (array_key_exists('host', $host_names) && array_key_exists($host['host'], $host_names['host'])) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _s('Duplicate host. Host with the same host name "%s" already exists in data.', $host['host']));
             }
             $host_names['host'][$host['host']] = $host['hostid'];
         }
         if (array_key_exists('name', $host)) {
             // if visible name is empty replace it with host name
             if (zbx_empty(trim($host['name']))) {
                 if (!array_key_exists('host', $host)) {
                     self::exception(ZBX_API_ERROR_PARAMETERS, _s('Visible name cannot be empty if host name is missing.'));
                 }
                 $host['name'] = $host['host'];
             }
             if (array_key_exists('name', $host_names) && array_key_exists($host['name'], $host_names['name'])) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _s('Duplicate host. Host with the same visible name "%s" already exists in data.', $host['name']));
             }
             $host_names['name'][$host['name']] = $host['hostid'];
         }
         $hosts_full[] = zbx_array_merge($db_host, $host);
     }
     unset($host);
     if (array_key_exists('host', $host_names) || array_key_exists('name', $host_names)) {
         $filter = [];
         if (array_key_exists('host', $host_names)) {
             $filter['host'] = array_keys($host_names['host']);
         }
         if (array_key_exists('name', $host_names)) {
             $filter['name'] = array_keys($host_names['name']);
         }
         $hosts_exists = $this->get(['output' => ['hostid', 'host', 'name'], 'filter' => $filter, 'searchByAny' => true, 'nopermissions' => true, 'preservekeys' => true]);
         foreach ($hosts_exists as $host_exists) {
             if (array_key_exists('host', $host_names) && array_key_exists($host_exists['host'], $host_names['host']) && bccomp($host_exists['hostid'], $host_names['host'][$host_exists['host']]) != 0) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _s('Host with the same name "%s" already exists.', $host_exists['host']));
             }
             if (array_key_exists('name', $host_names) && array_key_exists($host_exists['name'], $host_names['name']) && bccomp($host_exists['hostid'], $host_names['name'][$host_exists['name']]) != 0) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _s('Host with the same visible name "%s" already exists.', $host_exists['name']));
             }
         }
         $templates_exists = API::Template()->get(['output' => ['hostid', 'host', 'name'], 'filter' => $filter, 'searchByAny' => true, 'nopermissions' => true, 'preservekeys' => true]);
//.........这里部分代码省略.........
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:101,代码来源:CHost.php

示例6: addRelatedObjects

 protected function addRelatedObjects(array $options, array $result)
 {
     $result = parent::addRelatedObjects($options, $result);
     if ($options['globalmacro'] === null) {
         $hostMacroIds = array_keys($result);
         /*
          * Adding objects
          */
         // adding groups
         if ($options['selectGroups'] !== null && $options['selectGroups'] != API_OUTPUT_COUNT) {
             $res = DBselect('SELECT hm.hostmacroid,hg.groupid' . ' FROM hostmacro hm,hosts_groups hg' . ' WHERE ' . dbConditionInt('hm.hostmacroid', $hostMacroIds) . ' AND hm.hostid=hg.hostid');
             $relationMap = new CRelationMap();
             while ($relation = DBfetch($res)) {
                 $relationMap->addRelation($relation['hostmacroid'], $relation['groupid']);
             }
             $groups = API::HostGroup()->get(array('output' => $options['selectGroups'], 'groupids' => $relationMap->getRelatedIds(), 'preservekeys' => true));
             $result = $relationMap->mapMany($result, $groups, 'groups');
         }
         // adding templates
         if ($options['selectTemplates'] !== null && $options['selectTemplates'] != API_OUTPUT_COUNT) {
             $relationMap = $this->createRelationMap($result, 'hostmacroid', 'hostid');
             $templates = API::Template()->get(array('output' => $options['selectTemplates'], 'templateids' => $relationMap->getRelatedIds(), 'preservekeys' => true));
             $result = $relationMap->mapMany($result, $templates, 'templates');
         }
         // adding templates
         if ($options['selectHosts'] !== null && $options['selectHosts'] != API_OUTPUT_COUNT) {
             $relationMap = $this->createRelationMap($result, 'hostmacroid', 'hostid');
             $templates = API::Host()->get(array('output' => $options['selectHosts'], 'hostids' => $relationMap->getRelatedIds(), 'preservekeys' => true));
             $result = $relationMap->mapMany($result, $templates, 'hosts');
         }
     }
     return $result;
 }
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:33,代码来源:CUserMacro.php

示例7: validateItems

 /**
  * Check if all templates trigger belongs to are linked to same hosts.
  *
  * @throws APIException
  *
  * @param $trigger
  *
  * @return bool
  */
 protected function validateItems(array $trigger)
 {
     $expressionData = new CTriggerExpression();
     $expressionData->parse($trigger['expression']);
     $templatesData = API::Template()->get(['output' => ['templateid'], 'selectHosts' => ['hostid'], 'selectTemplates' => ['templateid'], 'filter' => ['host' => $expressionData->getHosts()], 'nopermissions' => true, 'preservekeys' => true]);
     $firstTemplate = array_pop($templatesData);
     if ($firstTemplate) {
         $compareLinks = array_merge(zbx_objectValues($firstTemplate['hosts'], 'hostid'), zbx_objectValues($firstTemplate['templates'], 'templateid'));
         foreach ($templatesData as $data) {
             $linkedTo = array_merge(zbx_objectValues($data['hosts'], 'hostid'), zbx_objectValues($data['templates'], 'templateid'));
             if (array_diff($compareLinks, $linkedTo) || array_diff($linkedTo, $compareLinks)) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _s('Trigger "%s" belongs to templates with different linkages.', $trigger['description']));
             }
         }
     }
     return true;
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:26,代码来源:CTrigger.php

示例8: array

     $hosts = API::Host()->get(array('groupids' => $pageFilter->groupid > 0 ? $pageFilter->groupid : null, 'editable' => true, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'limit' => $config['search_limit'] + 1, 'search' => array('name' => empty($_REQUEST['filter_host']) ? null : $_REQUEST['filter_host'], 'ip' => empty($_REQUEST['filter_ip']) ? null : $_REQUEST['filter_ip'], 'dns' => empty($_REQUEST['filter_dns']) ? null : $_REQUEST['filter_dns']), 'filter' => array('port' => empty($_REQUEST['filter_port']) ? null : $_REQUEST['filter_port'])));
 } else {
     $hosts = array();
 }
 // sorting && paging
 order_result($hosts, $sortfield, $sortorder);
 $paging = getPagingLine($hosts, array('hostid'));
 $hosts = API::Host()->get(array('hostids' => zbx_objectValues($hosts, 'hostid'), 'output' => API_OUTPUT_EXTEND, 'selectParentTemplates' => array('hostid', 'name'), 'selectInterfaces' => API_OUTPUT_EXTEND, 'selectItems' => API_OUTPUT_COUNT, 'selectDiscoveries' => API_OUTPUT_COUNT, 'selectTriggers' => API_OUTPUT_COUNT, 'selectGraphs' => API_OUTPUT_COUNT, 'selectApplications' => API_OUTPUT_COUNT, 'selectHttpTests' => API_OUTPUT_COUNT, 'selectDiscoveryRule' => array('itemid', 'name'), 'selectHostDiscovery' => array('ts_delete')));
 order_result($hosts, $sortfield, $sortorder);
 // selecting linked templates to templates linked to hosts
 $templateIds = array();
 foreach ($hosts as $host) {
     $templateIds = array_merge($templateIds, zbx_objectValues($host['parentTemplates'], 'templateid'));
 }
 $templateIds = array_unique($templateIds);
 $templates = API::Template()->get(array('templateids' => $templateIds, 'selectParentTemplates' => array('hostid', 'name')));
 $templates = zbx_toHash($templates, 'templateid');
 // get proxy host IDs that that are not 0
 $proxyHostIds = array();
 foreach ($hosts as $host) {
     if ($host['proxy_hostid']) {
         $proxyHostIds[$host['proxy_hostid']] = $host['proxy_hostid'];
     }
 }
 if ($proxyHostIds) {
     $proxies = API::Proxy()->get(array('proxyids' => $proxyHostIds, 'output' => array('host'), 'preservekeys' => true));
 }
 foreach ($hosts as $host) {
     $interface = reset($host['interfaces']);
     $applications = array(new CLink(_('Applications'), 'applications.php?groupid=' . $_REQUEST['groupid'] . '&hostid=' . $host['hostid']), ' (' . $host['applications'] . ')');
     $items = array(new CLink(_('Items'), 'items.php?filter_set=1&hostid=' . $host['hostid']), ' (' . $host['items'] . ')');
开发者ID:micromachine,项目名称:RackTables-ZABBIX-bridge,代码行数:31,代码来源:hosts.php

示例9: CForm

 $frmGroup->addItem(array(_('Group') . SPACE, $pageFilter->getGroupsCB()));
 $templateWidget->addHeader(_('Templates'), $frmGroup);
 $templateWidget->addHeaderRowNumber();
 $form = new CForm();
 $form->setName('templates');
 $table = new CTableInfo(_('No templates found.'));
 $table->setHeader(array(new CCheckBox('all_templates', null, "checkAll('" . $form->getName() . "', 'all_templates', 'templates');"), make_sorting_header(_('Templates'), 'name', $sortField, $sortOrder), _('Applications'), _('Items'), _('Triggers'), _('Graphs'), _('Screens'), _('Discovery'), _('Web'), _('Linked templates'), _('Linked to')));
 // get templates
 $templates = array();
 if ($pageFilter->groupsSelected) {
     $templates = API::Template()->get(array('output' => array('templateid', 'name'), 'groupids' => $pageFilter->groupid > 0 ? $pageFilter->groupid : null, 'editable' => true, 'sortfield' => $sortField, 'limit' => $config['search_limit'] + 1));
 }
 // sorting && paging
 order_result($templates, $sortField, $sortOrder);
 $paging = getPagingLine($templates);
 $templates = API::Template()->get(array('templateids' => zbx_objectValues($templates, 'templateid'), 'editable' => true, 'output' => array('name', 'proxy_hostid'), 'selectHosts' => array('hostid', 'name', 'status'), 'selectTemplates' => array('hostid', 'name', 'status'), 'selectParentTemplates' => array('hostid', 'name', 'status'), 'selectItems' => API_OUTPUT_COUNT, 'selectTriggers' => API_OUTPUT_COUNT, 'selectGraphs' => API_OUTPUT_COUNT, 'selectApplications' => API_OUTPUT_COUNT, 'selectDiscoveries' => API_OUTPUT_COUNT, 'selectScreens' => API_OUTPUT_COUNT, 'selectHttpTests' => API_OUTPUT_COUNT, 'nopermissions' => true));
 order_result($templates, $sortField, $sortOrder);
 foreach ($templates as $template) {
     $templatesOutput = array();
     if ($template['proxy_hostid']) {
         $proxy = get_host_by_hostid($template['proxy_hostid']);
         $templatesOutput[] = $proxy['host'] . NAME_DELIMITER;
     }
     $templatesOutput[] = new CLink($template['name'], 'templates.php?form=update&templateid=' . $template['templateid'] . url_param('groupid'));
     $applications = array(new CLink(_('Applications'), 'applications.php?groupid=' . $_REQUEST['groupid'] . '&hostid=' . $template['templateid']), ' (' . $template['applications'] . ')');
     $items = array(new CLink(_('Items'), 'items.php?filter_set=1&groupid=' . $_REQUEST['groupid'] . '&hostid=' . $template['templateid']), ' (' . $template['items'] . ')');
     $triggers = array(new CLink(_('Triggers'), 'triggers.php?groupid=' . $_REQUEST['groupid'] . '&hostid=' . $template['templateid']), ' (' . $template['triggers'] . ')');
     $graphs = array(new CLink(_('Graphs'), 'graphs.php?groupid=' . $_REQUEST['groupid'] . '&hostid=' . $template['templateid']), ' (' . $template['graphs'] . ')');
     $screens = array(new CLink(_('Screens'), 'screenconf.php?templateid=' . $template['templateid']), ' (' . $template['screens'] . ')');
     $discoveries = array(new CLink(_('Discovery'), 'host_discovery.php?&hostid=' . $template['templateid']), ' (' . $template['discoveries'] . ')');
     $httpTests = array(new CLink(_('Web'), 'httpconf.php?groupid=' . $_REQUEST['groupid'] . '&hostid=' . $template['templateid']), ' (' . $template['httpTests'] . ')');
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:31,代码来源:templates.php

示例10: array

 $templates = array();
 $sortfield = getPageSortField('name');
 $sortorder = getPageSortOrder();
 if ($pageFilter->groupsSelected) {
     $options = array('editable' => 1, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'limit' => $config['search_limit'] + 1);
     if ($pageFilter->groupid > 0) {
         $options['groupids'] = $pageFilter->groupid;
     }
     $templates = API::Template()->get($options);
 }
 // sorting && paging
 order_result($templates, $sortfield, $sortorder);
 $paging = getPagingLine($templates);
 //--------
 $options = array('templateids' => zbx_objectValues($templates, 'templateid'), 'editable' => 1, 'output' => array('name', 'proxy_hostid'), 'selectHosts' => array('hostid', 'name', 'status'), 'selectTemplates' => array('hostid', 'name', 'status'), 'selectParentTemplates' => array('hostid', 'name', 'status'), 'selectItems' => API_OUTPUT_COUNT, 'selectTriggers' => API_OUTPUT_COUNT, 'selectGraphs' => API_OUTPUT_COUNT, 'selectApplications' => API_OUTPUT_COUNT, 'selectDiscoveries' => API_OUTPUT_COUNT, 'selectScreens' => API_OUTPUT_COUNT, 'nopermissions' => 1);
 $templates = API::Template()->get($options);
 order_result($templates, $sortfield, $sortorder);
 //-----
 foreach ($templates as $template) {
     $templates_output = array();
     if ($template['proxy_hostid']) {
         $proxy = get_host_by_hostid($template['proxy_hostid']);
         $templates_output[] = $proxy['host'] . ':';
     }
     $templates_output[] = new CLink($template['name'], 'templates.php?form=update&templateid=' . $template['templateid'] . url_param('groupid'));
     $applications = array(new CLink(_('Applications'), 'applications.php?groupid=' . $_REQUEST['groupid'] . '&hostid=' . $template['templateid']), ' (' . $template['applications'] . ')');
     $items = array(new CLink(_('Items'), 'items.php?filter_set=1&groupid=' . $_REQUEST['groupid'] . '&hostid=' . $template['templateid']), ' (' . $template['items'] . ')');
     $triggers = array(new CLink(_('Triggers'), 'triggers.php?groupid=' . $_REQUEST['groupid'] . '&hostid=' . $template['templateid']), ' (' . $template['triggers'] . ')');
     $graphs = array(new CLink(_('Graphs'), 'graphs.php?groupid=' . $_REQUEST['groupid'] . '&hostid=' . $template['templateid']), ' (' . $template['graphs'] . ')');
     $screens = array(new CLink(_('Screens'), 'screenconf.php?templateid=' . $template['templateid']), ' (' . $template['screens'] . ')');
     $discoveries = array(new CLink(_('Discovery'), 'host_discovery.php?&hostid=' . $template['hostid']), ' (' . $template['discoveries'] . ')');
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:31,代码来源:templates.php

示例11: CView

    $itemView = new CView('configuration.item.edit', $data);
    $itemView->render();
    $itemView->show();
} elseif ((hasRequest('action') && getRequest('action') == 'item.massupdateform' || hasRequest('massupdate')) && hasRequest('group_itemid')) {
    $data = array('form' => getRequest('form'), 'action' => 'item.massupdateform', 'hostid' => getRequest('hostid'), 'itemids' => getRequest('group_itemid', array()), 'description' => getRequest('description', ''), 'delay' => getRequest('delay', ZBX_ITEM_DELAY_DEFAULT), 'delay_flex' => getRequest('delay_flex', array()), 'history' => getRequest('history', 90), 'status' => getRequest('status', 0), 'type' => getRequest('type', 0), 'interfaceid' => getRequest('interfaceid', 0), 'snmp_community' => getRequest('snmp_community', 'public'), 'port' => getRequest('port', ''), 'value_type' => getRequest('value_type', ITEM_VALUE_TYPE_UINT64), 'data_type' => getRequest('data_type', ITEM_DATA_TYPE_DECIMAL), 'trapper_hosts' => getRequest('trapper_hosts', ''), 'units' => getRequest('units', ''), 'authtype' => getRequest('authtype', ''), 'username' => getRequest('username', ''), 'password' => getRequest('password', ''), 'publickey' => getRequest('publickey', ''), 'privatekey' => getRequest('privatekey', ''), 'valuemapid' => getRequest('valuemapid', 0), 'delta' => getRequest('delta', 0), 'trends' => getRequest('trends', DAY_IN_YEAR), 'applications' => getRequest('applications', array()), 'snmpv3_contextname' => getRequest('snmpv3_contextname', ''), 'snmpv3_securityname' => getRequest('snmpv3_securityname', ''), 'snmpv3_securitylevel' => getRequest('snmpv3_securitylevel', 0), 'snmpv3_authprotocol' => getRequest('snmpv3_authprotocol', ITEM_AUTHPROTOCOL_MD5), 'snmpv3_authpassphrase' => getRequest('snmpv3_authpassphrase', ''), 'snmpv3_privprotocol' => getRequest('snmpv3_privprotocol', ITEM_PRIVPROTOCOL_DES), 'snmpv3_privpassphrase' => getRequest('snmpv3_privpassphrase', ''), 'formula' => getRequest('formula', '1'), 'logtimefmt' => getRequest('logtimefmt', ''), 'initial_item_type' => null, 'multiple_interface_types' => false, 'visible' => getRequest('visible', array()));
    $data['displayApplications'] = true;
    $data['displayInterfaces'] = true;
    // hosts
    $data['hosts'] = API::Host()->get(array('output' => array('hostid'), 'itemids' => $data['itemids'], 'selectItems' => array('itemid'), 'selectInterfaces' => API_OUTPUT_EXTEND));
    $hostCount = count($data['hosts']);
    if ($hostCount > 1) {
        $data['displayApplications'] = false;
        $data['displayInterfaces'] = false;
    } else {
        // get template count to display applications multiselect only for single template
        $templates = API::Template()->get(array('output' => array('templateid'), 'itemids' => $data['itemids']));
        $templateCount = count($templates);
        if ($templateCount != 0) {
            $data['displayInterfaces'] = false;
            if ($templateCount == 1 && !$data['hostid']) {
                // if selected from filter without 'hostid'
                $templates = reset($templates);
                $data['hostid'] = $templates['templateid'];
            }
            // if items belong to single template and some belong to single host, don't display application multiselect
            // and don't display application multiselect for multiple templates
            if ($hostCount == 1 && $templateCount == 1 || $templateCount > 1) {
                $data['displayApplications'] = false;
            }
        }
        if ($hostCount == 1 && $data['displayInterfaces']) {
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:31,代码来源:items.php

示例12: unlink

 protected function unlink($templateids, $targetids = null)
 {
     $cond = ['templateid' => $templateids];
     if (!is_null($targetids)) {
         $cond['hostid'] = $targetids;
     }
     DB::delete('hosts_templates', $cond);
     if (!is_null($targetids)) {
         $hosts = API::Host()->get(['hostids' => $targetids, 'output' => ['hostid', 'host'], 'nopermissions' => true]);
     } else {
         $hosts = API::Host()->get(['templateids' => $templateids, 'output' => ['hostid', 'host'], 'nopermissions' => true]);
     }
     if (!empty($hosts)) {
         $templates = API::Template()->get(['templateids' => $templateids, 'output' => ['hostid', 'host'], 'nopermissions' => true]);
         $hosts = implode(', ', zbx_objectValues($hosts, 'host'));
         $templates = implode(', ', zbx_objectValues($templates, 'host'));
         info(_s('Templates "%1$s" unlinked from hosts "%2$s".', $templates, $hosts));
     }
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:19,代码来源:CHostBase.php

示例13: addRelatedObjects

 protected function addRelatedObjects(array $options, array $result)
 {
     $result = parent::addRelatedObjects($options, $result);
     $hostids = array_keys($result);
     // adding groups
     if ($options['selectGroups'] !== null) {
         $relationMap = $this->createRelationMap($result, 'hostid', 'groupid', 'hosts_groups');
         $groups = API::HostGroup()->get(array('output' => $options['selectGroups'], 'groupids' => $relationMap->getRelatedIds(), 'preservekeys' => true));
         $result = $relationMap->mapMany($result, $groups, 'groups');
     }
     // adding templates
     if ($options['selectParentTemplates'] !== null) {
         if ($options['selectParentTemplates'] != API_OUTPUT_COUNT) {
             $relationMap = $this->createRelationMap($result, 'hostid', 'templateid', 'hosts_templates');
             $templates = API::Template()->get(array('output' => $options['selectParentTemplates'], 'templateids' => $relationMap->getRelatedIds(), 'preservekeys' => true));
             if (!is_null($options['limitSelects'])) {
                 order_result($templates, 'host');
             }
             $result = $relationMap->mapMany($result, $templates, 'parentTemplates', $options['limitSelects']);
         } else {
             $templates = API::Template()->get(array('hostids' => $hostids, 'countOutput' => true, 'groupCount' => true));
             $templates = zbx_toHash($templates, 'hostid');
             foreach ($result as $hostid => $host) {
                 $result[$hostid]['parentTemplates'] = isset($templates[$hostid]) ? $templates[$hostid]['rowscount'] : 0;
             }
         }
     }
     // adding items
     if ($options['selectItems'] !== null) {
         if ($options['selectItems'] != API_OUTPUT_COUNT) {
             $items = API::Item()->get(array('output' => $this->outputExtend($options['selectItems'], array('hostid', 'itemid')), 'hostids' => $hostids, 'nopermissions' => true, 'preservekeys' => true));
             if (!is_null($options['limitSelects'])) {
                 order_result($items, 'name');
             }
             $relationMap = $this->createRelationMap($items, 'hostid', 'itemid');
             $items = $this->unsetExtraFields($items, array('hostid', 'itemid'), $options['selectItems']);
             $result = $relationMap->mapMany($result, $items, 'items', $options['limitSelects']);
         } else {
             $items = API::Item()->get(array('hostids' => $hostids, 'nopermissions' => true, 'countOutput' => true, 'groupCount' => true));
             $items = zbx_toHash($items, 'hostid');
             foreach ($result as $hostid => $host) {
                 $result[$hostid]['items'] = isset($items[$hostid]) ? $items[$hostid]['rowscount'] : 0;
             }
         }
     }
     // adding discoveries
     if ($options['selectDiscoveries'] !== null) {
         if ($options['selectDiscoveries'] != API_OUTPUT_COUNT) {
             $items = API::DiscoveryRule()->get(array('output' => $this->outputExtend($options['selectDiscoveries'], array('hostid', 'itemid')), 'hostids' => $hostids, 'nopermissions' => true, 'preservekeys' => true));
             if (!is_null($options['limitSelects'])) {
                 order_result($items, 'name');
             }
             $relationMap = $this->createRelationMap($items, 'hostid', 'itemid');
             $items = $this->unsetExtraFields($items, array('hostid', 'itemid'), $options['selectDiscoveries']);
             $result = $relationMap->mapMany($result, $items, 'discoveries', $options['limitSelects']);
         } else {
             $items = API::DiscoveryRule()->get(array('hostids' => $hostids, 'nopermissions' => true, 'countOutput' => true, 'groupCount' => true));
             $items = zbx_toHash($items, 'hostid');
             foreach ($result as $hostid => $host) {
                 $result[$hostid]['discoveries'] = isset($items[$hostid]) ? $items[$hostid]['rowscount'] : 0;
             }
         }
     }
     // adding triggers
     if ($options['selectTriggers'] !== null) {
         if ($options['selectTriggers'] != API_OUTPUT_COUNT) {
             // discovered items
             $res = DBselect('SELECT i.hostid,f.triggerid' . ' FROM items i,functions f' . ' WHERE ' . dbConditionInt('i.hostid', $hostids) . ' AND i.itemid=f.itemid');
             $relationMap = new CRelationMap();
             while ($relation = DBfetch($res)) {
                 $relationMap->addRelation($relation['hostid'], $relation['triggerid']);
             }
             $triggers = API::Trigger()->get(array('output' => $options['selectTriggers'], 'triggerids' => $relationMap->getRelatedIds(), 'preservekeys' => true));
             if (!is_null($options['limitSelects'])) {
                 order_result($triggers, 'description');
             }
             $result = $relationMap->mapMany($result, $triggers, 'triggers', $options['limitSelects']);
         } else {
             $triggers = API::Trigger()->get(array('hostids' => $hostids, 'countOutput' => true, 'groupCount' => true));
             $triggers = zbx_toHash($triggers, 'hostid');
             foreach ($result as $hostid => $host) {
                 $result[$hostid]['triggers'] = isset($triggers[$hostid]) ? $triggers[$hostid]['rowscount'] : 0;
             }
         }
     }
     // adding graphs
     if ($options['selectGraphs'] !== null) {
         if ($options['selectGraphs'] != API_OUTPUT_COUNT) {
             // discovered items
             $res = DBselect('SELECT i.hostid,gi.graphid' . ' FROM items i,graphs_items gi' . ' WHERE ' . dbConditionInt('i.hostid', $hostids) . ' AND i.itemid=gi.itemid');
             $relationMap = new CRelationMap();
             while ($relation = DBfetch($res)) {
                 $relationMap->addRelation($relation['hostid'], $relation['graphid']);
             }
             $graphs = API::Graph()->get(array('output' => $options['selectGraphs'], 'graphids' => $relationMap->getRelatedIds(), 'preservekeys' => true));
             if (!is_null($options['limitSelects'])) {
                 order_result($graphs, 'name');
             }
             $result = $relationMap->mapMany($result, $graphs, 'graphs', $options['limitSelects']);
         } else {
//.........这里部分代码省略.........
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:101,代码来源:CHostGeneral.php

示例14: CComboBox

 if (isset($_REQUEST['hostgroupid']) && !empty($_REQUEST['hostgroupid'])) {
     $triggerOptions['groupids'] = $_REQUEST['hostgroupid'];
 }
 // filter template group
 $groupsComboBox = new CComboBox('filter_groupid', $_REQUEST['filter_groupid'], 'javascript: submit();');
 $groupsComboBox->addItem(0, _('all'));
 $groups = API::HostGroup()->get(array('output' => array('groupid', 'name'), 'templated_hosts' => true, 'with_triggers' => true));
 order_result($groups, 'name');
 foreach ($groups as $group) {
     $groupsComboBox->addItem($group['groupid'], $group['name']);
 }
 $filterForm->addRow(_('Template group'), $groupsComboBox);
 // filter template
 $templateComboBox = new CComboBox('filter_hostid', $_REQUEST['filter_hostid'], 'javascript: submit();');
 $templateComboBox->addItem(0, _('all'));
 $templates = API::Template()->get(array('output' => array('templateid', 'name'), 'groupids' => empty($_REQUEST['filter_groupid']) ? null : $_REQUEST['filter_groupid'], 'with_triggers' => true));
 order_result($templates, 'name');
 $templateIds = array();
 foreach ($templates as $template) {
     $templateIds[$template['templateid']] = $template['templateid'];
     $templateComboBox->addItem($template['templateid'], $template['name']);
 }
 $filterForm->addRow(_('Template'), $templateComboBox);
 // filter trigger
 $triggerComboBox = new CComboBox('tpl_triggerid', getRequest('tpl_triggerid', 0), 'javascript: submit()');
 $triggerComboBox->addItem(0, _('all'));
 $sqlCondition = empty($_REQUEST['filter_hostid']) ? ' AND ' . dbConditionInt('h.hostid', $templateIds) : ' AND h.hostid=' . zbx_dbstr($_REQUEST['filter_hostid']);
 $sql = 'SELECT DISTINCT t.triggerid,t.description,h.name' . ' FROM triggers t,hosts h,items i,functions f' . ' WHERE f.itemid=i.itemid' . ' AND h.hostid=i.hostid' . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' AND t.triggerid=f.triggerid' . ' AND h.status=' . HOST_STATUS_TEMPLATE . ' AND i.status=' . ITEM_STATUS_ACTIVE . $sqlCondition . ' ORDER BY t.description';
 $triggers = DBfetchArrayAssoc(DBselect($sql), 'triggerid');
 foreach ($triggers as $trigger) {
     $templateName = empty($_REQUEST['filter_hostid']) ? $trigger['name'] . NAME_DELIMITER : '';
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:31,代码来源:report2.php

示例15: implode

            CProfile::update('web.items.' . $name, implode(';', $_REQUEST[$name]), PROFILE_TYPE_STR);
        } else {
            $_REQUEST[$name] = array();
            $subfiltersVal = CProfile::get('web.items.' . $name);
            if (!zbx_empty($subfiltersVal)) {
                $_REQUEST[$name] = explode(';', $subfiltersVal);
                $_REQUEST[$name] = array_combine($_REQUEST[$name], $_REQUEST[$name]);
            }
        }
    }
}
if (!isset($_REQUEST['form']) && isset($_REQUEST['filter_hostid']) && !empty($_REQUEST['filter_hostid'])) {
    if (!isset($host)) {
        $host = API::Host()->getObjects(array('hostid' => $_REQUEST['filter_hostid']));
        if (empty($host)) {
            $host = API::Template()->getObjects(array('hostid' => $_REQUEST['filter_hostid']));
        }
        $host = reset($host);
    }
    if ($host) {
        $_REQUEST['hostid'] = isset($host['hostid']) ? $host['hostid'] : $host['templateid'];
    }
}
/*
 * Actions
 */
$result = false;
if (isset($_REQUEST['add_delay_flex']) && isset($_REQUEST['new_delay_flex'])) {
    $timePeriodValidator = new CTimePeriodValidator(array('allowMultiple' => false));
    $_REQUEST['delay_flex'] = get_request('delay_flex', array());
    if ($timePeriodValidator->validate($_REQUEST['new_delay_flex']['period'])) {
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:31,代码来源:items.php


注:本文中的API::Template方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。