TYPO3 API  SVNRelease
class.tx_coreupdates_mergeadvanced.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 2008-2011 Steffen Kamper <info@sk-typo3.de>
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00027 
00028 /**
00029  * Contains the update class for merging advanced and normal pagetype.
00030  *
00031  * @author Steffen Kamper <info@sk-typo3.de>
00032  * @version $Id: class.tx_coreupdates_mergeadvanced.php 10120 2011-01-18 20:03:36Z ohader $
00033  */
00034 class tx_coreupdates_mergeadvanced extends Tx_Install_Updates_Base {
00035     protected $title = 'Update Pages with Pagetype "Advanced"';
00036 
00037     /**
00038      * Checks if an update is needed
00039      *
00040      * @param   string      &$description: The description for the update
00041      * @return  boolean     whether an update is needed (true) or not (false)
00042      */
00043     public function checkForUpdate(&$description) {
00044         $result = false;
00045         $description = 'Merges the "Advanced" pagetype (doktype 2) to "Standard" (doktype 1) because "Standard" now has the same features, and "Advanced" is not needed anymore.';
00046 
00047         if ($this->versionNumber >= 4002000) {
00048             $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'pages', 'doktype=2', '', '', '1');
00049             if($GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
00050                 $result = true;
00051             }
00052             $GLOBALS['TYPO3_DB']->sql_free_result($res);
00053         }
00054         return $result;
00055     }
00056 
00057 
00058     /**
00059      * Performs the database update. Changes the doktype from 2 (advanced) to 1 (standard)
00060      *
00061      * @param   array       &$dbQueries: queries done in this update
00062      * @param   mixed       &$customMessages: custom messages
00063      * @return  boolean     whether it worked (true) or not (false)
00064      */
00065     public function performUpdate(&$dbQueries, &$customMessages) {
00066         $result = false;
00067         if($this->versionNumber >= 4002000) {
00068             $updateArray = array(
00069                 'doktype' => 1,
00070             );
00071 
00072             $res = $GLOBALS['TYPO3_DB']->exec_UPDATEquery('pages', 'doktype=2', $updateArray);
00073             $dbQueries[] = str_replace(chr(10), ' ', $GLOBALS['TYPO3_DB']->debug_lastBuiltQuery);
00074 
00075             if ($GLOBALS['TYPO3_DB']->sql_error()) {
00076                 $customMessages = 'SQL-ERROR: ' . htmlspecialchars($GLOBALS['TYPO3_DB']->sql_error());
00077             } else {
00078                 $result = true;
00079             }
00080         }
00081         return $result;
00082     }
00083 }
00084 ?>