OSDN Git Service

ADDED: upgrade code for 3.5 in upgrades folder. Includes notices about end of PHP4...
[nucleus-jp/nucleus-jp-ancient.git] / utf8 / nucleus / upgrades / upgrade2.0.php
1 <?php
2 /*
3  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
4  * Copyright (C) 2002-2009 The Nucleus Group
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  * (see nucleus/documentation/index.html#license for more info)
11  */
12 /**
13  * @license http://nucleuscms.org/license.txt GNU General Public License
14  * @copyright Copyright (C) 2002-2009 The Nucleus Group
15  * @version $Id$
16  * $NucleusJP: upgrade2.0.php,v 1.3.2.1 2007/10/24 05:39:16 kimitake Exp $
17  *
18  */
19
20 function upgrade_do200() {
21
22     if (upgrade_checkinstall(200))
23         return "already installed";
24
25     // queries come here
26     
27     // add ikarmaneg 
28     if (!upgrade_checkIfColumnExists('item','ikarmaneg')) {
29         $query =  'ALTER TABLE '.sql_table('item')
30                . " ADD ikarmaneg int(11) NOT NULL default '0'";
31         upgrade_query("Adding ikarmaneg column to items",$query);
32     }
33
34     // rename ikarma to ikarmapos
35     if (!upgrade_checkIfColumnExists('item','ikarmapos')) {
36         $query =  'ALTER TABLE '.sql_table('item')
37                . " CHANGE ikarma ikarmapos int(11) NOT NULL default '0'";
38         upgrade_query("Renaming ikarma column for items to ikarmapos",$query);
39     }
40
41     // drop key in actionlog
42     $query = 'ALTER TABLE '.sql_table('actionlog').' DROP PRIMARY KEY';
43     upgrade_query("Dropping primary key in actionlog table",$query);    
44     
45     // change cmail field length
46     $query = 'ALTER TABLE '.sql_table('comment').' CHANGE cmail cmail varchar(100) default NULL';
47     upgrade_query("changing max email/url length of guest comments to 100",$query); 
48     
49     // create default skin option
50     if (!upgrade_checkIfCVExists('BaseSkin')) {
51         $skinid = SKIN::getIdFromName('default');
52         $query = 'INSERT INTO '.sql_table('config')." VALUES ('BaseSkin', '$skinid');";
53         upgrade_query("Adding setting BaseSkin",$query);
54     }
55
56     global $CONF;
57     // add SkinsURL setting
58     if (!upgrade_checkIfCVExists('SkinsURL')) {
59         $skinsurl = str_replace('/media/','/skins/',$CONF['MediaURL']);
60         $query = 'INSERT INTO '.sql_table('config')." VALUES ('SkinsURL', '".addslashes($skinsurl)."');";
61         upgrade_query("Adding setting SkinsURL",$query);
62     }
63
64     // add ActionURL setting
65     if (!upgrade_checkIfCVExists('ActionURL')) {
66         $actionurl = str_replace('/media/','/action.php',$CONF['MediaURL']);
67         $query = 'INSERT INTO '.sql_table('config')." VALUES ('ActionURL', '".addslashes($actionurl)."');";
68         upgrade_query("Adding setting ActionURL",$query);
69     }
70     
71     // time offset can also be decimal (for half time zones like GMT+3:30)
72     $query = 'ALTER TABLE '.sql_table('blog')." CHANGE btimeoffset btimeoffset DECIMAL( 3, 1 ) DEFAULT '0' NOT NULL";
73     upgrade_query('Changing time offset column type to decimal',$query);
74     
75     // add ballowpast option to nucleus_blog
76     if (!upgrade_checkIfColumnExists('blog','ballowpast')) {
77         $query =  'ALTER TABLE '.sql_table('blog')." ADD ballowpast tinyint(2) NOT NULL default '0'";
78         upgrade_query("Adding 'Allow posting to the past' option to blogs",$query);
79     }
80     
81     // URLMode
82     if (!upgrade_checkIfCVExists('URLMode')) {
83         $query = 'INSERT INTO '.sql_table('config')." VALUES ('URLMode', 'normal');";
84         upgrade_query("Adding setting URLMode",$query);
85     }
86     
87     // add id to nucleus_plugin_option (allows for ordening)
88     if (!upgrade_checkIfColumnExists('plugin_option','oid')) {
89         $query =  'ALTER TABLE '.sql_table('plugin_option').' ADD oid int(11) NOT NULL auto_increment UNIQUE ';
90         upgrade_query("Adding id attribute to plugin options table",$query);
91     }
92
93     // add sdincmode and sdincpref to skins
94     global $upgrade_failures;
95     if (0 == $upgrade_failures && !upgrade_checkIfColumnExists('skin_desc','sdincpref')) {
96         $query =  'ALTER TABLE '.sql_table('skin_desc')
97                . " ADD sdincmode varchar(10) NOT NULL default 'normal',"
98                . " ADD sdincpref varchar(50) NOT NULL default ''";
99         upgrade_query('Adding IncludeMode and IncludePrefix properties to skins',$query);   
100     }else{
101         echo "<li>Adding IncludeMode and IncludePrefix properties to skins ... <span class=\"warning\">NOT EXECUTED</span>\n<blockquote>Errors occurred during upgrade process.</blockquote>";
102     }
103 }
104 ?>