function recurseGetChildren($node) { $children = array(); $qh = doQuery("SELECT id FROM privnode WHERE parent = {$node}", 340); while ($row = mysql_fetch_row($qh)) { array_push($children, $row[0]); $children = array_merge($children, recurseGetChildren($row[0])); } return $children; }
function XMLRPCremoveNode($nodeID) { require_once ".ht-inc/privileges.php"; global $user; if (!is_numeric($nodeID)) { return array('status' => 'error', 'errorcode' => 78, 'errormsg' => 'Invalid nodeid specified'); } if (!in_array("nodeAdmin", $user['privileges'])) { return array('status' => 'error', 'errorcode' => 70, 'errormsg' => 'User cannot administer nodes'); } if (!checkUserHasPriv("nodeAdmin", $user['id'], $nodeID)) { return array('status' => 'error', 'errorcode' => 57, 'errormsg' => 'User cannot edit this node'); } $nodes = recurseGetChildren($nodeID); array_push($nodes, $nodeID); $deleteNodes = implode(',', $nodes); $query = "DELETE FROM privnode " . "WHERE id IN ({$deleteNodes})"; doQuery($query, 345); return array('status' => 'success'); }