Revision 1916
Added by Dietmar over 11 years ago
upgrade.php | ||
---|---|---|
5 | 5 |
* @package droplet |
6 | 6 |
* @author Ruud Eisinga (Ruud) John (PCWacht) |
7 | 7 |
* @author WebsiteBaker Project |
8 |
* @copyright 2004-2009, Ryan Djurovich |
|
9 |
* @copyright 2009-2011, Website Baker Org. e.V. |
|
10 |
* @link http://www.websitebaker2.org/ |
|
8 |
* @copyright 2009-2013, WebsiteBaker Org. e.V. |
|
9 |
* @link http://www.websitebaker.org/ |
|
11 | 10 |
* @license http://www.gnu.org/licenses/gpl.html |
12 | 11 |
* @platform WebsiteBaker 2.8.x |
13 | 12 |
* @requirements PHP 5.2.2 and higher |
14 | 13 |
* @version $Id$ |
15 |
* @filesource $HeadURL$
|
|
14 |
* @filesource $HeadURL$
|
|
16 | 15 |
* @lastmodified $Date$ |
17 | 16 |
* |
18 | 17 |
*/ |
... | ... | |
24 | 23 |
throw new IllegalFileException(); |
25 | 24 |
} |
26 | 25 |
/* -------------------------------------------------------- */ |
27 |
$database=WbDatabase::getInstance(); |
|
28 |
$table_name = TABLE_PREFIX .'mod_droplets'; |
|
29 |
$description = 'INT NOT NULL default 0 '; |
|
30 |
$database->field_add($table_name,'show_wysiwyg',$description.'AFTER `active`' ); |
|
31 |
$database->field_add($table_name,'admin_view',$description.'AFTER `active`' ); |
|
32 |
$database->field_add($table_name,'admin_edit',$description.'AFTER `active`' ); |
|
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 |
} |
Also available in: Unified diff
! /modules/droplets/ set to version 1.3.0
installing module with sql import
make upgrade.php compatible with upgrade-scrip.php