* Expanded the feature that disables/enables login in a branch so now you can allow...
authorKasper Skårhøj <kasper@typo3.org>
Fri, 9 Oct 2009 07:06:29 +0000 (07:06 +0000)
committerKasper Skårhøj <kasper@typo3.org>
Fri, 9 Oct 2009 07:06:29 +0000 (07:06 +0000)
* Implemented a simple hook after retrieval of a page from cache.

git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@6120 709f56b5-9817-0410-a4d7-c38de5d9e867

typo3/sysext/cms/ext_tables.php
typo3/sysext/cms/locallang_tca.xml
typo3/sysext/cms/tslib/class.tslib_fe.php

index 56e48eb..c86050b 100755 (executable)
@@ -483,7 +483,8 @@ if (TYPO3_MODE=='BE')       {
                                'type' => 'select',
                                'items' => array (
                                        array('', 0),
-                                       array('LLL:EXT:cms/locallang_tca.xml:pages.fe_login_mode.disable', 1),
+                                       array('LLL:EXT:cms/locallang_tca.xml:pages.fe_login_mode.disableall', 1),
+                                       array('LLL:EXT:cms/locallang_tca.xml:pages.fe_login_mode.disablegroups', 3),
                                        array('LLL:EXT:cms/locallang_tca.xml:pages.fe_login_mode.enable', 2),
                                )
                        )
index 9ed99a2..ca1a8a3 100755 (executable)
@@ -73,8 +73,9 @@
                        <label index="pages.l18n_cfg.I.2">Hide page if no translation for current language exists</label>
                        <label index="pages.l18n_cfg.I.2a">Show page even if no translation exists</label>
                        <label index="pages.fe_login_mode">Login Mode:</label>
-                       <label index="pages.fe_login_mode.disable">Disable</label>
-                       <label index="pages.fe_login_mode.enable">Enable</label>
+                       <label index="pages.fe_login_mode.disableall">Disable user login completely</label>
+                       <label index="pages.fe_login_mode.disablegroups">Allow logins, but not usergroups</label>
+                       <label index="pages.fe_login_mode.enable">(Re-)Enable logins</label>
                        <label index="tt_content">Pagecontent</label>
                        <label index="fe_users">Website user</label>
                        <label index="fe_users.username">Username:</label>
index 19ff854..df0667a 100644 (file)
        var $beUserLogin='';                            // Flag that indicates if a Backend user is logged in!
        var $workspacePreview='';                       // Integer, that indicates which workspace is being previewed.
        var $loginAllowedInBranch = TRUE;       // Shows whether logins are allowed in branch
+       var $loginAllowedInBranch_mode = '';    // Shows specific mode (all or groups)
        var $ADMCMD_preview_BEUSER_uid = 0;     // Integer, set to backend user ID to initialize when keyword-based preview is used.
 
                // PREVIEW
                        // Clean up.
                $gr_array = array_unique($gr_array);    // Make unique...
                sort($gr_array);        // sort
-               if (count($gr_array))   {
+               if (count($gr_array) && !$this->loginAllowedInBranch_mode)      {
                        $this->gr_list.=','.implode(',',$gr_array);
                }
 
                $this->loginAllowedInBranch = $this->checkIfLoginAllowedInBranch();
                if (!$this->loginAllowedInBranch)       {       // Logins are not allowed:
                        if ($this->isUserOrGroupSet())  {       // Only if there is a login will we run this...
-
-                                       // Clear out user and group:
-                               unset($this->fe_user->user);
-                               $this->gr_list = '0,-1';
+                               if ($this->loginAllowedInBranch_mode=='all')    {
+                                               // Clear out user and group:
+                                       unset($this->fe_user->user);
+                                       $this->gr_list = '0,-1';
+                               } else {
+                                       $this->gr_list = '0,-2';
+                               }
 
                                        // Fetching the id again, now with the preview settings reset.
                                $this->fetch_the_id();
                        if ($this->rootLine[$a]['fe_login_mode'] > 0)   {
 
                                        // Determine state from value:
-                               $disable = (int)$this->rootLine[$a]['fe_login_mode'] === 1 ? TRUE : FALSE;
+                               if ((int)$this->rootLine[$a]['fe_login_mode'] === 1)    {
+                                       $disable = TRUE;
+                                       $this->loginAllowedInBranch_mode = 'all';
+                               } elseif ((int)$this->rootLine[$a]['fe_login_mode'] === 3)      {
+                                       $disable = TRUE;
+                                       $this->loginAllowedInBranch_mode = 'groups';
+                               } else {
+                                       $disable = FALSE;
+                               }
                        }
                }
 
                                        if (is_array($row)) {
                                                        // Release this lock
                                                $this->releasePageGenerationLock($this->pages_lockObj);
+
+                                                       // Call hook when a page is retrieved from cache:
+                                               if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['pageLoadedFromCache']))  {
+                                                       $_params = array('pObj' => &$this, 'cache_pages_row' => &$row);
+                                                       foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['pageLoadedFromCache'] as $_funcRef)   {
+                                                               t3lib_div::callUserFunction($_funcRef,$_params,$this);
+                                                       }
+                                               }
+
                                                $this->config = (array)unserialize($row['cache_data']);         // Fetches the lowlevel config stored with the cached data
                                                $this->content = (TYPO3_UseCachingFramework ? $row['content'] : $row['HTML']);  // Getting the content
                                                $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'];