Index: typo3/sysext/cms/tslib/class.tslib_fe.php
===================================================================
--- typo3/sysext/cms/tslib/class.tslib_fe.php	(Revision 6130)
+++ typo3/sysext/cms/tslib/class.tslib_fe.php	(Arbeitskopie)
@@ -555,7 +555,7 @@
 
 	/**
 	 * Gets instance of PageRenderer
-	 * 
+	 *
 	 * @return	t3lib_PageRenderer
 	 */
 	public function getPageRenderer() {
@@ -1167,31 +1167,53 @@
 	 * @return	boolean
 	 * @access private
 	 */
-	function checkRootlineForIncludeSection()	{
-		$c=count($this->rootLine);
-		$removeTheRestFlag=0;
+	function checkRootlineForIncludeSection() {
+		$trunc = FALSE;
+		$remove = FALSE;
+		$rethought = FALSE;
 
-		for ($a=0;$a<$c;$a++)	{
-			if (!$this->checkPagerecordForIncludeSection($this->rootLine[$a]))	{
-					// Add to page access failure history:
+		$c = count($this->rootLine);
+		for ($a = 0; $a < $c; $a++) {
+			if ($this->rootLine[$a]['fe_group'] && !$this->checkEnableFields($this->rootLine[$a])) {
+				// Add to page access failure history:
 				$this->pageAccessFailureHistory['sub_section'][] = $this->rootLine[$a];
-				$removeTheRestFlag=1;
+				$remove = TRUE;
 			}
-			if ($this->rootLine[$a]['doktype']==6)	{
-				if ($this->beUserLogin)	{	// If there is a backend user logged in, check if he has read access to the page:
-					$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'pages', 'uid='.intval($this->id).' AND '.$GLOBALS['BE_USER']->getPagePermsClause(1));	// versionOL()?
+
+			if ($this->rootLine[$a]['doktype'] == 6) {
+				if ($this->beUserLogin)	{
+					// If there is a backend user logged in, check if he has read access to the page:
+					$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'pages', 'uid=' . intval($this->id) . ' AND ' . $GLOBALS['BE_USER']->getPagePermsClause(1));	// versionOL()?
+
+					// If there was no page selected, the user apparently did not have read
+					// access to the current PAGE (not position in rootline) and we set the
+					// remove-flag...
 					list($isPage) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
-					if (!$isPage)	$removeTheRestFlag=1;	// If there was no page selected, the user apparently did not have read access to the current PAGE (not position in rootline) and we set the remove-flag...
-				} else {	// Dont go here, if there is no backend user logged in.
-					$removeTheRestFlag=1;
+					if (!$isPage)
+						$remove = TRUE;
+				} else {
+					// Dont go here, if there is no backend user logged in.
+					$remove = TRUE;
 				}
 			}
-			if ($removeTheRestFlag)	{
-				$this->pageNotFound=2;			// Page is 'not found' in case a subsection was found and not accessible, code 2
+
+			if ($remove) {
+				// if permitions extend to the sub-tree, continue clipping it off
+				if (!$this->rootLine[$a]['extendToSubpages'])
+					$remove = $trunc;
+				else
+					$remove = $trunc = TRUE;
+
+				// Page is 'not found' in case a subsection was found and not accessible, code 2
+				$this->pageNotFound = 2;
 				unset($this->rootLine[$a]);
+
+				$rethought = TRUE;
 			}
 		}
-		return $removeTheRestFlag;
+
+		// the rootLine has been re-thought
+		return $rethought;
 	}
 
 	/**
@@ -1907,7 +1929,7 @@
 						$this->tempContent = $row['temp_content'];	// Flag for temp content
 						$this->cacheContentFlag = 1;	// Setting flag, so we know, that some cached content has been loaded
 						$this->cacheExpires = $row['expires'];
-						
+
 						if ($this->TYPO3_CONF_VARS['FE']['debug'] || (isset($this->config['config']['debug']) && $this->config['config']['debug'])) {
 							$dateFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'];
 							$timeFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'];
@@ -2101,7 +2123,7 @@
 
 					$this->config['FEData'] = $this->tmpl->setup['FEData'];
 					$this->config['FEData.'] = $this->tmpl->setup['FEData.'];
-					
+
 						// class for render Header and Footer parts
 					$template = '';
 					if ($this->pSetup['pageHeaderFooterTemplateFile']) {
@@ -2110,7 +2132,7 @@
 							$this->setTemplateFile($file);
 						}
 					}
-					
+
 				}
 				$GLOBALS['TT']->pull();
 			} else {
