require_once dirname(__FILE__).'/include/config.inc.php';
require_once dirname(__FILE__).'/include/hosts.inc.php';
require_once dirname(__FILE__).'/include/forms.inc.php';
$page['type'] = detect_page_type(PAGE_TYPE_HTML);
$page['title'] = _('Configuration of templates');
$page['file'] = 'templates.php';
$page['scripts'] = ['class.tagfilteritem.js'];
require_once dirname(__FILE__).'/include/page_header.php';
'groups' => [null, O_OPT, P_ONLY_ARRAY, NOT_EMPTY, 'isset({add}) || isset({update})'],
'clear_templates' => [T_ZBX_INT, O_OPT, P_SYS|P_ONLY_ARRAY, DB_ID, null],
'templates' => [T_ZBX_INT, O_OPT, P_ONLY_ARRAY, DB_ID, null],
'linked_templates' => [T_ZBX_INT, O_OPT, null, DB_ID, null],
'add_templates' => [T_ZBX_INT, O_OPT, P_ONLY_ARRAY, DB_ID, null],
'templateid' => [T_ZBX_INT, O_OPT, P_SYS, DB_ID, 'isset({form}) && {form} == "update"'],
'template_name' => [T_ZBX_STR, O_OPT, null, NOT_EMPTY, 'isset({add}) || isset({update})', _('Template name')],
'visiblename' => [T_ZBX_STR, O_OPT, null, null, 'isset({add}) || isset({update})'],
'groupids' => [T_ZBX_INT, O_OPT, P_ONLY_ARRAY, DB_ID, null],
'tags' => [T_ZBX_STR, O_OPT, P_ONLY_TD_ARRAY, null, null],
'description' => [T_ZBX_STR, O_OPT, null, null, null],
'macros' => [null, O_OPT, P_SYS|P_ONLY_TD_ARRAY, null, null],
'show_inherited_macros' => [T_ZBX_INT, O_OPT, null, IN([0,1]), null],
'valuemaps' => [null, O_OPT, P_ONLY_TD_ARRAY, null, null],
'action' => [T_ZBX_STR, O_OPT, P_SYS|P_ACT,
IN('"template.export","template.massdelete","template.massdeleteclear"'),
'unlink' => [T_ZBX_STR, O_OPT, P_SYS|P_ACT|P_ONLY_ARRAY, null, null],
'unlink_and_clear' => [T_ZBX_STR, O_OPT, P_SYS|P_ACT|P_ONLY_ARRAY, null, null],
'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],
'full_clone' => [T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null],
'delete' => [T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null],
'delete_and_clear' => [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],
'filter_set' => [T_ZBX_STR, O_OPT, P_SYS, null, null],
'filter_rst' => [T_ZBX_STR, O_OPT, P_SYS, null, null],
'filter_name' => [T_ZBX_STR, O_OPT, null, null, null],
'filter_vendor_name' => [T_ZBX_STR, O_OPT, null, null, null],
'filter_vendor_version' => [T_ZBX_STR, O_OPT, null, null, null],
'filter_templates' => [T_ZBX_INT, O_OPT, P_ONLY_ARRAY, DB_ID, null],
'filter_groups' => [T_ZBX_INT, O_OPT, P_ONLY_ARRAY, DB_ID, null],
'filter_evaltype' => [T_ZBX_INT, O_OPT, null,
IN([TAG_EVAL_TYPE_AND_OR, TAG_EVAL_TYPE_OR]),
'filter_tags' => [T_ZBX_STR, O_OPT, P_ONLY_TD_ARRAY, null, null],
'sort' => [T_ZBX_STR, O_OPT, P_SYS, IN('"name"'), null],
'sortorder' => [T_ZBX_STR, O_OPT, P_SYS, IN('"'.ZBX_SORT_DOWN.'","'.ZBX_SORT_UP.'"'), null]
if (getRequest('templateid')) {
$templates = API::Template()->get([
'templateids' => getRequest('templateid'),