function updateResourcePrivs($group, $node, $adds, $removes) { if (!(count($adds) || count($removes))) { return; } if (is_numeric($group)) { $groupid = $group; } else { $groupid = getResourceGroupID($group); } foreach ($adds as $type) { $query = "INSERT IGNORE INTO resourcepriv (" . "resourcegroupid, " . "privnodeid, " . "type) " . "VALUES (" . "{$groupid}, " . "{$node}, " . "'{$type}')"; doQuery($query, 377); } foreach ($removes as $type) { $query = "DELETE FROM resourcepriv " . "WHERE resourcegroupid = {$groupid} AND " . "privnodeid = {$node} AND " . "type = '{$type}'"; doQuery($query, 378); } }
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'); }