OSDN Git Service

6e4ef66c104b0c795e24c67c438974bff3d064d2
[nucleus-jp/nucleus-next.git] / 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: upgrade2.0.php 1889 2012-06-17 08:46:45Z sakamocchi $
16  */
17
18 function upgrade_do200() {
19
20         if (upgrade_checkinstall(200))
21                 return "already installed";
22
23         // queries come here
24         
25         // add ikarmaneg 
26         if (!upgrade_checkIfColumnExists('item','ikarmaneg')) {
27                 $query =  'ALTER TABLE '.sql_table('item')
28                            . " ADD ikarmaneg int(11) NOT NULL default '0'";
29                 upgrade_query("Adding ikarmaneg column to items",$query);
30         }
31
32         // rename ikarma to ikarmapos
33         if (!upgrade_checkIfColumnExists('item','ikarmapos')) {
34                 $query =  'ALTER TABLE '.sql_table('item')
35                            . " CHANGE ikarma ikarmapos int(11) NOT NULL default '0'";
36                 upgrade_query("Renaming ikarma column for items to ikarmapos",$query);
37         }
38
39         // drop key in actionlog
40         $query = 'ALTER TABLE '.sql_table('actionlog').' DROP PRIMARY KEY';
41         upgrade_query("Dropping primary key in actionlog table",$query);        
42         
43         // change cmail field length
44         $query = 'ALTER TABLE '.sql_table('comment').' CHANGE cmail cmail varchar(100) default NULL';
45         upgrade_query("changing max email/url length of guest comments to 100",$query); 
46         
47         // create default skin option
48         if (!upgrade_checkIfCVExists('BaseSkin')) {
49                 $skinid = SKIN::getIdFromName('default');
50                 $query = 'INSERT INTO '.sql_table('config')." VALUES ('BaseSkin', '$skinid');";
51                 upgrade_query("Adding setting BaseSkin",$query);
52         }
53
54         global $CONF;
55         // add SkinsURL setting
56         if (!upgrade_checkIfCVExists('SkinsURL')) {
57                 $skinsurl = str_replace('/media/','/skins/',$CONF['MediaURL']);
58                 $query = 'INSERT INTO '.sql_table('config')." VALUES ('SkinsURL', ".DB::quoteValue($skinsurl).');';
59                 upgrade_query("Adding setting SkinsURL",$query);
60         }
61
62         // add ActionURL setting
63         if (!upgrade_checkIfCVExists('ActionURL')) {
64                 $actionurl = str_replace('/media/','/action.php',$CONF['MediaURL']);
65                 $query = 'INSERT INTO '.sql_table('config')." VALUES ('ActionURL', ".DB::quoteValue($actionurl).');';
66                 upgrade_query("Adding setting ActionURL",$query);
67         }
68         
69         // time offset can also be decimal (for half time zones like GMT+3:30)
70         $query = 'ALTER TABLE '.sql_table('blog')." CHANGE btimeoffset btimeoffset DECIMAL( 3, 1 ) DEFAULT '0' NOT NULL";
71         upgrade_query('Changing time offset column type to decimal',$query);
72         
73         // add ballowpast option to nucleus_blog
74         if (!upgrade_checkIfColumnExists('blog','ballowpast')) {
75                 $query =  'ALTER TABLE '.sql_table('blog')." ADD ballowpast tinyint(2) NOT NULL default '0'";
76                 upgrade_query("Adding 'Allow posting to the past' option to blogs",$query);
77         }
78         
79         // URLMode
80         if (!upgrade_checkIfCVExists('URLMode')) {
81                 $query = 'INSERT INTO '.sql_table('config')." VALUES ('URLMode', 'normal');";
82                 upgrade_query("Adding setting URLMode",$query);
83         }
84         
85         // add id to nucleus_plugin_option (allows for ordening)
86         if (!upgrade_checkIfColumnExists('plugin_option','oid')) {
87                 $query =  'ALTER TABLE '.sql_table('plugin_option').' ADD oid int(11) NOT NULL auto_increment UNIQUE ';
88                 upgrade_query("Adding id attribute to plugin options table",$query);
89         }
90
91         // add sdincmode and sdincpref to skins
92         global $upgrade_failures;
93         if (0 == $upgrade_failures && !upgrade_checkIfColumnExists('skin_desc','sdincpref')) {
94                 $query =  'ALTER TABLE '.sql_table('skin_desc')
95                            . " ADD sdincmode varchar(10) NOT NULL default 'normal',"
96                            . " ADD sdincpref varchar(50) NOT NULL default ''";
97                 upgrade_query('Adding IncludeMode and IncludePrefix properties to skins',$query);       
98         }else{
99                 echo "<li>Adding IncludeMode and IncludePrefix properties to skins ... <span class=\"warning\">NOT EXECUTED</span>\n<blockquote>Errors occurred during upgrade process.</blockquote>";
100         }
101 }
102 ?>