[FEATURE] Extend access control for pages 22/23922/10
authorThorben Kapp <thorben@work.de>
Fri, 20 Sep 2013 08:30:49 +0000 (10:30 +0200)
committerPhilipp Gampe <philipp.gampe@typo3.org>
Sun, 18 Jan 2015 18:47:37 +0000 (19:47 +0100)
Add a hook to the end of TYPO3\CMS\Frontend\Page\PageRepository->init()
to make it possible to adjust the where_hid_del and other parts which are
responsible for page visibility.

Resolves: #52131
Releases: master
Change-Id: I27a915d7c345ec09ecead00e575ddd57ed92e939
Reviewed-on: http://review.typo3.org/23922
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Philipp Gampe <philipp.gampe@typo3.org>
Tested-by: Philipp Gampe <philipp.gampe@typo3.org>
typo3/sysext/core/Documentation/Changelog/master/Feature-52131-HookForPageRepositoryInit.rst [new file with mode: 0644]
typo3/sysext/frontend/Classes/Page/PageRepository.php
typo3/sysext/frontend/Classes/Page/PageRepositoryInitHookInterface.php [new file with mode: 0644]

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-52131-HookForPageRepositoryInit.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-52131-HookForPageRepositoryInit.rst
new file mode 100644 (file)
index 0000000..512bd57
--- /dev/null
@@ -0,0 +1,17 @@
+========================================================
+Feature: #52131 - Hook for end of PageRepository->init()
+========================================================
+
+Description
+===========
+
+A new hook at the very end of the PageRepository->init()
+Function allows manipulation of where clause in order to
+modify select queries that involve visibility of pages.
+
+Register the hook as follows:
+
+.. code-block:: php
+       $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Frontend\Page\PageRepository::class]['init']
+
+The hook class must implement the interface _\TYPO3\CMS\Frontend\Page\PageRepositoryInitHookInterface_.
\ No newline at end of file
index b460e28..c433e46 100644 (file)
@@ -175,6 +175,15 @@ class PageRepository {
                        // Restrict to live and current workspaces
                        $this->where_hid_del .= ' AND (pages.t3ver_wsid=0 OR pages.t3ver_wsid=' . (int)$this->versioningWorkspaceId . ')';
                }
+               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][PageRepository::class]['init'])) {
+                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][PageRepository::class]['init'] as $classRef) {
+                               $hookObject = GeneralUtility::makeInstance($classRef);
+                               if (!$hookObject instanceof PageRepositoryInitHookInterface) {
+                                       throw new \UnexpectedValueException($hookObject . ' must implement interface TYPO3\\CMS\\Frontend\\Page\\PageRepositoryInitHookInterface', 1379579812);
+                               }
+                               $hookObject->init_postProcess($this);
+                       }
+               }
        }
 
        /**************************
diff --git a/typo3/sysext/frontend/Classes/Page/PageRepositoryInitHookInterface.php b/typo3/sysext/frontend/Classes/Page/PageRepositoryInitHookInterface.php
new file mode 100644 (file)
index 0000000..dcae057
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+namespace TYPO3\CMS\Frontend\Page;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+/**
+ * Interface for classes which hook into pageSelect and do additional getPage processing
+ *
+ */
+interface PageRepositoryInitHookInterface {
+
+       /**
+        * Modifies the DB params
+        *
+        * @param \TYPO3\CMS\Frontend\Page\PageRepository $parentObject Parent object
+        * @return void
+        */
+       public function init_postProcess(PageRepository $parentObject);
+}
+
+?>
\ No newline at end of file