Added lockIP for backend users; New HMENU special type "language"
authorKasper Skårhøj <kasper@typo3.org>
Sun, 29 Aug 2004 00:53:57 +0000 (00:53 +0000)
committerKasper Skårhøj <kasper@typo3.org>
Sun, 29 Aug 2004 00:53:57 +0000 (00:53 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@446 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_page.php
t3lib/config_default.php
typo3/init.php
typo3/sysext/cms/tslib/class.tslib_fe.php
typo3/sysext/cms/tslib/class.tslib_menu.php

index e97ed22..0b8356b 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2004-08-29  Kasper Skårhøj,,,  <kasper@typo3.com>
+
+       * Added "lockIP" setting for backend users - this will solve the problem that some has reported about backend users not being able to login with 3.7.0...
+       * Added new HMENU special type, "language", which can generate a language selector using the "&L" variable directly.
+       * Added option for HMENU (protectLvar) so menu items linking to pages that are not translated will have their "&L" var set to zero, thus reverting to the default language.
+       * Corrected a bug in menu generation: Spacers for TMENU had a link around it - this was a bug, correct now. No links on spacer elements!
+
 2004-08-26  Kasper Skårhøj,,,  <kasper@typo3.com>
 
        * Adding editlock icon in Web>Access
index 5dd165d..df7c1e3 100755 (executable)
@@ -268,7 +268,7 @@ class t3lib_pageSelect {
                                        $row['_PAGES_OVERLAY'] = TRUE;
                                        $this->versionOL('pages_language_overlay',$row);
 
-                                               // Unset vital fields that are NOT allowed to be selected:
+                                               // Unset vital fields that are NOT allowed to be overlaid:
                                        unset($row['uid']);
                                        unset($row['pid']);
                                }
index de3db20..4f47376 100755 (executable)
@@ -106,6 +106,7 @@ $TYPO3_CONF_VARS = Array(
                'createGroup' => '',                                    // Group for newly created files and folders (UNIX only). Group ownership can be changed on unix file systems (see above). Set this if you want to change the group ownership of created files/folders to a specific group. This makes sense in all cases where the webserver is running with a different user/group as you do. Create a new group on your system and add you and the webserver user to the group. Now you can safely set the last bit in fileCreateMask/folderCreateMask to 0 (e.g. 770). Important: The user who is running your webserver needs to be a member of the group you specify here! Otherwise you might get some errors.
                'warning_email_addr' => '',                             // Email-address that will receive a warning if there has been failed logins 4 times within an hour (all users).
                'warning_mode' => '',                                   // Bit 1: If set, warning_email_addr gets a mail everytime a user logs in. Bit 2: If set, a mail is sent if an ADMIN user logs in! Other bits reserved for future options.
+               'lockIP' => 4,                                                  // Integer (0-4). Session IP locking for backend users. See [FE][lockIP] for details. Default is 4 (which is locking the FULL IP address to session).
                'IPmaskList' => '',                                             // String. Lets you define a list of IP-numbers (with *-wildcards) that are the ONLY ones allowed access to ANY backend activity. On error an error header is sent and the script exits. Works like IP masking for users configurable through TSconfig. See syntax for that (or look up syntax for the function t3lib_div::cmpIP())
                'lockBeUserToDBmounts' => 1,                    // Boolean. If set, the backend user is allowed to work only within his page-mount. It's advisable to leave this on because it makes security easy to manage.
                'lockSSL' => 0,                                                 // Int. 0,1,2: If set (1+2), the backend can only be operated from an ssl-encrypted connection (https). Set to 2 you will be redirected to the https admin-url supposed to be the http-url, but with https scheme instead.
index b55faef..746dda6 100755 (executable)
@@ -270,6 +270,7 @@ if (TYPO3_extTableDef_script)       {
 */
 $BE_USER = t3lib_div::makeInstance('t3lib_beUserAuth');        // New backend user object
 $BE_USER->warningEmail = $TYPO3_CONF_VARS['BE']['warning_email_addr'];
+$BE_USER->lockIP = $TYPO3_CONF_VARS['BE']['lockIP'];
 $BE_USER->OS = TYPO3_OS;
 $BE_USER->start();                     // Object is initialized
 $BE_USER->checkCLIuser();
index 2580e10..902cef8 100755 (executable)
                $this->sys_page->sys_language_uid = $this->sys_language_uid;
 
                        // If default translation is not available:
-               if (!$this->sys_language_uid && $this->page['l18n_cfg']&1)      {
+               if ((!$this->sys_language_uid || !$this->sys_language_content) && $this->page['l18n_cfg']&1)    {
                        $this->pageNotFoundAndExit('Page is not available in default language.');
                }
 
index 1317f32..910575d 100755 (executable)
@@ -199,9 +199,9 @@ class tslib_menu {
                                $this->doktypeExcludeList = $GLOBALS['TYPO3_DB']->cleanIntList($this->conf['excludeDoktypes']);
                        }
                        if($this->conf['includeNotInMenu']) {
-                               $exclDoktypeArr=t3lib_div::trimExplode(',',$this->doktypeExcludeList,1);
-                               $exclDoktypeArr=t3lib_div::removeArrayEntryByValue($exclDoktypeArr,'5');
-                               $this->doktypeExcludeList=implode(',',$exclDoktypeArr);
+                               $exclDoktypeArr = t3lib_div::trimExplode(',',$this->doktypeExcludeList,1);
+                               $exclDoktypeArr = t3lib_div::removeArrayEntryByValue($exclDoktypeArr,'5');
+                               $this->doktypeExcludeList = implode(',',$exclDoktypeArr);
                        }
 
                                // EntryLevel
@@ -322,6 +322,40 @@ class tslib_menu {
                                                );
                                                if (!is_array($temp))   $temp=array();
                                        break;
+                                       case 'language':
+                                               $temp = array();
+
+                                                       // Getting current page record NOT overlaid by any translation:
+                                               $currentPageWithNoOverlay = $this->sys_page->getRawRecord('pages',$GLOBALS['TSFE']->page['uid']);
+
+                                                       // Traverse languages set up:
+                                               $languageItems = t3lib_div::intExplode(',',$value);
+                                               foreach($languageItems as $sUid)        {
+                                                               // Find overlay record:
+                                                       if ($sUid)      {
+                                                               $lRecs = $this->sys_page->getPageOverlay($GLOBALS['TSFE']->page['uid'],$sUid);
+                                                       } else $lRecs=array();
+                                                               // Checking if the "disabled" state should be set.
+                                                       if (
+                                                                               ($GLOBALS['TSFE']->page['l18n_cfg']&2 && $sUid && !count($lRecs)) // Blocking for all translations?
+                                                                       || ($GLOBALS['TSFE']->page['l18n_cfg']&1 && (!$sUid || !count($lRecs))) // Blocking default translation?
+                                                                       || (!$this->conf['special.']['normalWhenNoLanguage'] && $sUid && !count($lRecs))
+                                                               )       {
+                                                               $iState = $GLOBALS['TSFE']->sys_language_uid==$sUid ? 'USERDEF2' : 'USERDEF1';
+                                                       } else {
+                                                               $iState = $GLOBALS['TSFE']->sys_language_uid==$sUid ? 'ACT' : 'NO';
+                                                       }
+                                                               // Adding menu item:
+                                                       $temp[] = array_merge(
+                                                               array_merge($currentPageWithNoOverlay, $lRecs),
+                                                               array(
+                                                                       'ITEM_STATE' => $iState,
+                                                                       '_ADD_GETVARS' => '&L='.$sUid,
+                                                                       '_SAFE' => TRUE
+                                                               )
+                                                       );
+                                               }
+                                       break;
                                        case 'directory':
                                                if ($value=='') {
                                                        $value=$GLOBALS['TSFE']->page['uid'];
@@ -724,7 +758,7 @@ class tslib_menu {
                                // Fill in the menuArr with elements that should go into the menu:
                        $this->menuArr = Array();
                        foreach($temp as $data) {
-                               $spacer = t3lib_div::inList($this->spacerIDList,$data['doktype']) ? 1 : 0;              // if item is a spacer, $spacer is set
+                               $spacer = (t3lib_div::inList($this->spacerIDList,$data['doktype']) || !strcmp($data['ITEM_STATE'],'SPC')) ? 1 : 0;              // if item is a spacer, $spacer is set
                                if ($this->filterMenuPages($data, $banUidArray, $spacer))       {
                                        $c_b++;
                                        if ($begin<=$c_b)       {               // If the beginning item has been reached.
@@ -793,7 +827,10 @@ class tslib_menu {
         * @param       boolean If set, then the page is a spacer.
         * @return      boolean Returns true if the page can be safely included.
         */
-       function filterMenuPages($data,$banUidArray,$spacer)    {
+       function filterMenuPages(&$data,$banUidArray,$spacer)   {
+
+               if ($data['_SAFE'])     return TRUE;
+
                $uid = $data['uid'];
                if ($this->mconf['SPC'] || !$spacer)    {       // If the spacer-function is not enabled, spacers will not enter the $menuArr
                        if (!t3lib_div::inList($this->doktypeExcludeList,$data['doktype']))     {               // Page may not be 'not_in_menu' or 'Backend User Section'
@@ -808,14 +845,26 @@ class tslib_menu {
                                                                // Checking if a page should be shown in the menu depending on whether a translation exists:
                                                        $tok = TRUE;
                                                        if ($GLOBALS['TSFE']->sys_language_uid && $data['l18n_cfg']&2)  {       // There is an alternative language active AND the current page requires a translation:
-                                                               $olRec = $GLOBALS['TSFE']->sys_page->getPageOverlay($data['uid'], $GLOBALS['TSFE']->sys_language_uid);
-                                                               if (!count($olRec))     {
+                                                               if (!$data['_PAGES_OVERLAY'])   {
                                                                        $tok = FALSE;
                                                                }
                                                        }
 
                                                                // Continue if token is true:
                                                        if ($tok)       {
+
+                                                                       // Checking if "&L" should be modified so links to non-accessible pages will not happen.
+                                                               if ($this->conf['protectLvar']) {
+                                                                       $Lvar = intval(t3lib_div::_GP('L'));
+                                                                       if (($this->conf['protectLvar']=='all' || $data['l18n_cfg']&2) && $Lvar!=$GLOBALS['TSFE']->sys_language_uid)    {       // page cannot be access in locaization and Lvar is different than sys_language uid - this means we must check!
+                                                                               $olRec = $GLOBALS['TSFE']->sys_page->getPageOverlay($data['uid'], $Lvar);
+                                                                               if (!count($olRec))     {
+                                                                                               // If no pages_language_overlay record then page can NOT be accessed in the language pointed to by "&L" and therefore we protect the link by setting "&L=0"
+                                                                                       $data['_ADD_GETVARS'].= '&L=0';
+                                                                               }
+                                                                       }
+                                                               }
+
                                                                return TRUE;
                                                        }
                                                }
@@ -1045,9 +1094,9 @@ class tslib_menu {
                        // Creating link:
                if ($this->mconf['collapse'] && $this->isActive($this->menuArr[$key]['uid'], $this->getMPvar($key)))    {
                        $thePage = $this->sys_page->getPage($this->menuArr[$key]['pid']);
-                       $LD = $this->tmpl->linkData($thePage,$mainTarget,'','',$overrideArray, $this->mconf['addParams'].$MP_params, $typeOverride);
+                       $LD = $this->tmpl->linkData($thePage,$mainTarget,'','',$overrideArray, $this->mconf['addParams'].$MP_params.$this->menuArr[$key]['_ADD_GETVARS'], $typeOverride);
                } else {
-                       $LD = $this->tmpl->linkData($this->menuArr[$key],$mainTarget,'','',$overrideArray, $this->mconf['addParams'].$MP_params, $typeOverride);
+                       $LD = $this->tmpl->linkData($this->menuArr[$key],$mainTarget,'','',$overrideArray, $this->mconf['addParams'].$MP_params.$this->menuArr[$key]['_ADD_GETVARS'], $typeOverride);
                }
 
                        // Overriding URL / Target if set to do so:
@@ -1435,13 +1484,12 @@ class tslib_tmenu extends tslib_menu {
                                }
 
 
-
                                        // Calling extra processing function
                                $this->extProc_beforeLinking($key);
 
                                        // Compile link tag
                                if (!$this->I['val']['doNotLinkIt']) {$this->I['val']['doNotLinkIt']=0;}
-                               if (!$this->I['val']['isSpacer'] && $this->I['val']['doNotLinkIt']!=1)  {
+                               if (!$this->I['spacer'] && $this->I['val']['doNotLinkIt']!=1)   {
                                        $this->setATagParts();
                                } else {
                                        $this->I['A1'] = '';
@@ -1514,7 +1562,7 @@ class tslib_tmenu extends tslib_menu {
                $res = '';
                if ($imgInfo = $this->WMcObj->getImgResource($this->I['val'][$pref.'Img'],$this->I['val'][$pref.'Img.']))       {
                        $imgInfo[3] = t3lib_div::png_to_gif_by_imagemagick($imgInfo[3]);
-                       if ($this->I['val']['RO'] && $this->I['val'][$pref.'ROImg'] && !$this->I['val']['isSpacer'])    {
+                       if ($this->I['val']['RO'] && $this->I['val'][$pref.'ROImg'] && !$this->I['spacer'])     {
                                $imgROInfo = $this->WMcObj->getImgResource($this->I['val'][$pref.'ROImg'],$this->I['val'][$pref.'ROImg.']);
                                $imgROInfo[3] = t3lib_div::png_to_gif_by_imagemagick($imgROInfo[3]);
                                if ($imgROInfo) {