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
1 1
<?php
2 2
/**
3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 4
 *
4
 * @category        module
5
 * @package         Form
6
 * @author          WebsiteBaker Project
7
 * @copyright       2009-2012, Website Baker Org. e.V.
8
 * @link			http://www.websitebaker2.org/
9
 * @license         http://www.gnu.org/licenses/gpl.html
10
 * @platform        WebsiteBaker 2.8.x
11
 * @requirements    PHP 5.2.2 and higher
12
 * @version         $Id$
13
 * @filesource		$HeadURL$
14
 * @lastmodified    $Date$
15
 * @description
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 17
 */
17 18

  
19
/**
20
 * upgrade.php
21
 * 
22
 * @category     Module
23
 * @package      Module_form
24
 * @subpackage   upgrade
25
 * @author       Dietmar Wöllbrink <dietmar.woellbrink@websitebaker.org>
26
 * @author       Werner v.d.Decken <wkl@isteam.de>
27
 * @copyright    Werner v.d.Decken <wkl@isteam.de>
28
 * @license      http://www.gnu.org/licenses/gpl.html   GPL License
29
 * @version      0.0.1
30
 * @revision     $Revision$
31
 * @link         $HeadURL$
32
 * @lastmodified $Date$
33
 * @since        File available since 17.01.2013
34
 * @description  xyz
35
 * 
36
 */
37

  
18 38
/* -------------------------------------------------------- */
19 39
// Must include code to stop this file being accessed directly
20
if(!defined('WB_PATH')) {
40
if(!defined('WB_URL')) {
21 41
	require_once(dirname(dirname(dirname(__FILE__))).'/framework/globalExceptionHandler.php');
22 42
	throw new IllegalFileException();
23 43
}
24 44
/* -------------------------------------------------------- */
25 45

  
26
if(!function_exists('mod_form_upgrade'))
27
{
28
    function mod_form_upgrade() {
29
        $msg = array();
30
        global $database,$bDebugModus;
31
        $callingScript = $_SERVER["SCRIPT_NAME"];
32
        // check if upgrade startet by upgrade-script to echo a message
33
        $tmp = 'upgrade-script.php';
34
        $globalStarted = substr_compare($callingScript, $tmp,(0-strlen($tmp)),strlen($tmp)) === 0;
35
        $aTable = array('mod_form_fields','mod_form_settings','mod_form_submissions');
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
        }
46
//if(!function_exists('mod_form_upgrade')){
47
	function mod_form_upgrade($bDebug=false) {
48
		global $OK ,$FAIL;
49
		$database=WbDatabase::getInstance();
50
		$msg = array();
51
		$callingScript = $_SERVER["SCRIPT_NAME"];
52
		// check if upgrade startet by upgrade-script to echo a message
53
		$tmp = 'upgrade-script.php';
54
		$globalStarted = substr_compare($callingScript, $tmp,(0-strlen($tmp)),strlen($tmp)) === 0;
55
// check for missing tables, if true stop the upgrade
56
		$aTable = array('mod_form_fields','mod_form_settings','mod_form_submissions');
57
		$aPackage = UpgradeHelper::existsAllTables($aTable);
58
		if( sizeof($aPackage) > 0){
59
			$msg[] =  'TABLE '.implode(' missing! '.$FAIL.'<br />TABLE ',$aPackage).' missing! '.$FAIL;
60
			$msg[] = 'Form upgrade failed'." $FAIL";
61
			if($globalStarted) {
62
				echo '<strong>'.implode('<br />',$msg).'</strong><br />';
63
			}
64
			return ( ($globalStarted==true ) ? $globalStarted : $msg);
65
		} else {
66
			for($x=0; $x<sizeof($aTable);$x++) {
67
				if(($sOldType = $database->getTableEngine($database->TablePrefix.$aTable[$x]))) {
68
					if(('myisam' != strtolower($sOldType))) {
69
						if(!$database->query('ALTER TABLE `'.$database->TablePrefix.$aTable[$x].'` Engine = \'MyISAM\' ')) {
70
							$msg[] = $database->get_error();
71
						} else{
72
							$msg[] = 'TABLE `'.$database->TablePrefix.$aTable[$x].'` changed to Engine = \'MyISAM\''." $OK";
73
						}
74
					} else {
75
						$msg[] = 'TABLE `'.$database->TablePrefix.$aTable[$x].'` has Engine = \'MyISAM\''." $OK";
76
					}
77
				} else {
78
					$msg[] = $database->get_error();
79
				}
80
			}
81
			$table_name = $database->TablePrefix.'mod_form_settings';
82
			$field_name = 'perpage_submissions';
83
			$description = "INT NOT NULL DEFAULT '10' AFTER `max_submissions`";
84
			if(!$database->field_exists($table_name,$field_name)) {
85
				$database->field_add($table_name, $field_name, $description);
86
				$msg[] = 'Add field `perpage_submissions` AFTER `max_submissions`';
87
			} else {
88
				$msg[] = 'Field `perpage_submissions` already exists'." $OK";
89
			}
90
// only for upgrade-script
91
			if($globalStarted) {
92
				if($bDebug) {
93
					echo '<strong>'.implode('<br />',$msg).'</strong><br />';
94
				}
95
			}
96
		}
97
		$msg[] = 'Form upgrade successfull finished ';
98
		if($globalStarted) {
99
			echo "<strong>Form upgrade successfull finished $OK</strong><br />";
100
		}
101
		return ( ($globalStarted==true ) ? $globalStarted : $msg);
102
	}
103
//}
104
// ------------------------------------
51 105

  
52
        $table_name = TABLE_PREFIX.'mod_form_settings';
53
        $field_name = 'perpage_submissions';
54
        $description = "INT NOT NULL DEFAULT '10' AFTER `max_submissions`";
55
        if(!$database->field_exists($table_name,$field_name)) {
56
        	$database->field_add($table_name, $field_name, $description);
57
            $msg[] = 'Add field `perpage_submissions` AFTER `max_submissions`';
58
        } else {
59
            $msg[] = 'Field `perpage_submissions` already exists';
60
        }
61

  
62
        // only for upgrade-script
63
        if($globalStarted) {
64
            if($bDebugModus) {
65
                foreach($msg as $title) {
66
                    echo '<strong>'.$title.'</strong><br />';
67
                }
68
            }
69
        }
70
        return $msg;
71
    }
106
$bDebugModus = ((isset($bDebugModus)) ? $bDebugModus : false);
107
if( is_array($msg = mod_form_upgrade($bDebugModus))) {
108
	echo '<strong>'.implode('<br />',$msg).'</strong><br />';
72 109
}
73
// ------------------------------------
74

  
75
$msg = mod_form_upgrade();
76 110

  

Also available in: Unified diff