本文整理汇总了PHP中zbx_array_mintersect函数的典型用法代码示例。如果您正苦于以下问题:PHP zbx_array_mintersect函数的具体用法?PHP zbx_array_mintersect怎么用?PHP zbx_array_mintersect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了zbx_array_mintersect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exists
/**
* Check if application exists.
*
* @deprecated As of version 2.4, use get method instead.
*
* @param array $object
*
* @return bool
*/
public function exists(array $object)
{
$this->deprecated('application.exists method is deprecated.');
$application = $this->get(array('output' => array('applicationid'), 'filter' => zbx_array_mintersect(array(array('hostid', 'host'), 'name'), $object), 'limit' => 1));
return (bool) $application;
}
示例2: exists
public function exists($data)
{
$keyFields = array(array('screenid', 'name'), 'templateid');
$options = array('filter' => zbx_array_mintersect($keyFields, $data), 'preservekeys' => true, 'output' => API_OUTPUT_SHORTEN, 'nopermissions' => true, 'limit' => 1);
if (isset($data['node'])) {
$options['nodeids'] = getNodeIdByNodeName($data['node']);
} elseif (isset($data['nodeids'])) {
$options['nodeids'] = $data['nodeids'];
}
$screens = $this->get($options);
return !empty($screens);
}
示例3: exists
/**
* Is interface exist.
*
* @param array $object
*
* @return bool
*/
public function exists(array $object)
{
$keyFields = array('interfaceid', 'hostid', 'ip', 'dns');
$options = array('filter' => zbx_array_mintersect($keyFields, $object), 'output' => array('interfaceid'), 'nopermissions' => true, 'limit' => 1);
if (isset($object['node'])) {
$options['nodeids'] = getNodeIdByNodeName($object['node']);
} elseif (isset($object['nodeids'])) {
$options['nodeids'] = $object['nodeids'];
}
$objs = $this->get($options);
return !empty($objs);
}
示例4: exists
/**
* @param $object
*
* @return bool
*/
public function exists(array $object)
{
$keyFields = array(array('hostid', 'host'), 'description');
$result = false;
if (!isset($object['hostid']) && !isset($object['host'])) {
$expressionData = new CTriggerExpression();
if (!$expressionData->parse($object['expression'])) {
return false;
}
$expressionHosts = $expressionData->getHosts();
$object['host'] = reset($expressionHosts);
}
$options = array('filter' => array_merge(zbx_array_mintersect($keyFields, $object), array('flags' => null)), 'output' => API_OUTPUT_EXTEND, 'nopermissions' => true);
if (isset($object['node'])) {
$options['nodeids'] = getNodeIdByNodeName($object['node']);
} elseif (isset($object['nodeids'])) {
$options['nodeids'] = $object['nodeids'];
}
$triggers = $this->get($options);
foreach ($triggers as $trigger) {
$tmpExp = explode_exp($trigger['expression']);
if (strcmp($tmpExp, $object['expression']) == 0) {
$result = true;
break;
}
}
return $result;
}
示例5: updateReal
/**
* Updates the host prototypes and propagates the changes to linked hosts and templates.
*
* @param array $hostPrototypes
*
* @return array
*/
protected function updateReal(array $hostPrototypes)
{
// save the host prototypes
foreach ($hostPrototypes as $hostPrototype) {
DB::updateByPk($this->tableName(), $hostPrototype['hostid'], $hostPrototype);
}
$exHostPrototypes = $this->get(['output' => ['hostid'], 'selectGroupLinks' => API_OUTPUT_EXTEND, 'selectGroupPrototypes' => API_OUTPUT_EXTEND, 'selectTemplates' => ['templateid'], 'selectInventory' => API_OUTPUT_EXTEND, 'hostids' => zbx_objectValues($hostPrototypes, 'hostid'), 'preservekeys' => true]);
// update related objects
$inventoryCreate = [];
$inventoryDeleteIds = [];
foreach ($hostPrototypes as $key => $hostPrototype) {
$exHostPrototype = $exHostPrototypes[$hostPrototype['hostid']];
// group prototypes
if (isset($hostPrototype['groupPrototypes'])) {
foreach ($hostPrototype['groupPrototypes'] as &$groupPrototype) {
$groupPrototype['hostid'] = $hostPrototype['hostid'];
}
unset($groupPrototype);
// save group prototypes
$exGroupPrototypes = zbx_toHash(array_merge($exHostPrototype['groupLinks'], $exHostPrototype['groupPrototypes']), 'group_prototypeid');
$modifiedGroupPrototypes = [];
foreach ($hostPrototype['groupPrototypes'] as $groupPrototype) {
if (isset($groupPrototype['group_prototypeid'])) {
unset($exGroupPrototypes[$groupPrototype['group_prototypeid']]);
}
$modifiedGroupPrototypes[] = $groupPrototype;
}
if ($exGroupPrototypes) {
$this->deleteGroupPrototypes(array_keys($exGroupPrototypes));
}
$hostPrototypes[$key]['groupPrototypes'] = DB::save('group_prototype', $modifiedGroupPrototypes);
}
// templates
if (isset($hostPrototype['templates'])) {
$existingTemplateIds = zbx_objectValues($exHostPrototype['templates'], 'templateid');
$newTemplateIds = zbx_objectValues($hostPrototype['templates'], 'templateid');
$this->unlink(array_diff($existingTemplateIds, $newTemplateIds), [$hostPrototype['hostid']]);
$this->link(array_diff($newTemplateIds, $existingTemplateIds), [$hostPrototype['hostid']]);
}
// inventory
if (isset($hostPrototype['inventory'])) {
$inventory = zbx_array_mintersect(['inventory_mode'], $hostPrototype['inventory']);
$inventory['hostid'] = $hostPrototype['hostid'];
if ($hostPrototype['inventory'] && (!isset($hostPrototype['inventory']['inventory_mode']) || $hostPrototype['inventory']['inventory_mode'] != HOST_INVENTORY_DISABLED)) {
if ($exHostPrototype['inventory']) {
DB::update('host_inventory', ['values' => $inventory, 'where' => ['hostid' => $inventory['hostid']]]);
} else {
$inventoryCreate[] = $inventory;
}
} else {
$inventoryDeleteIds[] = $hostPrototype['hostid'];
}
}
}
// save inventory
DB::insert('host_inventory', $inventoryCreate, false);
DB::delete('host_inventory', ['hostid' => $inventoryDeleteIds]);
// TODO: REMOVE info
$updatedHostPrototypes = $this->get(['hostids' => zbx_objectValues($hostPrototypes, 'hostid'), 'output' => ['host'], 'selectParentHost' => ['host'], 'nopermissions' => true]);
foreach ($updatedHostPrototypes as $hostProtototype) {
info(_s('Updated: Host prototype "%1$s" on "%2$s".', $hostProtototype['host'], $hostProtototype['parentHost']['host']));
}
return $hostPrototypes;
}
示例6: exists
public function exists($object)
{
$keyFields = array(array('dserviceid'));
$options = array('filter' => zbx_array_mintersect($keyFields, $object), 'output' => API_OUTPUT_SHORTEN, 'nopermissions' => 1, 'limit' => 1);
if (isset($object['node'])) {
$options['nodeids'] = getNodeIdByNodeName($object['node']);
} elseif (isset($object['nodeids'])) {
$options['nodeids'] = $object['nodeids'];
}
$objs = $this->get($options);
return !empty($objs);
}
示例7: exists
public static function exists($object)
{
$keyFields = array(array('hostid', 'host'), 'description');
$result = false;
if (!isset($object['hostid']) && !isset($object['host'])) {
$expr = new CTriggerExpression($object);
$expression = $object['expression'];
if (!empty($expr->errors)) {
return false;
}
if (empty($expr->data['hosts'])) {
return false;
}
$object['host'] = reset($expr->data['hosts']);
}
$options = array('filter' => zbx_array_mintersect($keyFields, $object), 'output' => API_OUTPUT_EXTEND, 'nopermissions' => 1);
if (isset($object['node'])) {
$options['nodeids'] = getNodeIdByNodeName($object['node']);
} else {
if (isset($object['nodeids'])) {
$options['nodeids'] = $object['nodeids'];
}
}
$triggers = self::get($options);
foreach ($triggers as $tnum => $trigger) {
$tmp_exp = explode_exp($trigger['expression'], false);
if (strcmp($tmp_exp, $object['expression']) == 0) {
$result = true;
break;
}
}
return $result;
}
示例8: exists
/**
* Check if host group exists.
*
* @deprecated As of version 2.4, use get method instead.
*
* @param array $object
*
* @return bool
*/
public function exists(array $object)
{
$this->deprecated('hostgroup.exists method is deprecated.');
$hostGroup = $this->get(array('output' => array('groupid'), 'filter' => zbx_array_mintersect(array('name', 'groupid'), $object), 'limit' => 1));
return (bool) $hostGroup;
}
示例9: exists
public static function exists($object)
{
$keyFields = array('name', 'groupid');
$options = array('filter' => zbx_array_mintersect($keyFields, $object), 'output' => API_OUTPUT_SHORTEN, 'nopermissions' => 1, 'limit' => 1);
if (isset($object['node'])) {
$options['nodeids'] = getNodeIdByNodeName($object['node']);
} else {
if (isset($object['nodeids'])) {
$options['nodeids'] = $object['nodeids'];
}
}
$objs = self::get($options);
return !empty($objs);
}
示例10: exists
/**
* Check if trigger exists.
*
* @deprecated As of version 2.4, use get method instead.
*
* @param array $object
*
* @return bool
*/
public function exists(array $object)
{
$this->deprecated('trigger.exists method is deprecated.');
$keyFields = array(array('hostid', 'host'), 'description');
$result = false;
if (!isset($object['hostid']) && !isset($object['host'])) {
$expressionData = new CTriggerExpression();
if (!$expressionData->parse($object['expression'])) {
return false;
}
$expressionHosts = $expressionData->getHosts();
$object['host'] = reset($expressionHosts);
}
$triggers = $this->get(array('filter' => array_merge(zbx_array_mintersect($keyFields, $object), array('flags' => null)), 'output' => API_OUTPUT_EXTEND));
foreach ($triggers as $trigger) {
$tmpExp = explode_exp($trigger['expression']);
if (strcmp($tmpExp, $object['expression']) == 0) {
$result = true;
break;
}
}
return $result;
}
示例11: exists
/**
* Check if discovered host exists.
*
* @deprecated As of version 2.4, use get method instead.
*
* @param array $object
*
* @return bool
*/
public function exists(array $object)
{
$this->deprecated('dhost.exists method is deprecated.');
$dHost = $this->get(array('output' => array('dhostid'), 'filter' => zbx_array_mintersect(array(array('dhostid')), $object), 'limit' => 1));
return (bool) $dHost;
}
示例12: exists
/**
* Check if template screen exists.
*
* @deprecated As of version 2.4, use get method instead.
*
* @param array $object
*
* @return bool
*/
public function exists(array $object)
{
$this->deprecated('templatescreen.exists method is deprecated.');
$templateScreen = $this->get(array('output' => array('screenid'), 'filter' => zbx_array_mintersect(array(array('screenid', 'name'), 'templateid'), $object), 'preservekeys' => true, 'limit' => 1));
return (bool) $templateScreen;
}
示例13: exists
public static function exists($data)
{
$keyFields = array(array('screenid', 'name'));
$options = array('filter' => zbx_array_mintersect($keyFields, $data), 'output' => API_OUTPUT_SHORTEN, 'nopermissions' => 1, 'limit' => 1);
if (isset($data['node'])) {
$options['nodeids'] = getNodeIdByNodeName($data['node']);
} else {
if (isset($data['nodeids'])) {
$options['nodeids'] = $data['nodeids'];
}
}
$sysmaps = self::get($options);
return !empty($sysmaps);
}
示例14: exists
/**
* Check if host interface exists.
*
* @deprecated As of version 2.4, use get method instead.
*
* @param array $object
*
* @return bool
*/
public function exists(array $object)
{
$this->deprecated('hostinterface.exists method is deprecated.');
$hostInterface = $this->get(array('output' => array('interfaceid'), 'filter' => zbx_array_mintersect(array('interfaceid', 'hostid', 'ip', 'dns'), $object), 'limit' => 1));
return (bool) $hostInterface;
}
示例15: exists
/**
* Check if maintenance exists.
*
* @deprecated As of version 2.4, use get method instead.
*
* @param array $object
*
* @return bool
*/
public function exists(array $object)
{
$this->deprecated('maintenance.exists method is deprecated.');
$keyFields = array(array('maintenanceid', 'name'));
$maintenance = $this->get(array('output' => array('maintenanceid'), 'filter' => zbx_array_mintersect($keyFields, $object), 'limit' => 1));
return (bool) $maintenance;
}