Source
xxxxxxxxxx
* Adds a new row to the permissions tables, either for template or host groups, with the specified permission.
<?php
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
/**
* @var CView $this
*/
?>
<script>
const view = new class {
init({templategroup_rights, hostgroup_rights, tag_filters, ldap_status, mfa_status, can_update_group}) {
this.tag_filters = tag_filters;
this.templategroup_rights = templategroup_rights;
this.can_update_group = can_update_group;
this.ldap_status = ldap_status;
this.mfa_status = mfa_status;
this.template_permission_template = new Template(
document.getElementById('templategroup-right-row-template').innerHTML
);
this.template_counter = 0;
this.hostgroup_rights = hostgroup_rights;
this.host_permission_template = new Template(
document.getElementById('hostgroup-right-row-template').innerHTML
);
this.host_counter = 0;
const permission_types = [<?= PERM_READ_WRITE ?>, <?= PERM_READ ?>, <?= PERM_DENY ?>];
permission_types.forEach(permission_type => {
if (this.templategroup_rights[permission_type]) {
this.#addRightRow('templategroup', this.templategroup_rights[permission_type], permission_type);
}
if (this.hostgroup_rights[permission_type]) {
this.#addRightRow('hostgroup', this.hostgroup_rights[permission_type], permission_type);
}
});
document.querySelector('.js-add-templategroup-right-row').addEventListener('click', () =>
this.#addRightRow('templategroup')
);
document.querySelector('.js-add-hostgroup-right-row').addEventListener('click', () =>
this.#addRightRow('hostgroup')
);
document.getElementById('user-group-form').addEventListener('click', event => {
if (event.target.classList.contains('js-remove-table-row')) {
this.#removeRow(event.target);
}
if (event.target.classList.contains('js-add-tag-filter')) {
this.#openAddPopup();
}
if (event.target.classList.contains('js-edit-tag-filter')) {
this.#openAddPopup(event.target.closest('tr'));
}
if (event.target.classList.contains('js-remove-tag-filter')) {
this.#removeTagFilterRow(event.target.closest('tr'));
}
});
document.getElementById('user-group-form').addEventListener('change', event => {
if (event.target.name == 'gui_access') {
this.#toggleUserdirectoryAndMfa(event.target.value);
}
if (event.target.name == 'mfaid') {
this.#toggleMfaWarningIcon(event.target.value);
}
if (event.target.name == 'userdirectoryid') {
this.#toggleLdapWarningIcon(event.target.value);
}
})
this.#setMultiselectDisabling('userids', true);
this.#setMultiselectDisabling('ms_hostgroup');
this.#setMultiselectDisabling('ms_templategroup');
if (this.can_update_group) {
this.#toggleUserdirectoryAndMfa(document.querySelector('[name="gui_access"]').value);