1<?php 2/* 3** Zabbix 4** Copyright (C) 2001-2021 Zabbix SIA 5** 6** This program is free software; you can redistribute it and/or modify 7** it under the terms of the GNU General Public License as published by 8** the Free Software Foundation; either version 2 of the License, or 9** (at your option) any later version. 10** 11** This program is distributed in the hope that it will be useful, 12** but WITHOUT ANY WARRANTY; without even the implied warranty of 13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14** GNU General Public License for more details. 15** 16** You should have received a copy of the GNU General Public License 17** along with this program; if not, write to the Free Software 18** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19**/ 20 21$form = (new CForm('post'))->setName('dashboard_sharing_form'); 22 23$table_user_groups = (new CTable()) 24 ->setHeader([_('User groups'), _('Permissions'), _('Action')]) 25 ->addRow( 26 (new CRow( 27 (new CCol( 28 (new CButton(null, _('Add'))) 29 ->onClick('return PopUp("popup.generic",'. 30 CJs::encodeJson([ 31 'srctbl' => 'usrgrp', 32 'srcfld1' => 'usrgrpid', 33 'srcfld2' => 'name', 34 'dstfrm' => $form->getName(), 35 'multiselect' => '1' 36 ]).', null, this);' 37 ) 38 ->addClass(ZBX_STYLE_BTN_LINK) 39 ))->setColSpan(3) 40 ))->setId('user_group_list_footer') 41 ) 42 ->addStyle('width: 100%;'); 43 44$table_users = (new CTable()) 45 ->setHeader([_('Users'), _('Permissions'), _('Action')]) 46 ->addRow( 47 (new CRow( 48 (new CCol( 49 (new CButton(null, _('Add'))) 50 ->onClick('return PopUp("popup.generic",'. 51 CJs::encodeJson([ 52 'srctbl' => 'users', 53 'srcfld1' => 'userid', 54 'srcfld2' => 'fullname', 55 'dstfrm' => $form->getName(), 56 'multiselect' => '1' 57 ]).', null, this);' 58 ) 59 ->addClass(ZBX_STYLE_BTN_LINK) 60 ))->setColSpan(3) 61 ))->setId('user_list_footer') 62 ) 63 ->addStyle('width: 100%;'); 64 65$form 66 ->addItem(getMessages()) 67 ->addItem(new CInput('hidden', 'dashboardid', $data['dashboard']['dashboardid'])) 68 // indicator to help delete all users 69 ->addItem(new CInput('hidden', 'users['.CControllerDashboardShareUpdate::EMPTY_USER.']', '1')) 70 // indicator to help delete all user groups 71 ->addItem(new CInput('hidden', 'userGroups['.CControllerDashboardShareUpdate::EMPTY_GROUP.']', '1')) 72 ->addItem((new CFormList('sharing_form')) 73 ->addRow(_('Type'), 74 (new CRadioButtonList('private', PRIVATE_SHARING)) 75 ->addValue(_('Private'), PRIVATE_SHARING) 76 ->addValue(_('Public'), PUBLIC_SHARING) 77 ->setModern(true) 78 ) 79 ->addRow(_('List of user group shares'), 80 (new CDiv($table_user_groups)) 81 ->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR) 82 ->addStyle('min-width: '.ZBX_TEXTAREA_STANDARD_WIDTH.'px;') 83 ) 84 ->addRow(_('List of user shares'), 85 (new CDiv($table_users)) 86 ->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR) 87 ->addStyle('min-width: '.ZBX_TEXTAREA_STANDARD_WIDTH.'px;') 88 ) 89 ); 90 91$output = [ 92 'header' => _('Dashboard sharing'), 93 'body' => $form->toString(), 94 'script_inline' => 95 'jQuery(document).ready(function($) {'. 96 '$("[name='.$form->getName().']").fillDashbrdSharingForm('.json_encode($data['dashboard']).');'. 97 '});', 98 'buttons' => [ 99 [ 100 'title' => _('Update'), 101 'isSubmit' => true, 102 'action' => 'return dashbrdConfirmSharing();' 103 ] 104 ] 105]; 106 107if ($data['user']['debug_mode'] == GROUP_DEBUG_MODE_ENABLED) { 108 CProfiler::getInstance()->stop(); 109 $output['debug'] = CProfiler::getInstance()->make()->toString(); 110} 111 112echo (new CJson())->encode($output); 113