Added feature #2278: Add hook to t3lib_TCEmain::checkModifyAccessList()
authorOliver Hader <oliver.hader@typo3.org>
Thu, 17 Sep 2009 19:24:23 +0000 (19:24 +0000)
committerOliver Hader <oliver.hader@typo3.org>
Thu, 17 Sep 2009 19:24:23 +0000 (19:24 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@5958 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_tcemain.php
t3lib/core_autoload.php
t3lib/interfaces/interface.t3lib_tcemain_checkmodifyaccesslisthook.php [new file with mode: 0644]

index 189d362..4a0584e 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,7 @@
        * Cleanup: Set SVN properties
        * Fixed bug #11985: Optimize disposal of t3lib_PageRenderer (thanks to Steffen Kamper)
        * Added feature #11669: Provide a reason for why $TSFE->set_no_cache() has been triggered (thanks to Michael Stucki)
+       * Added feature #2278: Add hook to t3lib_TCEmain::checkModifyAccessList() (thanks to Michael Stucki)
 
 2009-09-17  Sebastian Kurfuerst  <sebastian@typo3.org>
 
index ca380f6..313f020 100644 (file)
@@ -353,6 +353,7 @@ class t3lib_TCEmain {
        var $autoVersioningUpdate = FALSE;                      // A signal flag used to tell file processing that autoversioning has happend and hence certain action should be applied.
 
        protected $disableDeleteClause = false;         // Disable delete clause
+       protected $checkModifyAccessListHookObjects;
 
 
 
@@ -564,6 +565,31 @@ class t3lib_TCEmain        {
                }
        }
 
+       /**
+        * Gets the 'checkModifyAccessList' hook objects.
+        * The first call initializes the accordant objects.
+        *
+        * @return      array           The 'checkModifyAccessList' hook objects (if any)
+        */
+       protected function getCheckModifyAccessListHookObjects() {
+               if (!isset($this->checkModifyAccessListHookObjects)) {
+                       $this->checkModifyAccessListHookObjects = array();
+
+                       if(is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['checkModifyAccessList'])) {
+                               foreach($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['checkModifyAccessList'] as $classData) {
+                                       $hookObject = t3lib_div::getUserObj($classData);
+       
+                                       if(!($hookObject instanceof t3lib_TCEmain_checkModifyAccessListHook)) {
+                                               throw new UnexpectedValueException('$hookObject must implement interface t3lib_TCEmain_checkModifyAccessListHook', 1251892472);
+                                       }
+       
+                                       $this->checkModifyAccessListHookObjects[] = $hookObject;
+                               }
+                       }
+               }
+
+               return $this->checkModifyAccessListHookObjects;
+       }
 
 
 
@@ -5341,6 +5367,13 @@ $this->log($table,$id,6,0,0,'Stage raised...',30,array('comment'=>$comment,'stag
         */
        function checkModifyAccessList($table)  {
                $res = ($this->admin || (!$this->tableAdminOnly($table) && t3lib_div::inList($this->BE_USER->groupData['tables_modify'],$table)));
+
+                       // Hook 'checkModifyAccessList': Post-processing of the state of access
+               foreach($this->getCheckModifyAccessListHookObjects() as $hookObject) {
+                       /* @var $hookObject t3lib_TCEmain_checkModifyAccessListHook */
+                       $hookObject->checkModifyAccessList($res, $table, $this);
+               }
+
                return $res;
        }
 
index 8fc6b67..2191d8c 100644 (file)
@@ -105,6 +105,7 @@ return array(
        't3lib_localrecordlistgettablehook' => PATH_t3lib . 'interfaces/interface.t3lib_localrecordlistgettablehook.php',
        't3lib_singleton' => PATH_t3lib . 'interfaces/interface.t3lib_singleton.php',
        't3lib_tceformsinlinehook' => PATH_t3lib . 'interfaces/interface.t3lib_tceformsinlinehook.php',
+       't3lib_tcemain_checkmodifyaccesslisthook' => PATH_t3lib . 'interfaces/interface.t3lib_tcemain_checkmodifyaccesslisthook.php',
        't3lib_utility_client' => PATH_t3lib . 'utility/class.t3lib_utility_client.php',
        'tslib_adminpanel' => PATH_tslib . 'class.tslib_adminpanel.php',
        'tslib_cobj' => PATH_tslib . 'class.tslib_content.php',
diff --git a/t3lib/interfaces/interface.t3lib_tcemain_checkmodifyaccesslisthook.php b/t3lib/interfaces/interface.t3lib_tcemain_checkmodifyaccesslisthook.php
new file mode 100644 (file)
index 0000000..7e0b14b
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2009 Oliver Hader <oliver@typo3.org>
+*  All rights reserved
+*
+*  This script is part of the TYPO3 project. The TYPO3 project is
+*  free software; you can redistribute it and/or modify
+*  it under the terms of the GNU General Public License as published by
+*  the Free Software Foundation; either version 2 of the License, or
+*  (at your option) any later version.
+*
+*  The GNU General Public License can be found at
+*  http://www.gnu.org/copyleft/gpl.html.
+*  A copy is found in the textfile GPL.txt and important notices to the license
+*  from the author is found in LICENSE.txt distributed with these scripts.
+*
+*
+*  This script is distributed in the hope that it will be useful,
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*  GNU General Public License for more details.
+*
+*  This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+
+/**
+ * Interface for hook in t3lib_TCEmain::checkModifyAccessList
+ *
+ * @author     Oliver Hader <oliver@typo3.org>
+ * @package TYPO3
+ * @subpackage t3lib
+ */
+interface t3lib_TCEmain_checkModifyAccessListHook {
+       /**
+        * Hook that determines whether a user has access to modify a table.
+        *
+        * @param       boolean                 &$accessAllowed: Whether the user has access to modify a table
+        * @param       string                  $table: The name of the table to be modified
+        * @param       t3lib_TCEmain   $parent: The calling parent object
+        * @return      void
+        */
+       public function checkModifyAccessList(&$accessAllowed, $table, t3lib_TCEmain $parent);
+}
+
+?>
\ No newline at end of file