OSDN Git Service

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