/** * Additionally allows to remove interfaces from hosts. * * Checks write permissions for hosts. * * Additional supported $data parameters are: * - interfaces - an array of interfaces to delete from the hosts * * @param array $data * * @return array */ public function massRemove(array $data) { $hostids = zbx_toArray($data['hostids']); $this->checkPermissions($hostids); if (isset($data['interfaces'])) { $options = ['hostids' => $hostids, 'interfaces' => zbx_toArray($data['interfaces'])]; API::HostInterface()->massRemove($options); } // rename the "templates" parameter to the common "templates_link" if (isset($data['templateids'])) { $data['templateids_link'] = $data['templateids']; unset($data['templateids']); } $data['templateids'] = []; return parent::massRemove($data); }
/** * Additionally allows to unlink templates from hosts and other templates. * * Checks write permissions for templates. * * Additional supported $data parameters are: * - hostids - an array of host or template IDs to unlink the given templates from * * @param array $data * * @return array */ public function massRemove(array $data) { $templateids = zbx_toArray($data['templateids']); // check permissions if (!$this->isWritable($templateids)) { self::exception(ZBX_API_ERROR_PERMISSIONS, _('You do not have permission to perform this operation.')); } if (isset($data['hostids'])) { API::Template()->unlink($templateids, zbx_toArray($data['hostids'])); } $data['hostids'] = array(); return parent::massRemove($data); }
/** * Additionally allows to remove interfaces from hosts. * * Checks write permissions for hosts. * * Additional supported $data parameters are: * - interfaces - an array of interfaces to delete from the hosts * * @param array $data * * @return array */ public function massRemove(array $data) { $hostids = zbx_toArray($data['hostids']); // check permissions if (!$this->isWritable($hostids)) { self::exception(ZBX_API_ERROR_PERMISSIONS, _('You do not have permission to perform this operation.')); } if (isset($data['interfaces'])) { $options = array('hostids' => $hostids, 'interfaces' => zbx_toArray($data['interfaces'])); API::HostInterface()->massRemove($options); } // rename the "templates" parameter to the common "templates_link" if (isset($data['templateids'])) { $data['templateids_link'] = $data['templateids']; unset($data['templateids']); } $data['templateids'] = array(); return parent::massRemove($data); }
/** * Additionally allows to unlink templates from hosts and other templates. * * Checks write permissions for templates. * * Additional supported $data parameters are: * - hostids - an array of host or template IDs to unlink the given templates from * * @param array $data * * @return array */ public function massRemove(array $data) { $templateids = zbx_toArray($data['templateids']); // check permissions if (!$this->isWritable($templateids)) { self::exception(ZBX_API_ERROR_PERMISSIONS, _('You do not have permission to perform this operation.')); } if (isset($data['hostids'])) { // check if any of the hosts are discovered $this->checkValidator($data['hostids'], new CHostNormalValidator(array('message' => _('Cannot update templates on discovered host "%1$s".')))); API::Template()->unlink($templateids, zbx_toArray($data['hostids'])); } $data['hostids'] = array(); return parent::massRemove($data); }