1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category module
|
5
|
* @package droplet
|
6
|
* @author Ruud Eisinga (Ruud) John (PCWacht)
|
7
|
* @author WebsiteBaker Project
|
8
|
* @copyright 2009-2013, WebsiteBaker Org. e.V.
|
9
|
* @link http://www.websitebaker.org/
|
10
|
* @license http://www.gnu.org/licenses/gpl.html
|
11
|
* @platform WebsiteBaker 2.8.x
|
12
|
* @requirements PHP 5.2.2 and higher
|
13
|
* @version $Id: upgrade.php 1916 2013-06-07 04:06:48Z Luisehahne $
|
14
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/modules/droplets/upgrade.php $
|
15
|
* @lastmodified $Date: 2013-06-07 06:06:48 +0200 (Fri, 07 Jun 2013) $
|
16
|
*
|
17
|
*/
|
18
|
/* -------------------------------------------------------- */
|
19
|
// Must include code to stop this file being accessed directly
|
20
|
if(!defined('WB_PATH')) {
|
21
|
|
22
|
require_once(dirname(dirname(dirname(__FILE__))).'/framework/globalExceptionHandler.php');
|
23
|
throw new IllegalFileException();
|
24
|
}
|
25
|
/* -------------------------------------------------------- */
|
26
|
|
27
|
if(!function_exists('insertDropletFile')) { require('droplets.functions.php'); }
|
28
|
|
29
|
function mod_droplets_upgrade($bDebug=false) {
|
30
|
global $admin;
|
31
|
$OK = ' <span style="color:#006400; font-weight:bold;">OK</span> ';
|
32
|
$FAIL = ' <span style="color:#ff0000; font-weight:bold;">FAILED</span> ';
|
33
|
$database=WbDatabase::getInstance();
|
34
|
$msg = array();
|
35
|
$callingScript = $_SERVER["SCRIPT_NAME"];
|
36
|
// check if upgrade startet by upgrade-script to echo a message
|
37
|
$tmp = 'upgrade-script.php';
|
38
|
$globalStarted = substr_compare($callingScript, $tmp,(0-strlen($tmp)),strlen($tmp)) === 0;
|
39
|
// check for missing tables, if true stop the upgrade
|
40
|
$aTable = array('mod_droplets');
|
41
|
$aPackage = UpgradeHelper::existsAllTables($aTable);
|
42
|
if( sizeof($aPackage) > 0){
|
43
|
$msg[] = 'TABLE '.implode(' missing! '.$FAIL.'<br />TABLE ',$aPackage).' missing! '.$FAIL;
|
44
|
$msg[] = 'Droplets upgrade failed'." $FAIL";
|
45
|
if($globalStarted) {
|
46
|
echo '<strong>'.implode('<br />',$msg).'</strong><br />';
|
47
|
}
|
48
|
return ( ($globalStarted==true ) ? $globalStarted : $msg);
|
49
|
} else {
|
50
|
for($x=0; $x<sizeof($aTable);$x++) {
|
51
|
if(($sOldType = $database->getTableEngine($database->TablePrefix.$aTable[$x]))) {
|
52
|
if(('myisam' != strtolower($sOldType))) {
|
53
|
if(!$database->query('ALTER TABLE `'.$database->TablePrefix.$aTable[$x].'` Engine = \'MyISAM\' ')) {
|
54
|
$msg[] = $database->get_error();
|
55
|
} else{
|
56
|
$msg[] = 'TABLE `'.$database->TablePrefix.$aTable[$x].'` changed to Engine = \'MyISAM\''." $OK";
|
57
|
}
|
58
|
} else {
|
59
|
$msg[] = 'TABLE `'.$database->TablePrefix.$aTable[$x].'` has Engine = \'MyISAM\''." $OK";
|
60
|
}
|
61
|
} else {
|
62
|
$msg[] = $database->get_error();
|
63
|
}
|
64
|
}
|
65
|
$table_name = $database->TablePrefix.'mod_droplets';
|
66
|
$description = "INT NOT NULL DEFAULT '0' AFTER `active`";
|
67
|
$field_name = 'show_wysiwyg';
|
68
|
if(!$database->field_exists($table_name,$field_name)) {
|
69
|
$database->field_add($table_name, $field_name, $description);
|
70
|
$msg[] = 'Add field `show_wysiwyg` AFTER `active`';
|
71
|
} else {
|
72
|
$msg[] = 'Field `show_wysiwyg` already exists'." $OK";
|
73
|
}
|
74
|
$field_name = 'admin_view';
|
75
|
if(!$database->field_exists($table_name,$field_name)) {
|
76
|
$database->field_add($table_name, $field_name, $description);
|
77
|
$msg[] = 'Add field `admin_view` AFTER `active`';
|
78
|
} else {
|
79
|
$msg[] = 'Field `admin_view` already exists'." $OK";
|
80
|
}
|
81
|
$field_name = 'admin_edit';
|
82
|
if(!$database->field_exists($table_name,$field_name)) {
|
83
|
$database->field_add($table_name, $field_name, $description);
|
84
|
$msg[] = 'Add field `admin_edit` AFTER `active`';
|
85
|
} else {
|
86
|
$msg[] = 'Field `admin_edit` already exists'." $OK";
|
87
|
}
|
88
|
|
89
|
$sBaseDir = realpath(dirname(__FILE__).'/example/');
|
90
|
$sBaseDir = rtrim(str_replace('\\', '/', $sBaseDir), '/').'/';
|
91
|
$aDropletFiles = getDropletFromFiles($sBaseDir);
|
92
|
|
93
|
$bOverwriteDroplets = false;
|
94
|
insertDropletFile($aDropletFiles,$msg,$bOverwriteDroplets,$admin);
|
95
|
// only for upgrade-script
|
96
|
if($globalStarted) {
|
97
|
if($bDebug) {
|
98
|
echo '<strong>'.implode('<br />',$msg).'</strong><br />';
|
99
|
}
|
100
|
}
|
101
|
}
|
102
|
$msg[] = 'Droplets upgrade successfull finished ';
|
103
|
if($globalStarted) {
|
104
|
echo "<strong>Droplets upgrade successfull finished $OK</strong><br />";
|
105
|
}
|
106
|
return ( ($globalStarted==true ) ? $globalStarted : $msg);
|
107
|
}
|
108
|
// ------------------------------------
|
109
|
|
110
|
$bDebugModus = ((isset($bDebugModus)) ? $bDebugModus : false);
|
111
|
if( is_array($msg = mod_droplets_upgrade($bDebugModus))) {
|
112
|
echo '<strong>'.implode('<br />',$msg).'</strong><br />';
|
113
|
}
|