** (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.
**/
include 'include/views/js/configuration.services.edit.js.php';
global $ZBX_MESSAGES;
$service = $this->data['service'];
$servicesWidget = new CWidget();
$servicesWidget->setRootClass('services-edit');
$servicesWidget->addPageHeader(_('CONFIGURATION OF IT SERVICES'));
// create form
$servicesForm = new CForm();
$servicesForm->setName('servicesForm');
$servicesForm->addVar('form', $this->data['form']);
$servicesForm->addVar('parentid', $this->data['parentid']);
$servicesForm->addVar('parentname', $this->data['parentname']);
$servicesForm->addVar('triggerid', $this->data['triggerid']);
if (isset($this->data['service'])) {
    $servicesForm->addVar('serviceid', $this->data['service']['serviceid']);
}
// create form list
$servicesFormList = new CFormList('servicesFormList');
$nameTextBox = new CTextBox('name', $this->data['name'], ZBX_TEXTBOX_STANDARD_SIZE, false, 128);
$nameTextBox->attr('autofocus', 'autofocus');
    $hostsWidget->addPageHeader(_('CONFIGURATION OF HOSTS'));
    $data = array();
    if ($hostId = get_request('hostid', 0)) {
        $hostsWidget->addItem(get_header_host_table('', $_REQUEST['hostid']));
        $dbHosts = API::Host()->get(array('hostids' => $hostId, 'selectGroups' => API_OUTPUT_EXTEND, 'selectParentTemplates' => array('templateid', 'name'), 'selectMacros' => API_OUTPUT_EXTEND, 'selectInventory' => true, 'selectDiscoveryRule' => array('name', 'itemid'), 'output' => API_OUTPUT_EXTEND));
        $dbHost = reset($dbHosts);
        $dbHost['interfaces'] = API::HostInterface()->get(array('hostids' => $hostId, 'output' => API_OUTPUT_EXTEND, 'selectItems' => array('type'), 'sortfield' => 'interfaceid', 'preservekeys' => true));
        $data['dbHost'] = $dbHost;
    }
    $hostForm = new CView('configuration.host.edit', $data);
    $hostsWidget->addItem($hostForm->render());
    $rootClass = 'host-edit';
    if (get_request('hostid') && $dbHost['flags'] == ZBX_FLAG_DISCOVERY_CREATED) {
        $rootClass .= ' host-edit-discovered';
    }
    $hostsWidget->setRootClass($rootClass);
} else {
    $displayNodes = is_array(get_current_nodeid()) && $pageFilter->groupid == 0;
    $frmForm = new CForm();
    $frmForm->cleanItems();
    $frmForm->addItem(new CDiv(array(new CSubmit('form', _('Create host')), new CButton('form', _('Import'), 'redirect("conf.import.php?rules_preset=host")'))));
    $frmForm->addItem(new CVar('groupid', $_REQUEST['groupid'], 'filter_groupid_id'));
    $hostsWidget->addPageHeader(_('CONFIGURATION OF HOSTS'), $frmForm);
    $frmGroup = new CForm('get');
    $frmGroup->addItem(array(_('Group') . SPACE, $pageFilter->getGroupsCB(true)));
    $hostsWidget->addHeader(_('Hosts'), $frmGroup);
    $hostsWidget->addHeaderRowNumber();
    $hostsWidget->setRootClass('host-list');
    // filter
    $filterTable = new CTable('', 'filter');
    $filterTable->addRow(array(array(array(bold(_('Name')), SPACE . _('like') . NAME_DELIMITER), new CTextBox('filter_host', $_REQUEST['filter_host'], 20)), array(array(bold(_('DNS')), SPACE . _('like') . NAME_DELIMITER), new CTextBox('filter_dns', $_REQUEST['filter_dns'], 20)), array(array(bold(_('IP')), SPACE . _('like') . NAME_DELIMITER), new CTextBox('filter_ip', $_REQUEST['filter_ip'], 20)), array(bold(_('Port') . NAME_DELIMITER), new CTextBox('filter_port', $_REQUEST['filter_port'], 20))));
Esempio n. 3
0
    $data['proxies'] = DBfetchArray(DBselect('SELECT h.hostid,h.host' . ' FROM hosts h' . ' WHERE h.status IN (' . HOST_STATUS_PROXY_ACTIVE . ',' . HOST_STATUS_PROXY_PASSIVE . ')' . ' AND ' . DBin_node('h.hostid') . ' ORDER BY h.host'));
    // get inventories
    if ($data['inventory_mode'] != HOST_INVENTORY_DISABLED) {
        $data['inventories'] = getHostInventories();
        $data['inventories'] = zbx_toHash($data['inventories'], 'db_field');
    }
    $hostForm = new CView('configuration.host.massupdate', $data);
    $hosts_wdgt->addItem($hostForm->render());
} elseif (isset($_REQUEST['form'])) {
    $hosts_wdgt->addPageHeader(_('CONFIGURATION OF HOSTS'));
    if ($hostid = get_request('hostid', 0)) {
        $hosts_wdgt->addItem(get_header_host_table('', $_REQUEST['hostid']));
    }
    $hostForm = new CView('configuration.host.edit');
    $hosts_wdgt->addItem($hostForm->render());
    $hosts_wdgt->setRootClass('host-edit');
} else {
    $frmForm = new CForm();
    $frmForm->cleanItems();
    $buttons = new CDiv(array(new CSubmit('form', _('Create host')), new CButton('form', _('Import'), 'redirect("conf.import.php?rules_preset=host")')));
    $frmForm->addItem($buttons);
    $frmForm->addItem(new CVar('groupid', $_REQUEST['groupid'], 'filter_groupid_id'));
    $hosts_wdgt->addPageHeader(_('CONFIGURATION OF HOSTS'), $frmForm);
    $frmGroup = new CForm('get');
    $frmGroup->addItem(array(_('Group') . SPACE, $pageFilter->getGroupsCB()));
    $hosts_wdgt->addHeader(_('Hosts'), $frmGroup);
    $hosts_wdgt->addHeaderRowNumber();
    $hosts_wdgt->setRootClass('host-list');
    // filter
    $filter_table = new CTable('', 'filter');
    $filter_table->addRow(array(array(array(bold(_('Name')), SPACE . _('like') . ': '), new CTextBox('filter_host', $_REQUEST['filter_host'], 20)), array(array(bold(_('DNS')), SPACE . _('like') . ': '), new CTextBox('filter_dns', $_REQUEST['filter_dns'], 20)), array(array(bold(_('IP')), SPACE . _('like') . ': '), new CTextBox('filter_ip', $_REQUEST['filter_ip'], 20)), array(bold(_('Port') . ': '), new CTextBox('filter_port', $_REQUEST['filter_port'], 20))));