Cleanup: Updated copyright comments
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / updates / class.tx_coreupdates_mergeadvanced.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2008-2011 Steffen Kamper <info@sk-typo3.de>
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 * Contains the update class for merging advanced and normal pagetype.
30 *
31 * @author Steffen Kamper <info@sk-typo3.de>
32 * @version $Id$
33 */
34 class tx_coreupdates_mergeadvanced extends Tx_Install_Updates_Base {
35 protected $title = 'Update Pages with Pagetype "Advanced"';
36
37 /**
38 * Checks if an update is needed
39 *
40 * @param string &$description: The description for the update
41 * @return boolean whether an update is needed (true) or not (false)
42 */
43 public function checkForUpdate(&$description) {
44 $result = false;
45 $description = 'Merges the "Advanced" pagetype (doktype 2) to "Standard" (doktype 1) because "Standard" now has the same features, and "Advanced" is not needed anymore.';
46
47 if ($this->versionNumber >= 4002000) {
48 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'pages', 'doktype=2', '', '', '1');
49 if($GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
50 $result = true;
51 }
52 $GLOBALS['TYPO3_DB']->sql_free_result($res);
53 }
54 return $result;
55 }
56
57
58 /**
59 * Performs the database update. Changes the doktype from 2 (advanced) to 1 (standard)
60 *
61 * @param array &$dbQueries: queries done in this update
62 * @param mixed &$customMessages: custom messages
63 * @return boolean whether it worked (true) or not (false)
64 */
65 public function performUpdate(&$dbQueries, &$customMessages) {
66 $result = false;
67 if($this->versionNumber >= 4002000) {
68 $updateArray = array(
69 'doktype' => 1,
70 );
71
72 $res = $GLOBALS['TYPO3_DB']->exec_UPDATEquery('pages', 'doktype=2', $updateArray);
73 $dbQueries[] = str_replace(chr(10), ' ', $GLOBALS['TYPO3_DB']->debug_lastBuiltQuery);
74
75 if ($GLOBALS['TYPO3_DB']->sql_error()) {
76 $customMessages = 'SQL-ERROR: ' . htmlspecialchars($GLOBALS['TYPO3_DB']->sql_error());
77 } else {
78 $result = true;
79 }
80 }
81 return $result;
82 }
83 }
84 ?>