OSDN Git Service

merged 3.3 beta1
[nucleus-jp/nucleus-jp-ancient.git] / utf8 / nucleus / upgrades / upgrade1.1.php
1 <?php
2 function upgrade_do11() {
3
4 if (upgrade_checkinstall(11))
5         return "already installed";
6
7 // 1. add some options to nucleus_config
8 $query = 'INSERT INTO '.sql_table('config')." VALUES ('CookiePath', '/');";
9 upgrade_query('CookiePath setting',$query);
10 $query = 'INSERT INTO '.sql_table('config')." VALUES ('CookieDomain', '');";
11 upgrade_query('CookieDomain setting',$query);
12 $query = 'INSERT INTO '.sql_table('config')." VALUES ('CookieSecure', '0');";
13 upgrade_query('CookieSecure setting',$query);
14 $query = 'INSERT INTO '.sql_table('config')." VALUES ('MediaPrefix', '1');";
15 upgrade_query('MediaPrefix setting',$query);
16
17
18 // 2. add language field to member table
19 upgrade_query("Language setting (member)", 
20                       'ALTER TABLE '.sql_table('member')." ADD deflang varchar(20) NOT NULL default '';");
21
22 // 3. create category table and update other tables (nucleus_item and nucleus_blog)
23 $query = 'CREATE TABLE '.sql_table('category').' ('
24         ." catid int(11) NOT NULL auto_increment,"
25         ." cblog int(11) NOT NULL, "
26         ." cname varchar(40),"
27         ." cdesc varchar(200),"
28         ." PRIMARY KEY (catid)"
29         .") ";
30 upgrade_query('New table '.sql_table('category'), $query);
31
32 upgrade_query("Adding category attribute to item-table", 
33         'ALTER TABLE '.sql_table('item').' ADD icat int(11)');
34 upgrade_query("Adding defcat attribute to blog-table", 
35         'ALTER TABLE '.sql_table('blog').' ADD bdefcat int(11)');
36
37 // 4. add 'general' categories for all blogs, and update nucleus_item
38 $catid = 1;     // generate catids ourself
39 $query = 'SELECT bnumber FROM '.sql_table('blog');
40 $res = mysql_query($query);
41 while ($current = mysql_fetch_object($res)) {
42         $blogid = $current->bnumber;
43         
44         $query = 'INSERT INTO '.sql_table('category')." (catid, cblog, cname, cdesc) VALUES ($catid, $blogid, 'General', 'Items that do not fit in other categories')";
45         $r = upgrade_query("Adding category 'general' for blog " . $blogid, $query);
46         
47         // only perform next actions when insert went ok
48         if ($r) {
49                 $query = 'UPDATE '.sql_table('blog')." SET bdefcat=$catid WHERE bnumber=$blogid";
50                 upgrade_query("Setting the default category for blog $blogid to the 'General' category", $query);
51         
52                 $query = 'UPDATE '.sql_table('item')." SET icat=$catid WHERE iblog=$blogid";
53                 upgrade_query("Assigning all existing items of blog $blogid to the 'General' category",$query);
54         }
55
56         $catid++;
57 }
58
59 // 5. add content type field to skins
60 $query = 'ALTER TABLE '.sql_table('skin_desc')." ADD sdtype VARCHAR(40) NOT NULL DEFAULT 'text/html'";
61 upgrade_query("Adding content type field to skins (text/html)", $query);
62
63 // 6. try to set content type for xml-rss skin to text/xml
64 $query = 'UPDATE '.sql_table('skin_desc')." SET sdtype='text/xml' WHERE sdname='xmlrss'";
65 upgrade_query("Setting content type for xmlrss skin to text/xml", $query);
66
67 // 7. add template parts for category lists to all templates
68 $query = 'SELECT tdnumber FROM '.sql_table('template_desc');
69 $res = sql_query($query);       // get all template ids
70 while ($obj = mysql_fetch_object($res)) {
71         $tid = $obj->tdnumber;  // template id
72
73         $query = 'INSERT INTO '.sql_table('template')." VALUES ($tid, 'CATLIST_HEADER', '<ul><li><a href=\"<%blogurl%>\">All</a></li>');";
74         $query2 = 'INSERT INTO '.sql_table('template')." VALUES ($tid, 'CATLIST_LISTITEM', '<li><a href=\"<%catlink%>\"><%catname%></a></li>');";
75         $query3 = 'INSERT INTO '.sql_table('template')." VALUES ($tid, 'CATLIST_FOOTER', '</ul>');";
76         upgrade_query("Adding categorylist header to template $tid",$query);
77         upgrade_query("Adding categorylist item to template $tid",$query2);
78         upgrade_query("Adding categorylist footer to template $tid",$query3);
79         
80 }
81
82 // 8. add bnotifytype column to blog tables
83 upgrade_query("Notify Type Setting", 
84                       'ALTER TABLE '.sql_table('blog')." ADD bnotifytype INT(11) NOT NULL default '15';");
85
86
87 }
88
89 ?>