3 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
4 * Copyright (C) 2002-2009 The Nucleus Group
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)
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 $
18 function upgrade_do200() {
20 if (upgrade_checkinstall(200))
21 return "already installed";
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);
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);
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);
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);
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);
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);
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);
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);
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);
80 if (!upgrade_checkIfCVExists('URLMode')) {
81 $query = 'INSERT INTO '.sql_table('config')." VALUES ('URLMode', 'normal');";
82 upgrade_query("Adding setting URLMode",$query);
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);
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);
99 echo "<li>Adding IncludeMode and IncludePrefix properties to skins ... <span class=\"warning\">NOT EXECUTED</span>\n<blockquote>Errors occurred during upgrade process.</blockquote>";