[BUGFIX] Install Tool: Settings added by extensions can be edited
authorChristian Kuhn <lolli@schwarzbu.ch>
Sun, 20 May 2012 12:05:53 +0000 (14:05 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sun, 20 May 2012 12:10:47 +0000 (14:10 +0200)
Change-Id: I13f3ec8a1f10029ce2b6e421bcc97be2e1276ca3
Fixes: #25213
Releases: 6.0, 4.7, 4.6, 4.5
Reviewed-on: http://review.typo3.org/11324
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
t3lib/class.t3lib_extmgm.php
typo3/sysext/install/mod/class.tx_install.php

index e6028ee..4beec44 100644 (file)
@@ -810,7 +810,24 @@ final class t3lib_extMgm {
        }
 
        /**
-        * Adds $content to the default Page TSconfig as set in $TYPO3_CONF_VARS[BE]['defaultPageTSconfig']
+        * 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
         * Usage: 5
@@ -819,8 +836,7 @@ final class t3lib_extMgm {
         * @return      void
         */
        public static function addPageTSConfig($content) {
-               global $TYPO3_CONF_VARS;
-               $TYPO3_CONF_VARS['BE']['defaultPageTSconfig'] .= "\n[GLOBAL]\n" . $content;
+               self::appendToTypoConfVars('BE', 'defaultPageTSconfig', "\n[GLOBAL]\n" . $content);
        }
 
        /**
@@ -833,8 +849,7 @@ final class t3lib_extMgm {
         * @return      void
         */
        public static function addUserTSConfig($content) {
-               global $TYPO3_CONF_VARS;
-               $TYPO3_CONF_VARS['BE']['defaultUserTSconfig'] .= "\n[GLOBAL]\n" . $content;
+               self::appendToTypoConfVars('BE', 'defaultUserTSconfig', "\n[GLOBAL]\n" . $content);
        }
 
        /**
@@ -1237,8 +1252,7 @@ tt_content.' . $key . $prefix . ' {
         * @return      void
         */
        public static function addTypoScriptSetup($content) {
-               global $TYPO3_CONF_VARS;
-               $TYPO3_CONF_VARS['FE']['defaultTypoScript_setup'] .= "\n[GLOBAL]\n" . $content;
+               self::appendToTypoConfVars('FE', 'defaultTypoScript_setup', "\n[GLOBAL]\n" . $content);
        }
 
        /**
@@ -1251,8 +1265,7 @@ tt_content.' . $key . $prefix . ' {
         * @return      void
         */
        public static function addTypoScriptConstants($content) {
-               global $TYPO3_CONF_VARS;
-               $TYPO3_CONF_VARS['FE']['defaultTypoScript_constants'] .= "\n[GLOBAL]\n" . $content;
+               self::appendToTypoConfVars('FE', 'defaultTypoScript_constants', "\n[GLOBAL]\n" . $content);
        }
 
        /**
index 0f9fa85..21ae8d7 100644 (file)
@@ -2015,6 +2015,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 = '';