Added feature #5068: Integrate mod.web_list.deniedNewTables as opposite of allowedNew...
authorOliver Hader <oliver.hader@typo3.org>
Mon, 11 Feb 2008 17:09:13 +0000 (17:09 +0000)
committerOliver Hader <oliver.hader@typo3.org>
Mon, 11 Feb 2008 17:09:13 +0000 (17:09 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@3145 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/class.db_list_extra.inc
typo3/db_list.php
typo3/db_new.php

index b6007ea..dd728fd 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,7 @@
 2008-02-11  Oliver Hader  <oh@inpublica.de>
 
        * (minor) Fixed bug: Fixed global variables in typo3/backend.php
+       * (feature) Added feature #5068: Integrate mod.web_list.deniedNewTables as opposite of allowedNewTables
 
 2008-02-08  Oliver Hader  <oh@inpublica.de>
 
index 6f6b645..1d17371 100755 (executable)
@@ -92,6 +92,7 @@ class localRecordList extends recordList {
                // External:
        var $alternateBgColors=FALSE;                   // If true, table rows in the list will alternate in background colors (and have background colors at all!)
        var $allowedNewTables=array();                  // Used to indicate which tables (values in the array) that can have a create-new-record link. If the array is empty, all tables are allowed.
+       var $deniedNewTables=array();                   // Used to indicate which tables (values in the array) that cannot have a create-new-record link. If the array is empty, all tables are allowed.
        var $newWizards=FALSE;                                  // If true, the control panel will contain links to the create-new wizards for pages and tt_content elements (normally, the link goes to just creating a new element without the wizards!).
 
        var $dontShowClipControlPanels=FALSE;   // If true, will disable the rendering of clipboard + control panels.
@@ -1352,10 +1353,20 @@ class localRecordList extends recordList {
         * Returns true if a link for creating new records should be displayed for $table
         *
         * @param       string          Table name
-        * @return      boolean
+        * @return      boolean         Returns true if a link for creating new records should be displayed for $table
+        * @see         SC_db_new::showNewRecLink
         */
        function showNewRecLink($table) {
-               return !count($this->allowedNewTables) || in_array($table,$this->allowedNewTables);
+                       // No deny/allow tables are set:
+               if (!count($this->allowedNewTables) && !count($this->deniedNewTables)) {
+                       return true;
+                       // If table is not denied (which takes precedence over allowed tables):
+               } elseif (!in_array($table, $this->deniedNewTables) && (!count($this->allowedNewTables) || in_array($table, $this->allowedNewTables))) {
+                       return true;
+                       // If table is denied or allowed tables are set, but table is not part of:
+               } else {
+                       return false;
+               }
        }
 
        /**
index 142c6ed..236b65c 100755 (executable)
@@ -227,7 +227,8 @@ class SC_db_list {
                $dblist->tableTSconfigOverTCA = $this->modTSconfig['properties']['table.'];
                $dblist->clickTitleMode = $this->modTSconfig['properties']['clickTitleMode'];
                $dblist->alternateBgColors=$this->modTSconfig['properties']['alternateBgColors']?1:0;
-               $dblist->allowedNewTables = t3lib_div::trimExplode(',',$this->modTSconfig['properties']['allowedNewTables'],1);
+               $dblist->allowedNewTables = t3lib_div::trimExplode(',', $this->modTSconfig['properties']['allowedNewTables'], 1);
+               $dblist->deniedNewTables = t3lib_div::trimExplode(',', $this->modTSconfig['properties']['deniedNewTables'], 1);
                $dblist->newWizards=$this->modTSconfig['properties']['newWizards']?1:0;
                $dblist->pageRow = $this->pageinfo;
                $dblist->counter++;
index 966ea43..f049b3a 100755 (executable)
@@ -133,8 +133,10 @@ class SC_db_new {
        var $newPagesAfter;
        var $web_list_modTSconfig;
        var $allowedNewTables;
+       var $deniedNewTables;
        var $web_list_modTSconfig_pid;
        var $allowedNewTables_pid;
+       var $deniedNewTables_pid;
        var $code;
        var $R_URI;
 
@@ -235,16 +237,18 @@ class SC_db_new {
                                // Acquiring TSconfig for this module/current page:
                        $this->web_list_modTSconfig = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list');
                        $this->allowedNewTables = t3lib_div::trimExplode(',',$this->web_list_modTSconfig['properties']['allowedNewTables'],1);
+                       $this->deniedNewTables = t3lib_div::trimExplode(',',$this->web_list_modTSconfig['properties']['deniedNewTables'],1);
 
                                // Acquiring TSconfig for this module/parent page:
                        $this->web_list_modTSconfig_pid = t3lib_BEfunc::getModTSconfig($this->pageinfo['pid'],'mod.web_list');
                        $this->allowedNewTables_pid = t3lib_div::trimExplode(',',$this->web_list_modTSconfig_pid['properties']['allowedNewTables'],1);
+                       $this->deniedNewTables_pid = t3lib_div::trimExplode(',',$this->web_list_modTSconfig_pid['properties']['deniedNewTables'],1);
 
                                // More init:
                        if (!$this->showNewRecLink('pages'))    {
                                $this->newPagesInto=0;
                        }
-                       if (!$this->showNewRecLink('pages',$this->allowedNewTables_pid))        {
+                       if (!$this->showNewRecLink('pages', $this->allowedNewTables_pid, $this->deniedNewTables_pid))   {
                                $this->newPagesAfter=0;
                        }
 
@@ -520,15 +524,31 @@ class SC_db_new {
        }
 
        /**
-        * Returns true if the $table tablename is found in $allowedNewTables (or if $allowedNewTables is empty)
+        * Returns true if:
+        * - $allowedNewTables and $deniedNewTables are empty
+        * - the table is not found in $deniedNewTables and $allowedNewTables is not set or the $table tablename is found in $allowedNewTables
+        *
+        * If $table tablename is found in $allowedNewTables and $deniedNewTables, $deniedNewTables
+        * has priority over $allowedNewTables.
         *
         * @param       string          Table name to test if in allowedTables
         * @param       array           Array of new tables that are allowed.
-        * @return      boolean         Returns true if the $table tablename is found in $allowedNewTables (or if $allowedNewTables is empty)
+        * @param       array           Array of new tables that are not allowed.
+        * @return      boolean         Returns true if a link for creating new records should be displayed for $table
         */
-       function showNewRecLink($table,$allowedNewTables='')    {
-               $allowedNewTables = is_array($allowedNewTables) ? $allowedNewTables : $this->allowedNewTables;
-               return !count($allowedNewTables) || in_array($table,$allowedNewTables);
+       function showNewRecLink($table, array $allowedNewTables=array(), array $deniedNewTables=array()) {
+               $allowedNewTables = ($allowedNewTables ? $allowedNewTables : $this->allowedNewTables);
+               $deniedNewTables = ($deniedNewTables ? $deniedNewTables : $this->deniedNewTables);
+                       // No deny/allow tables are set:
+               if (!count($allowedNewTables) && !count($deniedNewTables)) {
+                       return true;
+                       // If table is not denied (which takes precedence over allowed tables):
+               } elseif (!in_array($table, $deniedNewTables) && (!count($allowedNewTables) || in_array($table, $allowedNewTables))) {
+                       return true;
+                       // If table is denied or allowed tables are set, but table is not part of:
+               } else {
+                       return false;
+               }
        }
 }