[BUGFIX] Install Tool: Settings added by extensions can be edited (duplicating them)
authorErnesto Baschny <ernst@cron-it.de>
Thu, 26 Jan 2012 11:45:05 +0000 (12:45 +0100)
committerErnesto Baschny <ernst@cron-it.de>
Mon, 30 Jan 2012 19:52:44 +0000 (20:52 +0100)
Change-Id: I13f3ec8a1f10029ce2b6e421bcc97be2e1276ca3
Fixes: #25213
Releases: 4.7, 4.6, 4.5, 4.4
Reviewed-on: http://review.typo3.org/8704
Reviewed-by: Susanne Moog
Tested-by: Susanne Moog
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Ernesto Baschny
Tested-by: Ernesto Baschny
t3lib/class.t3lib_extmgm.php
typo3/sysext/install/mod/class.tx_install.php

index f1d2e5d..441426e 100644 (file)
@@ -869,6 +869,23 @@ final class t3lib_extMgm {
        }
 
        /**
+        * Adds some more content to a key of TYPO3_CONF_VARS array.
+        *
+        * This also tracks which content was added by extensions (in TYPO3_CONF_VARS_extensionAdded)
+        * so that they cannot be editted again through the Install Tool.
+        *
+        * @static
+        * @param       string  The group ('FE', 'BE', 'SYS' ...)
+        * @param       string  The key of this setting within the group
+        * @param       string  The text to add (include leading "\n" in case of multi-line entries)
+        * @return      void
+        */
+       public static function appendToTypoConfVars($group, $key, $content) {
+               $GLOBALS['TYPO3_CONF_VARS_extensionAdded'][$group][$key] .= $content;
+               $GLOBALS['TYPO3_CONF_VARS'][$group][$key] .= $content;
+       }
+
+       /**
         * Adds $content to the default Page TSconfig as set in $GLOBALS['TYPO3_CONF_VARS'][BE]['defaultPageTSconfig']
         * Prefixed with a [GLOBAL] line
         * FOR USE IN ext_tables.php/ext_localconf.php FILES
@@ -877,7 +894,7 @@ final class t3lib_extMgm {
         * @return      void
         */
        public static function addPageTSConfig($content) {
-               $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig'] .= "\n[GLOBAL]\n" . $content;
+               self::appendToTypoConfVars('BE', 'defaultPageTSconfig', "\n[GLOBAL]\n" . $content);
        }
 
        /**
@@ -889,7 +906,7 @@ final class t3lib_extMgm {
         * @return      void
         */
        public static function addUserTSConfig($content) {
-               $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultUserTSconfig'] .= "\n[GLOBAL]\n" . $content;
+               self::appendToTypoConfVars('BE', 'defaultUserTSconfig', "\n[GLOBAL]\n" . $content);
        }
 
        /**
@@ -1307,7 +1324,7 @@ tt_content.' . $key . $prefix . ' {
         * @return      void
         */
        public static function addTypoScriptSetup($content) {
-               $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup'] .= "\n[GLOBAL]\n" . $content;
+               self::appendToTypoConfVars('FE', 'defaultTypoScript_setup', "\n[GLOBAL]\n" . $content);
        }
 
        /**
@@ -1319,7 +1336,7 @@ tt_content.' . $key . $prefix . ' {
         * @return      void
         */
        public static function addTypoScriptConstants($content) {
-               $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_constants'] .= "\n[GLOBAL]\n" . $content;
+               self::appendToTypoConfVars('FE', 'defaultTypoScript_constants', "\n[GLOBAL]\n" . $content);
        }
 
        /**
index 632a32e..9c38f26 100644 (file)
@@ -1955,6 +1955,15 @@ REMOTE_ADDR was '".t3lib_div::getIndpEnv('REMOTE_ADDR')."' (".t3lib_div::getIndp
                                        $this->message($ext, '$TYPO3_CONF_VARS[\''.$k.'\']',$commentArr[0][$k],1);
 
                                        foreach ($va as $vk => $value) {
+                                               if (isset($GLOBALS['TYPO3_CONF_VARS_extensionAdded'][$k][$vk])) {
+                                                               // Don't allow editing stuff which is added by extensions
+                                                               // Make sure we fix potentially duplicated entries from older setups
+                                                       $potentialValue = str_replace(array("'.chr(10).'", "' . LF . '"), array(LF, LF), $value);
+                                                       while (preg_match('/' . $GLOBALS['TYPO3_CONF_VARS_extensionAdded'][$k][$vk] . '$/', '', $potentialValue)) {
+                                                               $potentialValue = preg_replace('/' . $GLOBALS['TYPO3_CONF_VARS_extensionAdded'][$k][$vk] . '$/', '', $potentialValue);
+                                                       }
+                                                       $value = $potentialValue;
+                                               }
                                                $textAreaSubpart = '';
                                                $booleanSubpart = '';
                                                $textLineSubpart = '';