/**
  * Returns array, $CPtable, of pages under the $pid going down to $counter levels.
  * Selecting ONLY pages which the user has read-access to!
  *
  * @param	array		Accumulation of page uid=>pid pairs in branch of $pid
  * @param	integer		Page ID for which to find subpages
  * @param	integer		Number of levels to go down.
  * @param	integer		ID of root point for new copied branch: The idea seems to be that a copy is not made of the already new page!
  * @return	array		Return array.
  */
 function int_pageTreeInfo($CPtable, $pid, $counter, $rootID)
 {
     if ($counter) {
         $addW = !$this->admin ? ' AND ' . $this->BE_USER->getPagePermsClause($this->pMap['show']) : '';
         $mres = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'pages', 'pid=' . intval($pid) . $this->deleteClause('pages') . $addW, '', 'sorting DESC');
         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($mres)) {
             if ($row['uid'] != $rootID) {
                 $CPtable[$row['uid']] = $pid;
                 if ($counter - 1) {
                     // If the uid is NOT the rootID of the copyaction and if we are supposed to walk further down
                     $CPtable = $this->int_pageTreeInfo($CPtable, $row['uid'], $counter - 1, $rootID);
                 }
             }
         }
         $GLOBALS['TYPO3_DB']->sql_free_result($mres);
     }
     return $CPtable;
 }