function confirmDeleteGroup() { $groupid = getContinuationVar("groupid"); $type = getContinuationVar("type"); $usergroups = getUserGroups(1); $resourcegroups = getResourceGroups(); if ($type == "user") { $title = "Delete User Group"; $question = "Delete the following user group?"; $name = $usergroups[$groupid]["name"]; $target = ""; } else { $title = "Delete Resource Group"; $question = "Delete the following resource group?"; list($resourcetype, $name) = split('/', $resourcegroups[$groupid]["name"]); $target = "#resources"; } if (checkForGroupUsage($groupid, $type)) { print "<H2 align=center>{$title}</H2>\n"; print "This group is currently assigned to at least one node in the "; print "privilege tree. You cannot delete it until it is no longer "; print "in use."; return; } print "<DIV align=center>\n"; print "<H2>{$title}</H2>\n"; print "{$question}<br><br>\n"; print "<TABLE>\n"; if ($type == "resource") { print " <TR>\n"; print " <TH align=right>Type:</TH>\n"; print " <TD>{$resourcetype}</TD>\n"; print " </TR>\n"; } print " <TR>\n"; print " <TH align=right>Name:</TH>\n"; print " <TD>{$name}</TD>\n"; print " </TR>\n"; if ($type == "resource") { print " <TR>\n"; print " <TH align=right>Owning User Group:</TH>\n"; print " <TD>" . $resourcegroups[$groupid]["owner"] . "</TD>\n"; print " </TR>\n"; } print "</TABLE>\n"; print "<TABLE>\n"; print " <TR valign=top>\n"; print " <TD>\n"; print " <FORM action=\"" . BASEURL . SCRIPT . "{$target}\" method=post>\n"; $cdata = array('groupid' => $groupid, 'type' => $type); $cont = addContinuationsEntry('submitDeleteGroup', $cdata); print " <INPUT type=hidden name=continuation value=\"{$cont}\">\n"; print " <INPUT type=submit value=Submit>\n"; print " </FORM>\n"; print " </TD>\n"; print " <TD>\n"; print " <FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n"; print " <INPUT type=hidden name=mode value=viewGroups>\n"; print " <INPUT type=submit value=Cancel>\n"; print " </FORM>\n"; print " </TD>\n"; print " </TR>\n"; print "</TABLE>\n"; }
function confirmDeleteGroup() { global $user; $groupid = getContinuationVar("groupid"); $type = getContinuationVar("type"); $usergroups = getUserGroups(); $groupid = processInputVar('groupid', ARG_NUMERIC); if ($type == 'user') { if (!array_key_exists($groupid, $usergroups)) { print "<h2>Delete User Group</h2>\n"; print "The selected user group does not exist.\n"; return; } if ($usergroups[$groupid]['ownerid'] != $user['id']) { if ($usergroups[$groupid]['custom'] == 0 || $usergroups[$groupid]['courseroll'] == 1) { if (!checkUserHasPerm('Manage Federated User Groups (global)') && (!checkUserHasPerm('Manage Federated User Groups (affiliation only)') || $usergroups[$groupid]['groupaffiliationid'] != $user['affiliationid'])) { print "<h2>Delete User Group</h2>\n"; print "You do not have access to delete the selected user group.\n"; return; } } else { print "<h2>Delete User Group</h2>\n"; print "You do not have access to delete the selected user group.\n"; return; } } $tmp = explode('@', $usergroups[$groupid]['name']); $checkname = $tmp[0]; if ($usergroups[$groupid]['groupaffiliationid'] == 1 && ($checkname == 'Specify End Time' || $checkname == 'Allow No User Check' || $checkname == 'Default for Editable by')) { print "<h2>Delete User Group</h2>\n"; print "{$usergroups[$groupid]['name']} is a system group that cannot be deleted"; return; } } else { $userresources = getUserResources(array("groupAdmin"), array("manageGroup"), 1); $noaccess = 1; foreach (array_keys($userresources) as $rtype) { if (array_key_exists($groupid, $userresources[$rtype])) { $noaccess = 0; break; } } if ($noaccess) { print "<h2>Delete Resource Group</h2>\n"; print "You do not have access to delete the selected resource group.\n"; return; } } $resourcegroups = getResourceGroups(); if ($type == "user") { $title = "Delete User Group"; $usemsg = "This group is currently in use. You cannot delete it until " . "it is no longer being used."; $question = "Delete the following user group?"; $name = $usergroups[$groupid]["name"]; $target = ""; } else { $title = "Delete Resource Group"; $usemsg = "This group is currently assigned to at least one node in the " . "privilege tree. You cannot delete it until it is no longer " . "in use."; $question = "Delete the following resource group?"; list($resourcetype, $name) = explode('/', $resourcegroups[$groupid]["name"]); $target = "#resources"; } if (checkForGroupUsage($groupid, $type, $usemsg)) { print "<H2 align=center>{$title}</H2>\n"; print $usemsg; return; } print "<DIV align=center>\n"; print "<H2>{$title}</H2>\n"; print "{$question}<br><br>\n"; print "<TABLE>\n"; if ($type == "resource") { print " <TR>\n"; print " <TH align=right>Type:</TH>\n"; print " <TD>{$resourcetype}</TD>\n"; print " </TR>\n"; } print " <TR>\n"; print " <TH align=right>Name:</TH>\n"; print " <TD>{$name}</TD>\n"; print " </TR>\n"; if ($type == "resource") { print " <TR>\n"; print " <TH align=right>Owning User Group:</TH>\n"; print " <TD>" . $resourcegroups[$groupid]["owner"] . "</TD>\n"; print " </TR>\n"; } elseif ($usergroups[$groupid]['courseroll'] == 1 || $usergroups[$groupid]['custom'] == 0) { print "<TR>\n"; print " <TH align=right>Type:</TH>\n"; if ($usergroups[$groupid]['courseroll'] == 1) { print " <TD>Course Roll</TD>\n"; } elseif ($usergroups[$groupid]['custom'] == 0) { print " <TD>Federated</TD>\n"; } print "</TR>\n"; print "<TR>\n"; print " <TD colspan=2><br><strong>Note</strong>: This type of group is "; print "created from external sources<br>and could be recreated from "; print "those sources at any time.<br><br></TD>\n"; print "</TR>\n"; } print "</TABLE>\n"; print "<TABLE>\n"; print " <TR valign=top>\n"; print " <TD>\n"; print " <FORM action=\"" . BASEURL . SCRIPT . "{$target}\" method=post>\n"; $cdata = array('groupid' => $groupid, 'type' => $type); $cont = addContinuationsEntry('submitDeleteGroup', $cdata); print " <INPUT type=hidden name=continuation value=\"{$cont}\">\n"; print " <INPUT type=submit value=Submit>\n"; print " </FORM>\n"; print " </TD>\n"; print " <TD>\n"; print " <FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n"; print " <INPUT type=hidden name=mode value=viewGroups>\n"; print " <INPUT type=submit value=Cancel>\n"; print " </FORM>\n"; print " </TD>\n"; print " </TR>\n"; print "</TABLE>\n"; print "</DIV>\n"; }
function XMLRPCremoveResourceGroup($name, $type) { global $user; if (!in_array("groupAdmin", $user['privileges'])) { return array('status' => 'error', 'errorcode' => 16, 'errormsg' => 'access denied for managing groups'); } if ($groupid = getResourceGroupID("{$type}/{$name}")) { $userresources = getUserResources(array("groupAdmin"), array("manageGroup"), 1); if (array_key_exists($type, $userresources)) { if (array_key_exists($groupid, $userresources[$type])) { if (checkForGroupUsage($groupid, 'resource')) { return array('status' => 'error', 'errorcode' => 72, 'errormsg' => 'group currently in use and cannot be removed'); } $query = "DELETE FROM resourcegroup " . "WHERE id = {$groupid}"; doQuery($query, 315); return array('status' => 'success'); } else { return array('status' => 'error', 'errorcode' => 75, 'errormsg' => 'access denied to specified resource group'); } } } return array('status' => 'error', 'errorcode' => 83, 'errormsg' => 'invalid resource group name'); }