Log in with username/password: lyceum/lyceum

root/trunk/src/lyceum/wp-admin/upgrade-schema.php

Revision 1004, 16.1 kB (checked in by jjb, 3 years ago)

Synchronizing with WordPress 2.0.4

http://source.ibiblio.org/trac/lyceum/milestone/0.44

Line 
1 <?php
2 // Here we keep the DB structure and option values
3
4 $wp_queries="CREATE TABLE $wpdb->categories (
5   cat_ID int unsigned NOT NULL auto_increment,
6   cat_name varchar(55) NOT NULL default '',
7   category_nicename varchar(200) NOT NULL default '',
8   category_description longtext NOT NULL default '',
9   category_parent int NOT NULL default '0',
10   category_count int NOT NULL default '0',
11   PRIMARY KEY  (cat_ID),
12   KEY category_nicename (category_nicename),
13   blog mediumint unsigned NOT NULL default '0',
14   KEY blog (blog,cat_ID),
15   KEY cat_name (cat_name)
16 ) ENGINE = InnoDB;
17 CREATE TABLE $wpdb->comments (
18   comment_ID int unsigned NOT NULL auto_increment,
19   comment_post_ID int unsigned NOT NULL default '0',
20   comment_author tinytext NOT NULL default '',
21   comment_author_email varchar(100) NOT NULL default '',
22   comment_author_url varchar(200) NOT NULL default '',
23   comment_author_IP varchar(100) NOT NULL default '',
24   comment_date datetime NOT NULL default '0000-00-00 00:00:00',
25   comment_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
26   comment_content text NOT NULL default '',
27   comment_karma int(11) NOT NULL default '0',
28   comment_approved enum('0','1','spam') NOT NULL default '1',
29   comment_agent varchar(255) NOT NULL default '',
30   comment_type varchar(20) NOT NULL default '',
31   comment_parent int NOT NULL default '0',
32   user_id int NOT NULL default '0',
33   PRIMARY KEY  (comment_ID),
34   KEY comment_approved (comment_approved),
35   KEY comment_post_ID (comment_post_ID)
36 ) ENGINE = InnoDB;
37 CREATE TABLE $wpdb->linkcategories (
38   cat_id int unsigned NOT NULL auto_increment,
39   cat_name tinytext NOT NULL default '',
40   auto_toggle enum('Y','N') NOT NULL default 'N',
41   show_images enum('Y','N') NOT NULL default 'Y',
42   show_description enum('Y','N') NOT NULL default 'N',
43   show_rating enum('Y','N') NOT NULL default 'Y',
44   show_updated enum('Y','N') NOT NULL default 'Y',
45   sort_order varchar(64) NOT NULL default 'rand',
46   sort_desc enum('Y','N') NOT NULL default 'N',
47   text_before_link varchar(128) NOT NULL default '<li>',
48   text_after_link varchar(128) NOT NULL default '<br />',
49   text_after_all varchar(128) NOT NULL default '</li>',
50   list_limit int(11) NOT NULL default '-1',
51   PRIMARY KEY  (cat_id),
52   blog mediumint unsigned NOT NULL default '0',
53   KEY blog (blog,cat_ID),
54   KEY cat_name (cat_name(5))
55 ) ENGINE = InnoDB;
56 CREATE TABLE $wpdb->links (
57   link_id int unsigned NOT NULL auto_increment,
58   link_url varchar(255) NOT NULL default '',
59   link_name varchar(255) NOT NULL default '',
60   link_image varchar(255) NOT NULL default '',
61   link_target varchar(25) NOT NULL default '',
62   link_category int NOT NULL default '0',
63   link_description varchar(255) NOT NULL default '',
64   link_visible enum('Y','N') NOT NULL default 'Y',
65   link_owner int(11) NOT NULL default '1',
66   link_rating int(11) NOT NULL default '0',
67   link_updated datetime NOT NULL default '0000-00-00 00:00:00',
68   link_rel varchar(255) NOT NULL default '',
69   link_notes mediumtext NOT NULL default '',
70   link_rss varchar(255) NOT NULL default '',
71   PRIMARY KEY  (link_id),
72   KEY link_category (link_category),
73   KEY link_visible (link_visible)
74 ) ENGINE = InnoDB;
75 CREATE TABLE $wpdb->options (
76   option_id int unsigned NOT NULL auto_increment,
77   blog_id int unsigned NOT NULL default '0',
78   option_name varchar(64) NOT NULL default '',
79   option_can_override enum('Y','N') NOT NULL default 'Y',
80   option_type int(11) NOT NULL default '1',
81   option_value longtext NOT NULL default '',
82   option_width int(11) NOT NULL default '20',
83   option_height int(11) NOT NULL default '8',
84   option_description tinytext NOT NULL default '',
85   option_admin_level int(11) NOT NULL default '1',
86   autoload enum('yes','no') NOT NULL default 'yes',
87   PRIMARY KEY  (option_id,blog_id,option_name),
88   KEY option_name (option_name),
89   option_domain enum('system','blog') NOT NULL default 'blog',
90   blog mediumint unsigned NOT NULL default '0',
91   UNIQUE blogdomainindex (blog, autoload, option_name),
92   UNIQUE systemdomainindex (option_domain, option_name, blog)
93 ) ENGINE = InnoDB;
94 CREATE TABLE $wpdb->post2cat (
95   rel_id int unsigned NOT NULL auto_increment,
96   post_id int unsigned NOT NULL default '0',
97   category_id int unsigned NOT NULL default '0',
98   PRIMARY KEY  (rel_id),
99   KEY post_id (post_id,category_id)
100 ) ENGINE = InnoDB;
101 CREATE TABLE $wpdb->postmeta (
102   meta_id int unsigned NOT NULL auto_increment,
103   post_id int unsigned NOT NULL default '0',
104   meta_key varchar(255) default NULL default '',
105   meta_value longtext default '',
106   PRIMARY KEY  (meta_id),
107   KEY post_id (post_id),
108   KEY meta_key (meta_key),
109   KEY mainkey (post_id, meta_key)
110 ) ENGINE = InnoDB;
111 CREATE TABLE $wpdb->posts (
112   ID int unsigned NOT NULL auto_increment,
113   post_author mediumint unsigned NOT NULL default '0',
114   post_date datetime NOT NULL default '0000-00-00 00:00:00',
115   post_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
116   post_content longtext NOT NULL default '',
117   post_title text NOT NULL default '',
118   post_category int(4) NOT NULL default '0',
119   post_excerpt text NOT NULL default '',
120   post_status enum('publish','draft','private','static','object','attachment') NOT NULL default 'publish',
121   comment_status enum('open','closed','registered_only') NOT NULL default 'open',
122   ping_status enum('open','closed') NOT NULL default 'open',
123   post_password varchar(20) NOT NULL default '',
124   post_name varchar(200) NOT NULL default '',
125   to_ping text NOT NULL default '',
126   pinged text NOT NULL default '',
127   post_modified datetime NOT NULL default '0000-00-00 00:00:00',
128   post_modified_gmt datetime NOT NULL default '0000-00-00 00:00:00',
129   post_content_filtered text NOT NULL default '',
130   post_parent int NOT NULL default '0',
131   guid varchar(255) NOT NULL default '',
132   menu_order int(11) NOT NULL default '0',
133   post_type varchar(100) NOT NULL default '',
134   post_mime_type varchar(100) NOT NULL default '',
135   comment_count int NOT NULL default '0',
136   PRIMARY KEY  (ID),
137   KEY post_name (post_name),
138   page_blog mediumint unsigned default NULL,
139   KEY page_blog (page_blog),
140   KEY post_parent (post_parent),
141   KEY post_date (post_date),
142   KEY main (post_status, post_author, post_date_gmt),
143   KEY page (post_status, page_blog)
144 ) ENGINE = InnoDB;
145 CREATE TABLE $wpdb->users (
146   ID mediumint unsigned NOT NULL auto_increment,
147   user_login varchar(60) NOT NULL default '',
148   user_pass varchar(64) NOT NULL default '',
149   user_nicename varchar(50) NOT NULL default '',
150   user_email varchar(100) NOT NULL default '',
151   user_url varchar(100) NOT NULL default '',
152   user_registered datetime NOT NULL default '0000-00-00 00:00:00',
153   user_activation_key varchar(60) NOT NULL default '',
154   user_status int(11) NOT NULL default '0',
155   display_name varchar(250) NOT NULL default '',
156   PRIMARY KEY  (ID),
157   UNIQUE user_login_key (user_login),
158   UNIQUE user_email (user_email),
159   user_locked enum('0','1') NOT NULL default '0',
160   user_admin enum('0','1') NOT NULL default '0'
161 ) ENGINE = InnoDB;
162 CREATE TABLE $wpdb->usermeta (
163   umeta_id int unsigned NOT NULL auto_increment,
164   user_id int unsigned NOT NULL default '0',
165   meta_key varchar(255) default NULL,
166   meta_value longtext default '',
167   PRIMARY KEY  (umeta_id),
168   KEY user_id (user_id),
169   KEY meta_key (meta_key),
170   meta_domain enum('system','blog') NOT NULL default 'blog',
171   blog mediumint unsigned default NULL,
172   UNIQUE blogindex (blog, user_id, meta_key),
173   KEY systemindex (meta_domain, user_id, meta_key)
174 ) ENGINE = InnoDB;
175 CREATE TABLE $wpdb->blogs (
176   `id` mediumint unsigned NOT NULL auto_increment,
177   `slug` varchar(60) unique NOT NULL default '',
178   `created` datetime NOT NULL default '0000-00-00 00:00:00',
179   `status` enum('active','deleted') NOT NULL default 'active',
180   PRIMARY KEY  (`id`),
181   UNIQUE mainkey (slug, id, status)
182 ) ENGINE = InnoDB;
183 CREATE TABLE $wpdb->postsearch (
184   `id` int unsigned NOT NULL auto_increment,
185   `post_id` int unsigned NOT NULL default '0',
186   `object_id` int unsigned NOT NULL default '0',
187   `component` enum('title', 'content','comment') NOT NULL,
188   `textdata` text NOT NULL default '',
189   PRIMARY KEY  (`id`),
190   KEY (`post_id`),
191   FULLTEXT (`textdata`)
192 ) ENGINE = MyIsam;
193 CREATE TABLE $wpdb->sessions (
194   id varchar(32) NOT NULL default '',
195   access int(10) unsigned,
196   data text,
197   PRIMARY KEY  (id)
198 ) ENGINE = InnoDB
199 ";
200
201 function populate_options() {
202     global $wpdb;
203     global $blog;
204     assert(isset($blog));
205     
206     $old_umask = umask(0);
207
208     $wpcontent = get_option('wp-content_file_path')."$blog/";
209
210     //add_option('themes_file_path', $wpcontent."themes/");
211     //add_option('themes_web_path', get_option('siteurl')."/wp-content/$blog/themes/");
212     //add_option('plugins_file_path', $wpcontent."plugins/");
213     add_option('uploads_file_path', $wpcontent."uploads/");
214     add_option('uploads_web_path', get_option('fileupload_base_url')."$blog/uploads/");
215
216     $stat = stat(get_option('wp-content_file_path'));
217     $mode = $stat['mode'] & 0000777;    // Get the permission bits.
218
219     if (!file_exists($wpcontent)){
220         mkdir($wpcontent);
221         chmod($wpcontent, $mode);
222     }
223     //mkdir(get_option('themes_file_path'));
224     //chmod(get_option('themes_file_path'), $mode);
225
226     //mkdir(get_option('plugins_file_path'));
227     //chmod(get_option('plugins_file_path'), $mode);
228
229     if (!file_exists(get_option('uploads_file_path'))){
230         mkdir(get_option('uploads_file_path'));
231         chmod(get_option('uploads_file_path'), $mode);
232     }
233
234     umask($old_umask);
235
236     $slug = $wpdb->get_var("SELECT slug FROM $wpdb->blogs WHERE id = '$blog'");
237     if (SUBDOMAINS)
238         $home = 'http://' . $slug . '.' . MAINDOMAIN;
239     else
240         $home = LURL . '/' . $slug;
241     add_option('home', $home);
242     add_option('blogname', __('My Weblog'), __('Blog title'));
243     add_option('blogdescription', __('Just another Lyceum weblog'), __('Short tagline'));
244     add_option('admin_email', 'you@example.com');
245     add_option('start_of_week', 1);
246     add_option('use_balanceTags', 0);
247     add_option('use_smilies', 1);
248     add_option('require_name_email', 1);
249     add_option('comments_notify', 1);
250     add_option('posts_per_rss', 10);
251     add_option('rss_excerpt_length', 50);
252     add_option('rss_use_excerpt', 0);
253     add_option('mailserver_url', 'mail.example.com');
254     add_option('mailserver_login', 'login@example.com');
255     add_option('mailserver_pass', 'password');
256     add_option('mailserver_port', 110);
257     add_option('default_category');
258     add_option('default_comment_status', 'open');
259     add_option('default_ping_status', 'open');
260     add_option('default_pingback_flag', 1);
261     add_option('default_post_edit_rows', 10);
262     add_option('posts_per_page', 10);
263     add_option('what_to_show', 'posts');
264     add_option('date_format', __('F j, Y'));
265     add_option('time_format', __('g:i a'));
266     add_option('links_updated_date_format', __('F j, Y g:i a'));
267     add_option('links_recently_updated_prepend', '<em>');
268     add_option('links_recently_updated_append', '</em>');
269     add_option('links_recently_updated_time', 120);
270     add_option('comment_moderation', 0);
271     add_option('moderation_notify', 1);
272     add_option('permalink_structure', DEFAULT_PS);
273     add_option('hack_file', 0);
274     add_option('blog_charset', 'UTF-8');
275     add_option('moderation_keys');
276     add_option('active_plugins');
277     add_option('category_base');
278     add_option('ping_sites', '');
279     add_option('advanced_edit', 0);
280     add_option('comment_max_links', 2);
281     add_option('gmt_offset', date('Z') / 3600);
282     // 1.5
283     add_option('default_email_category', 1, __('Posts by email go to this category'));
284     add_option('recently_edited');
285     add_option('use_linksupdate', 0);
286     add_option('template', DEFAULT_TEMPLATE);
287     add_option('stylesheet', DEFAULT_STYLESHEET);
288     add_option('comment_whitelist', 1);
289     add_option('page_uris');
290     add_option('blacklist_keys');
291     add_option('comment_registration', 0);
292     add_option('open_proxy_check', 0);
293     add_option('rss_language', 'en');
294     add_option('html_type', 'text/html');
295     // 1.5.1
296     add_option('use_trackback', 0);
297     // 2.0
298     add_option('default_role', 'subscriber');
299     add_option('rich_editing', 'true');
300     // 2.0.1
301 //    populate_roles();
302     
303     // Set up a few options not to load by default
304     $fatoptions = array( 'moderation_keys', 'recently_edited', 'blacklist_keys' );
305     foreach ($fatoptions as $fatoption) :
306         $wpdb->query("UPDATE $wpdb->options SET `autoload` = 'no' WHERE blog='$blog' AND option_name = '$fatoption'");
307     endforeach;
308
309     // Lyceum
310     add_option('default_link_category', 0);
311     add_option('comment_priviliges', 0);
312 }
313
314 function populate_system_options(){
315     global $optiondomain, $wp_db_version, $wp_rewrite;
316     $optiondomain = 'system';
317
318     add_option('siteurl', LURL);
319     add_option('users_can_register', 1);
320     add_option('gzipcompression', 0);
321     add_option('db_version', $wp_db_version);
322     add_option('wp-content_file_path', ABSPATH . "wp-content/blogs/");//lyceum administrator is responsible for creating this directory, and setting its permissions. the permissions of all subdirectories and files will mimick it.
323     add_option('fileupload_base_url', LURL . '/wp-content/blogs/');
324     add_option('email_structure', "/.*/");
325     add_option('admin_ips', $_SERVER['REMOTE_ADDR'].','.$_SERVER['SERVER_ADDR'].',127.0.0.1');
326     add_option('restrict_admin_ip', 0);
327     add_option('active_system_plugins');
328     add_option('blog_charset', 'UTF-8');
329     add_option('html_type', 'text/html');
330     add_option('presentation_tab', 1);
331     add_option('system_admin_email');
332     add_option('import_allowed', 1);
333     add_option('slug_blacklist', 'www,profile,login,register,index, availability,portal,private,readme,wp-atom, wp-blog-header,wp-comments-post,wp-commentsrss2, wp-feed,wp-login,wp-mail,wp-pass,wp-rdf,wp-register,wp-rss,wp-rss2,wp-trackback,xmlrpc');
334     add_option('username_blacklist', 'lyceum,root');
335     add_option('secret', md5(uniqid(microtime())));
336
337     //// this is a little ugly
338     $home_path = get_home_path();
339     //$wp_rewrite->permalink_structure = DEFAULT_PS;
340     $rules = explode("\n", $wp_rewrite->mod_rewrite_rules());
341     insert_with_markers($home_path.'.htaccess', 'Lyceum', $rules);
342     //////////////
343 }
344
345 function populate_roles() {
346     populate_roles_160();   
347 }
348
349 function populate_roles_160() {
350     global $wp_roles;
351
352     // Add roles
353     add_role('administrator', __('Administrator'));
354     add_role('editor', __('Editor'));
355     add_role('author', __('Author'));
356     add_role('contributor', __('Contributor'));
357     add_role('subscriber', __('Subscriber'));
358     
359     // Add caps for Administrator role
360     $role = get_role('administrator');
361     $role->add_cap('switch_themes');
362     $role->add_cap('edit_themes');
363     $role->add_cap('activate_plugins');
364     $role->add_cap('edit_plugins');
365     $role->add_cap('edit_users');
366     $role->add_cap('edit_files');
367     $role->add_cap('manage_options');
368     $role->add_cap('moderate_comments');
369     $role->add_cap('manage_categories');
370     $role->add_cap('manage_links');
371     $role->add_cap('upload_files');
372     $role->add_cap('import');
373     $role->add_cap('unfiltered_html');
374     $role->add_cap('edit_posts');
375     $role->add_cap('edit_others_posts');
376     $role->add_cap('edit_published_posts');
377     $role->add_cap('publish_posts');
378     $role->add_cap('edit_pages');
379     $role->add_cap('read');
380     $role->add_cap('level_10');
381     $role->add_cap('level_9');
382     $role->add_cap('level_8');
383     $role->add_cap('level_7');
384     $role->add_cap('level_6');
385     $role->add_cap('level_5');
386     $role->add_cap('level_4');
387     $role->add_cap('level_3');
388     $role->add_cap('level_2');
389     $role->add_cap('level_1');
390     $role->add_cap('level_0');
391     
392     // Add caps for Editor role
393     $role = get_role('editor');
394     $role->add_cap('moderate_comments');
395     $role->add_cap('manage_categories');
396     $role->add_cap('manage_links');
397     $role->add_cap('upload_files');
398     $role->add_cap('unfiltered_html');
399     $role->add_cap('edit_posts');
400     $role->add_cap('edit_others_posts');
401     $role->add_cap('edit_published_posts');
402     $role->add_cap('publish_posts');
403     $role->add_cap('edit_pages');
404     $role->add_cap('read');
405     $role->add_cap('level_7');
406     $role->add_cap('level_6');
407     $role->add_cap('level_5');
408     $role->add_cap('level_4');
409     $role->add_cap('level_3');
410     $role->add_cap('level_2');
411     $role->add_cap('level_1');
412     $role->add_cap('level_0');
413     
414     // Add caps for Author role
415     $role = get_role('author');
416     $role->add_cap('upload_files');
417     $role->add_cap('edit_posts');
418     $role->add_cap('edit_published_posts');
419     $role->add_cap('publish_posts');
420     $role->add_cap('read');
421     $role->add_cap('level_2');
422     $role->add_cap('level_1');
423     $role->add_cap('level_0');
424     
425     // Add caps for Contributor role
426     $role = get_role('contributor');
427     $role->add_cap('edit_posts');
428     $role->add_cap('read');
429     $role->add_cap('level_1');
430     $role->add_cap('level_0');
431     
432     // Add caps for Subscriber role
433     $role = get_role('subscriber');
434     $role->add_cap('read');
435     $role->add_cap('level_0');
436 }
437
438 ?>
439
Note: See TracBrowser for help on using the browser.
Log in with username/password: lyceum/lyceum