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 22if ($data['uncheck']) { 23 uncheckTableRows('modules'); 24} 25 26$widget = (new CWidget()) 27 ->setTitle(_('Modules')) 28 ->setTitleSubmenu(getAdministrationGeneralSubmenu()) 29 ->setControls( 30 (new CTag('nav', true, 31 (new CForm()) 32 ->addVar('action', 'module.scan') 33 ->addItem((new CList()) 34 ->addItem(new CSubmit('form', _('Scan directory'))) 35 ) 36 ))->setAttribute('aria-label', _('Content controls')) 37 ) 38 ->addItem( 39 (new CFilter((new CUrl('zabbix.php'))->setArgument('action', 'module.list'))) 40 ->addVar('action', 'module.list') 41 ->setProfile($data['filter_profile']) 42 ->setActiveTab($data['filter_active_tab']) 43 ->addFilterTab(_('Filter'), [ 44 (new CFormList())->addRow(_('Name'), 45 (new CTextBox('filter_name', $data['filter']['name'])) 46 ->setWidth(ZBX_TEXTAREA_FILTER_SMALL_WIDTH) 47 ->setAttribute('autofocus', 'autofocus') 48 ), 49 (new CFormList())->addRow(_('Status'), 50 (new CRadioButtonList('filter_status', (int) $data['filter']['status'])) 51 ->addValue(_('Any'), -1) 52 ->addValue(_('Enabled'), MODULE_STATUS_ENABLED) 53 ->addValue(_('Disabled'), MODULE_STATUS_DISABLED) 54 ->setModern(true) 55 ) 56 ]) 57 ); 58 59// create form 60$form = (new CForm())->setName('module-form'); 61 62// create table 63$table = (new CTableInfo()) 64 ->setHeader([ 65 (new CColHeader( 66 (new CCheckBox('all_modules')) 67 ->onClick("checkAll('".$form->getName()."', 'all_modules', 'moduleids');") 68 ))->addClass(ZBX_STYLE_CELL_WIDTH), 69 make_sorting_header(_('Name'), 'name', $data['sort'], $data['sortorder'], 70 (new CUrl('zabbix.php')) 71 ->setArgument('action', 'module.list') 72 ->getUrl() 73 ), 74 _('Version'), 75 _('Author'), 76 _('Description'), 77 _('Status') 78 ]); 79 80foreach ($data['modules'] as $moduleid => $module) { 81 $name = new CLink($module['name'], 82 (new CUrl('zabbix.php')) 83 ->setArgument('action', 'module.edit') 84 ->setArgument('moduleid', $moduleid) 85 ->getUrl() 86 ); 87 88 $status_url = (new CUrl('zabbix.php')) 89 ->setArgument('action', ($module['status'] == MODULE_STATUS_ENABLED) ? 'module.disable' : 'module.enable') 90 ->setArgument('moduleids[]', $moduleid) 91 ->getUrl(); 92 93 if ($module['status'] == MODULE_STATUS_ENABLED) { 94 $status = (new CLink(_('Enabled'), $status_url)) 95 ->addClass(ZBX_STYLE_LINK_ACTION) 96 ->addClass(ZBX_STYLE_GREEN) 97 ->addSID(); 98 } 99 else { 100 $status = (new CLink(_('Disabled'), $status_url)) 101 ->addClass(ZBX_STYLE_LINK_ACTION) 102 ->addClass(ZBX_STYLE_RED) 103 ->addSID(); 104 } 105 106 // append table row 107 $table->addRow([ 108 new CCheckBox('moduleids['.$moduleid.']', $moduleid), 109 (new CCol($name))->addClass(ZBX_STYLE_NOWRAP), 110 $module['version'], 111 $module['author'], 112 $module['description'], 113 $status 114 ]); 115} 116 117// append table to form 118$form->addItem([ 119 $table, 120 $data['paging'], 121 new CActionButtonList('action', 'moduleids', [ 122 'module.enable' => ['name' => _('Enable'), 'confirm' => _('Enable selected modules?')], 123 'module.disable' => ['name' => _('Disable'), 'confirm' => _('Disable selected modules?')] 124 ], 'modules') 125]); 126 127// append form to widget 128$widget->addItem($form); 129 130$widget->show(); 131