function selectNode() { global $user; $node = processInputVar("node", ARG_NUMERIC); if (!empty($_COOKIE["VCLNODES"])) { $openNodes = $_COOKIE["VCLNODES"]; } else { $openNodes = DEFAULT_PRIVNODE; } if (empty($node)) { dbDisconnect(); exit; } $return = ""; $text = ""; $js = ""; $privs = getNodePrivileges($node); $cascadePrivs = getNodeCascadePrivileges($node); $usertypes = getTypes("users"); $i = 0; $hasUserGrant = checkUserHasPriv("userGrant", $user["id"], $node, $privs, $cascadePrivs); $hasResourceGrant = checkUserHasPriv("resourceGrant", $user["id"], $node, $privs, $cascadePrivs); $hasNodeAdmin = checkUserHasPriv("nodeAdmin", $user["id"], $node, $privs, $cascadePrivs); if ($hasNodeAdmin) { $text .= "<TABLE>"; $text .= " <TR valign=top>"; $text .= " <TD><FORM action=\"" . BASEURL . SCRIPT . "\" method=post>"; $text .= " <button id=addNodeBtn dojoType=Button "; $text .= "onClick=\"showAddNodePane(); return false;\">"; $text .= "Add Child</button>"; $text .= " </FORM></TD>"; $text .= " <TD><FORM action=\"" . BASEURL . SCRIPT . "\" method=post>"; $text .= " <button id=deleteNodeBtn dojoType=Button onClick=\"showDeleteNodeDialog();\">"; $text .= "Delete Node and Children</button>"; $text .= " </FORM></TD>"; $text .= " </TR>"; $text .= "</TABLE>"; } $return .= setAttribute('treebuttons', 'innerHTML', $text); $return .= "AJdojoCreate('treebuttons');"; # privileges $text = ""; $text .= "<H3>Users</H3>"; $text .= "<FORM id=usersform action=\"" . BASEURL . SCRIPT . "#users\" method=post>"; $users = array(); if (count($privs["users"]) || count($cascadePrivs["users"])) { $text .= "<TABLE border=1 summary=\"\">"; $text .= " <TR>"; $text .= " <TD></TD>"; $text .= " <TH bgcolor=gray style=\"color: black;\">Block<br>Cascaded<br>Rights</TH>"; $text .= " <TH bgcolor=\"#008000\" style=\"color: black;\">Cascade<br>to Child<br>Nodes</TH>"; foreach ($usertypes["users"] as $type) { $img = getImageText($type); $text .= " <TD>{$img}</TD>"; } $text .= " </TR>"; $users = array_unique(array_merge(array_keys($privs["users"]), array_keys($cascadePrivs["users"]))); sort($users); foreach ($users as $_user) { $tmpArr = getUserPrivRowHTML($_user, $i, $privs["users"], $usertypes["users"], $cascadePrivs["users"], 'user', !$hasUserGrant); $text .= $tmpArr['html']; $js .= $tmpArr['javascript']; $i++; } $text .= "</TABLE>"; $text .= "<div id=lastUserNum class=hidden>" . ($i - 1) . "</div>"; if ($hasUserGrant) { $cont = addContinuationsEntry('AJchangeUserPrivs'); $text .= "<INPUT type=hidden id=changeuserprivcont value=\"{$cont}\">"; } } else { $text .= "There are no user privileges at the selected node.<br>"; } if ($hasUserGrant) { $text .= "<BUTTON id=addUserBtn dojoType=Button onClick=\"showAddUserPane(); return false;\">"; $text .= "Add User</button>"; } $text .= "</FORM>"; $return .= setAttribute('usersDiv', 'innerHTML', $text); $return .= "AJdojoCreate('usersDiv');"; # groups $text = ""; $text .= "<H3>User Groups</H3>"; if (count($privs["usergroups"]) || count($cascadePrivs["usergroups"])) { $text .= "<FORM action=\"" . BASEURL . SCRIPT . "#groups\" method=post>"; $text .= "<div id=firstUserGroupNum class=hidden>{$i}</div>"; $text .= "<TABLE border=1 summary=\"\">"; $text .= " <TR>"; $text .= " <TD></TD>"; $text .= " <TH bgcolor=gray style=\"color: black;\">Block<br>Cascaded<br>Rights</TH>"; #$img = getImageText("Block Cascaded Rights"); #$text .= " <TD>$img</TD>"; $text .= " <TH bgcolor=\"#008000\" style=\"color: black;\">Cascade<br>to Child<br>Nodes</TH>"; #$img = getImageText("Cascade to Child Nodes"); #$text .= " <TD>$img</TD>"; foreach ($usertypes["users"] as $type) { $img = getImageText($type); $text .= " <TH>{$img}</TH>"; } $text .= " </TR>"; $groups = array_unique(array_merge(array_keys($privs["usergroups"]), array_keys($cascadePrivs["usergroups"]))); sort($groups); foreach ($groups as $group) { $tmpArr = getUserPrivRowHTML($group, $i, $privs["usergroups"], $usertypes["users"], $cascadePrivs["usergroups"], 'group', !$hasUserGrant); $text .= $tmpArr['html']; $js .= $tmpArr['javascript']; $i++; } $text .= "</TABLE>"; $text .= "<div id=lastUserGroupNum class=hidden>" . ($i - 1) . "</div>"; if ($hasUserGrant) { $cont = addContinuationsEntry('AJchangeUserGroupPrivs'); $text .= "<INPUT type=hidden id=changeusergroupprivcont value=\"{$cont}\">"; } } else { $text .= "There are no user group privileges at the selected node.<br>"; $groups = array(); } if ($hasUserGrant) { $text .= "<BUTTON id=addGroupBtn dojoType=Button onclick=\"showAddUserGroupPane(); return false;\">"; $text .= "Add Group</button>"; } $text .= "</FORM>"; $return .= setAttribute('usergroupsDiv', 'innerHTML', $text); $return .= "AJdojoCreate('usergroupsDiv');"; # resources $text = ""; $resourcetypes = array("available", "administer", "manageGroup"); $text .= "<H3>Resources</H3>"; $text .= "<FORM id=resourceForm action=\"" . BASEURL . SCRIPT . "#resources\" method=post>"; if (count($privs["resources"]) || count($cascadePrivs["resources"])) { $text .= "<TABLE border=1 summary=\"\">"; $text .= " <TR>"; $text .= " <TH>Group<br>Name</TH>"; $text .= " <TH>Group<br>Type</TH>"; $text .= " <TH bgcolor=gray style=\"color: black;\">Block<br>Cascaded<br>Rights</TH>"; $text .= " <TH bgcolor=\"#008000\" style=\"color: black;\">Cascade<br>to Child<br>Nodes</TH>"; foreach ($resourcetypes as $type) { $img = getImageText("{$type}"); $text .= " <TH>{$img}</TH>"; } $text .= " </TR>"; $resources = array_unique(array_merge(array_keys($privs["resources"]), array_keys($cascadePrivs["resources"]))); sort($resources); $resourcegroups = getResourceGroups(); $resgroupmembers = getResourceGroupMembers(); foreach ($resources as $resource) { $tmpArr = getResourcePrivRowHTML($resource, $i, $privs["resources"], $resourcetypes, $resourcegroups, $resgroupmembers, $cascadePrivs["resources"], !$hasResourceGrant); $text .= $tmpArr['html']; $js .= $tmpArr['javascript']; $i++; } $text .= "</TABLE>"; if ($hasResourceGrant) { $cont = addContinuationsEntry('AJchangeResourcePrivs'); $text .= "<INPUT type=hidden id=changeresourceprivcont value=\"{$cont}\">"; } } else { $text .= "There are no resource group privileges at the selected node.<br>"; $resources = array(); } if ($hasResourceGrant) { $text .= "<BUTTON id=addResourceBtn dojoType=Button onclick=\"showAddResourceGroupPane(); return false;\">"; $text .= "Add Resource Group</button>"; } $text .= "</FORM>"; $return .= setAttribute('resourcesDiv', 'innerHTML', $text); $return .= "AJdojoCreate('resourcesDiv');"; $return .= "showPrivileges();"; print $return; print $js; dbDisconnect(); exit; }
function selectNode() { global $user; $node = processInputVar("node", ARG_NUMERIC); if (empty($node)) { return; } $return = ""; $text = ""; $js = ""; $privs = getNodePrivileges($node); $cascadePrivs = getNodeCascadePrivileges($node); $usertypes = getTypes("users"); $i = 0; $hasUserGrant = checkUserHasPriv("userGrant", $user["id"], $node, $privs, $cascadePrivs); $hasResourceGrant = checkUserHasPriv("resourceGrant", $user["id"], $node, $privs, $cascadePrivs); $hasNodeAdmin = checkUserHasPriv("nodeAdmin", $user["id"], $node, $privs, $cascadePrivs); if ($hasNodeAdmin) { $text .= "<TABLE>"; $text .= " <TR valign=top>"; $text .= " <TD><FORM action=\"" . BASEURL . SCRIPT . "\" method=post>"; $text .= " <button id=addNodeBtn dojoType=\"dijit.form.Button\">"; $text .= " Add Child"; $text .= " <script type=\"dojo/method\" event=onClick>"; $text .= " showPrivPane(\"addNodePane\");"; $text .= " return false;"; $text .= " </script>"; $text .= " </button>"; $text .= " </FORM></TD>"; $text .= " <TD><FORM action=\"" . BASEURL . SCRIPT . "\" method=post>"; $text .= " <button id=deleteNodeBtn dojoType=\"dijit.form.Button\">"; $text .= " Delete Node and Children"; $text .= " <script type=\"dojo/method\" event=onClick>"; $text .= " dijit.byId(\"deleteDialog\").show();"; $text .= " return false;"; $text .= " </script>"; $text .= " </button>"; $text .= " </FORM></TD>"; $text .= " <TD><FORM action=\"" . BASEURL . SCRIPT . "\" method=post>"; $text .= " <button id=renameNodeBtn dojoType=\"dijit.form.Button\">"; $text .= " Rename Node"; $text .= " <script type=\"dojo/method\" event=onClick>"; $text .= " dijit.byId(\"renameDialog\").show();"; $text .= " return false;"; $text .= " </script>"; $text .= " </button>"; $text .= " </FORM></TD>"; $text .= " </TR>"; $text .= "</TABLE>"; } $return .= "if(dijit.byId('addNodeBtn')) dijit.byId('addNodeBtn').destroy();"; $return .= "if(dijit.byId('deleteNodeBtn')) dijit.byId('deleteNodeBtn').destroy();"; $return .= "if(dijit.byId('renameNodeBtn')) dijit.byId('renameNodeBtn').destroy();"; $return .= setAttribute('treebuttons', 'innerHTML', $text); $return .= "AJdojoCreate('treebuttons');"; # privileges $return .= "dojo.query('*', 'nodePerms').forEach(function(item){if(dijit.byId(item.id)) dijit.byId(item.id).destroy();});"; $text = ""; $text .= "<H3>Users</H3>"; $users = array(); if (count($privs["users"]) || count($cascadePrivs["users"])) { $text .= "<FORM id=usersform action=\"" . BASEURL . SCRIPT . "#users\" method=post>"; $text .= "<TABLE border=1 summary=\"\">"; $text .= " <TR>"; $text .= " <TD></TD>"; $text .= " <TH bgcolor=gray style=\"color: black;\">Block<br>Cascaded<br>Rights</TH>"; $text .= " <TH bgcolor=\"#008000\" style=\"color: black;\">Cascade<br>to Child<br>Nodes</TH>"; foreach ($usertypes["users"] as $type) { $img = getImageText($type); $text .= " <TD>{$img}</TD>"; } $text .= " </TR>"; $users = array_unique(array_merge(array_keys($privs["users"]), array_keys($cascadePrivs["users"]))); sort($users); foreach ($users as $_user) { $tmpArr = getUserPrivRowHTML($_user, $i, $privs["users"], $usertypes["users"], $cascadePrivs["users"], 'user', !$hasUserGrant); $text .= $tmpArr['html']; $js .= $tmpArr['javascript']; $i++; } $text .= "</TABLE>"; $text .= "<div id=lastUserNum class=hidden>" . ($i - 1) . "</div>"; if ($hasUserGrant) { $cont = addContinuationsEntry('AJchangeUserPrivs'); $text .= "<INPUT type=hidden id=changeuserprivcont value=\"{$cont}\">"; } } else { $text .= "There are no user privileges at the selected node.<br>"; } if ($hasUserGrant) { $text .= "<button id=addUserBtn dojoType=\"dijit.form.Button\">"; $text .= " Add User"; $text .= " <script type=\"dojo/method\" event=onClick>"; $text .= " showPrivPane(\"addUserPane\");"; $text .= " return false;"; $text .= " </script>"; $text .= "</button>"; } $text .= "</FORM>"; $return .= setAttribute('usersDiv', 'innerHTML', $text); $return .= "AJdojoCreate('usersDiv');"; # groups $text = ""; $text .= "<H3>User Groups</H3>"; if (count($privs["usergroups"]) || count($cascadePrivs["usergroups"])) { $text .= "<FORM action=\"" . BASEURL . SCRIPT . "#groups\" method=post>"; $text .= "<div id=firstUserGroupNum class=hidden>{$i}</div>"; $text .= "<TABLE border=1 summary=\"\">"; $text .= " <TR>"; $text .= " <TD></TD>"; $text .= " <TH bgcolor=gray style=\"color: black;\">Block<br>Cascaded<br>Rights</TH>"; $text .= " <TH bgcolor=\"#008000\" style=\"color: black;\">Cascade<br>to Child<br>Nodes</TH>"; foreach ($usertypes["users"] as $type) { $img = getImageText($type); $text .= " <TH>{$img}</TH>"; } $text .= " </TR>"; $groupids = array_unique(array_merge(array_keys($privs["usergroups"]), array_keys($cascadePrivs["usergroups"]))); $allids = implode(',', $groupids); $query = "SELECT id " . "FROM usergroup " . "WHERE id IN ({$allids}) " . "ORDER BY name"; $qh = doQuery($query); $orderedgroups = array(); while ($row = mysql_fetch_assoc($qh)) { $orderedgroups[] = $row['id']; } foreach ($orderedgroups as $id) { $tmpArr = getUserPrivRowHTML($id, $i, $privs["usergroups"], $usertypes["users"], $cascadePrivs["usergroups"], 'group', !$hasUserGrant); $text .= $tmpArr['html']; $js .= $tmpArr['javascript']; $i++; } $text .= "</TABLE>"; $text .= "<div id=lastUserGroupNum class=hidden>" . ($i - 1) . "</div>"; if ($hasUserGrant) { $cont = addContinuationsEntry('AJchangeUserGroupPrivs'); $text .= "<INPUT type=hidden id=changeusergroupprivcont value=\"{$cont}\">"; } $cont = addContinuationsEntry('jsonGetUserGroupMembers'); $text .= "<INPUT type=hidden id=ugmcont value=\"{$cont}\">"; } else { $text .= "There are no user group privileges at the selected node.<br>"; $groups = array(); } if ($hasUserGrant) { $text .= "<button id=addGroupBtn dojoType=\"dijit.form.Button\">"; $text .= " Add Group"; $text .= " <script type=\"dojo/method\" event=onClick>"; $text .= " showPrivPane(\"addUserGroupPane\");"; $text .= " return false;"; $text .= " </script>"; $text .= "</button>"; } $text .= "</FORM>"; $return .= setAttribute('usergroupsDiv', 'innerHTML', $text); $return .= "AJdojoCreate('usergroupsDiv');"; # resources $text = ""; $resourcetypes = getResourcePrivs(); $text .= "<H3>Resources</H3>"; $text .= "<FORM id=resourceForm action=\"" . BASEURL . SCRIPT . "#resources\" method=post>"; if (count($privs["resources"]) || count($cascadePrivs["resources"])) { $text .= "<TABLE border=1 summary=\"\">"; $text .= " <TR>"; $text .= " <TH>Group<br>Name</TH>"; $text .= " <TH>Group<br>Type</TH>"; $text .= " <TH bgcolor=gray style=\"color: black;\">Block<br>Cascaded<br>Rights</TH>"; $text .= " <TH bgcolor=\"#008000\" style=\"color: black;\">Cascade<br>to Child<br>Nodes</TH>"; foreach ($resourcetypes as $type) { if ($type == 'block' || $type == 'cascade') { continue; } $img = getImageText("{$type}"); $text .= " <TH>{$img}</TH>"; } $text .= " </TR>"; $resources = array_unique(array_merge(array_keys($privs["resources"]), array_keys($cascadePrivs["resources"]))); sort($resources); $resourcegroups = getResourceGroups(); $resgroupmembers = getResourceGroupMembers(); foreach ($resources as $resource) { $tmpArr = getResourcePrivRowHTML($resource, $i, $privs["resources"], $resourcetypes, $resourcegroups, $resgroupmembers, $cascadePrivs["resources"], !$hasResourceGrant); $html = str_replace("\n", '', $tmpArr['html']); $html = str_replace("'", "\\'", $html); $html = preg_replace("/>\\s*</", "><", $html); $text .= $html; $js .= $tmpArr['javascript']; $i++; } $text .= "</TABLE>"; if ($hasResourceGrant) { $cont = addContinuationsEntry('AJchangeResourcePrivs'); $text .= "<INPUT type=hidden id=changeresourceprivcont value=\"{$cont}\">"; } $cont = addContinuationsEntry('jsonGetResourceGroupMembers'); $text .= "<INPUT type=hidden id=rgmcont value=\"{$cont}\">"; } else { $text .= "There are no resource group privileges at the selected node.<br>"; $resources = array(); } if ($hasResourceGrant) { $text .= "<button id=addResourceBtn dojoType=\"dijit.form.Button\">"; $text .= " Add Resource Group"; $text .= " <script type=\"dojo/method\" event=onClick>"; $text .= " showPrivPane(\"addResourceGroupPane\");"; $text .= " return false;"; $text .= " </script>"; $text .= "</button>"; } $text .= "</FORM>"; $return .= setAttribute('resourcesDiv', 'innerHTML', $text); $return .= "AJdojoCreate('resourcesDiv');"; print $return; print $js; }