Revision 1977
Added by Luisehahne about 12 years ago
| upgrade.php | ||
|---|---|---|
| 25 | 25 |
* @author Dietmar Wöllbrink <dietmar.woellbrink@websiteBaker.org> |
| 26 | 26 |
* @copyright Werner v.d.Decken <wkl@isteam.de> |
| 27 | 27 |
* @license http://www.gnu.org/licenses/gpl.html GPL License |
| 28 |
* @version 1.6.8
|
|
| 28 |
* @version 1.6.9
|
|
| 29 | 29 |
* @revision $Revision$ |
| 30 | 30 |
* @link $HeadURL$ |
| 31 | 31 |
* @lastmodified $Date$ |
| ... | ... | |
| 41 | 41 |
} |
| 42 | 42 |
/* -------------------------------------------------------- */ |
| 43 | 43 |
|
| 44 |
// Work-out if we should check for existing page_code |
|
| 45 |
$sql = 'DESCRIBE `'.$database->TablePrefix.'pages` `page_code`'; |
|
| 46 |
$field_sql = $database->query($sql); |
|
| 47 |
$field_set = $field_sql->numRows(); |
|
| 48 |
$format = $field_sql->fetchRow(MYSQL_ASSOC) ; |
|
| 49 |
// upgrade only if old format |
|
| 50 |
if($format['Type'] == 'varchar(255)' ) |
|
| 51 |
{
|
|
| 52 |
$sql = 'SELECT `page_code`,`page_id` FROM `'.$database->TablePrefix.'pages` ORDER BY `page_id`'; |
|
| 53 |
if($query_code = $database->query($sql)) |
|
| 54 |
{
|
|
| 55 |
// extract page_id from old format |
|
| 56 |
$pattern = '/(?<=_)([0-9]{1,11})/s';
|
|
| 57 |
while( $page = $query_code->fetchRow(MYSQL_ASSOC)) |
|
| 58 |
{
|
|
| 59 |
preg_match($pattern, $page['page_code'], $array); |
|
| 60 |
$page_code = $array[0]; |
|
| 61 |
$page_id = $page['page_id']; |
|
| 62 |
$sql = 'UPDATE `'.$database->TablePrefix.'pages` SET '; |
|
| 63 |
$sql .= ((empty($array[0])) ? '`page_code` = 0 ' : '`page_code` = '.$page_code.' '); |
|
| 64 |
$sql .= 'WHERE `page_id` = '.$page_id; |
|
| 65 |
$database->query($sql); |
|
| 66 |
} |
|
| 67 |
$field_set = $database->field_modify('page_code', 'pages', 'INT(11) NOT NULL AFTER `modified_by`');
|
|
| 68 |
// $sql = 'ALTER TABLE `'.$database->TablePrefix.'pages` MODIFY COLUMN `page_code` INT(11) NOT NULL'; |
|
| 69 |
// $database->query($sql); |
|
| 70 |
} |
|
| 44 |
function mod_MultiLingual_upgrade($bDebug=false) {
|
|
| 45 |
global $OK ,$FAIL; |
|
| 46 |
$database=WbDatabase::getInstance(); |
|
| 47 |
$msg = array(); |
|
| 48 |
$callingScript = $_SERVER["SCRIPT_NAME"]; |
|
| 49 |
// check if upgrade startet by upgrade-script to echo a message |
|
| 50 |
$tmp = 'upgrade-script.php'; |
|
| 51 |
$globalStarted = substr_compare($callingScript, $tmp,(0-strlen($tmp)),strlen($tmp)) === 0; |
|
| 52 |
// change table structure |
|
| 53 |
$sTable = $database->TablePrefix.'pages'; |
|
| 54 |
$sFieldName = 'page_code'; |
|
| 55 |
$sDescription = "INT NOT NULL DEFAULT '0' AFTER `language`"; |
|
| 56 |
if(!$database->field_add($sTable,$sFieldName,$sDescription)) {
|
|
| 57 |
$msg[] = ''.$database->get_error(); |
|
| 58 |
} else {
|
|
| 59 |
$msg[] = 'Field ( `page_code` ) description has been add successfully'." $OK"; |
|
| 60 |
} |
|
| 61 |
// Work-out if we should check old format for existing page_code |
|
| 62 |
$sql = 'DESCRIBE `'.$database->TablePrefix.'pages` `page_code`'; |
|
| 63 |
$field_sql = $database->query($sql); |
|
| 64 |
// $field_set = $field_sql->numRows(); |
|
| 65 |
$format = $field_sql->fetchRow(MYSQL_ASSOC) ; |
|
| 66 |
// upgrade only if old format |
|
| 67 |
if($format['Type'] == 'varchar(255)' ) |
|
| 68 |
{
|
|
| 69 |
$sql = 'SELECT `page_code`,`page_id` FROM `'.$database->TablePrefix.'pages` ORDER BY `page_id`'; |
|
| 70 |
if($query_code = $database->query($sql)) |
|
| 71 |
{
|
|
| 72 |
// extract page_id from old format |
|
| 73 |
$pattern = '/(?<=_)([0-9]{1,11})/s';
|
|
| 74 |
while( $page = $query_code->fetchRow(MYSQL_ASSOC)) |
|
| 75 |
{
|
|
| 76 |
preg_match($pattern, $page['page_code'], $array); |
|
| 77 |
$page_code = $array[0]; |
|
| 78 |
$page_id = $page['page_id']; |
|
| 79 |
$sql = 'UPDATE `'.$database->TablePrefix.'pages` SET '; |
|
| 80 |
$sql .= ((empty($array[0])) ? '`page_code` = 0 ' : '`page_code` = '.$page_code.' '); |
|
| 81 |
$sql .= 'WHERE `page_id` = '.$page_id; |
|
| 82 |
$database->query($sql); |
|
| 83 |
} |
|
| 84 |
$field_set = $database->field_modify($sTable,$sFieldName,$sDescription); |
|
| 85 |
$msg[] = 'Field ( `page_code` ) description has been changed successfully'." $OK"; |
|
| 86 |
// only for upgrade-script |
|
| 87 |
if($globalStarted) {
|
|
| 88 |
if($bDebug) {
|
|
| 89 |
echo '<strong>'.implode('<br />',$msg).'</strong><br />';
|
|
| 90 |
} |
|
| 91 |
} |
|
| 92 |
} else {
|
|
| 93 |
$msg[] = ''.$database->get_error(); |
|
| 94 |
} |
|
| 95 |
} |
|
| 96 |
// |
|
| 97 |
$msg[] = 'MultiLingual upgrade successfull finished '; |
|
| 98 |
if($globalStarted) {
|
|
| 99 |
echo "<strong>MultiLingual upgrade successfull finished $OK</strong><br />"; |
|
| 100 |
} |
|
| 101 |
return ( ($globalStarted==true ) ? $globalStarted : $msg); |
|
| 102 |
|
|
| 103 |
} |
|
| 104 |
// ------------------------------------ |
|
| 105 |
//$directory = dirname(__FILE__).'/'.'info.php'; |
|
| 106 |
//// update entry in table addons to new version |
|
| 107 |
//load_module($directory, $install = false); |
|
| 108 |
|
|
| 109 |
$bDebugModus = ((isset($bDebugModus)) ? $bDebugModus : false); |
|
| 110 |
// Don't show the messages twice |
|
| 111 |
if( is_array($msg = mod_MultiLingual_upgrade($bDebugModus))) {
|
|
| 112 |
echo '<strong>'.implode('<br />',$msg).'</strong><br />';
|
|
| 71 | 113 |
} |
| 72 |
// |
|
| 73 |
$directory = dirname(__FILE__).'/'.'info.php'; |
|
| 74 |
// update entry in table addons to new version |
|
| 75 |
load_module($directory, $install = false); |
|
| 114 |
|
|
| 115 |
// ------------------------------------ |
|
Also available in: Unified diff
! /framework/functions.php: started implementation of packet AccessFile in function rebuild_all_accessfiles()
+ /framework/functions.php::rm_full_dir() added additional argument to set list of protected files
! integrate the new processes into the upgrade-script.php
+ extended checks and informations in /modules/MultiLingual/upgrade.php
increasing version for module MultiLingual to 1.6.9