Project

General

Profile

« Previous | Next » 

Revision 1890

Added by Dietmar over 11 years ago

  1. bugfix and update form module set version to 2.9.1
    ! update code module set version to 2.8.4
    ! update wysiwyg module set version to 2.9.1

View differences:

upgrade.php
5 5
 * @package         wysiwyg
6 6
 * @author          WebsiteBaker Project
7 7
 * @copyright       2009-2012, Website Baker Org. e.V.
8
 * @link			http://www.websitebaker2.org/
8
 * @link            http://www.websitebaker2.org/
9 9
 * @license         http://www.gnu.org/licenses/gpl.html
10 10
 * @platform        WebsiteBaker 2.8.3
11 11
 * @requirements    PHP 5.2.2 and higher
12
 * @version      	$Id$
13
 * @filesource		$HeadURL$
12
 * @version         $Id$
13
 * @filesource      $HeadURL$
14 14
 * @lastmodified    $Date$
15 15
 *
16 16
 */
......
22 22
}
23 23
/* -------------------------------------------------------- */
24 24

  
25
if(!function_exists('mod_wysiwyg_upgrade'))
26
{
27
	function mod_wysiwyg_upgrade () {
28
		global $database,$bDebugModus;
25
	function mod_wysiwyg_upgrade ($bDebug=false) {
26
		global $OK ,$FAIL;
27
		$database=WbDatabase::getInstance();
28
		$msg = array();
29 29
		$callingScript = $_SERVER["SCRIPT_NAME"];
30 30
		// check if upgrade startet by upgrade-script to echo a message
31 31
		$tmp = 'upgrade-script.php';
32 32
		$globalStarted = substr_compare($callingScript, $tmp,(0-strlen($tmp)),strlen($tmp)) === 0;
33

  
34
		$msg = array();
33
// check for missing tables, if true stop the upgrade
35 34
		$aTable = array('mod_wysiwyg');
36
		for($x=0; $x<sizeof($aTable);$x++) {
37
			if(($sOldType = $database->getTableEngine(TABLE_PREFIX.$aTable[$x]))) {
38
				if(('myisam' != strtolower($sOldType))) {
39
					if(!$database->query('ALTER TABLE `'.TABLE_PREFIX.$aTable[$x].'` Engine = \'MyISAM\' ')) {
40
						$msg[] = $database->get_error();
41
					} else{
42
						$msg[] = 'TABLE `'.TABLE_PREFIX.$aTable[$x].'` changed to Engine = \'MyISAM\'';
35
		$aPackage = UpgradeHelper::existsAllTables($aTable);
36
		if( sizeof($aPackage) > 0){
37
			$msg[] =  'TABLE '.implode(' missing! '.$FAIL.'<br />TABLE ',$aPackage).' missing! '.$FAIL;
38
			$msg[] = 'WYSIWYG upgrade failed '." $FAIL";
39
			if($globalStarted) {
40
				echo '<strong>'.implode('<br />',$msg).'</strong><br />';
41
			}
42
			return ( ($globalStarted==true ) ? $globalStarted : $msg);
43
		} else {
44
			for($x=0; $x<sizeof($aTable);$x++) {
45
				if(($sOldType = $database->getTableEngine($database->TablePrefix.$aTable[$x]))) {
46
					if(('myisam' != strtolower($sOldType))) {
47
						if(!$database->query('ALTER TABLE `'.$database->TablePrefix.$aTable[$x].'` Engine = \'MyISAM\' ')) {
48
							$msg[] = $database->get_error();
49
						} else{
50
							$msg[] = 'TABLE `'.$database->TablePrefix.$aTable[$x].'` changed to Engine = \'MyISAM\''." $OK";
51
						}
52
					} else {
53
						 $msg[] = 'TABLE `'.$database->TablePrefix.$aTable[$x].'` has Engine = \'MyISAM\''." $OK";
43 54
					}
44 55
				} else {
45
					 $msg[] = 'TABLE `'.TABLE_PREFIX.$aTable[$x].'` has Engine = \'MyISAM\'';
56
					$msg[] = $database->get_error();
46 57
				}
58
			}
59
// add change or missing index
60
			$sTable = $database->TablePrefix.'mod_wysiwyg';
61
			if($database->index_exists($sTable, 'PRIMARY')) {
62
				$sql = 'ALTER TABLE `'.$database->DbName.'`.`'.$sTable.'` DROP PRIMARY KEY';
63
				if(!$database->query($sql)) {
64
					$msg[] = ''.$database->get_error();
65
				}
66
			}
67
			if(!$database->index_add($sTable, '', 'section_id', 'PRIMARY')) {
68
				$msg[] = ''.$database->get_error();
47 69
			} else {
48
				$msg[] = $database->get_error();
70
				$msg[] = 'Create PRIMARY KEY ( `section_id` )'." $OK";
49 71
			}
50
		}
51

  
52
		$sTable = TABLE_PREFIX.'mod_wysiwyg';
53
		if($database->index_exists($sTable, 'PRIMARY')) {
54
			$sql = 'ALTER TABLE `'.$database->DbName.'`.`'.$sTable.'` DROP PRIMARY KEY';
55
			if(!$database->query($sql)) {
56
			    $msg[] = ''.$database->get_error().'';
72
// change table structure
73
			$sTable = $database->TablePrefix.'mod_wysiwyg';
74
			$sDescription = 'LONGTEXT NOT NULL';
75
			$sFieldName = 'text';
76
			if(!$database->field_modify($sTable,$sFieldName,$sDescription)) {
77
				$msg[] = ''.$database->get_error();
78
			} else {
79
				$msg[] = 'Field ( `text` ) description has been changed successfully'." $OK";
57 80
			}
58
		}
59

  
60
		if(!$database->index_add($sTable, '', 'section_id', 'PRIMARY')) {
61
			$msg[] = ''.$database->get_error().'';
62
		} else {
63
		    $msg[] = 'Create PRIMARY KEY ( `section_id` )';
64
		}
65

  
66
		// change internal absolute links into relative links
67
		$sTable = TABLE_PREFIX.'mod_wysiwyg';
68
		$sql  = 'UPDATE `'.$sTable.'` ';
69
		$sql .= 'SET `content` = REPLACE(`content`, \'"'.WB_URL.MEDIA_DIRECTORY.'\', \'"{SYSVAR:MEDIA_REL}\')';
70
		if (!$database->query($sql)) {
71
			$msg[] = ''.$database->get_error().'';
72
		} else {
73
		    $msg[] = 'Change internal absolute links into relative links';
74
		}
75
		// only for $callingScript upgrade-script.php
76
		if($globalStarted) {
77
			if($bDebugModus) {
78
				foreach($msg as $title) {
79
				    echo '<strong>'.$title.'</strong><br />';
81
			$sFieldName = 'content';
82
			if(!$database->field_modify($sTable,$sFieldName,$sDescription)) {
83
				$msg[] = ''.$database->get_error();
84
			} else {
85
				$msg[] = 'Field ( `content` ) description has been changed successfully'." $OK";
86
			}
87
// change internal absolute links into relative links
88
			$sTable = $database->TablePrefix.'mod_wysiwyg';
89
			$sql  = 'UPDATE `'.$sTable.'` ';
90
			$sql .= 'SET `content` = REPLACE(`content`, \'"'.WB_URL.MEDIA_DIRECTORY.'\', \'"{SYSVAR:MEDIA_REL}\')';
91
			if (!$database->query($sql)) {
92
				$msg[] = ''.$database->get_error();
93
			} else {
94
				$msg[] = 'Change internal absolute links into relative links'." $OK";
95
			}
96
// only for $callingScript upgrade-script.php
97
			if($globalStarted) {
98
				if($bDebug) {
99
					echo '<strong>'.implode('<br />',$msg).'</strong><br />';
80 100
				}
81 101
			}
82 102
		}
83
		return $msg;
103
		$msg[] = 'WYSIWYG upgrade successfull finished'." $OK";
104
		if($globalStarted) {
105
			echo "<strong>WYSIWYG upgrade successfull finished $OK</strong><br />";
106
		}
107
		return ( ($globalStarted==true ) ? $globalStarted : $msg);
84 108
	}
109
// ------------------------------------
110
$bDebugModus = ((isset($bDebugModus)) ? $bDebugModus : false);
111
if( is_array($msg = mod_wysiwyg_upgrade($bDebugModus)) ) {
112
	echo '<strong>'.implode('<br />',$msg).'</strong><br />';
85 113
}
86
// ------------------------------------
87

  
88
$msg = mod_wysiwyg_upgrade();
89 114

  

Also available in: Unified diff