]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/upgrade-schema.php
1bcdb45a218b6d97bc00ba2adf818b38bdb15f55
[autoinstalls/wordpress.git] / wp-admin / upgrade-schema.php
1 <?php
2 // Here we keep the DB structure and option values
3
4 $wp_queries="CREATE TABLE $wpdb->categories (
5   cat_ID bigint(20) 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 bigint(20) NOT NULL default '0',
10   category_count bigint(20) NOT NULL default '0',
11   PRIMARY KEY  (cat_ID),
12   KEY category_nicename (category_nicename)
13 );
14 CREATE TABLE $wpdb->comments (
15   comment_ID bigint(20) unsigned NOT NULL auto_increment,
16   comment_post_ID int(11) NOT NULL default '0',
17   comment_author tinytext NOT NULL,
18   comment_author_email varchar(100) NOT NULL default '',
19   comment_author_url varchar(200) NOT NULL default '',
20   comment_author_IP varchar(100) NOT NULL default '',
21   comment_date datetime NOT NULL default '0000-00-00 00:00:00',
22   comment_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
23   comment_content text NOT NULL,
24   comment_karma int(11) NOT NULL default '0',
25   comment_approved enum('0','1','spam') NOT NULL default '1',
26   comment_agent varchar(255) NOT NULL default '',
27   comment_type varchar(20) NOT NULL default '',
28   comment_parent bigint(20) NOT NULL default '0',
29   user_id bigint(20) NOT NULL default '0',
30   PRIMARY KEY  (comment_ID),
31   KEY comment_approved (comment_approved),
32   KEY comment_post_ID (comment_post_ID)
33 );
34 CREATE TABLE $wpdb->linkcategories (
35   cat_id bigint(20) NOT NULL auto_increment,
36   cat_name tinytext NOT NULL,
37   auto_toggle enum('Y','N') NOT NULL default 'N',
38   show_images enum('Y','N') NOT NULL default 'Y',
39   show_description enum('Y','N') NOT NULL default 'N',
40   show_rating enum('Y','N') NOT NULL default 'Y',
41   show_updated enum('Y','N') NOT NULL default 'Y',
42   sort_order varchar(64) NOT NULL default 'rand',
43   sort_desc enum('Y','N') NOT NULL default 'N',
44   text_before_link varchar(128) NOT NULL default '<li>',
45   text_after_link varchar(128) NOT NULL default '<br />',
46   text_after_all varchar(128) NOT NULL default '</li>',
47   list_limit int(11) NOT NULL default '-1',
48   PRIMARY KEY  (cat_id)
49 );
50 CREATE TABLE $wpdb->links (
51   link_id bigint(20) NOT NULL auto_increment,
52   link_url varchar(255) NOT NULL default '',
53   link_name varchar(255) NOT NULL default '',
54   link_image varchar(255) NOT NULL default '',
55   link_target varchar(25) NOT NULL default '',
56   link_category bigint(20) NOT NULL default '0',
57   link_description varchar(255) NOT NULL default '',
58   link_visible enum('Y','N') NOT NULL default 'Y',
59   link_owner int(11) NOT NULL default '1',
60   link_rating int(11) NOT NULL default '0',
61   link_updated datetime NOT NULL default '0000-00-00 00:00:00',
62   link_rel varchar(255) NOT NULL default '',
63   link_notes mediumtext NOT NULL,
64   link_rss varchar(255) NOT NULL default '',
65   PRIMARY KEY  (link_id),
66   KEY link_category (link_category),
67   KEY link_visible (link_visible)
68 );
69 CREATE TABLE $wpdb->options (
70   option_id bigint(20) NOT NULL auto_increment,
71   blog_id int(11) NOT NULL default '0',
72   option_name varchar(64) NOT NULL default '',
73   option_can_override enum('Y','N') NOT NULL default 'Y',
74   option_type int(11) NOT NULL default '1',
75   option_value longtext NOT NULL,
76   option_width int(11) NOT NULL default '20',
77   option_height int(11) NOT NULL default '8',
78   option_description tinytext NOT NULL,
79   option_admin_level int(11) NOT NULL default '1',
80   autoload enum('yes','no') NOT NULL default 'yes',
81   PRIMARY KEY  (option_id,blog_id,option_name),
82   KEY option_name (option_name)
83 );
84 CREATE TABLE $wpdb->post2cat (
85   rel_id bigint(20) NOT NULL auto_increment,
86   post_id bigint(20) NOT NULL default '0',
87   category_id bigint(20) NOT NULL default '0',
88   PRIMARY KEY  (rel_id),
89   KEY post_id (post_id,category_id)
90 );
91 CREATE TABLE $wpdb->postmeta (
92   meta_id bigint(20) NOT NULL auto_increment,
93   post_id bigint(20) NOT NULL default '0',
94   meta_key varchar(255) default NULL,
95   meta_value longtext,
96   PRIMARY KEY  (meta_id),
97   KEY post_id (post_id),
98   KEY meta_key (meta_key)
99 );
100 CREATE TABLE $wpdb->posts (
101   ID bigint(20) unsigned NOT NULL auto_increment,
102   post_author bigint(20) NOT NULL default '0',
103   post_date datetime NOT NULL default '0000-00-00 00:00:00',
104   post_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
105   post_content longtext NOT NULL,
106   post_title text NOT NULL,
107   post_category int(4) NOT NULL default '0',
108   post_excerpt text NOT NULL,
109   post_status enum('publish','draft','private','static','object','attachment') NOT NULL default 'publish',
110   comment_status enum('open','closed','registered_only') NOT NULL default 'open',
111   ping_status enum('open','closed') NOT NULL default 'open',
112   post_password varchar(20) NOT NULL default '',
113   post_name varchar(200) NOT NULL default '',
114   to_ping text NOT NULL,
115   pinged text NOT NULL,
116   post_modified datetime NOT NULL default '0000-00-00 00:00:00',
117   post_modified_gmt datetime NOT NULL default '0000-00-00 00:00:00',
118   post_content_filtered text NOT NULL,
119   post_parent bigint(20) NOT NULL default '0',
120   guid varchar(255) NOT NULL default '',
121   menu_order int(11) NOT NULL default '0',
122   post_type varchar(100) NOT NULL default '',
123   post_mime_type varchar(100) NOT NULL default '',
124   comment_count bigint(20) NOT NULL default '0',
125   PRIMARY KEY  (ID),
126   KEY post_name (post_name)
127 );
128 CREATE TABLE $wpdb->users (
129   ID bigint(20) unsigned NOT NULL auto_increment,
130   user_login varchar(60) NOT NULL default '',
131   user_pass varchar(64) NOT NULL default '',
132   user_nicename varchar(50) NOT NULL default '',
133   user_email varchar(100) NOT NULL default '',
134   user_url varchar(100) NOT NULL default '',
135   user_registered datetime NOT NULL default '0000-00-00 00:00:00',
136   user_activation_key varchar(60) NOT NULL default '',
137   user_status int(11) NOT NULL default '0',
138   display_name varchar(250) NOT NULL default '',
139   PRIMARY KEY  (ID),
140   KEY user_login_key (user_login)
141 );
142 CREATE TABLE $wpdb->usermeta (
143   umeta_id bigint(20) NOT NULL auto_increment,
144   user_id bigint(20) NOT NULL default '0',
145   meta_key varchar(255) default NULL,
146   meta_value longtext,
147   PRIMARY KEY  (umeta_id),
148   KEY user_id (user_id),
149   KEY meta_key (meta_key)
150 );";
151
152 function populate_options() {
153         global $wpdb, $wp_db_version;
154
155         $schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
156         $guessurl = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
157         add_option('siteurl', $guessurl, __('WordPress web address'));
158         add_option('blogname', __('My Weblog'), __('Blog title'));
159         add_option('blogdescription', __('Just another WordPress weblog'), __('Short tagline'));
160         add_option('new_users_can_blog', 0);
161         add_option('users_can_register', 0);
162         add_option('admin_email', 'you@example.com');
163         add_option('start_of_week', 1);
164         add_option('use_balanceTags', 0);
165         add_option('use_smilies', 1);
166         add_option('require_name_email', 1);
167         add_option('comments_notify', 1);
168         add_option('posts_per_rss', 10);
169         add_option('rss_excerpt_length', 50);
170         add_option('rss_use_excerpt', 0);
171         add_option('mailserver_url', 'mail.example.com');
172         add_option('mailserver_login', 'login@example.com');
173         add_option('mailserver_pass', 'password');
174         add_option('mailserver_port', 110);
175         add_option('default_category', 1);
176         add_option('default_comment_status', 'open');
177         add_option('default_ping_status', 'open');
178         add_option('default_pingback_flag', 1);
179         add_option('default_post_edit_rows', 10);
180         add_option('posts_per_page', 10);
181         add_option('what_to_show', 'posts');
182         add_option('date_format', __('F j, Y'));
183         add_option('time_format', __('g:i a'));
184         add_option('links_updated_date_format', __('F j, Y g:i a'));
185         add_option('links_recently_updated_prepend', '<em>');
186         add_option('links_recently_updated_append', '</em>');
187         add_option('links_recently_updated_time', 120);
188         add_option('comment_moderation', 0);
189         add_option('moderation_notify', 1);
190         add_option('permalink_structure');
191         add_option('gzipcompression', 0);
192         add_option('hack_file', 0);
193         add_option('blog_charset', 'UTF-8');
194         add_option('moderation_keys');
195         add_option('active_plugins');
196         add_option('home', $guessurl);
197         // in case it is set, but blank, update "home"
198         if ( !__get_option('home') ) update_option('home', $guessurl);
199         add_option('category_base');
200         add_option('ping_sites', 'http://rpc.pingomatic.com/');
201         add_option('advanced_edit', 0);
202         add_option('comment_max_links', 2);
203         add_option('gmt_offset', date('Z') / 3600);
204         // 1.5
205         add_option('default_email_category', 1, __('Posts by email go to this category'));
206         add_option('recently_edited');
207         add_option('use_linksupdate', 0);
208         add_option('template', 'default');
209         add_option('stylesheet', 'default');
210         add_option('comment_whitelist', 1);
211         add_option('page_uris');
212         add_option('blacklist_keys');
213         add_option('comment_registration', 0);
214         add_option('open_proxy_check', 0);
215         add_option('rss_language', 'en');
216         add_option('html_type', 'text/html');
217         // 1.5.1
218         add_option('use_trackback', 0);
219         // 2.0
220         add_option('default_role', 'subscriber');
221         add_option('rich_editing', 'true');
222         add_option('db_version', $wp_db_version);
223         // 2.0.1
224         if ( ini_get('safe_mode') ) {
225                 // Safe mode screws up mkdir(), so we must use a flat structure.
226                 add_option('uploads_use_yearmonth_folders', 0);
227                 add_option('upload_path', 'wp-content');
228         } else {
229                 add_option('uploads_use_yearmonth_folders', 1);
230                 add_option('upload_path', 'wp-content/uploads');
231         }
232         
233         // 2.0.3
234         add_option('secret', md5(uniqid(microtime())));
235
236         // Delete unused options
237         $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog');
238         foreach ($unusedoptions as $option) :
239                 delete_option($option);
240         endforeach;
241
242         // Set up a few options not to load by default
243         $fatoptions = array( 'moderation_keys', 'recently_edited', 'blacklist_keys' );
244         foreach ($fatoptions as $fatoption) :
245                 $wpdb->query("UPDATE $wpdb->options SET `autoload` = 'no' WHERE option_name = '$fatoption'");
246         endforeach;
247 }
248
249 function populate_roles() {
250         populate_roles_160();   
251 }
252
253 function populate_roles_160() {
254         global $wp_roles;
255
256         // Add roles
257         add_role('administrator', __('Administrator'));
258         add_role('editor', __('Editor'));
259         add_role('author', __('Author'));
260         add_role('contributor', __('Contributor'));
261         add_role('subscriber', __('Subscriber'));
262         
263         // Add caps for Administrator role
264         $role = get_role('administrator');
265         $role->add_cap('switch_themes');
266         $role->add_cap('edit_themes');
267         $role->add_cap('activate_plugins');
268         $role->add_cap('edit_plugins');
269         $role->add_cap('edit_users');
270         $role->add_cap('edit_files');
271         $role->add_cap('manage_options');
272         $role->add_cap('moderate_comments');
273         $role->add_cap('manage_categories');
274         $role->add_cap('manage_links');
275         $role->add_cap('upload_files');
276         $role->add_cap('import');
277         $role->add_cap('unfiltered_html');
278         $role->add_cap('edit_posts');
279         $role->add_cap('edit_others_posts');
280         $role->add_cap('edit_published_posts');
281         $role->add_cap('publish_posts');
282         $role->add_cap('edit_pages');
283         $role->add_cap('read');
284         $role->add_cap('level_10');
285         $role->add_cap('level_9');
286         $role->add_cap('level_8');
287         $role->add_cap('level_7');
288         $role->add_cap('level_6');
289         $role->add_cap('level_5');
290         $role->add_cap('level_4');
291         $role->add_cap('level_3');
292         $role->add_cap('level_2');
293         $role->add_cap('level_1');
294         $role->add_cap('level_0');
295         
296         // Add caps for Editor role
297         $role = get_role('editor');
298         $role->add_cap('moderate_comments');
299         $role->add_cap('manage_categories');
300         $role->add_cap('manage_links');
301         $role->add_cap('upload_files');
302         $role->add_cap('unfiltered_html');
303         $role->add_cap('edit_posts');
304         $role->add_cap('edit_others_posts');
305         $role->add_cap('edit_published_posts');
306         $role->add_cap('publish_posts');
307         $role->add_cap('edit_pages');
308         $role->add_cap('read');
309         $role->add_cap('level_7');
310         $role->add_cap('level_6');
311         $role->add_cap('level_5');
312         $role->add_cap('level_4');
313         $role->add_cap('level_3');
314         $role->add_cap('level_2');
315         $role->add_cap('level_1');
316         $role->add_cap('level_0');
317         
318         // Add caps for Author role
319         $role = get_role('author');
320         $role->add_cap('upload_files');
321         $role->add_cap('edit_posts');
322         $role->add_cap('edit_published_posts');
323         $role->add_cap('publish_posts');
324         $role->add_cap('read');
325         $role->add_cap('level_2');
326         $role->add_cap('level_1');
327         $role->add_cap('level_0');
328         
329         // Add caps for Contributor role
330         $role = get_role('contributor');
331         $role->add_cap('edit_posts');
332         $role->add_cap('read');
333         $role->add_cap('level_1');
334         $role->add_cap('level_0');
335         
336         // Add caps for Subscriber role
337         $role = get_role('subscriber');
338         $role->add_cap('read');
339         $role->add_cap('level_0');
340 }
341
342 ?>