} } $messageTable = new CFormTable($title . ' "' . getUserFullname(CWebUser::$data) . '"'); $messageTable->addVar('backurl', $_REQUEST['backurl']); if (in_array($_REQUEST['backurl'], array('tr_events.php', 'events.php'))) { $messageTable->addVar('eventid', $_REQUEST['eventid']); $messageTable->addVar('triggerid', $_REQUEST['triggerid']); } elseif (in_array($_REQUEST['backurl'], array('screenedit.php', 'screens.php'))) { $messageTable->addVar('screenid', $_REQUEST['screenid']); } if (isset($_REQUEST['eventid'])) { $messageTable->addVar('eventid', $_REQUEST['eventid']); } elseif (isset($_REQUEST['triggers'])) { foreach ($_REQUEST['triggers'] as $triggerId) { $messageTable->addVar('triggers[' . $triggerId . ']', $triggerId); } } elseif (isset($_REQUEST['events'])) { foreach ($_REQUEST['events'] as $eventId) { $messageTable->addVar('events[' . $eventId . ']', $eventId); } } $message = new CTextArea('message', '', array('rows' => ZBX_TEXTAREA_STANDARD_ROWS, 'width' => ZBX_TEXTAREA_BIG_WIDTH, 'maxlength' => 255)); $message->attr('autofocus', 'autofocus'); $messageTable->addRow(_('Message'), $message); $messageTable->addItemToBottomRow(new CSubmit('saveandreturn', $saveAndReturnLabel)); if (!$bulk) { $messageTable->addItemToBottomRow(new CSubmit('save', $saveLabel)); } $messageTable->addItemToBottomRow(new CButtonCancel(url_params(array('backurl', 'eventid', 'triggerid', 'screenid')))); $messageTable->show(false); require_once dirname(__FILE__) . '/include/page_footer.php';
** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** 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 General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ $widget = (new CWidget())->setTitle(_('Applications'))->addItem(get_header_host_table('applications', $this->data['hostid'])); // create form $applicationForm = (new CForm())->addVar('form', $this->data['form'])->addVar('hostid', $this->data['hostid']); if (!empty($this->data['applicationid'])) { $applicationForm->addVar('applicationid', $this->data['applicationid']); } // append tabs to form $applicationTab = (new CTabView())->addTab('applicationTab', _('Application'), (new CFormList())->addRow(_('Name'), (new CTextBox('appname', $this->data['appname']))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)->setAttribute('autofocus', 'autofocus'))); // append buttons to form if (!empty($this->data['applicationid'])) { $applicationTab->setFooter(makeFormFooter(new CSubmit('update', _('Update')), [new CSubmit('clone', _('Clone')), new CButtonDelete(_('Delete application?'), url_params(['hostid', 'form', 'applicationid'])), new CButtonCancel(url_param('hostid'))])); } else { $applicationTab->setFooter(makeFormFooter(new CSubmit('add', _('Add')), [new CButtonCancel(url_param('hostid'))])); } $applicationForm->addItem($applicationTab); // append form to widget $widget->addItem($applicationForm); return $widget;
// append tabs to form $itemTab = new CTabView(); $itemTab->addTab('itemTab', $this->data['caption'], $itemFormList); $itemForm->addItem($itemTab); // append buttons to form $buttons = array(); if (!empty($this->data['itemid'])) { array_push($buttons, new CSubmit('clone', _('Clone'))); if (!$this->data['is_template'] && !empty($this->data['itemid']) && empty($this->data['parent_discoveryid']) && !$this->data['is_discovery_rule']) { array_push($buttons, new CButtonQMessage('del_history', _('Clear history and trends'), _('History clearing can take a long time. Continue?'))); } if (!$this->data['limited']) { if ($this->data['is_discovery_rule']) { array_push($buttons, new CButtonDelete(_('Delete discovery rule?'), url_params(array('form', 'groupid', 'itemid', 'parent_discoveryid')))); } else { array_push($buttons, new CButtonDelete(_('Delete item?'), url_params(array('form', 'groupid', 'itemid', 'parent_discoveryid')))); } } } array_push($buttons, new CButtonCancel(url_param('groupid') . url_param('parent_discoveryid') . url_param('hostid'))); $itemForm->addItem(makeFormFooter(array(new CSubmit('save', _('Save'))), $buttons)); $itemWidget->addItem($itemForm); /* * Visibility */ $this->data['typeVisibility'] = array(); $i = 0; foreach ($this->data['delay_flex'] as $delayFlex) { if (!isset($delayFlex['delay']) && !isset($delayFlex['period'])) { continue; }
if (!$this->data['form_refresh']) { $graphTab->setSelected(0); } $graphTab->addTab('graphTab', empty($this->data['parent_discoveryid']) ? _('Graph') : _('Graph prototype'), $graphFormList); /* * Preview tab */ $chartImage = new CImg('chart3.php?period=3600'); $chartImage->preload(); $graphPreviewTable = new CTable(null, 'center maxwidth'); $graphPreviewTable->addRow(new CDiv($chartImage, null, 'previewChar')); $graphTab->addTab('previewTab', _('Preview'), $graphPreviewTable); $graphForm->addItem($graphTab); // append buttons to form if (!empty($this->data['graphid'])) { $updateButton = new CSubmit('update', _('Update')); $deleteButton = new CButtonDelete($this->data['parent_discoveryid'] ? _('Delete graph prototype?') : _('Delete graph?'), url_params(array('graphid', 'parent_discoveryid', 'hostid'))); if (!empty($this->data['templateid'])) { $updateButton->setEnabled(false); $deleteButton->setEnabled(false); } $graphForm->addItem(makeFormFooter($updateButton, array(new CSubmit('clone', _('Clone')), $deleteButton, new CButtonCancel(url_param('parent_discoveryid'))))); } else { $graphForm->addItem(makeFormFooter(new CSubmit('add', _('Add')), new CButtonCancel(url_param('parent_discoveryid')))); } // insert js (depended from some variables inside the file) insert_show_color_picker_javascript(); require_once dirname(__FILE__) . '/js/configuration.graph.edit.js.php'; // append form to widget $graphWidget->addItem($graphForm); return $graphWidget;
function build_nav($tree, $url_params = false) { // Remove Index unset($tree['index']); if (!is_array($url_params)) { $url_params = url_params(); } $url_path = url_path(); $html = '<ul class="nav nav-list">'; foreach ($tree as $key => $val) { // Active Tree Node if (isset($url_params[0]) && $url_params[0] == $val['clean']) { array_shift($url_params); // Final Node if ($url_path == $val['url']) { $html .= '<li class="active">'; } else { $html .= '<li class="open">'; } } else { $html .= '<li>'; } if ($val['type'] == 'folder') { $html .= '<a href="#" class="aj-nav folder">' . $val['name'] . '</a>'; $html .= build_nav($val['tree'], $url_params); } else { $html .= '<a href="' . $val['url'] . '">' . $val['name'] . '</a>'; } $html .= '</li>'; } $html .= '</ul>'; return $html; }
// append tabs to form $itemTab = new CTabView(); $itemTab->addTab('itemTab', $this->data['caption'], $itemFormList); $itemForm->addItem($itemTab); // append buttons to form $buttons = array(); if (!empty($this->data['itemid'])) { array_push($buttons, new CSubmit('clone', _('Clone'))); if (!$this->data['is_template'] && !empty($this->data['itemid']) && empty($this->data['parent_discoveryid']) && !$this->data['is_discovery_rule']) { array_push($buttons, new CButtonQMessage('del_history', _('Clear history and trends'), _('History clearing can take a long time. Continue?'))); } if (!$this->data['limited']) { if ($this->data['is_discovery_rule']) { array_push($buttons, new CButtonDelete(_('Delete discovery rule?'), url_params(array('form', 'groupid', 'itemid', 'parent_discoveryid', 'hostid')))); } else { $buttons[] = new CButtonDelete($this->data['parent_discoveryid'] ? _('Delete item prototype?') : _('Delete item?'), url_params(array('form', 'groupid', 'itemid', 'parent_discoveryid', 'hostid'))); } } } array_push($buttons, new CButtonCancel(url_param('groupid') . url_param('parent_discoveryid') . url_param('hostid'))); $itemForm->addItem(makeFormFooter(new CSubmit('save', _('Save')), $buttons)); $itemWidget->addItem($itemForm); /* * Visibility */ $this->data['typeVisibility'] = array(); $i = 0; foreach ($this->data['delay_flex'] as $delayFlex) { if (!isset($delayFlex['delay']) && !isset($delayFlex['period'])) { continue; }
} $addButton = new CButton('macro_add', _('Add'), null, 'link_menu element-table-add'); $buttonColumn = new CCol($addButton); $buttonColumn->setAttribute('colspan', 5); $buttonRow = new CRow(); $buttonRow->setAttribute('id', 'row_new_macro'); $buttonRow->addItem($buttonColumn); $conditionTable->addRow($buttonRow); $conditionFormList->addRow(_('Filters'), new CDiv($conditionTable, 'objectgroup inlineblock border_dotted ui-corner-all')); // append tabs to form $itemTab = new CTabView(); if (!hasRequest('form_refresh')) { $itemTab->setSelected(0); } $itemTab->addTab('itemTab', $this->data['caption'], $itemFormList); $itemTab->addTab('macroTab', _('Filters'), $conditionFormList); $itemForm->addItem($itemTab); // append buttons to form if (!empty($this->data['itemid'])) { if (!$this->data['limited']) { $btnDelete = new CButtonDelete(_('Delete discovery rule?'), url_params(array('form', 'groupid', 'itemid', 'parent_discoveryid', 'hostid'))); } else { $btnDelete = null; } $itemForm->addItem(makeFormFooter(new CSubmit('update', _('Update')), array(new CSubmit('clone', _('Clone')), $btnDelete, new CButtonCancel(url_param('groupid') . url_param('parent_discoveryid') . url_param('hostid'))))); } else { $itemForm->addItem(makeFormFooter(new CSubmit('add', _('Add')), new CButtonCancel(url_param('groupid') . url_param('parent_discoveryid') . url_param('hostid')))); } $itemWidget->addItem($itemForm); require_once dirname(__FILE__) . '/js/configuration.host.discovery.edit.js.php'; return $itemWidget;
foreach ($this->data['slides'] as $step => $slides) { $name = ''; if (!empty($slides['screenid'])) { $screen = get_screen_by_screenid($slides['screenid']); if (!empty($screen['name'])) { $name = $screen['name']; } } $delay = new CNumericBox('slides[' . $step . '][delay]', !empty($slides['delay']) ? $slides['delay'] : '', 5, 'no', true, false); $delay->setAttribute('placeholder', _('default')); $removeButton = new CButton('remove_' . $step, _('Remove'), 'javascript: removeSlide(this);', 'link_menu'); $removeButton->setAttribute('remove_slide', $step); $row = new CRow(array(new CSpan(null, 'ui-icon ui-icon-arrowthick-2-n-s move'), new CSpan($i++ . ':', 'rowNum', 'current_slide_' . $step), $name, $delay, $removeButton), 'sortable', 'slides_' . $step); $slideTable->addRow($row); } $addButtonColumn = new CCol(empty($this->data['work_slide']) ? new CButton('add', _('Add'), 'return PopUp("popup.php?srctbl=screens&srcfld1=screenid&dstfrm=' . $slideForm->getName() . '&multiselect=1", 450, 450)', 'link_menu') : null, null, 5); $addButtonColumn->setAttribute('style', 'vertical-align: middle;'); $slideTable->addRow(new CRow($addButtonColumn, null, 'screenListFooter')); $slideFormList->addRow(_('Slides'), new CDiv($slideTable, 'objectgroup inlineblock border_dotted')); // append tabs to form $slideTab = new CTabView(); $slideTab->addTab('slideTab', _('Slide'), $slideFormList); $slideForm->addItem($slideTab); // append buttons to form if (empty($this->data['slideshowid'])) { $slideForm->addItem(makeFormFooter(new CSubmit('save', _('Save')), new CButtonCancel())); } else { $slideForm->addItem(makeFormFooter(new CSubmit('save', _('Save')), array(new CSubmit('clone', _('Clone')), new CButtonDelete(_('Delete slide show?'), url_params(array('form', 'slideshowid'))), new CButtonCancel()))); } $slideWidget->addItem($slideForm); return $slideWidget;
} else { $enabled = true; } $hostInventoryFieldComboBox->addItem($fieldNo, $fieldInfo['title'], $this->data['inventory_link'] == $fieldNo && $enabled ? 'yes' : null, $enabled); } $itemFormList->addRow(_('Populates host inventory field'), $hostInventoryFieldComboBox, 'row_inventory_link'); // append description to form list $itemFormList->addRow(_('Description'), (new CTextArea('description', $this->data['description']))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)); // status $enabledCheckBox = (new CCheckBox('status', ITEM_STATUS_ACTIVE))->setChecked($this->data['status'] == ITEM_STATUS_ACTIVE); $itemFormList->addRow(_('Enabled'), $enabledCheckBox); // append tabs to form $itemTab = (new CTabView())->addTab('itemTab', $this->data['caption'], $itemFormList); // append buttons to form if ($this->data['itemid'] != 0) { $buttons = [new CSubmit('clone', _('Clone'))]; if ($host['status'] == HOST_STATUS_MONITORED || $host['status'] == HOST_STATUS_NOT_MONITORED) { $buttons[] = new CButtonQMessage('del_history', _('Clear history and trends'), _('History clearing can take a long time. Continue?')); } if (!$this->data['limited']) { $buttons[] = new CButtonDelete(_('Delete item?'), url_params(['form', 'groupid', 'itemid', 'hostid'])); } $buttons[] = new CButtonCancel(url_param('groupid') . url_param('hostid')); $itemTab->setFooter(makeFormFooter(new CSubmit('update', _('Update')), $buttons)); } else { $itemTab->setFooter(makeFormFooter(new CSubmit('add', _('Add')), [new CButtonCancel(url_param('groupid') . url_param('hostid'))])); } $itemForm->addItem($itemTab); $widget->addItem($itemForm); require_once dirname(__FILE__) . '/js/configuration.item.edit.js.php'; return $widget;
$screenFormList->addRow(_('Width'), (new CNumericBox('width', $width, 5))->setWidth(ZBX_TEXTAREA_NUMERIC_STANDARD_WIDTH)); $screenFormList->addRow(_('Height'), (new CNumericBox('height', $height, 5))->setWidth(ZBX_TEXTAREA_NUMERIC_STANDARD_WIDTH)); } else { $form->addVar('width', 500)->addVar('height', 100); } $resourcesWithHAlign = [SCREEN_RESOURCE_GRAPH, SCREEN_RESOURCE_SIMPLE_GRAPH, SCREEN_RESOURCE_MAP, SCREEN_RESOURCE_CLOCK, SCREEN_RESOURCE_URL, SCREEN_RESOURCE_LLD_GRAPH, SCREEN_RESOURCE_LLD_SIMPLE_GRAPH]; if (in_array($resourceType, $resourcesWithHAlign)) { $screenFormList->addRow(_('Horizontal align'), (new CRadioButtonList('halign', (int) $halign))->addValue(_('Left'), HALIGN_LEFT)->addValue(_('Center'), HALIGN_CENTER)->addValue(_('Right'), HALIGN_RIGHT)->setModern(true)); } else { $form->addVar('halign', 0); } $screenFormList->addRow(_('Vertical align'), (new CRadioButtonList('valign', (int) $valign))->addValue(_('Top'), VALIGN_TOP)->addValue(_('Middle'), VALIGN_MIDDLE)->addValue(_('Bottom'), VALIGN_BOTTOM)->setModern(true)); $screenFormList->addRow(_('Column span'), (new CNumericBox('colspan', $colspan, 3))->setWidth(ZBX_TEXTAREA_NUMERIC_STANDARD_WIDTH)); $screenFormList->addRow(_('Row span'), (new CNumericBox('rowspan', $rowspan, 3))->setWidth(ZBX_TEXTAREA_NUMERIC_STANDARD_WIDTH)); // dynamic addon $resourcesWithDynamic = [SCREEN_RESOURCE_GRAPH, SCREEN_RESOURCE_SIMPLE_GRAPH, SCREEN_RESOURCE_PLAIN_TEXT, SCREEN_RESOURCE_URL, SCREEN_RESOURCE_LLD_GRAPH, SCREEN_RESOURCE_LLD_SIMPLE_GRAPH]; if ($this->data['screen']['templateid'] == 0 && in_array($resourceType, $resourcesWithDynamic)) { $screenFormList->addRow(_('Dynamic item'), (new CCheckBox('dynamic'))->setChecked($dynamic == 1)); } // append tabs to form $screenTab = new CTabView(); $screenTab->setAttribute('style', 'text-align: left;'); $screenTab->addTab('screenTab', _('Screen cell configuration'), $screenFormList); // append buttons to form if (isset($_REQUEST['screenitemid'])) { $screenTab->setFooter(makeFormFooter(new CSubmit('update', _('Update')), [new CButtonDelete(null, url_params(['form', 'screenid', 'templateid', 'screenitemid'])), new CButtonCancel(url_params(['screenid', 'templateid']))])); } else { $screenTab->setFooter(makeFormFooter(new CSubmit('add', _('Add')), [new CButtonCancel(url_params(['screenid', 'templateid']))])); } $form->addItem($screenTab); return $form;
$user_group_shares_table->addRow((new CRow((new CCol($add_user_group_btn))->setColSpan(3)))->setId('user_group_list_footer')); $user_groups = []; foreach ($data['screen']['userGroups'] as $user_group) { $user_groupid = $user_group['usrgrpid']; $user_groups[$user_groupid] = ['usrgrpid' => $user_groupid, 'name' => $data['user_groups'][$user_groupid]['name'], 'permission' => $user_group['permission']]; } $js_insert = 'addPopupValues(' . zbx_jsvalue(['object' => 'usrgrpid', 'values' => $user_groups]) . ');'; // User sharing table. $user_shares_table = (new CTable())->setHeader([_('Users'), _('Permissions'), _('Action')])->setAttribute('style', 'width: 100%;'); $add_user_btn = [(new CButton(null, _('Add')))->onClick('return PopUp("popup.php?dstfrm=' . $form->getName() . '&srctbl=users&srcfld1=userid&srcfld2=fullname&multiselect=1")')->addClass(ZBX_STYLE_BTN_LINK)]; $user_shares_table->addRow((new CRow((new CCol($add_user_btn))->setColSpan(3)))->setId('user_list_footer')); $users = []; foreach ($data['screen']['users'] as $user) { $userid = $user['userid']; $users[$userid] = ['id' => $userid, 'name' => getUserFullname($data['users'][$userid]), 'permission' => $user['permission']]; } $js_insert .= 'addPopupValues(' . zbx_jsvalue(['object' => 'userid', 'values' => $users]) . ');'; zbx_add_post_js($js_insert); $sharing_tab = (new CFormList('sharing_form'))->addRow(_('Type'), (new CRadioButtonList('private', (int) $data['screen']['private']))->addValue(_('Private'), PRIVATE_SHARING)->addValue(_('Public'), PUBLIC_SHARING)->setModern(true))->addRow(_('List of user group shares'), (new CDiv($user_group_shares_table))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_STANDARD_WIDTH . 'px;'))->addRow(_('List of user shares'), (new CDiv($user_shares_table))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_STANDARD_WIDTH . 'px;')); // Append data to form. $tabs->addTab('sharing_tab', _('Sharing'), $sharing_tab); } // append buttons to form if ($data['screen']['screenid']) { $tabs->setFooter(makeFormFooter(new CSubmit('update', _('Update')), [new CSubmit('clone', _('Clone')), new CButtonDelete(_('Delete screen?'), url_params(['form', 'screenid', 'templateid'])), new CButtonCancel(url_param('templateid'))])); } else { $tabs->setFooter(makeFormFooter(new CSubmit('add', _('Add')), [new CButtonCancel(url_param('templateid'))])); } $form->addItem($tabs); $widget->addItem($form); return $widget;
$user_groupid = $user_group['usrgrpid']; if (array_key_exists($user_groupid, $data['user_groups'])) { $user_groups[$user_groupid] = ['usrgrpid' => $user_groupid, 'name' => $data['user_groups'][$user_groupid]['name'], 'permission' => $user_group['permission']]; } } $js_insert = 'addPopupValues(' . zbx_jsvalue(['object' => 'usrgrpid', 'values' => $user_groups]) . ');'; // User sharing table. $user_shares_table = (new CTable())->setHeader([_('Users'), _('Permissions'), _('Action')])->setAttribute('style', 'width: 100%;'); $add_user_btn = [(new CButton(null, _('Add')))->onClick('return PopUp("popup.php?dstfrm=' . $form->getName() . '&srctbl=users&srcfld1=userid&srcfld2=fullname&multiselect=1")')->addClass(ZBX_STYLE_BTN_LINK)]; $user_shares_table->addRow((new CRow((new CCol($add_user_btn))->setColSpan(3)))->setId('user_list_footer')); $users = []; foreach ($data['slideshow']['users'] as $user) { $userid = $user['userid']; if (array_key_exists($userid, $data['users'])) { $users[$userid] = ['id' => $userid, 'name' => getUserFullname($data['users'][$userid]), 'permission' => $user['permission']]; } } $js_insert .= 'addPopupValues(' . zbx_jsvalue(['object' => 'userid', 'values' => $users]) . ');'; zbx_add_post_js($js_insert); $sharing_tab = (new CFormList('sharing_form'))->addRow(_('Type'), (new CRadioButtonList('private', (int) $data['slideshow']['private']))->addValue(_('Private'), PRIVATE_SHARING)->addValue(_('Public'), PUBLIC_SHARING)->setModern(true))->addRow(_('List of user group shares'), (new CDiv($user_group_shares_table))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_STANDARD_WIDTH . 'px;'))->addRow(_('List of user shares'), (new CDiv($user_shares_table))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_STANDARD_WIDTH . 'px;')); // Append data to form. $tabs->addTab('sharing_tab', _('Sharing'), $sharing_tab); // append buttons to form if (isset($data['slideshow']['slideshowid'])) { $tabs->setFooter(makeFormFooter(new CSubmit('update', _('Update')), [new CSubmit('clone', _('Clone')), new CButtonDelete(_('Delete slide show?'), url_params(['form', 'slideshowid'])), new CRedirectButton(_('Cancel'), 'slides.php')])); } else { $tabs->setFooter(makeFormFooter(new CSubmit('add', _('Add')), [new CButtonCancel()])); } $form->addItem($tabs); $widget->addItem($form); return $widget;
if (empty($this->data['parent_discoveryid'])) { $dependenciesFormList = new CFormList('dependenciesFormList'); $dependenciesTable = new CTable(_('No dependencies defined.'), 'formElementTable'); $dependenciesTable->setAttribute('style', 'min-width: 500px;'); $dependenciesTable->setAttribute('id', 'dependenciesTable'); $dependenciesTable->setHeader(array(_('Name'), _('Action'))); foreach ($this->data['db_dependencies'] as $dependency) { $triggersForm->addVar('dependencies[]', $dependency['triggerid'], 'dependencies_' . $dependency['triggerid']); $row = new CRow(array($dependency['host'] . NAME_DELIMITER . $dependency['description'], new CButton('remove', _('Remove'), 'javascript: removeDependency("' . $dependency['triggerid'] . '");', 'link_menu'))); $row->setAttribute('id', 'dependency_' . $dependency['triggerid']); $dependenciesTable->addRow($row); } $dependenciesFormList->addRow(_('Dependencies'), new CDiv(array($dependenciesTable, new CButton('bnt1', _('Add'), 'return PopUp("popup.php?' . 'srctbl=triggers' . '&srcfld1=triggerid' . '&reference=deptrigger' . '&multiselect=1' . '&with_triggers=1", 1000, 700);', 'link_menu')), 'objectgroup inlineblock border_dotted ui-corner-all')); $triggersTab->addTab('dependenciesTab', _('Dependencies'), $dependenciesFormList); } // append tabs to form $triggersForm->addItem($triggersTab); // append buttons to form $buttons = array(); if (!empty($this->data['triggerid'])) { $buttons[] = new CSubmit('clone', _('Clone')); $deleteButton = new CButtonDelete($this->data['parent_discoveryid'] ? _('Delete trigger prototype?') : _('Delete trigger?'), url_params(array('form', 'groupid', 'hostid', 'triggerid', 'parent_discoveryid'))); if ($this->data['limited']) { $deleteButton->setAttribute('disabled', 'disabled'); } $buttons[] = $deleteButton; } $buttons[] = new CButtonCancel(url_params(array('groupid', 'hostid', 'parent_discoveryid'))); $triggersForm->addItem(makeFormFooter(new CSubmit('save', _('Save')), array($buttons))); $triggersWidget->addItem($triggersForm); return $triggersWidget;
/* * Dependencies tab */ $dependenciesFormList = new CFormList('dependenciesFormList'); $dependenciesTable = (new CTable())->setAttribute('style', 'width: 100%;')->setHeader([_('Name'), _('Action')]); foreach ($this->data['db_dependencies'] as $dependency) { $triggersForm->addVar('dependencies[]', $dependency['triggerid'], 'dependencies_' . $dependency['triggerid']); $depTriggerDescription = CHtml::encode(implode(', ', zbx_objectValues($dependency['hosts'], 'name')) . NAME_DELIMITER . $dependency['description']); if ($dependency['flags'] == ZBX_FLAG_DISCOVERY_NORMAL) { $description = (new CLink($depTriggerDescription, 'triggers.php?form=update&triggerid=' . $dependency['triggerid']))->setAttribute('target', '_blank'); } else { $description = $depTriggerDescription; } $dependenciesTable->addRow((new CRow([$description, (new CCol((new CButton('remove', _('Remove')))->onClick('javascript: removeDependency("' . $dependency['triggerid'] . '");')->addClass(ZBX_STYLE_BTN_LINK)))->addClass(ZBX_STYLE_NOWRAP)]))->setId('dependency_' . $dependency['triggerid'])); } $dependenciesFormList->addRow(_('Dependencies'), (new CDiv([$dependenciesTable, (new CButton('bnt1', _('Add')))->onClick('return PopUp("popup.php?srctbl=triggers&srcfld1=triggerid&reference=deptrigger&multiselect=1' . '&with_triggers=1&noempty=1");')->addClass(ZBX_STYLE_BTN_LINK)]))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_BIG_WIDTH . 'px;')); $triggersTab->addTab('dependenciesTab', _('Dependencies'), $dependenciesFormList); // append buttons to form if (!empty($this->data['triggerid'])) { $deleteButton = new CButtonDelete(_('Delete trigger?'), url_params(['form', 'hostid', 'triggerid'])); if ($this->data['limited']) { $deleteButton->setAttribute('disabled', 'disabled'); } $triggersTab->setFooter(makeFormFooter(new CSubmit('update', _('Update')), [new CSubmit('clone', _('Clone')), $deleteButton, new CButtonCancel(url_param('hostid'))])); } else { $triggersTab->setFooter(makeFormFooter(new CSubmit('add', _('Add')), [new CButtonCancel(url_param('hostid'))])); } // append tabs to form $triggersForm->addItem($triggersTab); $widget->addItem($triggersForm); return $widget;
liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage. */ require_once 'libs/functions.php'; $options = get_options(); $tree = get_tree($options['docs_path'], $base_url); // If a language is set in the config, rewrite urls based on the language if (!isset($language) || $language === null) { $homepage_url = homepage_url($tree); $docs_url = docs_url($tree); } else { $homepage_url = "/"; } $docs_url = docs_url($tree); $url_params = url_params(); if (count($options['languages']) > 0 && count($url_params) > 0 && strlen($url_params[0]) > 0) { $language = array_shift($url_params); $base_path = "docs/" . $language; } else { $language = null; $base_path = "docs"; } $tree = get_tree($base_path, $base_url, '', true, $language); $page = load_page($tree, $url_params); // If a timezone has been set in the config file, override the default PHP timezone for this application. if (isset($options['timezone'])) { date_default_timezone_set($options['timezone']); } // Redirect to docs, if there is no homepage if ($homepage && $homepage_url !== '/') {
$applicationWidget = new CWidget(); $applicationWidget->addPageHeader(_('CONFIGURATION OF APPLICATIONS')); // append host summary to widget header $applicationWidget->addItem(get_header_host_table('applications', $this->data['hostid'])); // create form $applicationForm = new CForm(); $applicationForm->setName('applicationForm'); $applicationForm->addVar('form', $this->data['form']); $applicationForm->addVar('groupid', $this->data['groupid']); $applicationForm->addVar('hostid', $this->data['hostid']); if (!empty($this->data['applicationid'])) { $applicationForm->addVar('applicationid', $this->data['applicationid']); } // create form list $applicationFormList = new CFormList('applicationFormList'); $nameTextBox = new CTextBox('appname', $this->data['appname'], ZBX_TEXTBOX_STANDARD_SIZE); $nameTextBox->attr('autofocus', 'autofocus'); $applicationFormList->addRow(_('Name'), $nameTextBox); // append tabs to form $applicationTab = new CTabView(); $applicationTab->addTab('applicationTab', _('Application'), $applicationFormList); $applicationForm->addItem($applicationTab); // append buttons to form if (!empty($this->data['applicationid'])) { $applicationForm->addItem(makeFormFooter(new CSubmit('save', _('Save')), array(new CSubmit('clone', _('Clone')), new CButtonDelete(_('Delete application?'), url_params(array('config', 'hostid', 'groupid', 'form', 'applicationid'))), new CButtonCancel(url_param('config') . url_param('hostid') . url_param('groupid'))))); } else { $applicationForm->addItem(makeFormFooter(new CSubmit('save', _('Save')), new CButtonCancel(url_param('config') . url_param('hostid') . url_param('groupid')))); } // append form to widget $applicationWidget->addItem($applicationForm); return $applicationWidget;
if ($paramId == 0 || $paramId == 1 && (substr($this->data['expr_type'], 0, 6) == 'regexp' || substr($this->data['expr_type'], 0, 7) == 'iregexp' || substr($this->data['expr_type'], 0, 3) == 'str' && substr($this->data['expr_type'], 0, 6) != 'strlen')) { if (isset($paramFunction['M'])) { $paramTypeElement = new CComboBox('paramtype', $this->data['paramtype'], null, $paramFunction['M']); } else { $expressionForm->addVar('paramtype', PARAM_TYPE_TIME); $paramTypeElement = _('Time'); } } if ($paramId == 1 && (substr($this->data['expr_type'], 0, 3) != 'str' || substr($this->data['expr_type'], 0, 6) == 'strlen') && substr($this->data['expr_type'], 0, 6) != 'regexp' && substr($this->data['expr_type'], 0, 7) != 'iregexp') { $paramTypeElement = _('Time'); $paramField = (new CTextBox('params[' . $paramId . ']', $paramValue))->setWidth(ZBX_TEXTAREA_SMALL_WIDTH); } else { $paramField = $this->data['paramtype'] == PARAM_TYPE_COUNTS ? (new CNumericBox('params[' . $paramId . ']', (int) $paramValue, 10))->setWidth(ZBX_TEXTAREA_NUMERIC_STANDARD_WIDTH) : (new CTextBox('params[' . $paramId . ']', $paramValue))->setWidth(ZBX_TEXTAREA_SMALL_WIDTH); } $expressionFormList->addRow($paramFunction['C'], [$paramField, (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN), $paramTypeElement]); } else { $expressionFormList->addRow($paramFunction['C'], (new CTextBox('params[' . $paramId . ']', $paramValue))->setWidth(ZBX_TEXTAREA_SMALL_WIDTH)); $expressionForm->addVar('paramtype', PARAM_TYPE_TIME); } } } else { $expressionForm->addVar('paramtype', PARAM_TYPE_TIME); } $expressionFormList->addRow('N', (new CTextBox('value', $this->data['value']))->setWidth(ZBX_TEXTAREA_SMALL_WIDTH)); // append tabs to form $expressionTab = (new CTabView())->addTab('expressionTab', _('Trigger expression condition'), $expressionFormList); // append buttons to form $expressionTab->setFooter(makeFormFooter(new CSubmit('insert', _('Insert')), [new CButtonCancel(url_params(['parent_discoveryid', 'dstfrm', 'dstfld1']))])); $expressionForm->addItem($expressionTab); $expressionWidget->addItem($expressionForm); return $expressionWidget;
} } else { $expressionForm->addVar('paramtype', PARAM_TYPE_TIME); $paramTypeElement = SPACE . _('Time'); } } if ($paramId == 1 && (substr($this->data['expr_type'], 0, 3) != 'str' || substr($this->data['expr_type'], 0, 6) == 'strlen') && substr($this->data['expr_type'], 0, 6) != 'regexp' && substr($this->data['expr_type'], 0, 7) != 'iregexp') { $paramTypeElement = SPACE . _('Time'); $paramField = new CTextBox('param[' . $paramId . ']', $paramValue, 10); } else { $paramField = $this->data['paramtype'] == PARAM_TYPE_COUNTS ? new CNumericBox('param[' . $paramId . ']', (int) $paramValue, 10) : new CTextBox('param[' . $paramId . ']', $paramValue, 10); } $expressionFormList->addRow($paramFunction['C'] . ' ', array($paramField, $paramTypeElement)); } else { $expressionFormList->addRow($paramFunction['C'], new CTextBox('param[' . $paramId . ']', $paramValue, 30)); $expressionForm->addVar('paramtype', PARAM_TYPE_TIME); } } } else { $expressionForm->addVar('paramtype', PARAM_TYPE_TIME); $expressionForm->addVar('param', 0); } $expressionFormList->addRow('N', new CTextBox('value', $this->data['value'], 10)); // append tabs to form $expressionTab = new CTabView(); $expressionTab->addTab('expressionTab', _('Trigger expression condition'), $expressionFormList); $expressionForm->addItem($expressionTab); // append buttons to form $expressionForm->addItem(makeFormFooter(new CSubmit('insert', _('Insert')), new CButtonCancel(url_params(array('parent_discoveryid', 'dstfrm', 'dstfld1'))))); $expressionWidget->addItem($expressionForm); return $expressionWidget;
/** * Process screen with particular screen objects. * * @return CTable */ public function show() { if (empty($this->screen)) { return new CTableInfo(); } $skipedFields = []; $screenitems = []; $emptyScreenColumns = []; // calculate table columns and rows foreach ($this->screen['screenitems'] as $screenitem) { $screenitems[] = $screenitem; for ($i = 0; $i < $screenitem['rowspan'] || $i == 0; $i++) { for ($j = 0; $j < $screenitem['colspan'] || $j == 0; $j++) { if ($i != 0 || $j != 0) { if (!isset($skipedFields[$screenitem['y'] + $i])) { $skipedFields[$screenitem['y'] + $i] = []; } $skipedFields[$screenitem['y'] + $i][$screenitem['x'] + $j] = 1; } } } } // create screen table $screenTable = (new CTable())->setId(self::makeScreenTableId($this->screen['screenid']))->addClass(ZBX_STYLE_SCREEN_TABLE); if ($this->mode == SCREEN_MODE_EDIT) { $screenTable->addClass(ZBX_STYLE_DASHED_BORDER); } // action top row if ($this->mode == SCREEN_MODE_EDIT) { $newColumns = [(new CCol())->addClass(ZBX_STYLE_CELL_WIDTH)]; for ($i = 0, $size = $this->screen['hsize']; $i < $size; $i++) { if ($this->screen['hsize'] >= SCREEN_MAX_SIZE) { $link = (new CDiv('+'))->addClass(ZBX_STYLE_TREEVIEW_PLUS)->addClass(ZBX_STYLE_DISABLED); } else { $link = (new CLink('+', 'screenedit.php?screenid=' . $this->screen['screenid'] . url_param('templateid') . '&add_col=' . $i))->addClass(ZBX_STYLE_TREEVIEW_PLUS)->addSID(); } $newColumns[] = (new CCol($link))->addClass(ZBX_STYLE_CENTER)->addClass(ZBX_STYLE_MIDDLE); } if ($this->screen['hsize'] >= SCREEN_MAX_SIZE) { $link = (new CDiv('+'))->addClass(ZBX_STYLE_TREEVIEW_PLUS)->addClass(ZBX_STYLE_DISABLED); } else { $link = (new CLink('+', 'screenedit.php?screenid=' . $this->screen['screenid'] . url_param('templateid') . '&add_col=' . $this->screen['hsize']))->addClass(ZBX_STYLE_TREEVIEW_PLUS)->addSID(); } $newColumns[] = (new CCol($link))->addClass(ZBX_STYLE_CENTER)->addClass(ZBX_STYLE_MIDDLE)->addClass(ZBX_STYLE_CELL_WIDTH); $screenTable->addRow($newColumns); } for ($r = 0; $r < $this->screen['vsize']; $r++) { $newColumns = []; $emptyScreenRow = true; // action left cell if ($this->mode == SCREEN_MODE_EDIT) { if ($this->screen['vsize'] >= SCREEN_MAX_SIZE) { $link = (new CDiv('+'))->addClass(ZBX_STYLE_TREEVIEW_PLUS)->addClass(ZBX_STYLE_DISABLED); } else { $link = (new CLink('+', 'screenedit.php?screenid=' . $this->screen['screenid'] . url_param('templateid') . '&add_row=' . $r))->addClass(ZBX_STYLE_TREEVIEW_PLUS)->addSID(); } $newColumns[] = (new CCol($link))->addClass(ZBX_STYLE_CENTER)->addClass(ZBX_STYLE_MIDDLE); } for ($c = 0; $c < $this->screen['hsize']; $c++) { if (isset($skipedFields[$r][$c])) { continue; } // screen item $isEditForm = false; $screenitem = []; foreach ($screenitems as $tmprow) { if ($tmprow['x'] == $c && $tmprow['y'] == $r) { $screenitem = $tmprow; break; } } if (empty($screenitem)) { $screenitem = ['screenitemid' => 0, 'resourcetype' => 0, 'resourceid' => 0, 'width' => 0, 'height' => 0, 'colspan' => 1, 'rowspan' => 1, 'elements' => 0, 'valign' => VALIGN_DEFAULT, 'halign' => HALIGN_DEFAULT, 'style' => 0, 'url' => '', 'dynamic' => 0, 'sort_triggers' => SCREEN_SORT_TRIGGERS_DATE_DESC]; } if (!empty($screenitem['screenitemid'])) { $emptyScreenRow = false; $emptyScreenColumns[$c] = true; } // action if ($this->mode == SCREEN_MODE_EDIT) { if ($screenitem['screenitemid'] != 0) { $action = 'screenedit.php?form=update' . url_params(['screenid', 'templateid']) . '&screenitemid=' . $screenitem['screenitemid']; } else { $action = 'screenedit.php?form=update' . url_params(['screenid', 'templateid']) . '&x=' . $c . '&y=' . $r; } } else { $action = null; } // edit form cell if ($this->mode == SCREEN_MODE_EDIT && (isset($_REQUEST['form']) && $_REQUEST['form'] == 'update') && (isset($_REQUEST['x']) && $_REQUEST['x'] == $c && isset($_REQUEST['y']) && $_REQUEST['y'] == $r || isset($_REQUEST['screenitemid']) && bccomp($_REQUEST['screenitemid'], $screenitem['screenitemid']) == 0)) { $screenView = new CView('monitoring.screen.constructor.edit', ['screen' => $this->screen]); $item = $screenView->render(); $isEditForm = true; } elseif (!empty($screenitem['screenitemid']) && isset($screenitem['resourcetype'])) { $screenBase = CScreenBuilder::getScreen(['screen' => $this->screen, 'screenid' => $this->screen['screenid'], 'isFlickerfree' => $this->isFlickerfree, 'pageFile' => $this->pageFile, 'mode' => $this->mode, 'timestamp' => $this->timestamp, 'hostid' => $this->hostid, 'profileIdx' => $this->profileIdx, 'profileIdx2' => $this->profileIdx2, 'updateProfile' => $this->updateProfile, 'timeline' => $this->timeline, 'resourcetype' => $screenitem['resourcetype'], 'screenitem' => $screenitem]); if (!empty($screenBase)) { $screenBase->action = $action; $item = $screenBase->get(); } else { $item = null; } } elseif ($this->mode == SCREEN_MODE_EDIT) { $item = [(new CDiv((new CLink(_('Change'), $action))->addClass('empty_change_link')))->addClass(ZBX_STYLE_CENTER)]; } else { $item = null; } if ($this->mode == SCREEN_MODE_EDIT && !$isEditForm) { $item = (new CDiv($item))->addClass('draggable')->setId('position_' . $r . '_' . $c)->setAttribute('data-xcoord', $c)->setAttribute('data-ycoord', $r); } // colspan/rowspan $newColumn = (new CCol($item))->addClass('screenitem'); if ($screenitem['halign'] == HALIGN_CENTER || $isEditForm) { $newColumn->addClass(ZBX_STYLE_CENTER); } elseif ($screenitem['halign'] == HALIGN_LEFT) { $newColumn->addClass(ZBX_STYLE_LEFT); } elseif ($screenitem['halign'] == HALIGN_RIGHT) { $newColumn->addClass(ZBX_STYLE_RIGHT); } if ($screenitem['valign'] == VALIGN_MIDDLE || $isEditForm) { $newColumn->addClass(ZBX_STYLE_MIDDLE); } elseif ($screenitem['valign'] == VALIGN_TOP) { $newColumn->addClass(ZBX_STYLE_TOP); } elseif ($screenitem['valign'] == VALIGN_BOTTOM) { $newColumn->addClass(ZBX_STYLE_BOTTOM); } if ($screenitem['colspan'] > 1) { $newColumn->setColSpan($screenitem['colspan']); } if ($screenitem['rowspan'] > 1) { $newColumn->setRowSpan($screenitem['rowspan']); } $newColumns[] = $newColumn; } // action right cell if ($this->mode == SCREEN_MODE_EDIT) { if ($this->screen['vsize'] == SCREEN_MIN_SIZE) { $link = (new CDiv('−'))->addClass(ZBX_STYLE_TREEVIEW_PLUS)->addClass(ZBX_STYLE_DISABLED); } else { $link = (new CLink('−', 'screenedit.php?screenid=' . $this->screen['screenid'] . url_param('templateid') . '&rmv_row=' . $r))->addClass(ZBX_STYLE_TREEVIEW_PLUS)->addSID(); if (!$emptyScreenRow) { $link->addConfirmation(CJs::encodeJson(_('This screen-row is not empty. Delete it?'))); } } $newColumns[] = (new CCol($link))->addClass(ZBX_STYLE_CENTER)->addClass(ZBX_STYLE_MIDDLE); } $screenTable->addRow(new CRow($newColumns)); } // action bottom row if ($this->mode == SCREEN_MODE_EDIT) { if ($this->screen['vsize'] >= SCREEN_MAX_SIZE) { $link = (new CDiv('+'))->addClass(ZBX_STYLE_TREEVIEW_PLUS)->addClass(ZBX_STYLE_DISABLED); } else { $link = (new CLink('+', 'screenedit.php?screenid=' . $this->screen['screenid'] . url_param('templateid') . '&add_row=' . $this->screen['vsize']))->addClass(ZBX_STYLE_TREEVIEW_PLUS)->addSID(); } $newColumns = [(new CCol($link))->addClass(ZBX_STYLE_CENTER)->addClass(ZBX_STYLE_MIDDLE)]; for ($i = 0; $i < $this->screen['hsize']; $i++) { if ($this->screen['hsize'] == SCREEN_MIN_SIZE) { $link = (new CDiv('−'))->addClass(ZBX_STYLE_TREEVIEW_PLUS)->addClass(ZBX_STYLE_DISABLED); } else { $link = (new CLink('−', 'screenedit.php?screenid=' . $this->screen['screenid'] . url_param('templateid') . '&rmv_col=' . $i))->addClass(ZBX_STYLE_TREEVIEW_PLUS)->addSID(); if (array_key_exists($i, $emptyScreenColumns)) { $link->addConfirmation(CJs::encodeJson(_('This screen-column is not empty. Delete it?'))); } } $newColumns[] = (new CCol($link))->addClass(ZBX_STYLE_CENTER)->addClass(ZBX_STYLE_MIDDLE); } $newColumns[] = ''; $screenTable->addRow($newColumns); } return $screenTable; }
// macro $macro = (new CTextBox('conditions[' . $i . '][macro]', $condition['macro'], false, 64))->setWidth(ZBX_TEXTAREA_MACRO_WIDTH)->addClass(ZBX_STYLE_UPPERCASE)->addClass('macro')->setAttribute('placeholder', '{#MACRO}')->setAttribute('data-formulaid', $condition['formulaid']); // value $value = (new CTextBox('conditions[' . $i . '][value]', $condition['value'], false, 255))->setWidth(ZBX_TEXTAREA_MACRO_VALUE_WIDTH)->setAttribute('placeholder', _('regular expression')); // delete button $deleteButtonCell = [(new CButton('conditions_' . $i . '_remove', _('Remove')))->addClass(ZBX_STYLE_BTN_LINK)->addClass('element-table-remove')]; $row = [$formulaId, $macro, new CSpan(_('matches')), $value, (new CCol($deleteButtonCell))->addClass(ZBX_STYLE_NOWRAP)]; $conditionTable->addRow($row, 'form_row'); } $conditionTable->setFooter(new CCol((new CButton('macro_add', _('Add')))->addClass(ZBX_STYLE_BTN_LINK)->addClass('element-table-add'))); $conditionFormList->addRow(_('Filters'), (new CDiv($conditionTable))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_BIG_WIDTH . 'px;')); // append tabs to form $itemTab = (new CTabView())->addTab('itemTab', $this->data['caption'], $itemFormList)->addTab('macroTab', _('Filters'), $conditionFormList); if (!hasRequest('form_refresh')) { $itemTab->setSelected(0); } // append buttons to form if (!empty($this->data['itemid'])) { $buttons = [new CSubmit('clone', _('Clone'))]; if (!$this->data['limited']) { $buttons[] = new CButtonDelete(_('Delete discovery rule?'), url_params(['form', 'groupid', 'itemid', 'parent_discoveryid', 'hostid'])); } $buttons[] = new CButtonCancel(url_param('groupid') . url_param('parent_discoveryid') . url_param('hostid')); $itemTab->setFooter(makeFormFooter(new CSubmit('update', _('Update')), $buttons)); } else { $itemTab->setFooter(makeFormFooter(new CSubmit('add', _('Add')), [new CButtonCancel(url_param('groupid') . url_param('parent_discoveryid') . url_param('hostid'))])); } $itemForm->addItem($itemTab); $widget->addItem($itemForm); require_once dirname(__FILE__) . '/js/configuration.host.discovery.edit.js.php'; return $widget;
/** * Execute request CURL. */ protected function call() { global $_COOKIE; $url = $this->url; // Make headers $headers = []; foreach ($this->header as $hk => $hv) { $headers[] = sprintf('%s: %s', $hk, $hv); } // Options request cURL $opts = []; $opts[CURLOPT_RETURNTRANSFER] = true; // Hide return $opts[CURLOPT_AUTOREFERER] = true; // Follow redirects $opts[CURLOPT_FOLLOWLOCATION] = true; // Follow redirects too $opts[CURLOPT_HEADER] = false; // Extract headers $opts[CURLOPT_SSL_VERIFYPEER] = true; // This make sure it fail on SSL CA $opts[CURLOPT_HTTPHEADER] = $headers; // Headers // Send cookies if ($this->sendcookie) { // remove XDEBUG_SESSION $cookie = $_COOKIE; if (array_key_exists('XDEBUG_SESSION', $cookie)) { unset($cookie['XDEBUG_SESSION']); } $opts[CURLOPT_COOKIE] = http_build_query($cookie, null, ';'); } // Method switch ($this->method) { case 'POST': $opts[CURLOPT_POST] = true; $opts[CURLOPT_POSTFIELDS] = $this->params; $opts[CURLOPT_URL] = $url; break; case 'GET': $opts[CURLOPT_HTTPGET] = true; $opts[CURLOPT_URL] = url_params($url, $this->params); break; case 'PUT': $opts[CURLOPT_PUT] = true; $opts[CURLOPT_URL] = url_params($url, $this->params); break; case 'DELETE': $opts[CURLOPT_CUSTOMREQUEST] = 'DELETE'; $opts[CURLOPT_URL] = $url; break; case '': error('RestClient: Method was not informed'); break; default: error('RestClient: Method %s not implemented', $this->method); break; } // cURL call $cr = curl_init(); curl_setopt_array($cr, $opts); $resp_body = curl_exec($cr); // Has error request if (curl_errno($cr)) { $e = new \Exception(curl_error($cr), curl_errno($cr)); curl_close($cr); throw $e; } // Get response header $resp_header = curl_getinfo($cr); curl_close($cr); $response = new Response($resp_header, $resp_body, $this->header['Accept']); $this->reset(); return $response->make(); }
$dependenciesTable->setHeader(array(_('Name'), _('Action'))); foreach ($this->data['dependencies'] as $dependency) { $triggersForm->addVar('dependencies[]', $dependency['triggerid'], 'dependencies_' . $dependency['triggerid']); $hostNames = array(); foreach ($dependency['hosts'] as $host) { $hostNames[] = CHtml::encode($host['name']); $hostNames[] = ', '; } array_pop($hostNames); if ($dependency['flags'] == ZBX_FLAG_DISCOVERY_NORMAL) { $description = new CLink(array($hostNames, NAME_DELIMITER, CHtml::encode($dependency['description'])), 'triggers.php?form=update&hostid=' . $dependency['hostid'] . '&triggerid=' . $dependency['triggerid']); $description->setAttribute('target', '_blank'); } else { $description = array($hostNames, NAME_DELIMITER, $dependency['description']); } $row = new CRow(array($description, new CButton('remove', _('Remove'), 'javascript: removeDependency(\'' . $dependency['triggerid'] . '\');', 'link_menu'))); $row->setAttribute('id', 'dependency_' . $dependency['triggerid']); $dependenciesTable->addRow($row); } $dependenciesDiv = new CDiv(array($dependenciesTable, new CButton('btn1', _('Add'), 'return PopUp("popup.php?' . 'dstfrm=massupdate' . '&dstact=add_dependency' . '&reference=deptrigger' . '&dstfld1=new_dependency' . '&srctbl=triggers' . '&objname=triggers' . '&srcfld1=triggerid' . '&multiselect=1' . '&with_triggers=1", 1000, 700);', 'link_menu')), 'objectgroup inlineblock border_dotted ui-corner-all'); $dependenciesDiv->setAttribute('id', 'dependencies_div'); $triggersFormList->addRow(array(_('Replace dependencies'), SPACE, new CVisibilityBox('visible[dependencies]', isset($this->data['visible']['dependencies']), 'dependencies_div', _('Original'))), $dependenciesDiv); } // append tabs to form $triggersTab = new CTabView(); $triggersTab->addTab('triggersTab', _('Mass update'), $triggersFormList); $triggersForm->addItem($triggersTab); // append buttons to form $triggersForm->addItem(makeFormFooter(new CSubmit('massupdate', _('Update')), new CButtonCancel(url_params(array('groupid', 'hostid', 'parent_discoveryid'))))); $triggersWidget->addItem($triggersForm); return $triggersWidget;
*/ $dependenciesFormList = new CFormList('dependenciesFormList'); $dependenciesTable = (new CTable())->setAttribute('style', 'width: 100%;')->setHeader([_('Name'), _('Action')]); foreach ($this->data['db_dependencies'] as $dependency) { $triggersForm->addVar('dependencies[]', $dependency['triggerid'], 'dependencies_' . $dependency['triggerid']); $depTriggerDescription = CHtml::encode(implode(', ', zbx_objectValues($dependency['hosts'], 'name')) . NAME_DELIMITER . $dependency['description']); if ($dependency['flags'] == ZBX_FLAG_DISCOVERY_PROTOTYPE) { $description = (new CLink($depTriggerDescription, 'trigger_prototypes.php?form=update' . url_param('parent_discoveryid') . '&triggerid=' . $dependency['triggerid']))->setAttribute('target', '_blank'); } elseif ($dependency['flags'] == ZBX_FLAG_DISCOVERY_NORMAL) { $description = (new CLink($depTriggerDescription, 'triggers.php?form=update&triggerid=' . $dependency['triggerid']))->setAttribute('target', '_blank'); } $row = new CRow([$description, (new CCol((new CButton('remove', _('Remove')))->onClick('javascript: removeDependency("' . $dependency['triggerid'] . '");')->addClass(ZBX_STYLE_BTN_LINK)))->addClass(ZBX_STYLE_NOWRAP)]); $row->setId('dependency_' . $dependency['triggerid']); $dependenciesTable->addRow($row); } $dependenciesFormList->addRow(_('Dependencies'), (new CDiv([$dependenciesTable, new CHorList([(new CButton('add_dep_trigger', _('Add')))->onClick('return PopUp("popup.php?srctbl=triggers&srcfld1=triggerid&reference=deptrigger' . '&multiselect=1&with_triggers=1&normal_only=1&noempty=1");')->addClass(ZBX_STYLE_BTN_LINK), (new CButton('add_dep_trigger_prototype', _('Add prototype')))->onClick('return PopUp("popup.php?srctbl=trigger_prototypes&srcfld1=triggerid&reference=deptrigger' . url_param('parent_discoveryid') . '&multiselect=1");')->addClass(ZBX_STYLE_BTN_LINK)])]))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_BIG_WIDTH . 'px;')); $triggersTab->addTab('dependenciesTab', _('Dependencies'), $dependenciesFormList); // append buttons to form if (!empty($this->data['triggerid'])) { $deleteButton = new CButtonDelete(_('Delete trigger prototype?'), url_params(['form', 'triggerid', 'parent_discoveryid'])); if ($this->data['limited']) { $deleteButton->setAttribute('disabled', 'disabled'); } $triggersTab->setFooter(makeFormFooter(new CSubmit('update', _('Update')), [new CSubmit('clone', _('Clone')), $deleteButton, new CButtonCancel(url_param('parent_discoveryid'))])); } else { $triggersTab->setFooter(makeFormFooter(new CSubmit('add', _('Add')), [new CButtonCancel(url_param('parent_discoveryid'))])); } // append tabs to form $triggersForm->addItem($triggersTab); $triggersWidget->addItem($triggersForm); return $triggersWidget;