本文整理汇总了PHP中CTemplate::massRemove方法的典型用法代码示例。如果您正苦于以下问题:PHP CTemplate::massRemove方法的具体用法?PHP CTemplate::massRemove怎么用?PHP CTemplate::massRemove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTemplate
的用法示例。
在下文中一共展示了CTemplate::massRemove方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: massRemove
/**
* remove Hosts from HostGroups. All Hosts are removed from all HostGroups.
*
* @param array $data
* @param array $data['hostids']
* @param array $data['groupids']
* @param array $data['templateids']
* @param array $data['macroids']
* @return array
*/
public static function massRemove($data)
{
$hostids = zbx_toArray($data['hostids']);
try {
self::BeginTransaction(__METHOD__);
$options = array('hostids' => $hostids, 'editable' => 1, 'preservekeys' => 1, 'output' => API_OUTPUT_SHORTEN);
$upd_hosts = self::get($options);
foreach ($hostids as $hostid) {
if (!isset($upd_hosts[$hostid])) {
self::exception(ZBX_API_ERROR_PERMISSIONS, S_NO_PERMISSION);
}
}
if (isset($data['groupids'])) {
$options = array('hostids' => $hostids, 'groupids' => zbx_toArray($data['groupids']));
$result = CHostGroup::massRemove($options);
if (!$result) {
self::exception();
}
}
if (isset($data['templateids'])) {
$options = array('hostids' => $hostids, 'templateids' => zbx_toArray($data['templateids']));
$result = CTemplate::massRemove($options);
if (!$result) {
self::exception();
}
}
if (isset($data['macros'])) {
$options = array('hostids' => $hostids, 'macros' => zbx_toArray($data['macros']));
$result = CUserMacro::massRemove($options);
if (!$result) {
self::exception();
}
}
self::EndTransaction(true, __METHOD__);
return array('hostids' => $hostids);
} catch (APIException $e) {
self::EndTransaction(false, __METHOD__);
$error = $e->getErrors();
$error = reset($error);
self::setError(__METHOD__, $e->getCode(), $error);
return false;
}
}