Cleanup: Updated copyright comments
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / updates / class.tx_coreupdates_charsetdefaults.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2010-2011 Michael Stucki <michael@typo3.org>, Benjamin Mack <benni@typo3.org>
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27
28 /**
29 * Displays warnings and information about the database character set
30 *
31 * @version $Id$
32 */
33 class tx_coreupdates_charsetDefaults extends Tx_Install_Updates_Base {
34 protected $title = 'Database Character Set';
35
36 /**
37 * Checks if the configuration is relying on old default values or not.
38 * If needed, this updater will fix the configuration appropriately.
39 *
40 * @param string &$description: The description for the update
41 * @param string &$showUpdate: 0=dont show update; 1=show update and next button; 2=only show description
42 * @return boolean whether an update is needed (true) or not (false)
43 */
44 public function checkForUpdate(&$description, &$showUpdate = FALSE) {
45 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] === '-1' ||
46 $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit'] === '-1') {
47
48 $description = 'The configuration variables $TYPO3_CONF_VARS[\'SYS\'][\'setDBinit\'] and/or
49 $TYPO3_CONF_VARS[\'BE\'][\'forceCharset\'] are relying on empty default values.<br />
50 However, the defaults for both values have changed in TYPO3 4.5.<br /><br />
51 Please click "Next" to write the former default settings to your localconf.php,
52 so that your setup will continue to work like before.';
53 $showUpdate = 1;
54 }
55 }
56
57
58 /**
59 * Write the current configuration to localconf.php
60 * This is needed for any sites that were relying on the former default
61 * values which are going to change in TYPO3 4.5.
62 *
63 * @param array &$dbQueries: queries done in this update
64 * @param mixed &$customMessages: custom messages
65 * @return boolean whether the updated was made or not
66 */
67 public function performUpdate(array &$dbQueries, &$customMessages) {
68 $localconf = $this->pObj->writeToLocalconf_control();
69
70 // Update "setDBinit" setting
71 if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit'] === '-1') {
72 $this->pObj->setValueInLocalconfFile($localconf, '$TYPO3_CONF_VARS[\'SYS\'][\'setDBinit\']', '');
73 }
74
75 // Update the "forceCharset" setting
76 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] === '-1') {
77 $this->pObj->setValueInLocalconfFile($localconf, '$TYPO3_CONF_VARS[\'BE\'][\'forceCharset\']', '');
78 }
79
80 $message = $this->pObj->writeToLocalconf_control($localconf);
81 if ($message == 'continue') {
82 $customMessages[] = 'The configuration was successfully updated.';
83 return TRUE;
84 } else {
85 return FALSE; // something went wrong
86 }
87 }
88 }
89
90 ?>