Log in with username/password: lyceum/lyceum

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

Revision 613, 15.5 kB (checked in by jjb, 4 years ago)

slugs!

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