Follow-up to feature #9625: Fixed regular expression
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_admin.php
index bd894eb..17679e5 100644 (file)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2006 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 1999-2008 Kasper Skaarhoj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -289,14 +289,14 @@ class t3lib_admin {
         *
         * @return      [type]          ...
         */
-       function genTreeStatus() {
+       function genTreeStatus($root=0) {
                $this->genTree_includeDeleted = TRUE;           // if set, genTree() includes deleted pages. This is default.
                $this->genTree_includeVersions = TRUE;          // if set, genTree() includes verisonized pages/records. This is default.
                $this->genTree_includeRecords = TRUE;           // if set, genTree() includes records from pages.
                $this->perms_clause = '';                                       // extra where-clauses for the tree-selection
                $this->genTree_makeHTML = 0;                            // if set, genTree() generates HTML, that visualizes the tree.
 
-               $this->genTree(537,'');
+               $this->genTree($root,'');
 
                return $this->recStats;
        }
@@ -319,12 +319,19 @@ class t3lib_admin {
                if ($pid_list)  {
                        while (list($table)=each($TCA)) {
                                t3lib_div::loadTCA($table);
-                               $garbage = $GLOBALS['TYPO3_DB']->exec_SELECTquery (
+
+                               $pid_list_tmp = $pid_list;
+                               if (!isset($TCA[$table]['ctrl']['versioningWS']) || !$TCA[$table]['ctrl']['versioningWS'])      {
+                                               // Remove preceding "-1," for non-versioned tables
+                                       $pid_list_tmp = preg_replace('/^\-1,/','',$pid_list_tmp);
+                               }
+
+                               $garbage = $GLOBALS['TYPO3_DB']->exec_SELECTquery (
                                                                'uid,pid,'.$TCA[$table]['ctrl']['label'],
                                                                $table,
-                                                               'pid NOT IN ('.$pid_list.')'
+                                                               'pid NOT IN ('.$pid_list_tmp.')'
                                                        );
-                               $lostIdList=Array();
+                               $lostIdList = array();
                                while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($garbage))  {
                                        $this->lRecords[$table][$row['uid']]=Array('uid'=>$row['uid'], 'pid'=>$row['pid'], 'title'=> strip_tags($row[$TCA[$table]['ctrl']['label']]) );
                                        $lostIdList[]=$row['uid'];
@@ -372,12 +379,19 @@ class t3lib_admin {
                if ($pid_list)  {
                        while (list($table)=each($TCA)) {
                                t3lib_div::loadTCA($table);
-                               $count = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $table, 'pid IN ('.$pid_list.')');
+
+                               $pid_list_tmp = $pid_list;
+                               if (!isset($TCA[$table]['ctrl']['versioningWS']) || !$TCA[$table]['ctrl']['versioningWS'])      {
+                                               // Remove preceding "-1," for non-versioned tables
+                                       $pid_list_tmp = preg_replace('/^\-1,/','',$pid_list_tmp);
+                               }
+
+                               $count = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $table, 'pid IN ('.$pid_list_tmp.')');
                                if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($count)) {
                                        $list[$table]=$row[0];
                                }
 
-                               $count = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $table, 'pid IN ('.$pid_list.')'.t3lib_BEfunc::deleteClause($table));
+                               $count = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $table, 'pid IN ('.$pid_list_tmp.')'.t3lib_BEfunc::deleteClause($table));
                                if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($count)) {
                                        $list_n[$table]=$row[0];
                                }
@@ -535,7 +549,7 @@ class t3lib_admin {
                                                                        if ($fieldConf['internal_type']=='db')  {
                                                                                // dbs - group
                                                                                $dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup');
-                                                                               $dbAnalysis->start($row[$field],$fieldConf['allowed'],$fieldConf['MM'],$row['uid']);
+                                                                               $dbAnalysis->start($row[$field],$fieldConf['allowed'],$fieldConf['MM'],$row['uid'], $table, $fieldConf);
                                                                                reset($dbAnalysis->itemArray);
                                                                                while (list(,$tempArr)=each($dbAnalysis->itemArray))    {
                                                                                        $this->checkGroupDBRefs[$tempArr['table']][$tempArr['id']]+=1;
@@ -545,7 +559,7 @@ class t3lib_admin {
                                                                if ($fieldConf['type']=='select' && $fieldConf['foreign_table'])        {
                                                                        // dbs - select
                                                                        $dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup');
-                                                                       $dbAnalysis->start($row[$field],$fieldConf['foreign_table'],$fieldConf['MM'],$row['uid']);
+                                                                       $dbAnalysis->start($row[$field],$fieldConf['foreign_table'],$fieldConf['MM'],$row['uid'], $table, $fieldConf);
                                                                        reset($dbAnalysis->itemArray);
                                                                        while (list(,$tempArr)=each($dbAnalysis->itemArray))    {
                                                                                if ($tempArr['id']>0)   {
@@ -673,7 +687,7 @@ class t3lib_admin {
                                $allowedTables = ($fieldConf['type']=='group') ? $fieldConf['allowed'] : $fieldConf['foreign_table'];
 
                                $dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup');
-                               $dbAnalysis->start($row[$field],$allowedTables,$fieldConf['MM'],$row['uid']);
+                               $dbAnalysis->start($row[$field],$allowedTables,$fieldConf['MM'],$row['uid'], $table, $fieldConf);
                                reset($dbAnalysis->itemArray);
                                while (list(,$tempArr)=each($dbAnalysis->itemArray))    {
                                        if ($tempArr['table']==$searchTable && $tempArr['id']==$id)     {