Project

General

Profile

« Previous | Next » 

Revision 1765

Added by Dietmar about 12 years ago

! recoded module news,form,wysiwyg upgrade to work with upgrade-script

View differences:

upgrade.php
21 21
	throw new IllegalFileException();
22 22
}
23 23
/* -------------------------------------------------------- */
24
$msg = '';
25
$sTable = TABLE_PREFIX.'mod_wysiwyg';
26
if(($sOldType = $database->getTableEngine($sTable))) {
27
	if(('myisam' != strtolower($sOldType))) {
28
		if(!$database->query('ALTER TABLE `'.$sTable.'` Engine = \'MyISAM\' ')) {
29
			$msg = $database->get_error();
30
		}
31
	}
32
} else {
33
	$msg .= $database->get_error().'<br />';
34
}
35 24

  
36
$sql = 'ALTER TABLE `'.DB_NAME.'`.`'.$sTable.'` DROP PRIMARY KEY';
37
if(!$database->query($sql)) {
38
	$msg .= $database->get_error().'<br />';
39
}
25
if(!function_exists('mod_wysiwyg_upgrade'))
26
{
27
    function mod_wysiwyg_upgrade () {
28
        global $database,$bDebugModus;
29
        $callingScript = $_SERVER["SCRIPT_NAME"];
30
        // check if upgrade startet by upgrade-script to echo a message
31
        $tmp = 'upgrade-script.php';
32
        $globalStarted = substr_compare($callingScript, $tmp,(0-strlen($tmp)),strlen($tmp)) === 0;
40 33

  
41
$sql = 'ALTER TABLE `'.$sTable.'`  ADD `wysiwyg_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST';
42
if(!$database->query($sql)) {
43
	$msg .= $database->get_error().'<br />';
44
}
34
        $msg = array();
35
        $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\'';
43
        			}
44
        		} else {
45
                 $msg[] = 'TABLE `'.TABLE_PREFIX.$aTable[$x].'` has Engine = \'MyISAM\'';
46
        		}
47
        	} else {
48
        		$msg[] = $database->get_error();
49
        	}
50
        }
45 51

  
46
// change internal absolute links into relative links
47
$sTable = TABLE_PREFIX.'mod_wysiwyg';
48
$sql  = 'UPDATE `'.$sTable.'` ';
49
$sql .= 'SET `content` = REPLACE(`content`, \'"'.WB_URL.MEDIA_DIRECTORY.'\', \'"{SYSVAR:MEDIA_REL}\')';
50
if (!$database->query($sql)) {
51
	$msg .= $database->get_error().'<br />';
52
        $sTable = TABLE_PREFIX.'mod_wysiwyg';
53
        if($database->index_exists($sTable, 'PRIMARY')) {
54
            $sql = 'ALTER TABLE `'.DB_NAME.'`.`'.$sTable.'` DROP PRIMARY KEY';
55
            if(!$database->query($sql)) {
56
                $msg[] = ''.$database->get_error().'';
57
            }
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 upgrade-script
76
        if($globalStarted) {
77
            if($bDebugModus) {
78
                foreach($msg as $title) {
79
                    echo '<strong>'.$title.'</strong><br />';
80
                }
81
            }
82
        }
83
        return $msg;
84
    }
52 85
}
86
// ------------------------------------
53 87

  
54
// ------------------------------------
88
$msg = mod_wysiwyg_upgrade();

Also available in: Unified diff