Fixed bug #14396: Warn when KEEP_FILE is set
authorSteffen Kamper <info@sk-typo3.de>
Sat, 16 Oct 2010 09:53:25 +0000 (09:53 +0000)
committerSteffen Kamper <info@sk-typo3.de>
Sat, 16 Oct 2010 09:53:25 +0000 (09:53 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@9091 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/setup/mod/index.php
typo3/sysext/setup/mod/locallang.xml
typo3/sysext/t3skin/stylesheets/visual/main_content.css

index b3194ce..08f1b1c 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
 2010-10-16 Steffen Kamper  <steffen@typo3.org>
 
+       * Fixed bug #14396: Warn when KEEP_FILE is set
        * Fixed bug #15789: Improve ExtJS skin: Grids
 
 2010-10-15  Oliver Hader  <oliver@typo3.org>
index e46a5dc..025e287 100755 (executable)
@@ -117,6 +117,8 @@ class SC_mod_user_setup_index {
        protected $passwordIsSubmitted = FALSE;
        protected $setupIsUpdated = FALSE;
        protected $tempDataIsCleared = FALSE;
+       protected $installToolFileExists = FALSE;
+       protected $installToolFileKeep = FALSE;
 
 
        /******************************
@@ -266,6 +268,9 @@ class SC_mod_user_setup_index {
        function init() {
                $this->MCONF = $GLOBALS['MCONF'];
 
+                       // check Install Tool enable file
+               $this->setInstallToolFileExists();
+               $this->setInstallToolFileKeep();
 
                        // Returns the script user - that is the REAL logged in user! ($GLOBALS[BE_USER] might be another user due to simulation!)
                $scriptUser = $this->getRealScriptUserObj();
@@ -305,10 +310,20 @@ class SC_mod_user_setup_index {
 
                        // file creation / delete
                if ($this->isAdmin) {
+                       if ($this->installToolFileKeep) {
+                               $flashMessage = t3lib_div::makeInstance(
+                                       't3lib_FlashMessage',
+                                       $LANG->getLL('enableInstallTool.fileHasKeep'),
+                                       $LANG->getLL('enableInstallTool.file'),
+                                       t3lib_FlashMessage::WARNING
+                               );
+                               $this->content .= $flashMessage->render();
+                       }
+
                        if (t3lib_div::_POST('deleteInstallToolEnableFile')) {
                                unlink(PATH_typo3conf . 'ENABLE_INSTALL_TOOL');
-                               $installToolEnableFileExists = is_file(PATH_typo3conf . 'ENABLE_INSTALL_TOOL');
-                               if ($installToolEnableFileExists) {
+                               $this->setInstallToolFileExists();
+                               if ($this->getInstallToolFileExists()) {
                                        $flashMessage = t3lib_div::makeInstance(
                                                't3lib_FlashMessage',
                                                $LANG->getLL('enableInstallTool.fileDelete_failed'),
@@ -328,8 +343,8 @@ class SC_mod_user_setup_index {
                        if (t3lib_div::_POST('createInstallToolEnableFile')) {
                                touch(PATH_typo3conf . 'ENABLE_INSTALL_TOOL');
                                t3lib_div::fixPermissions(PATH_typo3conf . 'ENABLE_INSTALL_TOOL');
-                               $installToolEnableFileExists = is_file(PATH_typo3conf . 'ENABLE_INSTALL_TOOL');
-                               if ($installToolEnableFileExists) {
+                               $this->setInstallToolFileExists();
+                               if ($this->getInstallToolFileExists()) {
                                        $flashMessage = t3lib_div::makeInstance(
                                                't3lib_FlashMessage',
                                                $LANG->getLL('enableInstallTool.fileCreate_ok'),
@@ -453,6 +468,42 @@ class SC_mod_user_setup_index {
        }
 
        /**
+        * Sets existance of Install Tool file
+        *
+        * return void
+        */
+       public function setInstallToolFileExists() {
+               $this->installToolFileExists = is_file(PATH_typo3conf . 'ENABLE_INSTALL_TOOL');
+       }
+
+       /**
+        * Sets property if Install Tool file contains "KEEP_FILE"
+        */
+       public function setInstallToolFileKeep() {
+               if ($this->installToolFileExists) {
+                       $this->installToolFileKeep = (trim(file_get_contents(PATH_typo3conf . 'ENABLE_INSTALL_TOOL')) === 'KEEP_FILE');
+               }
+       }
+
+       /**
+        * Gets property installToolFileExists
+        *
+        * @return boolean $this->installToolFileExists
+        */
+       public function getInstallToolFileExists() {
+               return $this->installToolFileExists;
+       }
+
+       /**
+        * Gets property installToolFileKeep
+        *
+        * @return boolean $this->installToolFileKeep
+        */
+       public function getInstallToolFileKeep() {
+               return $this->installToolFileKeep;
+       }
+
+       /**
         * Prints the content / ends page
         *
         * @return      void
@@ -761,22 +812,20 @@ class SC_mod_user_setup_index {
         * @return string                              html with description and button
         */
        public function renderInstallToolEnableFileButton(array $params, SC_mod_user_setup_index $parent) {
-               // Install Tool access file
+                       // Install Tool access file
                $installToolEnableFile = PATH_typo3conf . 'ENABLE_INSTALL_TOOL';
-               $installToolEnableFileExists = is_file($installToolEnableFile);
-               if ($installToolEnableFileExists && (time() - filemtime($installToolEnableFile) > 3600)) {
-                       $content = file_get_contents($installToolEnableFile);
-                       $verifyString = 'KEEP_FILE';
-
-                       if (trim($content) !== $verifyString) {
+               if ($parent->getInstallToolFileExists() && ($GLOBALS['EXEC_TIME'] - filemtime($installToolEnableFile) > 3600)) {
+                       if (!$parent->getInstallToolFileKeep()) {
                                        // Delete the file if it is older than 3600s (1 hour)
                                unlink($installToolEnableFile);
-                               $installToolEnableFileExists = is_file($installToolEnableFile);
+                               $parent->setInstallToolFileExists();
                        }
                }
 
-               if ($installToolEnableFileExists) {
-                       return '<input type="submit" name="deleteInstallToolEnableFile" value="' . $GLOBALS['LANG']->sL('LLL:EXT:setup/mod/locallang.xml:enableInstallTool.deleteFile') . '" />';
+               if ($parent->getInstallToolFileExists()) {
+                       return '<input type="submit" name="deleteInstallToolEnableFile"' .
+                                       ($parent->getInstallToolFileKeep() ? ' disabled="disabled"' : '') .
+                                       ' value="' . $GLOBALS['LANG']->sL('LLL:EXT:setup/mod/locallang.xml:enableInstallTool.deleteFile') . '" />';
                } else {
                        return '<input type="submit" name="createInstallToolEnableFile" value="' . $GLOBALS['LANG']->sL('LLL:EXT:setup/mod/locallang.xml:enableInstallTool.createFile') . '" />';
                }
index c40fd87..52c8459 100755 (executable)
                        <label index="enableInstallTool.deleteFile">Delete Install Tool Enable File</label>
                        <label index="enableInstallTool.fileDelete_ok">The Install Tool Enable file has been deleted.</label>
                        <label index="enableInstallTool.fileDelete_failed">The Install Tool Enable file could not be deleted!</label>
+                       <label index="enableInstallTool.fileHasKeep">The Install Tool file has the content "KEEP_FILE" and can not be deleted!</label>
                        <label index="tempDataCleared">Temporary data cleared</label>
                        <label index="tempDataClearedFlashMessage">The temporary data has been cleared.</label>
                        <label index="tempDataClearedLog">Temporary data cleared</label>
index f995f50..040373e 100644 (file)
@@ -284,7 +284,10 @@ textarea:hover {
 
 input[type="submit"],
 input[type="reset"],
-input[type="button"] {
+input[type="button"],
+input[type="submit"][disabled="disabled"]:hover,
+input[type="reset"][disabled="disabled"]:hover,
+input[type="button"][disabled="disabled"]:hover {
        background-color: #f6f6f6;
        background-image: url('../../images/backgrounds/button.png');
        background-image: linear-gradient(center top, #f6f6f6 10%, #d5d5d5 90%);
@@ -314,6 +317,16 @@ input[type="button"]:hover {
        cursor: pointer;
 }
 
+input[type="submit"][disabled="disabled"],
+input[type="reset"][disabled="disabled"],
+input[type="button"][disabled="disabled"],
+input[type="submit"][disabled="disabled"]:hover,
+input[type="reset"][disabled="disabled"]:hover,
+input[type="button"][disabled="disabled"]:hover {
+       color: #ffffff;
+       cursor: default;
+}
+
 .checkbox,
 .checkbox:hover,
 input[type="checkbox"] {