本文整理汇总了PHP中CApplication::massAdd方法的典型用法代码示例。如果您正苦于以下问题:PHP CApplication::massAdd方法的具体用法?PHP CApplication::massAdd怎么用?PHP CApplication::massAdd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CApplication
的用法示例。
在下文中一共展示了CApplication::massAdd方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseMain
//.........这里部分代码省略.........
if ($current_application) {
$item_applications = array_merge($item_applications, $current_application);
} else {
$applications_to_add[] = $application_db;
}
}
if (!empty($applications_to_add)) {
$result = CApplication::create($applications_to_add);
if (!$result) {
throw new APIException(1, CApplication::resetErrors());
}
$options = array('applicationids' => $result['applicationids'], 'output' => API_OUTPUT_EXTEND);
$new_applications = CApplication::get($options);
$item_applications = array_merge($item_applications, $new_applications);
}
// }}} ITEM APPLICATIONS
if ($current_item && isset($rules['item']['exist'])) {
$item_db['itemid'] = $current_item['itemid'];
$result = CItem::update($item_db);
if (!$result) {
throw new APIException(1, CItem::resetErrors());
}
$options = array('itemids' => $result['itemids'], 'webitems' => 1, 'output' => API_OUTPUT_EXTEND);
$current_item = CItem::get($options);
}
if (!$current_item && isset($rules['item']['missed'])) {
$result = CItem::create($item_db);
if (!$result) {
throw new APIException(1, CItem::resetErrors());
}
$options = array('itemids' => $result['itemids'], 'webitems' => 1, 'output' => API_OUTPUT_EXTEND);
$current_item = CItem::get($options);
}
$r = CApplication::massAdd(array('applications' => $item_applications, 'items' => $current_item));
if ($r === false) {
throw new APIException(1, CApplication::resetErrors());
}
}
}
// }}} ITEMS
// TRIGGERS {{{
if (isset($rules['trigger']['exist']) || isset($rules['trigger']['missed'])) {
$triggers = $xpath->query('triggers/trigger', $host);
$triggers_to_add = array();
$triggers_to_upd = array();
foreach ($triggers as $trigger) {
$trigger_db = self::mapXML2arr($trigger, XML_TAG_TRIGGER);
$trigger_db['expression'] = str_replace('{{HOSTNAME}:', '{' . $host_db['host'] . ':', $trigger_db['expression']);
$trigger_db['hostid'] = $current_host['hostid'];
if ($current_trigger = CTrigger::exists($trigger_db)) {
$ctriggers = CTrigger::get(array('filter' => array('description' => $trigger_db['description']), 'hostids' => $current_host['hostid'], 'output' => API_OUTPUT_EXTEND, 'editable' => 1));
$current_trigger = false;
foreach ($ctriggers as $tnum => $ct) {
$tmp_exp = explode_exp($ct['expression'], false);
if (strcmp($trigger_db['expression'], $tmp_exp) == 0) {
$current_trigger = $ct;
break;
}
}
if (!$current_trigger) {
throw new APIException(1, 'No permission for Trigger [' . $trigger_db['description'] . ']');
}
}
if (!$current_trigger && !isset($rules['trigger']['missed'])) {
info('Trigger [' . $trigger_db['description'] . '] skipped - user rule');
continue;