$group) { if(array_key_exists($id, $resourcegroups)) { // have to make sure it exists in case something was deleted from the session priv cache $resources[$id]["type"] = $type; $resources[$id]["name"] = $group; $resources[$id]["owner"] = $resourcegroups[$id]["owner"]; } } } print "

User Groups

\n"; if($modetype == "user") { if($mode == "submitAddGroup") { print "User group successfully added"; print "

\n"; } elseif($mode == "submitDeleteGroup") { print "User group successfully deleted"; print "

\n"; } elseif($mode == "submitEditGroup") { print "User group successfully updated"; print "

\n"; } } print "\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; if($viewmode == ADMIN_DEVELOPER) print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; if($user['showallgroups']) { $affils = getAffiliations(); print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; if($viewmode == ADMIN_DEVELOPER) { print " \n"; } $cont = addContinuationsEntry('submitAddGroup', array('type' => 'user')); print " \n"; print " \n"; print " \n"; $dispUserGrpIDs = array(); foreach(array_keys($usergroups) as $id) { if($usergroups[$id]["name"] == " None") continue; # figure out if user is owner or in editor group $owner = 0; $editor = 0; if($usergroups[$id]["ownerid"] == $user["id"]) $owner = 1; if(array_key_exists("editgroup", $usergroups[$id]) && in_array($usergroups[$id]["editgroup"], $user["groups"])) $editor = 1; if(! $owner && ! $editor) continue; if($user['showallgroups']) $dispUserGrpIDs[$id] = $usergroups[$id]['name']; elseif($usergroups[$id]['groupaffiliation'] == $user['affiliation'] && array_key_exists($id, $affilusergroups)) $dispUserGrpIDs[$id] = $affilusergroups[$id]['name']; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; if($viewmode == ADMIN_DEVELOPER) print " \n"; print " \n"; } print "
NameOwnerEditable byInitial Max Time (minutes)Total Max Time (minutes)Max Extend Time (minutes)Max Overlapping Reservations
"; print "@"; printSelectInput("affiliationid", $affils, $user['affiliationid']); } else print " "; print "\n"; printSelectInput("editgroupid", $affilusergroups, 82); print " "; print ""; print ""; print "
\n"; if($owner) { print "
"; $cdata = array('type' => 'user', 'groupid' => $id); $cont = addContinuationsEntry('confirmDeleteGroup', $cdata); print " "; print " "; print "
"; } print "
\n"; print "
\n"; $cdata = array('type' => 'user', 'groupid' => $id, 'isowner' => $owner); $cont = addContinuationsEntry('editGroup', $cdata); print " \n"; print " \n"; print "
\n"; print "
{$usergroups[$id]["name"]}{$usergroups[$id]["owner"]}{$usergroups[$id]["editgroup"]}@"; print "{$usergroups[$id]['editgroupaffiliation']}{$usergroups[$id]["initialmaxtime"]}{$usergroups[$id]["totalmaxtime"]}{$usergroups[$id]["maxextendtime"]}{$usergroups[$id]["overlapResCount"]}
\n"; print "\n"; print "

Resource Groups

\n"; if($modetype == "resource") { if($mode == "submitAddGroup") { print "Resource group successfully added"; print "

\n"; } elseif($mode == "submitDeleteGroup") { print "Resource group successfully deleted"; print "

\n"; } elseif($mode == "submitEditGroup") { print "Resource group successfully updated"; print "

\n"; } } print "\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; if(! empty($dispUserGrpIDs)) { print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; $cdata = array('type' => 'resource'/*, 'dispUserGrpIDs' => $dispUserGrpIDs*/); $cont = addContinuationsEntry('submitAddGroup', $cdata); print " \n"; print " \n"; print " \n"; } $jscont = addContinuationsEntry('jsonGetGroupInfo'); foreach(array_keys($resources) as $id) { print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; } print "
TypeNameOwning User Group"; print "\"\"
\n"; printSelectInput("resourcetypeid", $resourcetypes["resources"]); print " \n"; # remove the "None" group unset($usergroups[82]); # find a custom group the user is in and make it the default $defaultgroupkey = ""; foreach(array_keys($user["groups"]) as $grpid) { if(array_key_exists($grpid, $usergroups)) { $defaultgroupkey = $grpid; break; } } printSelectInput("ownergroup", $dispUserGrpIDs, $defaultgroupkey); print "
\n"; print "
\n"; $cdata = array('type' => 'resource', 'groupid' => $id); $cont = addContinuationsEntry('confirmDeleteGroup', $cdata); print " \n"; print " \n"; print "
\n"; print "
\n"; print "
\n"; $cdata = array('type' => 'resource', 'groupid' => $id, 'dispUserGrpIDs' => $dispUserGrpIDs); $cont = addContinuationsEntry('editGroup', $cdata); print " \n"; print " \n"; print "
\n"; print "
" . $resources[$id]["type"] . "" . $resources[$id]["name"] . "" . $resources[$id]["owner"] . ""; print "\"mouseover
\n"; } //////////////////////////////////////////////////////////////////////////////// /// /// \fn editOrAddGroup($state) /// /// \param $state - 0 for edit, 1 for add /// /// \brief prints a form for editing a group /// //////////////////////////////////////////////////////////////////////////////// function editOrAddGroup($state) { global $submitErr, $user, $mode, $viewmode; $usergroups = getUserGroups(1); if($user['showallgroups']) $affilusergroups = $usergroups; else $affilusergroups = getUserGroups(1, $user['affiliationid']); $resourcegroups = getResourceGroups(); $affils = getAffiliations(); $resourcetypes = getTypes("resources"); if($submitErr) { $data = processGroupInput(0); $newuser = processInputVar("newuser", ARG_STRING); if($mode == "submitEditGroup") { $id = $data["groupid"]; if($data["type"] == "resource") { list($grouptype, $junk) = explode('/', $resourcegroups[$id]["name"]); $ownerid = $resourcegroups[$id]["ownerid"]; } } else { if($data["type"] == "resource") { if($state) $grouptype = $resourcetypes['resources'][$data['resourcetypeid']]; else list($grouptype, $junk) = explode('/', $resourcegroups[$data['groupid']]["name"]); $ownerid = $data["ownergroup"]; } else { $selectAffil = getContinuationVar('selectAffil'); if(empty($selectAffil) && $user['showallgroups']) $selectAffil = 1; } } } else { $newuser = processInputVar("newuser", ARG_STRING); $data["groupid"] = getContinuationVar("groupid"); $data["type"] = getContinuationVar("type"); $data["isowner"] = getContinuationVar("isowner"); $id = $data["groupid"]; if($data["type"] == "user") { $data["name"] = $usergroups[$id]["name"]; $data["affiliationid"] = $usergroups[$id]["groupaffiliationid"]; $data["owner"] = $usergroups[$id]["owner"]; $data["editgroupid"] = $usergroups[$id]["editgroupid"]; $data["initialmax"] = $usergroups[$id]["initialmaxtime"]; $data["totalmax"] = $usergroups[$id]["totalmaxtime"]; $data["maxextend"] = $usergroups[$id]["maxextendtime"]; $data["overlap"] = $usergroups[$id]["overlapResCount"]; $tmp = explode('@', $data['name']); $data['name'] = $tmp[0]; if($user['showallgroups'] || (array_key_exists(1, $tmp) && $tmp[1] != $user['affiliation'])) $selectAffil = 1; else $selectAffil = 0; } else { list($grouptype, $data["name"]) = explode('/', $resourcegroups[$id]["name"]); $ownerid = $resourcegroups[$id]["ownerid"]; } } $editusergroup = 0; if($data['type'] != 'user') print "
\n"; else print "\n"; print "
\n"; if($state) { if($data["type"] == "user") print "

Add User Group

\n"; else print "

Add Resource Group

\n"; } else { if($data["type"] == "user") { print "

Edit User Group

\n"; print "{$usergroups[$data['groupid']]['name']}
\n"; $editusergroup = 1; } else print "

Edit Resource Group

\n"; } if(($state && $data["type"] == "user") || $data["isowner"] || $data["type"] == "resource") { print "\n"; if($data["type"] == "resource") { print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; } print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; if($data["type"] == "user") { print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " "; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; if($viewmode == ADMIN_DEVELOPER) { print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; } } else { print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; } print "
Type:\n"; if($state && $submitErr) $resourcetypeid = $data['resourcetypeid']; else $resourcetypeid = array_search($grouptype, $resourcetypes["resources"]); if($state) printSelectInput("resourcetypeid", $resourcetypes["resources"], $resourcetypeid); else print " $grouptype\n"; print "
Name:"; if($data['type'] == 'user' && $selectAffil) { print "@"; printSelectInput('affiliationid', $affils, $data['affiliationid']); } print ""; printSubmitErr(GRPNAMEERR); print "
Owner:"; printSubmitErr(GRPOWNER); print "
Editable by:\n"; if(! empty($data['editgroupid']) && ! array_key_exists($data['editgroupid'], $affilusergroups)) { $affilusergroups[$data['editgroupid']] = array('name' => getUserGroupName($data['editgroupid'], 1)); uasort($affilusergroups, "sortKeepIndex"); } printSelectInput("editgroupid", $affilusergroups, $data["editgroupid"]); print "
Initial Max Time (minutes):"; printSubmitErr(INITIALMAXERR); print "
Total Max Time (minutes):"; printSubmitErr(TOTALMAXERR); print "
Max Extend Time (minutes):"; printSubmitErr(MAXEXTENDERR); print "
Max Overlapping Reservations:"; printSubmitErr(MAXOVERLAPERR); print "
Owning User Group:\n"; if(! array_key_exists($ownerid, $affilusergroups)) { $affilusergroups[$ownerid] = $usergroups[$ownerid]; uasort($affilusergroups, "sortKeepIndex"); } printSelectInput("ownergroup", $affilusergroups, $ownerid); print "
\n"; print "\n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
\n"; if($state) { $cdata = array('type' => $data['type'], 'isowner' => $data['isowner']); $cont = addContinuationsEntry('submitAddGroup', $cdata); print " \n"; print " \n"; } else { $cdata = array('type' => $data['type'], 'groupid' => $data['groupid'], 'isowner' => $data['isowner']); if($data['type'] == 'resource') $cdata['resourcetypeid'] = $resourcetypeid; else $cdata['selectAffil'] = $selectAffil; $cont = addContinuationsEntry('confirmEditGroup', $cdata); print " \n"; print " \n"; } print " \n"; print " \n"; print "
\n"; print " \n"; print " \n"; print "
\n"; print "
\n"; } if($data["type"] != "user") return; if($editusergroup) { print "

Group Membership

\n"; if($mode == "addGroupUser" && ! ($submitErr & IDNAMEERR)) { print "$newuser successfully added to group"; print "

\n"; } if($mode == "deleteGroupUser") { print "$newuser successfully deleted from "; print "group

\n"; } $groupmembers = getUserGroupMembers($data["groupid"]); print "\n"; print " \n"; print " \n"; print " \n"; print " \n"; else print ">\n"; if($submitErr) { print " \n"; } $cont = addContinuationsEntry('addGroupUser', $data); print " \n"; print " \n"; print " \n"; foreach($groupmembers as $id => $login) { print " \n"; print " \n"; print " \n"; print " \n"; } print "
\n"; printSubmitErr(IDNAMEERR); print "
\n"; print "
\n"; print " \n"; $data['userid'] = $id; $data['newuser'] = $login; $cont = addContinuationsEntry('deleteGroupUser', $data); print " \n"; print "
\n"; print "
$login
\n"; } } //////////////////////////////////////////////////////////////////////////////// /// /// \fn processGroupInput($checks) /// /// \param $checks - (optional) 1 to perform validation, 0 not to /// /// \return an array with the following indexes:\n /// groupid, name, prettyname, platformid, osid /// /// \brief validates input from the previous form; if anything was improperly /// submitted, sets submitErr and submitErrMsg /// //////////////////////////////////////////////////////////////////////////////// function processGroupInput($checks=1) { global $submitErr, $submitErrMsg, $user, $viewmode; $return = array(); $return["groupid"] = getContinuationVar("groupid"); $return["type"] = getContinuationVar("type"); $return["name"] = getContinuationVar('name', processInputVar("name", ARG_STRING)); $return["affiliationid"] = getContinuationVar('affiliationid', processInputVar("affiliationid", ARG_NUMERIC, $user['affiliationid'])); $return["resourcetypeid"] = getContinuationVar('resourcetypeid', processInputVar("resourcetypeid", ARG_NUMERIC)); $return["owner"] = getContinuationVar('owner', processInputVar("owner", ARG_STRING)); $return["ownergroup"] = processInputVar("ownergroup", ARG_NUMERIC); $return["editgroupid"] = getContinuationVar('editgroupid', processInputVar("editgroupid", ARG_NUMERIC)); $return["isowner"] = getContinuationVar("isowner"); $return["initialmax"] = getContinuationVar('initialmax', processInputVar("initialmax", ARG_NUMERIC)); $return["totalmax"] = getContinuationVar('totalmax', processInputVar("totalmax", ARG_NUMERIC)); $return["maxextend"] = getContinuationVar('maxextend', processInputVar("maxextend", ARG_NUMERIC)); $return["overlap"] = getContinuationVar('overlap', processInputVar("overlap", ARG_NUMERIC, 0)); $affils = getAffiliations(); if(! array_key_exists($return['affiliationid'], $affils)) $return['affiliationid'] = $user['affiliationid']; if(! $checks) { return $return; } if(! preg_match('/^[-a-zA-Z0-9_\.: ]{3,30}$/', $return["name"])) { $submitErr |= GRPNAMEERR; $submitErrMsg[GRPNAMEERR] = "Name must be between 3 and 30 characters " . "and can only contain letters, numbers, and " . "these characters: - _ . :"; } if($return['type'] == 'user') $extraid = $return['affiliationid']; else $extraid = $return['resourcetypeid']; if(! empty($return["type"]) && ! empty($return["name"]) && ! ($submitErr & GRPNAMEERR) && checkForGroupName($return["name"], $return["type"], $return["groupid"], $extraid)) { $submitErr |= GRPNAMEERR; $submitErrMsg[GRPNAMEERR] = "A group already exists with this name."; } if($return["type"] == "user" && ! validateUserid($return["owner"])) { $submitErr |= GRPOWNER; $submitErrMsg[GRPOWNER] = "Submitted ID is not valid"; } if($return["type"] == "user" && $return["initialmax"] < 30) { $submitErr |= INITIALMAXERR; $submitErrMsg[INITIALMAXERR] = "Initial max time must be at least 30 " . "minutes"; } if($return["type"] == "user" && $return["totalmax"] < 30) { $submitErr |= TOTALMAXERR; $submitErrMsg[TOTALMAXERR] = "Total max time must be at least 30 " . "minutes"; } if($return["type"] == "user" && $return["maxextend"] < 15) { $submitErr |= MAXEXTENDERR; $submitErrMsg[MAXEXTENDERR] = "Max extend time must be at least 15 " . "minutes"; } if($viewmode == ADMIN_DEVELOPER && $return["type"] == "user" && ($return["overlap"] < 0 || $return["overlap"] == 1)) { $submitErr |= MAXOVERLAPERR; $submitErrMsg[MAXOVERLAPERR] = "Overlap can be 0 or greater than or equal to 2"; } return $return; } //////////////////////////////////////////////////////////////////////////////// /// /// \fn checkForGroupName($name, $type, $id, $extraid) /// /// \param $name - the name of a group /// \param $type - user or resource /// \param $id - id of a group to ignore /// \param $extraid - if $type is resource, this is a resource type id; if /// $type is user, this is an affiliation id /// /// \return 1 if $name is already in the associated table, 0 if not /// /// \brief checks for $name being in usergroup/resource group (based on $type) /// except for $id /// //////////////////////////////////////////////////////////////////////////////// function checkForGroupName($name, $type, $id, $extraid) { if($type == "user") $query = "SELECT id FROM usergroup " . "WHERE name = '$name' AND " . "affiliationid = $extraid"; else $query = "SELECT id FROM resourcegroup " . "WHERE name = '$name' AND " . "resourcetypeid = $extraid"; if(! empty($id)) $query .= " AND id != $id"; $qh = doQuery($query, 101); if(mysql_num_rows($qh)) return 1; return 0; } //////////////////////////////////////////////////////////////////////////////// /// /// \fn updateGroup($data) /// /// \param $data - an array returned from processGroupInput /// /// \return number of rows affected by the update\n /// \b NOTE: mysql reports that no rows were affected if none of the fields /// were actually changed even if the update matched a row /// /// \brief performs a query to update the group with data from $data /// //////////////////////////////////////////////////////////////////////////////// function updateGroup($data) { global $viewmode; if($data["type"] == "user") { $ownerid = getUserlistID($data["owner"]); $query = "UPDATE usergroup " . "SET name = '{$data["name"]}', " . "affiliationid = {$data['affiliationid']}, " . "ownerid = $ownerid, " . "editusergroupid = {$data["editgroupid"]}, " . "initialmaxtime = {$data["initialmax"]}, " . "totalmaxtime = {$data["totalmax"]}, "; if($viewmode == ADMIN_DEVELOPER) $query .= "overlapResCount = {$data["overlap"]}, "; $query .= "maxextendtime = {$data["maxextend"]} " . "WHERE id = {$data["groupid"]}"; } else { $query = "UPDATE resourcegroup " . "SET name = '{$data["name"]}', " . "ownerusergroupid = {$data["ownergroup"]} " . "WHERE id = {$data["groupid"]}"; } $qh = doQuery($query, 300); return mysql_affected_rows($GLOBALS["mysql_link_vcl"]); } //////////////////////////////////////////////////////////////////////////////// /// /// \fn addGroup($data) /// /// \param $data - an array returned from processGroupInput /// /// \return number of rows affected by the insert\n /// /// \brief performs a query to insert the group with data from $data /// //////////////////////////////////////////////////////////////////////////////// function addGroup($data) { global $viewmode; if($data["type"] == "user") { $ownerid = getUserlistID($data["owner"]); $query = "INSERT INTO usergroup " . "(name, " . "affiliationid, " . "ownerid, " . "editusergroupid, " . "custom, " . "initialmaxtime, " . "totalmaxtime, "; if($viewmode == ADMIN_DEVELOPER) $query .= "overlapResCount, "; $query .= "maxextendtime) " . "VALUES ('{$data["name"]}', " . "{$data["affiliationid"]}, " . "$ownerid, " . "{$data["editgroupid"]}, " . "1, " . "{$data["initialmax"]}, " . "{$data["totalmax"]}, "; if($viewmode == ADMIN_DEVELOPER) $query .= "{$data["overlap"]}, "; $query .= "{$data["maxextend"]})"; } else { $query = "INSERT INTO resourcegroup " . "(name, " . "ownerusergroupid, " . "resourcetypeid) " . "VALUES ('" . $data["name"] . "', " . $data["ownergroup"] . ", " . "'" . $data["resourcetypeid"] . "')"; } $qh = doQuery($query, 305); clearPrivCache(); return mysql_affected_rows($GLOBALS["mysql_link_vcl"]); } //////////////////////////////////////////////////////////////////////////////// /// /// \fn checkForGroupUsage($groupid, $type) /// /// \param $groupid - id of an group /// \param $type - group type: "user" or "resource" /// /// \return 0 if group is not used, 1 if it is /// /// \brief checks for $groupid being in the priv table corresponding to $type /// //////////////////////////////////////////////////////////////////////////////// function checkForGroupUsage($groupid, $type) { if($type == "user") { $query = "SELECT id FROM resourcegroup WHERE ownerusergroupid = $groupid"; $qh = doQuery($query, 310); if(mysql_num_rows($qh)) return 1; $query = "SELECT id " . "FROM blockRequest " . "WHERE groupid = $groupid " . "OR admingroupid = $groupid"; $qh = doQuery($query, 311); if(mysql_num_rows($qh)) return 1; $query = "SELECT id FROM imagemeta WHERE usergroupid = $groupid"; $qh = doQuery($query, 312); if(mysql_num_rows($qh)) return 1; $query = "SELECT id " . "FROM usergroup " . "WHERE editusergroupid = $groupid " . "AND id != $groupid"; $qh = doQuery($query, 313); if(mysql_num_rows($qh)) return 1; $query = "SELECT id FROM userpriv WHERE usergroupid = $groupid"; } else $query = "SELECT id FROM resourcepriv WHERE resourcegroupid = $groupid"; $qh = doQuery($query, 314); if(mysql_num_rows($qh)) return 1; return 0; } //////////////////////////////////////////////////////////////////////////////// /// /// \fn confirmEditOrAddGroup($state) /// /// \param $state - 0 for edit, 1 for add /// /// \brief prints a form for confirming changes to an group /// //////////////////////////////////////////////////////////////////////////////// function confirmEditOrAddGroup($state) { global $submitErr, $user, $viewmode; $data = processGroupInput(1); if($submitErr) { editOrAddGroup($state); return; } $resourcetypes = getTypes("resources"); $usergroups = getUserGroups(1); $affils = getAffiliations(); if($state) { if($data["type"] == "user") { $title = "Add User Group"; $question = "Add the following user group?"; $target = ""; } else { $title = "Add Resource Group"; $question = "Add the following resource group?"; $target = "#resources"; } $nextmode = "submitAddGroup"; } else { if($data["type"] == "user") { $title = "Edit User Group"; $question = "Submit changes to the user group?"; $target = ""; } else { $title = "Edit Resource Group"; $question = "Submit changes to the resource group?"; $target = "#resources"; } $nextmode = "submitEditGroup"; } print "
\n"; print "

$title

\n"; print "$question

\n"; print "\n"; if($data["type"] == "resource") { print " \n"; print " \n"; print " \n"; print " \n"; } print " \n"; print " \n"; if($data['type'] == 'user' && ($user['showallgroups'] || $data['affiliationid'] != $user['affiliationid'])) print " \n"; else print " \n"; print " \n"; if($data["type"] == "user") { print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; if(! $user['showallgroups']) { $tmp = explode('@', $usergroups[$data["editgroupid"]]["name"]); if($tmp[1] == $user['affiliation']) $usergroups[$data["editgroupid"]]["name"] = $tmp[0]; } print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; if($viewmode == ADMIN_DEVELOPER) { print " \n"; print " \n"; print " \n"; print " \n"; } } else { print " \n"; print " \n"; if(! $user['showallgroups'] && preg_match("/^(.+)@{$user['affiliation']}$/", $usergroups[$data['ownergroup']]['name'], $matches)) print " \n"; print " \n"; } print "
Type:" . $resourcetypes["resources"][$data["resourcetypeid"]]; print "
Name:{$data["name"]}@{$affils[$data['affiliationid']]}{$data["name"]}
Owner:" . $data["owner"] . "
Editable by:" . $usergroups[$data["editgroupid"]]["name"] . "
Initial Max Time (minutes):{$data["initialmax"]}
Total Max Time (minutes):{$data["totalmax"]}
Max Extend Time (minutes):{$data["maxextend"]}
Max Overlapping Reservations:{$data["overlap"]}
Owning User Group:{$matches[1]}"; else print " " . $usergroups[$data["ownergroup"]]["name"]; print "
\n"; print "\n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
\n"; print "
\n"; $cont = addContinuationsEntry($nextmode, $data, SECINDAY, 0, 0); print " \n"; print " \n"; print "
\n"; print "
\n"; print "
\n"; print " \n"; print " \n"; print "
\n"; print "
\n"; } //////////////////////////////////////////////////////////////////////////////// /// /// \fn submitEditGroup() /// /// \brief submits changes to group and notifies user /// //////////////////////////////////////////////////////////////////////////////// function submitEditGroup() { $data = getContinuationVar(); updateGroup($data); $_SESSION['userresources'] = array(); $_SESSION['nodeprivileges'] = array(); #$_SESSION['cascadenodeprivileges'] = array(); // might need this uncommented viewGroups(); } //////////////////////////////////////////////////////////////////////////////// /// /// \fn submitAddGroup() /// /// \brief adds the group and notifies user /// //////////////////////////////////////////////////////////////////////////////// function submitAddGroup() { global $submitErr; $data = processGroupInput(1); if($submitErr) { editOrAddGroup(1); return; } if(! addGroup($data)) abort(10); viewGroups(); } //////////////////////////////////////////////////////////////////////////////// /// /// \fn confirmDeleteGroup() /// /// \brief prints a form to confirm the deletion of an group /// //////////////////////////////////////////////////////////////////////////////// function confirmDeleteGroup() { $groupid = getContinuationVar("groupid"); $type = getContinuationVar("type"); $usergroups = getUserGroups(1); $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)) { print "

$title

\n"; print $usemsg; return; } print "
\n"; print "

$title

\n"; print "$question

\n"; print "\n"; if($type == "resource") { print " \n"; print " \n"; print " \n"; print " \n"; } print " \n"; print " \n"; print " \n"; print " \n"; if($type == "resource") { print " \n"; print " \n"; print " \n"; print " \n"; } print "
Type:$resourcetype
Name:$name
Owning User Group:" . $resourcegroups[$groupid]["owner"] . "
\n"; print "\n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
\n"; print "
\n"; $cdata = array('groupid' => $groupid, 'type' => $type); $cont = addContinuationsEntry('submitDeleteGroup', $cdata); print " \n"; print " \n"; print "
\n"; print "
\n"; print "
\n"; print " \n"; print " \n"; print "
\n"; print "
\n"; } //////////////////////////////////////////////////////////////////////////////// /// /// \fn submitDeleteGroup() /// /// \brief deletes an group from the database and notifies the user /// //////////////////////////////////////////////////////////////////////////////// function submitDeleteGroup() { $groupid = getContinuationVar("groupid"); $type = getContinuationVar("type"); if($type == "user") $table = "usergroup"; else $table = "resourcegroup"; $query = "DELETE FROM $table " . "WHERE id = $groupid"; doQuery($query, 315); clearPrivCache(); viewGroups(); } //////////////////////////////////////////////////////////////////////////////// /// /// \fn addGroupUser() /// /// \brief adds a user to a group /// //////////////////////////////////////////////////////////////////////////////// function addGroupUser() { global $submitErr, $submitErrMsg; $groupid = getContinuationVar("groupid"); $newuser = processInputVar("newuser", ARG_STRING); if(! validateUserid($newuser)) { $submitErr |= IDNAMEERR; $submitErrMsg[IDNAMEERR] = "Invalid login ID"; editOrAddGroup(0); return; } addUserGroupMember($newuser, $groupid); editOrAddGroup(0); } //////////////////////////////////////////////////////////////////////////////// /// /// \fn deleteGroupUser() /// /// \brief deletes a user from a group /// //////////////////////////////////////////////////////////////////////////////// function deleteGroupUser() { $groupid = getContinuationVar("groupid"); $userid = getContinuationVar("userid"); $test = getUserUnityID($userid); if(! empty($test)) deleteUserGroupMember($userid, $groupid); editOrAddGroup(0); } //////////////////////////////////////////////////////////////////////////////// /// /// \fn jsonGetGroupInfo() /// /// \brief /// //////////////////////////////////////////////////////////////////////////////// function jsonGetGroupInfo() { $groupid = processInputVar('groupid', ARG_NUMERIC); $mousex = processInputVar('mousex', ARG_NUMERIC); $mousey = processInputVar('mousey', ARG_NUMERIC); $userresources = getUserResources(array("groupAdmin"), array("manageGroup"), 1); $found = 0; foreach(array_keys($userresources) as $type) { if(array_key_exists($groupid, $userresources[$type])) { $found = 1; break; } } if(! $found || $mousex < 0 || $mousex > 5000 || $mousey < 0 || $mousey > 500000) { header('Content-Type: text/json; charset=utf-8'); print '{} && {"items":' . json_encode(array()) . '}'; return; } $members = getResourceGroupMembers($type); $data = ''; if(! empty($members[$type][$groupid])) { uasort($members[$type][$groupid], "sortKeepIndex"); foreach($members[$type][$groupid] as $mem) { $data .= "{$mem['name']}
"; } } else $data = '(empty group)'; $arr = array('members' => $data, 'x' => $mousex, 'y' => $mousey, 'groupid' => $groupid); header('Content-Type: text/json-comment-filtered; charset=utf-8'); print '{} && {"items":' . json_encode($arr) . '}'; } ?>