本文整理匯總了PHP中DBid2nodeid函數的典型用法代碼示例。如果您正苦於以下問題:PHP DBid2nodeid函數的具體用法?PHP DBid2nodeid怎麽用?PHP DBid2nodeid使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了DBid2nodeid函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: init_nodes
function init_nodes()
{
/* Init CURRENT NODE ID */
if (defined('ZBX_NODES_INITIALIZED')) {
return;
}
global $USER_DETAILS;
global $ZBX_LOCALNODEID, $ZBX_LOCMASTERID, $ZBX_CURRENT_NODEID, $ZBX_CURMASTERID, $ZBX_NODES, $ZBX_NODES_IDS, $ZBX_AVAILABLE_NODES, $ZBX_VIEWED_NODES, $ZBX_WITH_ALL_NODES;
$ZBX_AVAILABLE_NODES = array();
$ZBX_NODES_IDS = array();
$ZBX_NODES = array();
$ZBX_CURRENT_NODEID = $ZBX_LOCALNODEID;
$ZBX_WITH_ALL_NODES = !defined('ZBX_NOT_ALLOW_ALL_NODES');
if (!defined('ZBX_PAGE_NO_AUTHORIZATION') && ZBX_DISTRIBUTED) {
if ($USER_DETAILS['type'] == USER_TYPE_SUPER_ADMIN) {
$sql = 'SELECT DISTINCT n.nodeid,n.name,n.masterid FROM nodes n ';
} else {
$sql = 'SELECT DISTINCT n.nodeid,n.name,n.masterid ' . ' FROM nodes n, groups hg,rights r, users_groups g ' . ' WHERE r.id=hg.groupid ' . ' AND r.groupid=g.usrgrpid ' . ' AND g.userid=' . $USER_DETAILS['userid'] . ' AND n.nodeid=' . DBid2nodeid('hg.groupid');
}
$db_nodes = DBselect($sql);
while ($node = DBfetch($db_nodes)) {
$ZBX_NODES[$node['nodeid']] = $node;
$ZBX_NODES_IDS[$node['nodeid']] = $node['nodeid'];
}
$ZBX_AVAILABLE_NODES = get_accessible_nodes_by_user($USER_DETAILS, PERM_READ_LIST, PERM_RES_IDS_ARRAY, $ZBX_NODES_IDS);
$ZBX_VIEWED_NODES = get_viewed_nodes();
$ZBX_CURRENT_NODEID = $ZBX_VIEWED_NODES['selected'];
if ($node_data = DBfetch(DBselect('SELECT masterid FROM nodes WHERE nodeid=' . $ZBX_CURRENT_NODEID))) {
$ZBX_CURMASTERID = $node_data['masterid'];
}
if (!isset($ZBX_NODES[$ZBX_CURRENT_NODEID])) {
$ZBX_CURRENT_NODEID = $ZBX_LOCALNODEID;
$ZBX_CURMASTERID = $ZBX_LOCMASTERID;
}
if (isset($_REQUEST['select_nodes'])) {
// CProfile::update('web.nodes.selected', $ZBX_VIEWED_NODES['nodeids'], PROFILE_TYPE_ARRAY_ID);
update_node_profile($ZBX_VIEWED_NODES['nodeids']);
}
if (isset($_REQUEST['switch_node'])) {
CProfile::update('web.nodes.switch_node', $ZBX_VIEWED_NODES['selected'], PROFILE_TYPE_ID);
}
} else {
$ZBX_CURRENT_NODEID = $ZBX_LOCALNODEID;
$ZBX_CURMASTERID = $ZBX_LOCMASTERID;
}
// zbx_set_post_cookie('zbx_current_nodeid', $ZBX_CURRENT_NODEID);
define('ZBX_NODES_INITIALIZED', 1);
// reset profiles if node is different than local
if ($ZBX_CURRENT_NODEID != $ZBX_LOCALNODEID) {
CProfile::init();
}
}
示例2: elseif
} elseif (in_array($resourceType, array(SCREEN_RESOURCE_TRIGGERS_OVERVIEW, SCREEN_RESOURCE_DATA_OVERVIEW))) {
$data = array();
if ($resourceId > 0) {
$data = API::HostGroup()->get(array('groupids' => $resourceId, 'output' => array('groupid', 'name'), 'editable' => true));
if ($data) {
$data = reset($data);
$data['prefix'] = get_node_name_by_elid($data['groupid'], true, NAME_DELIMITER);
}
}
$screenFormList->addRow(_('Group'), new CMultiSelect(array('name' => 'resourceid', 'objectName' => 'hostGroup', 'objectOptions' => array('editable' => true), 'data' => $data ? array(array('id' => $data['groupid'], 'name' => $data['name'], 'prefix' => $data['prefix'])) : null, 'selectedLimit' => 1, 'popup' => array('parameters' => 'srctbl=host_groups&dstfrm=' . $screenForm->getName() . '&dstfld1=resourceid' . '&srcfld1=groupid&writeonly=1', 'width' => 450, 'height' => 450))));
$screenFormList->addRow(_('Application'), new CTextBox('application', $application, ZBX_TEXTBOX_STANDARD_SIZE, false, 255));
} elseif ($resourceType == SCREEN_RESOURCE_SCREEN) {
$caption = '';
$id = 0;
if ($resourceId > 0) {
$db_screens = 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=' . zbx_dbstr($resourceId));
while ($row = DBfetch($db_screens)) {
$screen = API::Screen()->get(array('screenids' => $row['screenid'], 'output' => array('screenid')));
if (empty($screen)) {
continue;
}
if (check_screen_recursion($_REQUEST['screenid'], $row['screenid'])) {
continue;
}
$row['node_name'] = !empty($row['node_name']) ? '(' . $row['node_name'] . ') ' : '';
$caption = $row['node_name'] . $row['name'];
$id = $resourceId;
}
}
$screenFormList->addVar('resourceid', $id);
$screenFormList->addRow(_('Parameter'), array(new CTextBox('caption', $caption, ZBX_TEXTBOX_STANDARD_SIZE, 'yes'), new CButton('select', _('Select'), 'javascript: return PopUp("popup.php?srctbl=screens2&srcfld1=screenid&srcfld2=name' . '&dstfrm=' . $screenForm->getName() . '&dstfld1=resourceid&dstfld2=caption' . '&writeonly=1&screenid=' . $_REQUEST['screenid'] . '", 800, 450);', 'formlist')));
示例3: reset
$data['usrgrp'] = reset($dbUserGroup);
}
if (isset($_REQUEST['usrgrpid']) && !isset($_REQUEST['form_refresh'])) {
$data['name'] = $data['usrgrp']['name'];
$data['users_status'] = $data['usrgrp']['users_status'];
$data['gui_access'] = $data['usrgrp']['gui_access'];
$data['debug_mode'] = $data['usrgrp']['debug_mode'];
// group users
$data['group_users'] = array();
$dbUsers = DBselect('SELECT DISTINCT u.userid ' . ' FROM users u,users_groups ug ' . ' WHERE u.userid=ug.userid ' . ' AND ug.usrgrpid=' . zbx_dbstr($data['usrgrpid']));
while ($dbUser = DBfetch($dbUsers)) {
$data['group_users'][$dbUser['userid']] = $dbUser['userid'];
}
// group rights
$data['group_rights'] = array();
$dbRights = DBselect('SELECT r.*,n.name AS nodename,g.name AS name' . ' FROM groups g' . ' LEFT JOIN rights r ON r.id=g.groupid' . ' LEFT JOIN nodes n ON n.nodeid=' . DBid2nodeid('g.groupid') . ' WHERE r.groupid=' . zbx_dbstr($data['usrgrpid']));
while ($dbRight = DBfetch($dbRights)) {
if (!empty($dbRight['nodename'])) {
$dbRight['name'] = $dbRight['nodename'] . NAME_DELIMITER . $dbRight['name'];
}
$data['group_rights'][$dbRight['id']] = array('permission' => $dbRight['permission'], 'name' => $dbRight['name'], 'id' => $dbRight['id']);
}
} else {
$data['name'] = get_request('gname', '');
$data['users_status'] = get_request('users_status', GROUP_STATUS_ENABLED);
$data['gui_access'] = get_request('gui_access', GROUP_GUI_ACCESS_SYSTEM);
$data['debug_mode'] = get_request('debug_mode', GROUP_DEBUG_MODE_DISABLED);
$data['group_users'] = get_request('group_users', array());
$data['group_rights'] = get_request('group_rights', array());
}
$data['selected_usrgrp'] = get_request('selusrgrp', 0);
示例4: insert_map_element_form
function insert_map_element_form()
{
global $USER_DETAILS;
$frmEl = new CFormTable('New map element', 'sysmap.php');
$frmEl->SetHelp('web.sysmap.host.php');
$frmEl->addVar('sysmapid', $_REQUEST['sysmapid']);
if (isset($_REQUEST['selementid'])) {
$frmEl->addVar('selementid', $_REQUEST['selementid']);
$element = get_sysmaps_element_by_selementid($_REQUEST['selementid']);
$frmEl->SetTitle('Map element "' . $element['label'] . '"');
}
if (isset($_REQUEST['selementid']) && !isset($_REQUEST['form_refresh'])) {
$elementid = $element['elementid'];
$elementtype = $element['elementtype'];
$label = $element['label'];
$x = $element['x'];
$y = $element['y'];
$url = $element['url'];
$iconid_off = $element['iconid_off'];
$iconid_on = $element['iconid_on'];
$iconid_unknown = $element['iconid_unknown'];
$iconid_disabled = $element['iconid_disabled'];
$label_location = $element['label_location'];
if (is_null($label_location)) {
$label_location = -1;
}
} else {
$elementid = get_request('elementid', 0);
$elementtype = get_request('elementtype', SYSMAP_ELEMENT_TYPE_HOST);
$label = get_request('label', '');
$x = get_request('x', 0);
$y = get_request('y', 0);
$url = get_request('url', '');
$iconid_off = get_request('iconid_off', 0);
$iconid_on = get_request('iconid_on', 0);
$iconid_unknown = get_request('iconid_unknown', 0);
$iconid_disabled = get_request('iconid_disabled', 0);
$label_location = get_request('label_location', '-1');
}
$cmbType = new CComboBox('elementtype', $elementtype, 'submit()');
$available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, null, get_current_nodeid(true));
$sql = 'SELECT DISTINCT n.name as node_name,h.hostid,h.host ' . ' FROM hosts h' . ' LEFT JOIN nodes n on n.nodeid=' . DBid2nodeid('h.hostid') . ' WHERE ' . DBcondition('h.hostid', $available_hosts) . ' ORDER BY node_name,h.host';
$db_hosts = DBselect($sql);
if ($db_hosts) {
$cmbType->addItem(SYSMAP_ELEMENT_TYPE_HOST, S_HOST);
}
$db_maps = DBselect('SELECT sysmapid FROM sysmaps WHERE sysmapid!=' . $_REQUEST['sysmapid']);
if (DBfetch($db_maps)) {
$cmbType->addItem(SYSMAP_ELEMENT_TYPE_MAP, S_MAP);
}
$cmbType->addItem(SYSMAP_ELEMENT_TYPE_TRIGGER, S_TRIGGER);
$cmbType->addItem(SYSMAP_ELEMENT_TYPE_HOST_GROUP, S_HOST_GROUP);
$cmbType->addItem(SYSMAP_ELEMENT_TYPE_IMAGE, S_IMAGE);
$frmEl->addRow(S_TYPE, $cmbType);
$frmEl->addRow(S_LABEL, new CTextArea('label', $label, 32, 4));
$cmbLocation = new CComboBox('label_location', $label_location);
$cmbLocation->addItem(-1, '-');
$cmbLocation->addItem(0, S_BOTTOM);
$cmbLocation->addItem(1, S_LEFT);
$cmbLocation->addItem(2, S_RIGHT);
$cmbLocation->addItem(3, S_TOP);
$frmEl->addRow(S_LABEL_LOCATION, $cmbLocation);
if ($elementtype == SYSMAP_ELEMENT_TYPE_HOST) {
$host = '';
$host_info = DBfetch(DBselect('SELECT DISTINCT n.name as node_name,h.hostid,h.host ' . ' FROM hosts h ' . ' LEFT JOIN nodes n ON n.nodeid=' . DBid2nodeid('h.hostid') . ' WHERE ' . DBcondition('h.hostid', $available_hosts) . ' AND hostid=' . $elementid . ' ORDER BY node_name,h.host'));
if ($host_info) {
$host = $host_info['host'];
} else {
$elementid = 0;
}
if ($elementid == 0) {
$host = '';
$elementid = 0;
}
$frmEl->addVar('elementid', $elementid);
$frmEl->addRow(S_HOST, array(new CTextBox('host', $host, 32, 'yes'), new CButton('btn1', S_SELECT, "return PopUp('popup.php?dstfrm=" . $frmEl->GetName() . "&dstfld1=elementid&dstfld2=host&srctbl=hosts&srcfld1=hostid&srcfld2=host',450,450);", 'T')));
} else {
if ($elementtype == SYSMAP_ELEMENT_TYPE_MAP) {
$cmbMaps = new CComboBox('elementid', $elementid);
$db_maps = DBselect('SELECT DISTINCT n.name as node_name,s.sysmapid,s.name ' . ' FROM sysmaps s' . ' LEFT JOIN nodes n on n.nodeid=' . DBid2nodeid('s.sysmapid') . ' ORDER BY node_name,s.name');
while ($db_map = DBfetch($db_maps)) {
if (!sysmap_accessible($db_map['sysmapid'], PERM_READ_ONLY)) {
continue;
}
$node_name = isset($db_map['node_name']) ? '(' . $db_map['node_name'] . ') ' : '';
$cmbMaps->addItem($db_map['sysmapid'], $node_name . $db_map['name']);
}
$frmEl->addRow(S_MAP, $cmbMaps);
} else {
if ($elementtype == SYSMAP_ELEMENT_TYPE_TRIGGER) {
$available_triggers = get_accessible_triggers(PERM_READ_ONLY, array(), PERM_RES_IDS_ARRAY, get_current_nodeid(true));
$trigger = '';
$trigger_info = DBfetch(DBselect('SELECT DISTINCT n.name as node_name,h.hostid,h.host,t.*' . ' FROM triggers t ' . ' LEFT JOIN functions f on t.triggerid=f.triggerid ' . ' LEFT JOIN items i on i.itemid=f.itemid ' . ' LEFT JOIN hosts h on h.hostid=i.hostid ' . ' LEFT JOIN nodes n on n.nodeid=' . DBid2nodeid('t.triggerid') . ' WHERE t.triggerid=' . $elementid . ' AND ' . DBcondition('t.triggerid', $available_triggers) . ' ORDER BY node_name,h.host,t.description'));
if ($trigger_info) {
$trigger = expand_trigger_description_by_data($trigger_info);
} else {
$elementid = 0;
}
if ($elementid == 0) {
$trigger = '';
//.........這裏部分代碼省略.........
示例5: get_accessible_groups_by_rights
function get_accessible_groups_by_rights(&$rights, $user_type, $perm, $perm_res = null, $nodeid = null)
{
if (is_null($perm_res)) {
$perm_res = PERM_RES_STRING_LINE;
}
$result = array();
$where = array();
if (!is_null($nodeid)) {
array_push($where, DBin_node('g.groupid', $nodeid));
}
if (count($where)) {
$where = ' WHERE ' . implode(' AND ', $where);
} else {
$where = '';
}
$group_perm = array();
foreach ($rights as $id => $right) {
$group_perm[$right['id']] = $right['permission'];
}
$sql = 'SELECT n.nodeid as nodeid,n.name as node_name, g.*, ' . PERM_DENY . ' as permission ' . ' FROM groups g ' . ' LEFT JOIN nodes n ON ' . DBid2nodeid('g.groupid') . '=n.nodeid ' . $where . ' ORDER BY n.name, g.name';
$db_groups = DBselect($sql);
while ($group_data = DBfetch($db_groups)) {
if (USER_TYPE_SUPER_ADMIN == $user_type) {
$group_data['permission'] = PERM_MAX;
} else {
if (isset($group_perm[$group_data['groupid']])) {
$group_data['permission'] = $group_perm[$group_data['groupid']];
} else {
if (is_null($group_data['nodeid'])) {
$group_data['nodeid'] = id2nodeid($group_data['groupid']);
}
$group_data['permission'] = PERM_DENY;
}
}
if ($group_data['permission'] < $perm) {
continue;
}
switch ($perm_res) {
case PERM_RES_DATA_ARRAY:
$result[$group_data['groupid']] = $group_data;
break;
default:
$result[$group_data['groupid']] = $group_data['groupid'];
}
}
if ($perm_res == PERM_RES_STRING_LINE) {
if (count($result) == 0) {
$result = '-1';
} else {
$result = implode(',', $result);
}
}
return $result;
}
示例6: init_nodes
function init_nodes()
{
/* Init CURRENT NODE ID */
global $USER_DETAILS, $ZBX_LOCALNODEID, $ZBX_LOCMASTERID, $ZBX_CURRENT_NODEID, $ZBX_CURRENT_SUBNODES, $ZBX_CURMASTERID, $ZBX_NODES, $ZBX_NODES_IDS, $ZBX_WITH_SUBNODES;
$ZBX_CURRENT_SUBNODES = array();
$ZBX_NODES_IDS = array();
$ZBX_NODES = array();
if (!defined('ZBX_PAGE_NO_AUTHERIZATION') && ZBX_DISTRIBUTED) {
$ZBX_CURRENT_NODEID = get_cookie('zbx_current_nodeid', $ZBX_LOCALNODEID);
// Selected node
$ZBX_WITH_SUBNODES = get_cookie('zbx_with_subnodes', false);
// Show elements FROM subnodes
if (isset($_REQUEST['switch_node'])) {
if ($node_data = DBfetch(DBselect('SELECT * FROM nodes WHERE nodeid=' . $_REQUEST['switch_node']))) {
$ZBX_CURRENT_NODEID = $_REQUEST['switch_node'];
}
unset($node_data);
}
if (isset($_REQUEST['show_subnodes'])) {
$ZBX_WITH_SUBNODES = !empty($_REQUEST['show_subnodes']);
}
if ($node_data = DBfetch(DBselect('SELECT * FROM nodes WHERE nodeid=' . $ZBX_CURRENT_NODEID))) {
$ZBX_CURMASTERID = $node_data['masterid'];
}
if ($USER_DETAILS['type'] == USER_TYPE_SUPER_ADMIN) {
$sql = 'SELECT DISTINCT n.nodeid,n.name,n.masterid FROM nodes n';
} else {
$sql = 'SELECT DISTINCT n.nodeid,n.name,n.masterid ' . ' FROM nodes n, groups hg,rights r, users_groups g ' . ' WHERE r.id=hg.groupid ' . ' AND r.groupid=g.usrgrpid ' . ' AND g.userid=' . $USER_DETAILS['userid'] . ' AND ' . DBid2nodeid('hg.groupid') . '=n.nodeid;';
}
$db_nodes = DBselect($sql);
while ($node = DBfetch($db_nodes)) {
$ZBX_NODES_IDS[$node['nodeid']] = $node['nodeid'];
$ZBX_NODES[$node['nodeid']] = $node;
}
if (!isset($ZBX_NODES[$ZBX_CURRENT_NODEID])) {
$denyed_page_requested = true;
$ZBX_CURRENT_NODEID = $ZBX_LOCALNODEID;
$ZBX_CURMASTERID = $ZBX_LOCMASTERID;
}
foreach ($ZBX_NODES as $nodeid => $node_data) {
$curr_node =& $node_data;
if ($curr_node['masterid'] != 0 && bccomp($curr_node['masterid'], $ZBX_CURRENT_NODEID) != 0) {
$curr_node =& $ZBX_NODES[$curr_node['masterid']];
}
if (bccomp($curr_node['masterid'], $ZBX_CURRENT_NODEID) == 0) {
$ZBX_CURRENT_SUBNODES[$nodeid] = $nodeid;
}
}
zbx_set_post_cookie('zbx_current_nodeid', $ZBX_CURRENT_NODEID);
zbx_set_post_cookie('zbx_with_subnodes', $ZBX_WITH_SUBNODES);
} else {
$ZBX_CURRENT_NODEID = $ZBX_LOCALNODEID;
$ZBX_CURMASTERID = $ZBX_LOCMASTERID;
$ZBX_WITH_SUBNODES = false;
}
$ZBX_CURRENT_SUBNODES[$ZBX_CURRENT_NODEID] = $ZBX_CURRENT_NODEID;
if (count($ZBX_CURRENT_SUBNODES) < 2 && !defined('ZBX_DISABLE_SUBNODES')) {
define('ZBX_DISABLE_SUBNODES', 1);
} else {
$ZBX_CURRENT_SUBNODES = get_accessible_nodes_by_user($USER_DETAILS, PERM_READ_LIST, PERM_RES_IDS_ARRAY, $ZBX_CURRENT_SUBNODES);
}
}
示例7: get_window_opener
$row['name'] = $row['node_name'] . $row['name'];
if (isset($_REQUEST['reference']) && $_REQUEST['reference'] == 'dashboard') {
$action = get_window_opener($dstfrm, $dstfld1, $srcfld2) . get_window_opener($dstfrm, $dstfld2, $row[$srcfld2]) . "window.opener.setTimeout('add2favorites();', 1000);";
} else {
$action = get_window_opener($dstfrm, $dstfld1, $row[$srcfld1]) . (isset($srcfld2) ? get_window_opener($dstfrm, $dstfld2, $row[$srcfld2]) : '');
}
$name->setAction($action . " close_window(); return false;");
$table->addRow($name);
}
$table->Show();
} else {
if ($srctbl == 'host_group_scr') {
$available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_ONLY, null, $nodeid);
$table = new CTableInfo(S_NO_GROUPS_DEFINED);
$table->setHeader(array(S_NAME));
$db_groups = DBselect('SELECT DISTINCT n.name as node_name,g.groupid,g.name,n.nodeid ' . ' FROM hosts_groups hg, groups g ' . ' LEFT JOIN nodes n ON n.nodeid=' . DBid2nodeid('g.groupid') . ' WHERE ' . DBcondition('g.groupid', $available_groups) . ' AND ' . DBin_node('g.groupid', $nodeid) . ' ORDER BY n.nodeid,g.name');
$all = false;
while ($row = DBfetch($db_groups)) {
$row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : '';
if (!$all) {
$name = new CLink(bold(S_MINUS_ALL_GROUPS_MINUS), '#', 'action');
if (isset($_REQUEST['reference']) && $_REQUEST['reference'] == 'dashboard') {
$action = get_window_opener($dstfrm, $dstfld1, $srcfld2) . get_window_opener($dstfrm, $dstfld2, create_id_by_nodeid(0, $nodeid)) . "window.opener.setTimeout('add2favorites();', 1000);";
} else {
$action = get_window_opener($dstfrm, $dstfld1, create_id_by_nodeid(0, $nodeid)) . get_window_opener($dstfrm, $dstfld2, $row['node_name'] . S_MINUS_ALL_GROUPS_MINUS);
}
$name->setAction($action . " close_window(); return false;");
$table->addRow($name);
$all = true;
}
$name = new CLink($row['name'], '#', 'action');
示例8: insert_usergroups_form
function insert_usergroups_form()
{
$frm_title = S_USER_GROUP;
if (isset($_REQUEST['usrgrpid'])) {
$usrgrp = CUserGroup::get(array('usrgrpids' => $_REQUEST['usrgrpid'], 'extendoutput' => 1));
$usrgrp = reset($usrgrp);
$frm_title = S_USER_GROUP . ' "' . $usrgrp['name'] . '"';
}
if (isset($_REQUEST['usrgrpid']) && !isset($_REQUEST['form_refresh'])) {
$name = $usrgrp['name'];
$users_status = $usrgrp['users_status'];
$gui_access = $usrgrp['gui_access'];
$api_access = $usrgrp['api_access'];
$debug_mode = $usrgrp['debug_mode'];
$group_users = array();
$sql = 'SELECT DISTINCT u.userid ' . ' FROM users u,users_groups ug ' . ' WHERE u.userid=ug.userid ' . ' AND ug.usrgrpid=' . $_REQUEST['usrgrpid'];
$db_users = DBselect($sql);
while ($db_user = DBfetch($db_users)) {
$group_users[$db_user['userid']] = $db_user['userid'];
}
$group_rights = array();
$sql = 'SELECT r.*, n.name as node_name, g.name as name ' . ' FROM groups g ' . ' LEFT JOIN rights r on r.id=g.groupid ' . ' LEFT JOIN nodes n on n.nodeid=' . DBid2nodeid('g.groupid') . ' WHERE r.groupid=' . $_REQUEST['usrgrpid'];
$db_rights = DBselect($sql);
while ($db_right = DBfetch($db_rights)) {
if (isset($db_right['node_name'])) {
$db_right['name'] = $db_right['node_name'] . ':' . $db_right['name'];
}
$group_rights[$db_right['id']] = array('permission' => $db_right['permission'], 'name' => $db_right['name'], 'id' => $db_right['id']);
}
} else {
$name = get_request('gname', '');
$users_status = get_request('users_status', GROUP_STATUS_ENABLED);
$gui_access = get_request('gui_access', GROUP_GUI_ACCESS_SYSTEM);
$api_access = get_request('api_access', GROUP_API_ACCESS_DISABLED);
$debug_mode = get_request('debug_mode', GROUP_DEBUG_MODE_DISABLED);
$group_users = get_request('group_users', array());
$group_rights = get_request('group_rights', array());
}
$perm_details = get_request('perm_details', 0);
order_result($group_rights, 'name');
$frmUserG = new CFormTable($frm_title, 'usergrps.php');
$frmUserG->setHelp('web.users.groups.php');
if (isset($_REQUEST['usrgrpid'])) {
$frmUserG->addVar('usrgrpid', $_REQUEST['usrgrpid']);
}
$grName = new CTextBox('gname', $name, 49);
$grName->attributes['style'] = 'width: 280px';
$frmUserG->addRow(S_GROUP_NAME, $grName);
$frmUserG->addVar('group_rights', $group_rights);
/////////////////
// create table header +
$selusrgrp = get_request('selusrgrp', 0);
$cmbGroups = new CComboBox('selusrgrp', $selusrgrp, 'submit()');
$cmbGroups->addItem(0, S_ALL_S);
$sql = 'SELECT usrgrpid, name FROM usrgrp WHERE ' . DBin_node('usrgrpid') . ' ORDER BY name';
$result = DBselect($sql);
while ($row = DBfetch($result)) {
$cmbGroups->addItem($row['usrgrpid'], $row['name']);
}
// -
// create user twinbox +
$user_tb = new CTweenBox($frmUserG, 'group_users', $group_users, 10);
$sql_from = '';
$sql_where = '';
if ($selusrgrp > 0) {
$sql_from = ', users_groups g ';
$sql_where = ' AND u.userid=g.userid AND g.usrgrpid=' . $selusrgrp;
}
$sql = 'SELECT DISTINCT u.userid, u.alias ' . ' FROM users u ' . $sql_from . ' WHERE ' . DBcondition('u.userid', $group_users) . ' OR (' . DBin_node('u.userid') . $sql_where . ' ) ORDER BY u.alias';
$result = DBselect($sql);
while ($row = DBfetch($result)) {
$user_tb->addItem($row['userid'], $row['alias']);
}
$frmUserG->addRow(S_USERS, $user_tb->get(S_IN . SPACE . S_GROUP, array(S_OTHER . SPACE . S_GROUPS . SPACE . '|' . SPACE, $cmbGroups)));
// -
/////////////////
/*
$lstUsers = new CListBox('group_users_to_del[]');
$lstUsers->attributes['style'] = 'width: 280px';
foreach($group_users as $userid => $alias){
$lstUsers->addItem($userid, $alias);
}
$frmUserG->addRow(S_USERS,
array(
$lstUsers,
BR(),
new CButton('add_user',S_ADD,
"return PopUp('popup_users.php?dstfrm=".$frmUserG->getName().
"&list_name=group_users_to_del[]&var_name=group_users',600,300);"),
(count($group_users) > 0) ? new CButton('del_group_user',S_DELETE_SELECTED) : null
));
*/
/////////////////
$granted = true;
if (isset($_REQUEST['usrgrpid'])) {
$granted = granted2update_group($_REQUEST['usrgrpid']);
}
if ($granted) {
//.........這裏部分代碼省略.........
示例9: get
/**
* Get HostGroups
*
* {@source}
* @access public
* @static
* @since 1.8
* @version 1
*
* @static
* @param array $params
* @return array
*/
public static function get($params)
{
global $USER_DETAILS;
$result = array();
$user_type = $USER_DETAILS['type'];
$userid = $USER_DETAILS['userid'];
$sort_columns = array('groupid', 'name');
// allowed columns for sorting
$sql_parts = array('select' => array('groups' => 'g.groupid'), 'from' => array('groups g'), 'where' => array(), 'order' => array(), 'limit' => null);
$def_options = array('nodeids' => 0, 'groupids' => 0, 'hostids' => 0, 'monitored_hosts' => 0, 'templated_hosts' => 0, 'real_hosts' => 0, 'not_proxy_hosts' => 0, 'with_items' => 0, 'with_monitored_items' => 0, 'with_historical_items' => 0, 'with_triggers' => 0, 'with_monitored_triggers' => 0, 'with_httptests' => 0, 'with_monitored_httptests' => 0, 'with_graphs' => 0, 'only_current_node' => 0, 'editable' => 0, 'nopermissions' => 0, 'select_hosts' => 0, 'extendoutput' => 0, 'count' => 0, 'pattern' => '', 'order' => '', 'limit' => 0);
$options = array_merge($def_options, $params);
// *** ????? *** //
// nodes
// disabled by false
// TODO('check this ~106');
if (false && ZBX_DISTRIBUTED) {
$sql_parts['select'][] = 'n.name as node_name';
$sql_parts['from'][] = 'nodes n';
$sql_parts['where'][] = 'n.nodeid=' . DBid2nodeid('g.groupid');
$sql_parts['order'][] = 'node_name';
}
// *** ????? *** //
// editable + PERMISSION CHECK
if (defined('ZBX_API_REQUEST')) {
$options['nopermissions'] = false;
}
if (USER_TYPE_SUPER_ADMIN == $user_type || $options['nopermissions']) {
} else {
$permission = $options['editable'] ? PERM_READ_WRITE : PERM_READ_ONLY;
$sql_parts['from']['r'] = 'rights r';
$sql_parts['from']['ug'] = 'users_groups ug';
$sql_parts['where'][] = 'r.id=g.groupid';
$sql_parts['where'][] = 'r.groupid=ug.usrgrpid';
$sql_parts['where'][] = 'ug.userid=' . $userid;
$sql_parts['where'][] = 'r.permission>=' . $permission;
$sql_parts['where'][] = 'NOT EXISTS( ' . ' SELECT gg.groupid ' . ' FROM groups gg, rights rr, users_groups ugg ' . ' WHERE rr.id=g.groupid ' . ' AND rr.groupid=ugg.usrgrpid ' . ' AND ugg.userid=' . $userid . ' AND rr.permission<' . $permission . ')';
}
// nodeids
$nodeids = $options['nodeids'] ? $options['nodeids'] : get_current_nodeid(false);
// groupids
if ($options['groupids'] != 0) {
zbx_value2array($options['groupids']);
$sql_parts['where'][] = DBcondition('g.groupid', $options['groupids']);
}
// hostids
if ($options['hostids'] != 0) {
zbx_value2array($options['hostids']);
$sql_parts['from']['hg'] = 'hosts_groups hg';
$sql_parts['where'][] = DBcondition('hg.hostid', $options['hostids']);
$sql_parts['where']['hgg'] = 'hg.groupid=g.groupid';
}
// monitored_hosts, real_hosts, templated_hosts, not_proxy_hosts
if ($options['monitored_hosts'] != 0) {
$sql_parts['from']['hg'] = 'hosts_groups hg';
$sql_parts['from']['h'] = 'hosts h';
$sql_parts['where']['hgg'] = 'hg.groupid=g.groupid';
$sql_parts['where'][] = 'h.hostid=hg.hostid';
$sql_parts['where'][] = 'h.status=' . HOST_STATUS_MONITORED;
} else {
if ($options['real_hosts'] != 0) {
$sql_parts['from']['hg'] = 'hosts_groups hg';
$sql_parts['from']['h'] = 'hosts h';
$sql_parts['where']['hgg'] = 'hg.groupid=g.groupid';
$sql_parts['where'][] = 'h.hostid=hg.hostid';
$sql_parts['where'][] = 'h.status IN(' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ')';
} else {
if ($options['templated_hosts'] != 0) {
$sql_parts['from']['hg'] = 'hosts_groups hg';
$sql_parts['from']['h'] = 'hosts h';
$sql_parts['where']['hgg'] = 'hg.groupid=g.groupid';
$sql_parts['where'][] = 'h.hostid=hg.hostid';
$sql_parts['where'][] = 'h.status=' . HOST_STATUS_TEMPLATE;
} else {
if ($options['not_proxy_hosts'] != 0) {
$sql_parts['from']['hg'] = 'hosts_groups hg';
$sql_parts['from']['h'] = 'hosts h';
$sql_parts['where']['hgg'] = 'hg.groupid=g.groupid';
$sql_parts['where'][] = 'h.hostid=hg.hostid';
$sql_parts['where'][] = 'h.status<>' . HOST_STATUS_PROXY;
}
}
}
}
// with_items, with_monitored_items, with_historical_items
if ($options['with_items'] != 0) {
$sql_parts['from']['hg'] = 'hosts_groups hg';
$sql_parts['where']['hgg'] = 'hg.groupid=g.groupid';
//.........這裏部分代碼省略.........
示例10: get_accessible_groups_by_rights
function get_accessible_groups_by_rights(&$rights, $user_type, $perm, $perm_res = null, $nodeid = null)
{
$result = array();
$where = array();
if (!is_null($nodeid)) {
$where = sqlPartDbNode($where, 'g.groupid', $nodeid);
}
if (count($where)) {
$where = ' WHERE ' . implode(' AND ', $where);
} else {
$where = '';
}
$group_perm = array();
foreach ($rights as $right) {
$group_perm[$right['id']] = $right['permission'];
}
$dbHostGroups = DBselect('SELECT n.nodeid AS nodeid,n.name AS node_name,g.*,' . PERM_DENY . ' AS permission' . ' FROM groups g' . ' LEFT JOIN nodes n ON ' . DBid2nodeid('g.groupid') . '=n.nodeid' . $where);
while ($dbHostGroup = DBfetch($dbHostGroups)) {
if (USER_TYPE_SUPER_ADMIN == $user_type) {
$dbHostGroup['permission'] = PERM_READ_WRITE;
} else {
if (isset($group_perm[$dbHostGroup['groupid']])) {
$dbHostGroup['permission'] = $group_perm[$dbHostGroup['groupid']];
} else {
if (is_null($dbHostGroup['nodeid'])) {
$dbHostGroup['nodeid'] = id2nodeid($dbHostGroup['groupid']);
}
$dbHostGroup['permission'] = PERM_DENY;
}
}
if ($dbHostGroup['permission'] < $perm) {
continue;
}
switch ($perm_res) {
case PERM_RES_DATA_ARRAY:
$result[$dbHostGroup['groupid']] = $dbHostGroup;
break;
default:
$result[$dbHostGroup['groupid']] = $dbHostGroup['groupid'];
}
}
CArrayHelper::sort($result, array(array('field' => 'node_name', 'order' => ZBX_SORT_UP), array('field' => 'name', 'order' => ZBX_SORT_UP)));
return $result;
}
示例11: get_screen_item_form
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 = '';
//.........這裏部分代碼省略.........
示例12: get_accessible_nodes_by_user
$available_nodes = get_accessible_nodes_by_user($USER_DETAILS, PERM_READ_WRITE, PERM_RES_IDS_ARRAY);
$cmbResourceNode = new CComboBox('nodeid', $nodeid, 'submit();');
$cmbResourceNode->AddItem(0, S_ALL_S);
$sql = 'SELECT name,nodeid FROM nodes WHERE ' . DBcondition('nodeid', $available_nodes);
$db_nodes = DBselect($sql);
while ($node = DBfetch($db_nodes)) {
$cmbResourceNode->AddItem($node['nodeid'], $node['name']);
}
$frmTitle->AddItem(array(S_NODE, SPACE, $cmbResourceNode));
}
show_table_header(permission2str($permission), $frmTitle);
$form = new CForm();
$form->addOption('id', 'groups');
$table = new CTableInfo(S_NO_RESOURCES_DEFINED);
$table->SetHeader(new CCol(array(new CCheckBox("all_groups", NULL, 'check_all(this.checked)'), S_NAME)));
$result = DBselect('SELECT n.name as node_name, g.name as name, g.groupid as id' . ' FROM groups g ' . ' LEFT JOIN nodes n on ' . DBid2nodeid('g.groupid') . '=n.nodeid ' . ($nodeid ? ' WHERE nodeid=' . $nodeid : '') . ' ORDER BY n.name, g.name');
$grouplist = array();
while ($row = DBfetch($result)) {
if (isset($row['node_name'])) {
$row['name'] = $row['node_name'] . ':' . $row['name'];
}
$grouplist[$row['id']] = array('name' => $row['name'], 'permission' => $permission);
$table->addRow(new CCol(array(new CCheckBox('groups[' . $row['id'] . ']', NULL, NULL, $row['id']), $row['name'])));
}
insert_js('var grouplist = ' . zbx_jsvalue($grouplist) . ';');
$button = new CButton('select', S_SELECT, 'add_groups("' . $dstfrm . '")');
$button->setType('button');
$table->setFooter(new CCol($button, 'right'));
$form->addItem($table);
$form->show();
?>
示例13: array
}
if (isset($_REQUEST['usrgrpid']) && !isset($_REQUEST['form_refresh'])) {
$data['name'] = $data['usrgrp']['name'];
$data['users_status'] = $data['usrgrp']['users_status'];
$data['gui_access'] = $data['usrgrp']['gui_access'];
$data['debug_mode'] = $data['usrgrp']['debug_mode'];
// group users
$data['group_users'] = array();
$sql = 'SELECT DISTINCT u.userid ' . ' FROM users u,users_groups ug ' . ' WHERE u.userid=ug.userid ' . ' AND ug.usrgrpid=' . $data['usrgrpid'];
$db_users = DBselect($sql);
while ($db_user = DBfetch($db_users)) {
$data['group_users'][$db_user['userid']] = $db_user['userid'];
}
// group rights
$data['group_rights'] = array();
$sql = 'SELECT r.*,n.name AS node_name,g.name AS name ' . ' FROM groups g ' . ' LEFT JOIN rights r ON r.id=g.groupid ' . ' LEFT JOIN nodes n ON n.nodeid=' . DBid2nodeid('g.groupid') . ' WHERE r.groupid=' . $data['usrgrpid'];
$db_rights = DBselect($sql);
while ($db_right = DBfetch($db_rights)) {
if (!empty($db_right['node_name'])) {
$db_right['name'] = $db_right['node_name'] . ':' . $db_right['name'];
}
$data['group_rights'][$db_right['id']] = array('permission' => $db_right['permission'], 'name' => $db_right['name'], 'id' => $db_right['id']);
}
} else {
$data['name'] = get_request('gname', '');
$data['users_status'] = get_request('users_status', GROUP_STATUS_ENABLED);
$data['gui_access'] = get_request('gui_access', GROUP_GUI_ACCESS_SYSTEM);
$data['debug_mode'] = get_request('debug_mode', GROUP_DEBUG_MODE_DISABLED);
$data['group_users'] = get_request('group_users', array());
$data['group_rights'] = get_request('group_rights', array());
}
示例14: DBin_node
function DBin_node($id_name, $nodes = null)
{
if (is_null($nodes)) {
$nodes = get_current_nodeid();
}
if (empty($nodes)) {
$nodes = 0;
}
if (is_array($nodes)) {
$nodes = implode(',', $nodes);
} else {
if (is_string($nodes)) {
if (!eregi('([0-9\\,]+)', $nodes)) {
fatal_error('Incorrect "nodes" for "DBin_node". Passed [' . $nodes . ']');
}
} else {
if (!zbx_numeric($nodes)) {
fatal_error('Incorrect type of "nodes" for "DBin_node". Passed [' . gettype($nodes) . ']');
}
}
}
return ' ' . DBid2nodeid($id_name) . ' in (' . $nodes . ') ';
}
示例15: get_screen_item_form
//.........這裏部分代碼省略.........
$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 {