require_once dirname(__FILE__).'/include/config.inc.php';
require_once dirname(__FILE__).'/include/hosts.inc.php';
require_once dirname(__FILE__).'/include/items.inc.php';
require_once dirname(__FILE__).'/include/forms.inc.php';
$page['title'] = _('Configuration of host prototypes');
$page['file'] = 'host_prototypes.php';
$page['scripts'] = ['effects.js'];
require_once dirname(__FILE__).'/include/page_header.php';
'hostid' => [T_ZBX_INT, O_NO, P_SYS, DB_ID, '(isset({form}) && ({form} == "update")) || (isset({action}) && {action} == "hostprototype.updatediscover")'],
'parent_discoveryid' => [T_ZBX_INT, O_MAND, P_SYS, DB_ID, null],
'host' => [T_ZBX_STR, O_OPT, null, NOT_EMPTY, 'isset({add}) || isset({update})', _('Host name')],
'name' => [T_ZBX_STR, O_OPT, null, null, 'isset({add}) || isset({update})'],
'status' => [T_ZBX_INT, O_OPT, null, IN([HOST_STATUS_NOT_MONITORED, HOST_STATUS_MONITORED]), null],
'discover' => [T_ZBX_INT, O_OPT, null, IN([ZBX_PROTOTYPE_DISCOVER, ZBX_PROTOTYPE_NO_DISCOVER]), null],
'inventory_mode' => [T_ZBX_INT, O_OPT, null, IN([HOST_INVENTORY_DISABLED, HOST_INVENTORY_MANUAL, HOST_INVENTORY_AUTOMATIC]), null],
'templates' => [T_ZBX_STR, O_OPT, P_ONLY_ARRAY, NOT_EMPTY, null],
'add_templates' => [T_ZBX_STR, O_OPT, P_ONLY_ARRAY, NOT_EMPTY, null],
'group_links' => [T_ZBX_STR, O_OPT, P_ONLY_ARRAY, NOT_EMPTY, null],
'group_prototypes' => [T_ZBX_STR, O_OPT, P_ONLY_TD_ARRAY, NOT_EMPTY, null],
'unlink' => [T_ZBX_STR, O_OPT, P_SYS|P_ACT|P_ONLY_ARRAY, null, null],
'group_hostid' => [T_ZBX_INT, O_OPT, P_ONLY_ARRAY, DB_ID, null],
'show_inherited_macros' => [T_ZBX_INT, O_OPT, null, IN([0,1]), null],
'tags' => [T_ZBX_STR, O_OPT, P_SYS|P_ONLY_TD_ARRAY, null, null],
'macros' => [null, O_OPT, P_SYS|P_ONLY_TD_ARRAY, null, null],
'custom_interfaces' => [T_ZBX_INT, O_OPT, null, IN([HOST_PROT_INTERFACES_INHERIT, HOST_PROT_INTERFACES_CUSTOM]), null],
'interfaces' => [null, O_OPT, P_ONLY_TD_ARRAY, null, null],
'mainInterfaces' => [T_ZBX_INT, O_OPT, P_ONLY_ARRAY, DB_ID, null],
'context' => [T_ZBX_STR, O_MAND, P_SYS, IN('"host", "template"'), null],
'action' => [T_ZBX_STR, O_OPT, P_SYS|P_ACT,
IN('"hostprototype.massdelete","hostprototype.massdisable",'.
'"hostprototype.massenable","hostprototype.updatediscover"'
'add' => [T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null],
'update' => [T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null],
'clone' => [T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null],
'delete' => [T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null],
'cancel' => [T_ZBX_STR, O_OPT, P_SYS, null, null],
'form' => [T_ZBX_STR, O_OPT, P_SYS, null, null],
'form_refresh' => [T_ZBX_INT, O_OPT, P_SYS, null, null],
'backurl' => [T_ZBX_STR, O_OPT, null, null, null],
'sort' => [T_ZBX_STR, O_OPT, P_SYS, IN('"name","status","discover"'), null],
'sortorder' => [T_ZBX_STR, O_OPT, P_SYS, IN('"'.ZBX_SORT_DOWN.'","'.ZBX_SORT_UP.'"'), null]
$hostid = getRequest('hostid', 0);
if (getRequest('parent_discoveryid')) {
$discoveryRule = API::DiscoveryRule()->get([
'itemids' => getRequest('parent_discoveryid'),
'output' => API_OUTPUT_EXTEND,
$discoveryRule = reset($discoveryRule);
$hostPrototype = API::HostPrototype()->get([
'output' => API_OUTPUT_EXTEND,
'selectGroupLinks' => ['groupid'],
'selectGroupPrototypes' => ['group_prototypeid', 'name'],
'selectTemplates' => ['templateid', 'name'],
'selectParentHost' => ['hostid'],