本文整理匯總了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;
}
}