예제 #1
0
파일: scripts.php 프로젝트: phedders/zabbix
    $usr_groups->addItem(0, S_ALL_S);
    $sql = 'SELECT DISTINCT ug.name, ug.usrgrpid ' . ' FROM usrgrp ug ' . ' WHERE ' . DBin_node('ug.usrgrpid') . ' ORDER BY ug.name';
    $usrgrp_result = DBselect($sql);
    while ($usr_group = DBfetch($usrgrp_result)) {
        $usr_groups->addItem($usr_group['usrgrpid'], $usr_group['name']);
    }
    $frmScr->addRow(S_USER_GROUPS, $usr_groups);
    $host_groups = new CCombobox('groupid', $groupid);
    $host_groups->addItem(0, S_ALL_S);
    $sql = 'SELECT DISTINCT g.name, g.groupid ' . ' FROM groups g ' . ' WHERE ' . DBcondition('g.groupid', $available_groups) . ' ORDER BY g.name';
    $grp_result = DBselect($sql);
    while ($group = DBfetch($grp_result)) {
        $host_groups->addItem($group['groupid'], $group['name']);
    }
    $frmScr->addRow(S_HOST_GROUPS, $host_groups);
    $select_acc = new CCombobox('access', $access);
    $select_acc->addItem(PERM_READ_ONLY, S_READ);
    $select_acc->addItem(PERM_READ_WRITE, S_WRITE);
    $frmScr->addRow(S_REQUIRED_HOST . SPACE . S_PERMISSIONS_SMALL, $select_acc);
    $frmScr->addItemToBottomRow(new CButton('save', S_SAVE, "javascript: document.getElementById('scripts').action+='?action=1'; "));
    $frmScr->addItemToBottomRow(SPACE);
    if (isset($_REQUEST['scriptid'])) {
        $deleteButton = new CButtonDelete(S_DELETE_SCRIPTS_Q, '&action=1&scriptid=' . $_REQUEST['scriptid']);
        $frmScr->addItemToBottomRow($deleteButton);
        $frmScr->addItemToBottomRow(SPACE);
    }
    $frmScr->addItemToBottomRow(new CButtonCancel());
    $frmScr->Show();
} else {
    validate_sort_and_sortorder('s.name', ZBX_SORT_UP);
    $form = new CForm();
$scriptFormList->addRow(_('Description'), new CTextArea('description', $this->get('description')));
// user groups
$userGroups = new CCombobox('usrgrpid', $this->get('usrgrpid'));
$userGroups->addItem(0, _('All'));
foreach ($this->getArray('usergroups') as $userGroup) {
    $userGroups->addItem($userGroup['usrgrpid'], $userGroup['name']);
}
$scriptFormList->addRow(_('User groups'), $userGroups);
// host groups
$hostGroups = new CCombobox('hgstype', $this->get('hgstype'));
$hostGroups->addItem(0, _('All'));
$hostGroups->addItem(1, _('Selected'));
$scriptFormList->addRow(_('Host groups'), $hostGroups);
$scriptFormList->addRow(null, new CMultiSelect(array('name' => 'groupid', 'selectedLimit' => 1, 'objectName' => 'hostGroup', 'data' => $this->get('hostGroup'))), null, 'hostGroupSelection');
// access
$accessComboBox = new CCombobox('access', $this->get('access'));
$accessComboBox->addItem(PERM_READ, _('Read'));
$accessComboBox->addItem(PERM_READ_WRITE, _('Write'));
$scriptFormList->addRow(_('Required host permissions'), $accessComboBox);
$scriptFormList->addRow(new CLabel(_('Enable confirmation'), 'enableConfirmation'), new CCheckBox('enableConfirmation', $this->get('enableConfirmation')));
$confirmationLabel = new CLabel(_('Confirmation text'), 'confirmation');
$confirmationLabel->setAttribute('id', 'confirmationLabel');
$scriptFormList->addRow($confirmationLabel, array(new CTextBox('confirmation', $this->get('confirmation'), ZBX_TEXTBOX_STANDARD_SIZE), SPACE, new CButton('testConfirmation', _('Test confirmation'), null, 'link_menu')));
$scriptView = new CTabView();
$scriptView->addTab('scripts', _('Script'), $scriptFormList);
$scriptForm->addItem($scriptView);
// footer
$others = array();
if (isset($_REQUEST['scriptid'])) {
    $others[] = new CButton('clone', _('Clone'));
    $others[] = new CButtonDelete(_('Delete script?'), url_param('form') . url_param('scriptid'));
$usr_groups->addItem(0, _('All'));
$usergroups = $this->getArray('usergroups');
foreach ($usergroups as $ugnum => $usr_group) {
    $usr_groups->addItem($usr_group['usrgrpid'], $usr_group['name']);
}
$scriptTab->addRow(_('User groups'), $usr_groups);
// host groups
$host_groups = new CCombobox('groupid', $this->get('groupid'));
$host_groups->addItem(0, _('All'));
$groups = $this->getArray('groups');
foreach ($groups as $gnum => $group) {
    $host_groups->addItem($group['groupid'], $group['name']);
}
$scriptTab->addRow(_('Host groups'), $host_groups);
// permissions
$select_acc = new CCombobox('access', $this->get('access'));
$select_acc->addItem(PERM_READ_ONLY, _('Read'));
$select_acc->addItem(PERM_READ_WRITE, _('Write'));
$scriptTab->addRow(_('Required host permissions'), $select_acc);
// confirmation
$enableQuestCB = new CCheckBox('enableConfirmation', $this->get('enableConfirmation'));
$scriptTab->addRow(new CLabel(_('Enable confirmation'), 'enableConfirmation'), array($enableQuestCB, SPACE));
$confirmationTB = new CTextBox('confirmation', $this->get('confirmation'));
$confirmationTB->addStyle('width: 50em;');
$confirmationTB->setAttribute('maxlength', 255);
$testLink = new CButton('testConfirmation', _('Test confirmation'), null, 'link_menu');
$confirmationLabel = new CLabel(_('Confirmation text'), 'confirmation');
$confirmationLabel->setAttribute('id', 'confirmationLabel');
$scriptTab->addRow($confirmationLabel, array($confirmationTB, SPACE, $testLink));
$scriptView = new CTabView();
$scriptView->addTab('scripts', _('Script'), $scriptTab);
예제 #4
0
                    $usr_test->addItem($db_user['alias'], $db_user['alias']);
                }
            }
        } else {
            $usr_test = new CTextBox('user', $USER_DETAILS['alias'], null, 'yes');
        }
        $frmAuth->addRow(S_LOGIN, $usr_test);
        $frmAuth->addRow(S_USER . SPACE . S_PASSWORD, new CPassBox('user_password'));
        $frmAuth->addItemToBottomRow(new CButton('save', S_SAVE));
        $frmAuth->addItemToBottomRow(new CButton('test', S_TEST));
        $frmAuth->Show();
    } else {
        if (ZBX_AUTH_HTTP == $_REQUEST['config']) {
            $form_refresh_http = get_request('form_refresh_http', 0);
            $form_refresh_http++;
            $frmAuth = new CFormTable(S_HTTP_AUTH, 'authentication.php');
            $frmAuth->SetHelp('web.authentication.php');
            $frmAuth->addVar('form_refresh_http', $form_refresh_http);
            $cmbConfig = new CCombobox('config', ZBX_AUTH_HTTP, 'submit()');
            $cmbConfig->addItem(ZBX_AUTH_INTERNAL, S_INTERNAL_S);
            $cmbConfig->addItem(ZBX_AUTH_LDAP, S_LDAP);
            $cmbConfig->addItem(ZBX_AUTH_HTTP, S_HTTP);
            $frmAuth->addRow(S_DEFAULT_AUTHENTICATION, $cmbConfig);
            $action = "javascript: if(confirm('" . S_SWITCHING_HTTP . "')) return true; else return false;";
            $frmAuth->addRow(S_HTTP_AUTH . SPACE . S_ENABLED, new CCheckBox('authentication_type', ZBX_AUTH_HTTP == $config['authentication_type'], $action, ZBX_AUTH_HTTP));
            $frmAuth->addItemToBottomRow(new CButton('save', S_SAVE));
            $frmAuth->Show();
        }
    }
}
include_once 'include/page_footer.php';
    $urlLink = new CTextBox('urls[' . $i . '][url]', $url['url'], 32);
    $urlEtype = new CCombobox('urls[' . $i . '][elementtype]', $url['elementtype']);
    $urlEtype->addItems(sysmap_element_types());
    $removeButton = new CSpan(_('Remove'), 'link_menu');
    $removeButton->addAction('onclick', '$("urlEntry_' . $i . '").remove();');
    $urlRow = new CRow(array($urlLabel, $urlLink, $urlEtype, $removeButton));
    $urlRow->setAttribute('id', 'urlEntry_' . $i);
    $urlTable->addRow($urlRow);
    $i++;
}
// append empty template row to url table
$templateUrlLabel = new CTextBox('urls[#{id}][name]', '', 32);
$templateUrlLabel->setAttribute('disabled', 'disabled');
$templateUrlLink = new CTextBox('urls[#{id}][url]', '', 32);
$templateUrlLink->setAttribute('disabled', 'disabled');
$templateUrlEtype = new CCombobox('urls[#{id}][elementtype]');
$templateUrlEtype->setAttribute('disabled', 'disabled');
$templateUrlEtype->addItems(sysmap_element_types());
$templateRemoveButton = new CSpan(_('Remove'), 'link_menu');
$templateRemoveButton->addAction('onclick', '$("entry_#{id}").remove();');
$templateUrlRow = new CRow(array($templateUrlLabel, $templateUrlLink, $templateUrlEtype, $templateRemoveButton));
$templateUrlRow->addStyle('display: none');
$templateUrlRow->setAttribute('id', 'urlEntryTpl');
$urlTable->addRow($templateUrlRow);
// append "add" button to url table
$addButton = new CSpan(_('Add'), 'link_menu');
$addButton->addAction('onclick', 'cloneRow("urlEntryTpl", ' . $i . ')');
$addButtonColumn = new CCol($addButton);
$addButtonColumn->setColSpan(4);
$urlTable->addRow($addButtonColumn);
// append url table to form list
예제 #6
0
function get_screen_item_form()
{
    global $USER_DETAILS;
    $form = new CFormTable(S_SCREEN_CELL_CONFIGURATION, 'screenedit.php?screenid=' . $_REQUEST['screenid']);
    $form->SetHelp('web.screenedit.cell.php');
    if (isset($_REQUEST['screenitemid'])) {
        $sql = 'SELECT * ' . ' FROM screens_items' . ' WHERE screenid=' . $_REQUEST['screenid'] . ' AND screenitemid=' . $_REQUEST['screenitemid'];
        $iresult = DBSelect($sql);
        $form->addVar('screenitemid', $_REQUEST['screenitemid']);
    } else {
        $form->addVar('x', $_REQUEST['x']);
        $form->addVar('y', $_REQUEST['y']);
    }
    if (isset($_REQUEST['screenitemid']) && !isset($_REQUEST['form_refresh'])) {
        $irow = DBfetch($iresult);
        $resourcetype = $irow['resourcetype'];
        $resourceid = $irow['resourceid'];
        $width = $irow['width'];
        $height = $irow['height'];
        $colspan = $irow['colspan'];
        $rowspan = $irow['rowspan'];
        $elements = $irow['elements'];
        $valign = $irow['valign'];
        $halign = $irow['halign'];
        $style = $irow['style'];
        $url = $irow['url'];
        $dynamic = $irow['dynamic'];
    } else {
        $resourcetype = get_request('resourcetype', 0);
        $resourceid = get_request('resourceid', 0);
        $width = get_request('width', 500);
        $height = get_request('height', 100);
        $colspan = get_request('colspan', 0);
        $rowspan = get_request('rowspan', 0);
        $elements = get_request('elements', 25);
        $valign = get_request('valign', VALIGN_DEFAULT);
        $halign = get_request('halign', HALIGN_DEFAULT);
        $style = get_request('style', 0);
        $url = get_request('url', '');
        $dynamic = get_request('dynamic', SCREEN_SIMPLE_ITEM);
    }
    $form->addVar('screenid', $_REQUEST['screenid']);
    // a-z order!!!
    $cmbRes = new CCombobox('resourcetype', $resourcetype, 'submit()');
    $cmbRes->addItem(SCREEN_RESOURCE_CLOCK, S_CLOCK);
    $cmbRes->addItem(SCREEN_RESOURCE_DATA_OVERVIEW, S_DATA_OVERVIEW);
    $cmbRes->addItem(SCREEN_RESOURCE_GRAPH, S_GRAPH);
    $cmbRes->addItem(SCREEN_RESOURCE_ACTIONS, S_HISTORY_OF_ACTIONS);
    $cmbRes->addItem(SCREEN_RESOURCE_EVENTS, S_HISTORY_OF_EVENTS);
    $cmbRes->addItem(SCREEN_RESOURCE_HOSTS_INFO, S_HOSTS_INFO);
    $cmbRes->addItem(SCREEN_RESOURCE_MAP, S_MAP);
    $cmbRes->addItem(SCREEN_RESOURCE_PLAIN_TEXT, S_PLAIN_TEXT);
    $cmbRes->addItem(SCREEN_RESOURCE_SCREEN, S_SCREEN);
    $cmbRes->addItem(SCREEN_RESOURCE_SERVER_INFO, S_SERVER_INFO);
    $cmbRes->addItem(SCREEN_RESOURCE_SIMPLE_GRAPH, S_SIMPLE_GRAPH);
    $cmbRes->addItem(SCREEN_RESOURCE_HOSTGROUP_TRIGGERS, S_STATUS_OF_HOSTGROUP_TRIGGERS);
    $cmbRes->addItem(SCREEN_RESOURCE_HOST_TRIGGERS, S_STATUS_OF_HOST_TRIGGERS);
    $cmbRes->addItem(SCREEN_RESOURCE_SYSTEM_STATUS, S_SYSTEM_STATUS);
    $cmbRes->addItem(SCREEN_RESOURCE_TRIGGERS_INFO, S_TRIGGERS_INFO);
    $cmbRes->addItem(SCREEN_RESOURCE_TRIGGERS_OVERVIEW, S_TRIGGERS_OVERVIEW);
    $cmbRes->addItem(SCREEN_RESOURCE_URL, S_URL);
    $form->addRow(S_RESOURCE, $cmbRes);
    if ($resourcetype == SCREEN_RESOURCE_GRAPH) {
        // User-defined graph
        $options = array('graphids' => $resourceid, 'select_hosts' => array('hostid', 'host'), 'output' => API_OUTPUT_EXTEND);
        $graphs = CGraph::get($options);
        $caption = '';
        $id = 0;
        if (!empty($graphs)) {
            $id = $resourceid;
            $graph = reset($graphs);
            order_result($graph['hosts'], 'host');
            $graph['host'] = reset($graph['hosts']);
            $caption = $graph['host']['host'] . ':' . $graph['name'];
            $nodeName = get_node_name_by_elid($graph['host']['hostid']);
            if (!zbx_empty($nodeName)) {
                $caption = '(' . $nodeName . ') ' . $caption;
            }
        }
        $form->addVar('resourceid', $id);
        $textfield = new CTextbox('caption', $caption, 75, 'yes');
        $selectbtn = new CButton('select', S_SELECT, "javascript: return PopUp('popup.php?writeonly=1&dstfrm=" . $form->getName() . "&real_hosts=1&dstfld1=resourceid&dstfld2=caption&srctbl=graphs&srcfld1=graphid&srcfld2=name',800,450);");
        $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';");
        $form->addRow(S_GRAPH_NAME, array($textfield, SPACE, $selectbtn));
    } else {
        if ($resourcetype == SCREEN_RESOURCE_SIMPLE_GRAPH) {
            // Simple graph
            $options = array('itemids' => $resourceid, 'select_hosts' => array('hostid', 'host'), 'output' => API_OUTPUT_EXTEND);
            $items = CItem::get($options);
            $caption = '';
            $id = 0;
            if (!empty($items)) {
                $id = $resourceid;
                $item = reset($items);
                $item['host'] = reset($item['hosts']);
                $caption = item_description($item);
                $nodeName = get_node_name_by_elid($item['itemid']);
                if (!zbx_empty($nodeName)) {
                    $caption = '(' . $nodeName . ') ' . $caption;
                }
            }
            $form->addVar('resourceid', $id);
            $textfield = new Ctextbox('caption', $caption, 75, 'yes');
            $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?writeonly=1&real_hosts=1&dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=simple_graph&srcfld1=itemid&srcfld2=description',800,450);");
            $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';");
            $form->addRow(S_PARAMETER, array($textfield, SPACE, $selectbtn));
        } else {
            if ($resourcetype == SCREEN_RESOURCE_MAP) {
                // Map
                $options = array('sysmapids' => $resourceid, 'output' => API_OUTPUT_EXTEND);
                $maps = CMap::get($options);
                $caption = '';
                $id = 0;
                if (!empty($maps)) {
                    $id = $resourceid;
                    $map = reset($maps);
                    $caption = $map['name'];
                    $nodeName = get_node_name_by_elid($map['sysmapid']);
                    if (!zbx_empty($nodeName)) {
                        $caption = '(' . $nodeName . ') ' . $caption;
                    }
                }
                $form->addVar('resourceid', $id);
                $textfield = new Ctextbox('caption', $caption, 60, 'yes');
                $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?writeonly=1&dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=sysmaps&srcfld1=sysmapid&srcfld2=name',400,450);");
                $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';");
                $form->addRow(S_PARAMETER, array($textfield, SPACE, $selectbtn));
            } else {
                if ($resourcetype == SCREEN_RESOURCE_PLAIN_TEXT) {
                    // Plain text
                    $options = array('itemids' => $resourceid, 'select_hosts' => array('hostid', 'host'), 'output' => API_OUTPUT_EXTEND);
                    $items = CItem::get($options);
                    $caption = '';
                    $id = 0;
                    if (!empty($items)) {
                        $id = $resourceid;
                        $item = reset($items);
                        $item['host'] = reset($item['hosts']);
                        $caption = item_description($item);
                        $nodeName = get_node_name_by_elid($item['itemid']);
                        if (!zbx_empty($nodeName)) {
                            $caption = '(' . $nodeName . ') ' . $caption;
                        }
                    }
                    $form->addVar('resourceid', $id);
                    $textfield = new CTextbox('caption', $caption, 75, 'yes');
                    $selectbtn = new CButton('select', S_SELECT, "javascript: return PopUp('popup.php?writeonly=1&dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=plain_text&srcfld1=itemid&srcfld2=description',800,450);");
                    $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';");
                    $form->addRow(S_PARAMETER, array($textfield, SPACE, $selectbtn));
                    $form->addRow(S_SHOW_LINES, new CNumericBox('elements', $elements, 2));
                    $form->addRow(S_SHOW_TEXT_AS_HTML, new CCheckBox('style', $style, null, 1));
                } else {
                    if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_HOSTGROUP_TRIGGERS, SCREEN_RESOURCE_HOST_TRIGGERS))) {
                        // Status of triggers
                        $caption = '';
                        $id = 0;
                        if (SCREEN_RESOURCE_HOSTGROUP_TRIGGERS == $resourcetype) {
                            if ($resourceid > 0) {
                                $options = array('groupids' => $resourceid, 'output' => API_OUTPUT_EXTEND, 'editable' => 1);
                                $groups = CHostgroup::get($options);
                                foreach ($groups as $gnum => $group) {
                                    $caption = get_node_name_by_elid($group['groupid'], true, ':') . $group['name'];
                                    $id = $resourceid;
                                }
                            }
                            $form->addVar('resourceid', $id);
                            $textfield = new CTextbox('caption', $caption, 60, 'yes');
                            $selectbtn = new CButton('select', S_SELECT, "javascript: return PopUp('popup.php?writeonly=1&dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=host_group&srcfld1=groupid&srcfld2=name',800,450);");
                            $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';");
                            $form->addRow(S_GROUP, array($textfield, SPACE, $selectbtn));
                        } else {
                            if ($resourceid > 0) {
                                $options = array('hostids' => $resourceid, 'output' => API_OUTPUT_EXTEND, 'editable' => 1);
                                $hosts = CHost::get($options);
                                foreach ($hosts as $hnum => $host) {
                                    $caption = get_node_name_by_elid($host['hostid'], true, ':') . $host['host'];
                                    $id = $resourceid;
                                }
                            }
                            $form->addVar('resourceid', $id);
                            $textfield = new CTextbox('caption', $caption, 60, 'yes');
                            $selectbtn = new CButton('select', S_SELECT, "javascript: return PopUp('popup.php?writeonly=1&dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=hosts&srcfld1=hostid&srcfld2=host',800,450);");
                            $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';");
                            $form->addRow(S_HOST, array($textfield, SPACE, $selectbtn));
                        }
                        $form->addRow(S_SHOW_LINES, new CNumericBox('elements', $elements, 2));
                    } else {
                        if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_EVENTS, SCREEN_RESOURCE_ACTIONS))) {
                            // History of actions
                            // History of events
                            $form->addRow(S_SHOW_LINES, new CNumericBox('elements', $elements, 2));
                            $form->addVar('resourceid', 0);
                        } else {
                            if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_TRIGGERS_OVERVIEW, SCREEN_RESOURCE_DATA_OVERVIEW))) {
                                // Overviews
                                $caption = '';
                                $id = 0;
                                if ($resourceid > 0) {
                                    $options = array('groupids' => $resourceid, 'output' => API_OUTPUT_EXTEND, 'editable' => 1);
                                    $groups = CHostgroup::get($options);
                                    foreach ($groups as $gnum => $group) {
                                        $caption = get_node_name_by_elid($group['groupid'], true, ':') . $group['name'];
                                        $id = $resourceid;
                                    }
                                }
                                $form->addVar('resourceid', $id);
                                $textfield = new CTextbox('caption', $caption, 75, 'yes');
                                $selectbtn = new CButton('select', S_SELECT, "javascript: return PopUp('popup.php?writeonly=1&dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=overview&srcfld1=groupid&srcfld2=name',800,450);");
                                $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';");
                                $form->addRow(S_GROUP, array($textfield, SPACE, $selectbtn));
                            } else {
                                if ($resourcetype == SCREEN_RESOURCE_SCREEN) {
                                    // Screens
                                    $caption = '';
                                    $id = 0;
                                    if ($resourceid > 0) {
                                        $result = DBselect('SELECT DISTINCT n.name as node_name,s.screenid,s.name ' . ' FROM screens s ' . ' LEFT JOIN nodes n ON n.nodeid=' . DBid2nodeid('s.screenid') . ' WHERE s.screenid=' . $resourceid);
                                        while ($row = DBfetch($result)) {
                                            $r = CScreen::get(array('screenids' => $row['screenid'], 'output' => API_OUTPUT_SHORTEN));
                                            if (empty($r)) {
                                                continue;
                                            }
                                            if (check_screen_recursion($_REQUEST['screenid'], $row['screenid'])) {
                                                continue;
                                            }
                                            $row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : '';
                                            $caption = $row['node_name'] . $row['name'];
                                            $id = $resourceid;
                                        }
                                    }
                                    $form->addVar('resourceid', $id);
                                    $textfield = new Ctextbox('caption', $caption, 60, 'yes');
                                    $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?writeonly=1&dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=screens2&srcfld1=screenid&srcfld2=name&screenid=" . $_REQUEST['screenid'] . "',800,450);");
                                    $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';");
                                    $form->addRow(S_PARAMETER, array($textfield, SPACE, $selectbtn));
                                } else {
                                    if ($resourcetype == SCREEN_RESOURCE_HOSTS_INFO || $resourcetype == SCREEN_RESOURCE_TRIGGERS_INFO) {
                                        // HOSTS info
                                        $caption = '';
                                        $id = 0;
                                        $available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_ONLY);
                                        if (remove_nodes_from_id($resourceid) > 0) {
                                            $result = DBselect('SELECT DISTINCT n.name as node_name,g.groupid,g.name ' . ' FROM hosts_groups hg, groups g ' . ' LEFT JOIN nodes n ON n.nodeid=' . DBid2nodeid('g.groupid') . ' WHERE ' . DBcondition('g.groupid', $available_groups) . ' AND g.groupid=' . $resourceid);
                                            while ($row = DBfetch($result)) {
                                                $row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : '';
                                                $caption = $row['node_name'] . $row['name'];
                                                $id = $resourceid;
                                            }
                                        } else {
                                            if (remove_nodes_from_id($resourceid) == 0) {
                                                $result = DBselect('SELECT DISTINCT n.name as node_name ' . ' FROM nodes n ' . ' WHERE n.nodeid=' . id2nodeid($resourceid));
                                                while ($row = DBfetch($result)) {
                                                    $row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : '';
                                                    $caption = $row['node_name'] . S_MINUS_ALL_GROUPS_MINUS;
                                                    $id = $resourceid;
                                                }
                                            }
                                        }
                                        $form->addVar('resourceid', $id);
                                        $textfield = new CTextbox('caption', $caption, 60, 'yes');
                                        $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?writeonly=1&dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=host_group_scr&srcfld1=groupid&srcfld2=name',480,450);");
                                        $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';");
                                        $form->addRow(S_GROUP, array($textfield, SPACE, $selectbtn));
                                    } else {
                                        // SCREEN_RESOURCE_CLOCK
                                        $form->addVar('resourceid', 0);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_HOSTS_INFO, SCREEN_RESOURCE_TRIGGERS_INFO))) {
        $cmbStyle = new CComboBox("style", $style);
        $cmbStyle->addItem(STYLE_HORISONTAL, S_HORIZONTAL);
        $cmbStyle->addItem(STYLE_VERTICAL, S_VERTICAL);
        $form->addRow(S_STYLE, $cmbStyle);
    } else {
        if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_TRIGGERS_OVERVIEW, SCREEN_RESOURCE_DATA_OVERVIEW))) {
            $cmbStyle = new CComboBox('style', $style);
            $cmbStyle->addItem(STYLE_LEFT, S_LEFT);
            $cmbStyle->addItem(STYLE_TOP, S_TOP);
            $form->addRow(S_HOSTS_LOCATION, $cmbStyle);
        } else {
            if ($resourcetype == SCREEN_RESOURCE_CLOCK) {
                $cmbStyle = new CComboBox('style', $style);
                $cmbStyle->addItem(TIME_TYPE_LOCAL, S_LOCAL_TIME);
                $cmbStyle->addItem(TIME_TYPE_SERVER, S_SERVER_TIME);
                $form->addRow(S_TIME_TYPE, $cmbStyle);
            } else {
                $form->addVar('style', 0);
            }
        }
    }
    if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_URL))) {
        $form->addRow(S_URL, new CTextBox('url', $url, 60));
    } else {
        $form->addVar('url', '');
    }
    if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_GRAPH, SCREEN_RESOURCE_SIMPLE_GRAPH, SCREEN_RESOURCE_CLOCK, SCREEN_RESOURCE_URL))) {
        $form->addRow(S_WIDTH, new CNumericBox('width', $width, 5));
        $form->addRow(S_HEIGHT, new CNumericBox('height', $height, 5));
    } else {
        $form->addVar('width', 500);
        $form->addVar('height', 100);
    }
    if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_GRAPH, SCREEN_RESOURCE_SIMPLE_GRAPH, SCREEN_RESOURCE_MAP, SCREEN_RESOURCE_CLOCK, SCREEN_RESOURCE_URL))) {
        $cmbHalign = new CComboBox('halign', $halign);
        $cmbHalign->addItem(HALIGN_CENTER, S_CENTRE);
        $cmbHalign->addItem(HALIGN_LEFT, S_LEFT);
        $cmbHalign->addItem(HALIGN_RIGHT, S_RIGHT);
        $form->addRow(S_HORIZONTAL_ALIGN, $cmbHalign);
    } else {
        $form->addVar('halign', 0);
    }
    $cmbValign = new CComboBox('valign', $valign);
    $cmbValign->addItem(VALIGN_MIDDLE, S_MIDDLE);
    $cmbValign->addItem(VALIGN_TOP, S_TOP);
    $cmbValign->addItem(VALIGN_BOTTOM, S_BOTTOM);
    $form->addRow(S_VERTICAL_ALIGN, $cmbValign);
    $form->addRow(S_COLUMN_SPAN, new CNumericBox('colspan', $colspan, 2));
    $form->addRow(S_ROW_SPAN, new CNumericBox('rowspan', $rowspan, 2));
    // dynamic AddOn
    if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_GRAPH, SCREEN_RESOURCE_SIMPLE_GRAPH, SCREEN_RESOURCE_PLAIN_TEXT))) {
        $form->addRow(S_DYNAMIC_ITEM, new CCheckBox('dynamic', $dynamic, null, 1));
    }
    $form->addItemToBottomRow(new CButton('save', S_SAVE));
    if (isset($_REQUEST['screenitemid'])) {
        $form->addItemToBottomRow(SPACE);
        $form->addItemToBottomRow(new CButtonDelete(null, url_param('form') . url_param('screenid') . url_param('screenitemid')));
    }
    $form->addItemToBottomRow(SPACE);
    $form->addItemToBottomRow(new CButtonCancel(url_param('screenid')));
    return $form;
}
예제 #7
0
function get_screen_item_form()
{
    global $USER_DETAILS;
    $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY, get_current_nodeid(true));
    $form = new CFormTable(S_SCREEN_CELL_CONFIGURATION, 'screenedit.php#form');
    $form->SetHelp('web.screenedit.cell.php');
    if (isset($_REQUEST['screenitemid'])) {
        $iresult = DBSelect('SELECT * FROM screens_items' . ' WHERE screenid=' . $_REQUEST['screenid'] . ' AND screenitemid=' . $_REQUEST['screenitemid']);
        $form->AddVar('screenitemid', $_REQUEST['screenitemid']);
    } else {
        $form->AddVar('x', $_REQUEST['x']);
        $form->AddVar('y', $_REQUEST['y']);
    }
    if (isset($_REQUEST['screenitemid']) && !isset($_REQUEST['form_refresh'])) {
        $irow = DBfetch($iresult);
        $resourcetype = $irow['resourcetype'];
        $resourceid = $irow['resourceid'];
        $width = $irow['width'];
        $height = $irow['height'];
        $colspan = $irow['colspan'];
        $rowspan = $irow['rowspan'];
        $elements = $irow['elements'];
        $valign = $irow['valign'];
        $halign = $irow['halign'];
        $style = $irow['style'];
        $url = $irow['url'];
        $dynamic = $irow['dynamic'];
    } else {
        $resourcetype = get_request('resourcetype', 0);
        $resourceid = get_request('resourceid', 0);
        $width = get_request('width', 500);
        $height = get_request('height', 100);
        $colspan = get_request('colspan', 0);
        $rowspan = get_request('rowspan', 0);
        $elements = get_request('elements', 25);
        $valign = get_request('valign', VALIGN_DEFAULT);
        $halign = get_request('halign', HALIGN_DEFAULT);
        $style = get_request('style', 0);
        $url = get_request('url', '');
        $dynamic = get_request('dynamic', SCREEN_SIMPLE_ITEM);
    }
    $form->addVar('screenid', $_REQUEST['screenid']);
    $cmbRes = new CCombobox('resourcetype', $resourcetype, 'submit()');
    $cmbRes->addItem(SCREEN_RESOURCE_GRAPH, S_GRAPH);
    $cmbRes->addItem(SCREEN_RESOURCE_SIMPLE_GRAPH, S_SIMPLE_GRAPH);
    $cmbRes->addItem(SCREEN_RESOURCE_PLAIN_TEXT, S_PLAIN_TEXT);
    $cmbRes->addItem(SCREEN_RESOURCE_MAP, S_MAP);
    $cmbRes->addItem(SCREEN_RESOURCE_SCREEN, S_SCREEN);
    $cmbRes->addItem(SCREEN_RESOURCE_SERVER_INFO, S_SERVER_INFO);
    $cmbRes->addItem(SCREEN_RESOURCE_HOSTS_INFO, S_HOSTS_INFO);
    $cmbRes->addItem(SCREEN_RESOURCE_TRIGGERS_INFO, S_TRIGGERS_INFO);
    $cmbRes->addItem(SCREEN_RESOURCE_TRIGGERS_OVERVIEW, S_TRIGGERS_OVERVIEW);
    $cmbRes->addItem(SCREEN_RESOURCE_STATUS_OF_TRIGGERS, S_STATUS_OF_TRIGGERS);
    $cmbRes->addItem(SCREEN_RESOURCE_DATA_OVERVIEW, S_DATA_OVERVIEW);
    $cmbRes->addItem(SCREEN_RESOURCE_CLOCK, S_CLOCK);
    $cmbRes->addItem(SCREEN_RESOURCE_URL, S_URL);
    $cmbRes->addItem(SCREEN_RESOURCE_ACTIONS, S_HISTORY_OF_ACTIONS);
    $cmbRes->addItem(SCREEN_RESOURCE_EVENTS, S_HISTORY_OF_EVENTS);
    $form->addRow(S_RESOURCE, $cmbRes);
    if ($resourcetype == SCREEN_RESOURCE_GRAPH) {
        // User-defined graph
        $resourceid = graph_accessible($resourceid) ? $resourceid : 0;
        $caption = '';
        $id = 0;
        if ($resourceid > 0) {
            $result = DBselect('SELECT DISTINCT g.graphid,g.name,n.name as node_name, h.host' . ' FROM graphs g ' . ' LEFT JOIN graphs_items gi ON g.graphid=gi.graphid ' . ' LEFT JOIN items i ON gi.itemid=i.itemid ' . ' LEFT JOIN hosts h ON h.hostid=i.hostid ' . ' LEFT JOIN nodes n ON n.nodeid=' . DBid2nodeid('g.graphid') . ' WHERE g.graphid=' . $resourceid);
            while ($row = DBfetch($result)) {
                $row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : '';
                $caption = $row['node_name'] . $row['host'] . ':' . $row['name'];
                $id = $resourceid;
            }
        }
        $form->addVar('resourceid', $id);
        $textfield = new Ctextbox('caption', $caption, 75, 'yes');
        $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=graphs&srcfld1=graphid&srcfld2=name',800,450);");
        $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';");
        $form->AddRow(S_GRAPH_NAME, array($textfield, SPACE, $selectbtn));
    } else {
        if ($resourcetype == SCREEN_RESOURCE_SIMPLE_GRAPH) {
            // Simple graph
            $caption = '';
            $id = 0;
            if ($resourceid > 0) {
                $result = DBselect('SELECT n.name as node_name,h.host,i.description,i.itemid,i.key_ ' . ' FROM hosts h,items i ' . ' LEFT JOIN nodes n on n.nodeid=' . DBid2nodeid('i.itemid') . ' WHERE h.hostid=i.hostid ' . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND ' . DBcondition('i.hostid', $available_hosts) . ' AND i.itemid=' . $resourceid);
                while ($row = DBfetch($result)) {
                    $description_ = item_description($row);
                    $row["node_name"] = isset($row["node_name"]) ? "(" . $row["node_name"] . ") " : '';
                    $caption = $row['node_name'] . $row['host'] . ': ' . $description_;
                    $id = $resourceid;
                }
            }
            $form->AddVar('resourceid', $id);
            $textfield = new Ctextbox('caption', $caption, 75, 'yes');
            $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=simple_graph&srcfld1=itemid&srcfld2=description',800,450);");
            $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';");
            $form->AddRow(S_PARAMETER, array($textfield, SPACE, $selectbtn));
        } else {
            if ($resourcetype == SCREEN_RESOURCE_MAP) {
                // Map
                $caption = '';
                $id = 0;
                if ($resourceid > 0) {
                    $result = DBselect('SELECT n.name as node_name, s.sysmapid,s.name ' . ' FROM sysmaps s' . ' LEFT JOIN nodes n ON n.nodeid=' . DBid2nodeid('s.sysmapid') . ' WHERE s.sysmapid=' . $resourceid);
                    while ($row = DBfetch($result)) {
                        if (!sysmap_accessible($row['sysmapid'], PERM_READ_ONLY)) {
                            continue;
                        }
                        $row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : '';
                        $caption = $row['node_name'] . $row['name'];
                        $id = $resourceid;
                    }
                }
                $form->AddVar('resourceid', $id);
                $textfield = new Ctextbox('caption', $caption, 60, 'yes');
                $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=sysmaps&srcfld1=sysmapid&srcfld2=name',400,450);");
                $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';");
                $form->AddRow(S_PARAMETER, array($textfield, SPACE, $selectbtn));
            } else {
                if ($resourcetype == SCREEN_RESOURCE_PLAIN_TEXT) {
                    // Plain text
                    $caption = '';
                    $id = 0;
                    if ($resourceid > 0) {
                        $result = DBselect('SELECT n.name as node_name,h.host,i.description,i.itemid,i.key_ ' . ' FROM hosts h,items i ' . ' LEFT JOIN nodes n on n.nodeid=' . DBid2nodeid('i.itemid') . ' WHERE h.hostid=i.hostid ' . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND ' . DBcondition('i.hostid', $available_hosts) . ' AND i.itemid=' . $resourceid);
                        while ($row = DBfetch($result)) {
                            $description_ = item_description($row);
                            $row["node_name"] = isset($row["node_name"]) ? '(' . $row["node_name"] . ') ' : '';
                            $caption = $row['node_name'] . $row['host'] . ': ' . $description_;
                            $id = $resourceid;
                        }
                    }
                    $form->AddVar('resourceid', $id);
                    $textfield = new Ctextbox('caption', $caption, 75, 'yes');
                    $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=plain_text&srcfld1=itemid&srcfld2=description',800,450);");
                    $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';");
                    $form->addRow(S_PARAMETER, array($textfield, SPACE, $selectbtn));
                    $form->addRow(S_SHOW_LINES, new CNumericBox('elements', $elements, 2));
                    $form->addRow(S_SHOW_TEXT_AS_HTML, new CCheckBox('style', $style, null, 1));
                } else {
                    if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_EVENTS, SCREEN_RESOURCE_STATUS_OF_TRIGGERS, SCREEN_RESOURCE_ACTIONS))) {
                        // History of actions
                        // History of events
                        // Status of triggers
                        $form->addRow(S_SHOW_LINES, new CNumericBox('elements', $elements, 2));
                        $form->addVar('resourceid', 0);
                    } else {
                        if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_TRIGGERS_OVERVIEW, SCREEN_RESOURCE_DATA_OVERVIEW))) {
                            // Overviews
                            $caption = '';
                            $id = 0;
                            if ($resourceid > 0) {
                                $available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_ONLY);
                                $result = DBselect('SELECT DISTINCT n.name as node_name,g.groupid,g.name ' . ' FROM hosts_groups hg,hosts h,groups g ' . ' LEFT JOIN nodes n ON n.nodeid=' . DBid2nodeid('g.groupid') . ' WHERE ' . DBcondition('g.groupid', $available_groups) . ' AND g.groupid=hg.groupid ' . ' AND hg.hostid=h.hostid ' . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND g.groupid=' . $resourceid);
                                while ($row = DBfetch($result)) {
                                    $row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : '';
                                    $caption = $row['node_name'] . $row['name'];
                                    $id = $resourceid;
                                }
                            }
                            $form->AddVar('resourceid', $id);
                            $textfield = new Ctextbox('caption', $caption, 75, 'yes');
                            $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=overview&srcfld1=groupid&srcfld2=name',800,450);");
                            $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';");
                            $form->AddRow(S_GROUP, array($textfield, SPACE, $selectbtn));
                        } else {
                            if ($resourcetype == SCREEN_RESOURCE_SCREEN) {
                                // Screens
                                $caption = '';
                                $id = 0;
                                if ($resourceid > 0) {
                                    $result = DBselect('SELECT DISTINCT n.name as node_name,s.screenid,s.name ' . ' FROM screens s ' . ' LEFT JOIN nodes n ON n.nodeid=' . DBid2nodeid('s.screenid') . ' WHERE s.screenid=' . $resourceid);
                                    while ($row = DBfetch($result)) {
                                        if (!screen_accessible($row['screenid'], PERM_READ_ONLY)) {
                                            continue;
                                        }
                                        if (check_screen_recursion($_REQUEST['screenid'], $row['screenid'])) {
                                            continue;
                                        }
                                        $row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : '';
                                        $caption = $row['node_name'] . $row['name'];
                                        $id = $resourceid;
                                    }
                                }
                                $form->addVar('resourceid', $id);
                                $textfield = new Ctextbox('caption', $caption, 60, 'yes');
                                $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=screens2&srcfld1=screenid&srcfld2=name&screenid=" . $_REQUEST['screenid'] . "',800,450);");
                                $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';");
                                $form->AddRow(S_PARAMETER, array($textfield, SPACE, $selectbtn));
                            } else {
                                if ($resourcetype == SCREEN_RESOURCE_HOSTS_INFO || $resourcetype == SCREEN_RESOURCE_TRIGGERS_INFO) {
                                    // HOSTS info
                                    $caption = '';
                                    $id = 0;
                                    $available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_ONLY);
                                    if (remove_nodes_from_id($resourceid) > 0) {
                                        $result = DBselect('SELECT DISTINCT n.name as node_name,g.groupid,g.name ' . ' FROM hosts_groups hg, groups g ' . ' LEFT JOIN nodes n ON n.nodeid=' . DBid2nodeid('g.groupid') . ' WHERE ' . DBcondition('g.groupid', $available_groups) . ' AND g.groupid=' . $resourceid);
                                        while ($row = DBfetch($result)) {
                                            $row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : '';
                                            $caption = $row['node_name'] . $row['name'];
                                            $id = $resourceid;
                                        }
                                    } else {
                                        if (remove_nodes_from_id($resourceid) == 0) {
                                            $result = DBselect('SELECT DISTINCT n.name as node_name ' . ' FROM nodes n ' . ' WHERE n.nodeid=' . id2nodeid($resourceid));
                                            while ($row = DBfetch($result)) {
                                                $row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : '';
                                                $caption = $row['node_name'] . S_MINUS_ALL_GROUPS_MINUS;
                                                $id = $resourceid;
                                            }
                                        }
                                    }
                                    $form->AddVar('resourceid', $id);
                                    $textfield = new CTextbox('caption', $caption, 60, 'yes');
                                    $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=host_group_scr&srcfld1=groupid&srcfld2=name',480,450);");
                                    $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';");
                                    $form->AddRow(S_GROUP, array($textfield, SPACE, $selectbtn));
                                } else {
                                    // SCREEN_RESOURCE_CLOCK
                                    $form->addVar('resourceid', 0);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_HOSTS_INFO, SCREEN_RESOURCE_TRIGGERS_INFO))) {
        $cmbStyle = new CComboBox("style", $style);
        $cmbStyle->AddItem(STYLE_HORISONTAL, S_HORIZONTAL);
        $cmbStyle->AddItem(STYLE_VERTICAL, S_VERTICAL);
        $form->AddRow(S_STYLE, $cmbStyle);
    } else {
        if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_TRIGGERS_OVERVIEW, SCREEN_RESOURCE_DATA_OVERVIEW))) {
            $cmbStyle = new CComboBox('style', $style);
            $cmbStyle->AddItem(STYLE_LEFT, S_LEFT);
            $cmbStyle->AddItem(STYLE_TOP, S_TOP);
            $form->AddRow(S_HOSTS_LOCATION, $cmbStyle);
        } else {
            if ($resourcetype == SCREEN_RESOURCE_CLOCK) {
                $cmbStyle = new CComboBox('style', $style);
                $cmbStyle->AddItem(TIME_TYPE_LOCAL, S_LOCAL_TIME);
                $cmbStyle->AddItem(TIME_TYPE_SERVER, S_SERVER_TIME);
                $form->AddRow(S_TIME_TYPE, $cmbStyle);
            } else {
                $form->AddVar('style', 0);
            }
        }
    }
    if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_URL))) {
        $form->AddRow(S_URL, new CTextBox('url', $url, 60));
    } else {
        $form->AddVar('url', '');
    }
    if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_GRAPH, SCREEN_RESOURCE_SIMPLE_GRAPH, SCREEN_RESOURCE_CLOCK, SCREEN_RESOURCE_URL))) {
        $form->AddRow(S_WIDTH, new CNumericBox('width', $width, 5));
        $form->AddRow(S_HEIGHT, new CNumericBox('height', $height, 5));
    } else {
        $form->AddVar('width', 500);
        $form->AddVar('height', 100);
    }
    if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_GRAPH, SCREEN_RESOURCE_SIMPLE_GRAPH, SCREEN_RESOURCE_MAP, SCREEN_RESOURCE_CLOCK, SCREEN_RESOURCE_URL))) {
        $cmbHalign = new CComboBox('halign', $halign);
        $cmbHalign->AddItem(HALIGN_CENTER, S_CENTRE);
        $cmbHalign->AddItem(HALIGN_LEFT, S_LEFT);
        $cmbHalign->AddItem(HALIGN_RIGHT, S_RIGHT);
        $form->AddRow(S_HORIZONTAL_ALIGN, $cmbHalign);
    } else {
        $form->AddVar('halign', 0);
    }
    $cmbValign = new CComboBox('valign', $valign);
    $cmbValign->AddItem(VALIGN_MIDDLE, S_MIDDLE);
    $cmbValign->AddItem(VALIGN_TOP, S_TOP);
    $cmbValign->AddItem(VALIGN_BOTTOM, S_BOTTOM);
    $form->AddRow(S_VERTICAL_ALIGN, $cmbValign);
    $form->AddRow(S_COLUMN_SPAN, new CNumericBox('colspan', $colspan, 2));
    $form->AddRow(S_ROW_SPAN, new CNumericBox('rowspan', $rowspan, 2));
    // dynamic AddOn
    if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_GRAPH, SCREEN_RESOURCE_SIMPLE_GRAPH, SCREEN_RESOURCE_PLAIN_TEXT))) {
        $form->AddRow(S_DYNAMIC_ITEM, new CCheckBox('dynamic', $dynamic, null, 1));
    }
    $form->AddItemToBottomRow(new CButton('save', S_SAVE));
    if (isset($_REQUEST['screenitemid'])) {
        $form->addItemToBottomRow(SPACE);
        $form->addItemToBottomRow(new CButtonDelete(null, url_param('form') . url_param('screenid') . url_param('screenitemid')));
    }
    $form->addItemToBottomRow(SPACE);
    $form->addItemToBottomRow(new CButtonCancel(url_param('screenid')));
    return $form;
}
예제 #8
0
파일: config.php 프로젝트: rennhak/zabbix
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
?>

<?php 
$form = new CForm('config.php');
$form->SetMethod('get');
$cmbConfig = new CCombobox('config', $_REQUEST['config'], 'submit()');
//	$cmbConfig->AddItem(4,S_AUTOREGISTRATION);
//	$cmbConfig->AddItem(2,S_ESCALATION_RULES);
$cmbConfig->AddItem(8, S_EVENTS);
$cmbConfig->AddItem(0, S_HOUSEKEEPER);
$cmbConfig->AddItem(3, S_IMAGES);
$cmbConfig->AddItem(10, S_REGULAR_EXPRESSIONS);
$cmbConfig->AddItem(9, S_THEMES);
$cmbConfig->AddItem(6, S_VALUE_MAPPING);
$cmbConfig->AddItem(7, S_WORKING_TIME);
$cmbConfig->AddItem(5, S_OTHER);
$form->AddItem($cmbConfig);
switch ($_REQUEST['config']) {
    case 3:
        $form->AddItem(SPACE . '|' . SPACE);
        $form->AddItem(new CButton('form', S_CREATE_IMAGE));
예제 #9
0
                                    error($e->getMessage());
                                    show_messages(false, S_MACROS_UPDATED, S_CANNOT_UPDATE_MACROS);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
?>

<?php 
$form = new CForm('config.php', 'get');
$cmbConfig = new CCombobox('config', $_REQUEST['config'], 'javascript: redirect("config.php?config="+this.options[this.selectedIndex].value);');
//	$cmbConfig->addItem(4,S_AUTOREGISTRATION);
//	$cmbConfig->addItem(2,S_ESCALATION_RULES);
$cmbConfig->addItem(8, S_GUI);
$cmbConfig->addItem(0, S_HOUSEKEEPER);
$cmbConfig->addItem(3, S_IMAGES);
$cmbConfig->addItem(10, S_REGULAR_EXPRESSIONS);
//	$cmbConfig->addItem(9,S_THEMES);
$cmbConfig->addItem(11, S_MACROS);
$cmbConfig->addItem(6, S_VALUE_MAPPING);
$cmbConfig->addItem(7, S_WORKING_TIME);
$cmbConfig->addItem(5, S_OTHER);
$form->addItem($cmbConfig);
if (!isset($_REQUEST['form'])) {
    switch ($_REQUEST['config']) {
        case 3: