/** * Checks if a whole branch of pages exists * * Tests the branch under $pid (like doesRecordExist). It doesn't test the page with $pid as uid. Use doesRecordExist() for this purpose * Returns an ID-list or "" if OK. Else -1 which means that somewhere there was no permission (eg. to delete). * if $recurse is set, then the function will follow subpages. This MUST be set, if we need the idlist for deleting pages or else we get an incomplete list * * @param string List of page uids, this is added to and outputted in the end * @param integer Page ID to select subpages from. * @param integer Perms integer to check each page record for. * @param boolean Recursion flag: If set, it will go out through the branch. * @return string List of integers in branch */ function doesBranchExist($inList, $pid, $perms, $recurse) { global $TCA; $pid = intval($pid); $perms = intval($perms); if ($pid >= 0) { $mres = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid, perms_userid, perms_groupid, perms_user, perms_group, perms_everybody', 'pages', 'pid=' . intval($pid) . $this->deleteClause('pages'), '', 'sorting'); while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($mres)) { if ($this->admin || $this->BE_USER->doesUserHaveAccess($row, $perms)) { // IF admin, then it's OK $inList .= $row['uid'] . ','; if ($recurse) { // Follow the subpages recursively... $inList = $this->doesBranchExist($inList, $row['uid'], $perms, $recurse); if ($inList == -1) { return -1; } // No permissions somewhere in the branch } } else { return -1; // No permissions } } $GLOBALS['TYPO3_DB']->sql_free_result($mres); } return $inList; }