PluginProbe
wpForo Forum / 1.0.2
wpForo Forum v1.0.2
3.1.6 3.1.5 3.1.4 3.1.2 3.1.1 3.1.0 3.0.9 3.0.8 3.0.7 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 All 138 releases
wpforo / wpf-includes / functions-installation.php

functions-installation.php in wpForo Forum 1.0.2, at wpf-includes/functions-installation.php

662 lines 30.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // Exit if accessed directly
3 if( !defined( 'ABSPATH' ) ) exit;
4
5
6 function wpforo_activation(){
7
8 global $wpforo;
9 if( ! is_admin() ) return;
10 if( ! current_user_can( 'activate_plugins' ) ) return;
11 add_option('wpforo_default_groupid', 3);
12 require( WPFORO_DIR . '/wpf-includes/install-sql.php' );
13 foreach( $wpforo_sql as $sql ) @$wpforo->db->query( $sql );
14 $wpforo->member->synchronize_users();
15 $wpforo->member->init_current_user();
16 $blogname = get_option('blogname');
17 $adminemail = get_option('admin_email');
18 add_option( 'wpforo_count_per_page', 10 );
19
20 ###################################################################
21 // General Options ////////////////////////////////////////////////
22 $general_options = array(
23 'title' => $blogname . ' ' . __('Forum', 'wpforo'),
24 'description' => $blogname . ' ' . __('Discussion Board', 'wpforo'),
25 'lang' => 1,
26 );
27 wpforo_update_options( 'wpforo_general_options', $general_options );
28
29 ###################################################################
30 // Forums /////////////////////////////////////////////////////////
31 $wpforo_forum = array(
32 'layout_qa_intro_topics_toggle' => 1,
33 'layout_extended_intro_topics_toggle' => 1,
34 'layout_qa_intro_topics_count' => 3,
35 'layout_extended_intro_topics_count' => 5,
36 );
37 wpforo_update_options( 'wpforo_forum_options', $wpforo_forum );
38
39 ##################################################################
40 // Topics & Posts ////////////////////////////////////////////////
41 $upload_max_filesize = @ini_get('upload_max_filesize');
42 $upload_max_filesize = wpforo_human_size_to_bytes($upload_max_filesize);
43 if( !$upload_max_filesize || $upload_max_filesize > 10485760 ) $upload_max_filesize = 10485760;
44 $wpforo_post = array(
45 'layout_extended_intro_posts_toggle' => 1,
46 'layout_extended_intro_posts_count' => 4,
47 'topics_per_page' => 10,
48 'eot_durr' => 300,
49 'dot_durr' => 300,
50 'posts_per_page' => 15,
51 'eor_durr' => 300,
52 'dor_durr' => 300,
53 'max_upload_size' => $upload_max_filesize
54 );
55 wpforo_update_options( 'wpforo_post_options', $wpforo_post );
56
57 #################################################################
58 // Features /////////////////////////////////////////////////////
59 $wpforo_features = array(
60 'user-admin-bar' => 0,
61 'page-title' => 1,
62 'top-bar' => 1,
63 'top-bar-search' => 1,
64 'breadcrumb' => 1,
65 'footer-stat' => 1,
66 'author-link' => 0,
67 'comment-author-link' => 0,
68 'user-register' => 1,
69 'register-url' => 0,
70 'login-url' => 0,
71 'replace-avatar' => 1,
72 'avatars' => 1,
73 'custom-avatars' => 1,
74 'signature' => 1,
75 'rating' => 1,
76 'rating_title' => 1,
77 'member_cashe' => 1,
78 'seo-title' => 1,
79 'seo-meta' => 1,
80 'font-awesome' => 1,
81 'output-buffer' => 0,
82 'wp-date-format' => 0,
83 'subscribe_conf' => 1,
84 'attach-media-lib' => 1,
85 'debug-mode' => 0,
86 'copyright' => 1
87 );
88 wpforo_update_options( 'wpforo_features', $wpforo_features );
89
90 #################################################################
91 // Theme & Style ////////////////////////////////////////////////
92 $wpforo_style = array(
93 'font_size_forum' => 17,
94 'font_size_topic' => 16,
95 'font_size_post_content' => 14,
96 'custom_css' => "#wpforo-wrap {\r\n font-size: 13px; width: 100%; padding:10px 20px; margin:0px;\r\n}\r\n",
97 );
98 wpforo_update_options( 'wpforo_style_options', $wpforo_style );
99
100 $defaut_theme = 'classic';
101 $theme = $wpforo->tpl->find_theme( $defaut_theme );
102 $current_theme = get_option( 'wpforo_theme_options' );
103 if(!empty($current_theme)) {
104 $theme = wpforo_deep_merge($theme, $current_theme);
105 update_option( 'wpforo_theme_options', $theme );
106 }
107 add_option( 'wpforo_theme_options', $theme );
108
109 #################################################################
110 // Members //////////////////////////////////////////////////////
111 $wpforo_member = array(
112 'online_status_timeout' => 240,
113 'url_structure' => 'nicename',
114 'login_url' => '',
115 'register_url' => '',
116 'lost_password_url' => '',
117 'rating_title_ug' => array ( 1 => '1', 5 => '1', 4 => '1', 2 => '1', 3 => '1' ),
118 'rating_badge_ug' => array ( 1 => '1', 5 => '1', 4 => '1', 2 => '1', 3 => '1' ),
119 );
120 $exlude = array('rating_title_ug', 'rating_badge_ug');
121 wpforo_update_options( 'wpforo_member_options', $wpforo_member, $exlude);
122
123 #################################################################
124 // Subscribe Options ////////////////////////////////////////////
125 $subscriptions_options = array (
126 'from_name' => $blogname . ' - Forum',
127 'from_email' => $adminemail,
128 'admin_emails' => $adminemail,
129 'confirmation_email_subject' => "Please confirm subscription to [entry_title]",
130 'confirmation_email_message' => "Hello [member_name]!<br>\r\n Thank you for subscribing.<br>\r\n This is an automated response.<br>\r\n We are glad to inform you that after confirmation you will get updates from - [entry_title].<br>\r\n Please click on link below to complete this step.<br>\r\n [confirm_link]" ,
131 'new_topic_notification_email_subject' => "New Topic" ,
132 'new_topic_notification_email_message' => "Hello [member_name]!<br>\r\n New topic has been created on your subscribed forum - [forum].\r\n <br><br>\r\n <strong>[topic_title]</strong>\r\n <blockquote>\r\n [topic_desc]\r\n </blockquote>\r\n <br><hr>\r\n If you want to unsubscribe from this forum please use the link below.<br>\r\n [unsubscribe_link]" ,
133 'new_post_notification_email_subject' => "New Reply" ,
134 'new_post_notification_email_message' => "Hello [member_name]!<br>\r\n New reply has been posted on your subscribed topic - [topic].\r\n <br><br>\r\n <strong>[reply_title]</strong>\r\n <blockquote >\r\n [reply_desc]\r\n </blockquote>\r\n <br><hr>\r\n If you want to unsubscribe from this topic please use the link below.<br>\r\n [unsubscribe_link]" ,
135 'report_email_subject' => "Forum Post Report",
136 'report_email_message' => "<strong>Report details:</strong>\r\n Reporter: [reporter], <br>\r\n Message: [message],<br>\r\n <br>\r\n [post_url]",
137 'update' => '1'
138 );
139 wpforo_update_options( 'wpforo_subscribe_options', $subscriptions_options );
140
141 #################################################################
142 // Countries ////////////////////////////////////////////////////
143 $countries = array( "Afghanistan","�
144 land Islands","Albania","Algeria","American Samoa","Andorra","Angola","Anguilla","Antarctica",
145 "Antigua and Barbuda","Argentina","Armenia","Aruba","Australia","Austria","Azerbaijan","Bahamas","Bahrain",
146 "Bangladesh","Barbados","Belarus","Belgium","Belize","Benin","Bermuda","Bhutan","Bolivia","Bosnia and Herzegovina",
147 "Botswana","Bouvet Island","Brazil","British Indian Ocean Territory","Brunei Darussalam","Bulgaria","Burkina Faso",
148 "Burundi","Cambodia","Cameroon","Canada","Cape Verde","Cayman Islands","Central African Republic","Chad","Chile",
149 "China","Christmas Island","Cocos (Keeling) Islands","Colombia","Comoros","Congo","Congo, The Democratic Republic of The",
150 "Cook Islands","Costa Rica","Cote D'ivoire","Croatia","Cuba","Cyprus","Czech Republic","Denmark","Djibouti","Dominica",
151 "Dominican Republic","Ecuador","Egypt","El Salvador","Equatorial Guinea","Eritrea","Estonia","Ethiopia","Falkland Islands (Malvinas)",
152 "Faroe Islands","Fiji","Finland","France","French Guiana","French Polynesia","French Southern Territories","Gabon",
153 "Gambia","Georgia","Germany","Ghana","Gibraltar","Greece","Greenland","Grenada","Guadeloupe","Guam","Guatemala",
154 "Guernsey","Guinea","Guinea-bissau","Guyana","Haiti","Heard Island and Mcdonald Islands","Holy See (Vatican City State)",
155 "Honduras","Hong Kong","Hungary","Iceland","India","Indonesia","Iran, Islamic Republic of","Iraq","Ireland",
156 "Isle of Man","Israel","Italy","Jamaica","Japan","Jersey","Jordan","Kazakhstan","Kenya","Kiribati","Korea, Democratic People's Republic of",
157 "Korea, Republic of","Kuwait","Kyrgyzstan","Lao People's Democratic Republic","Latvia","Lebanon","Lesotho","Liberia",
158 "Libyan Arab Jamahiriya","Liechtenstein","Lithuania","Luxembourg","Macao","Macedonia, The Former Yugoslav Republic of",
159 "Madagascar","Malawi","Malaysia","Maldives","Mali","Malta","Marshall Islands","Martinique","Mauritania","Mauritius",
160 "Mayotte","Mexico","Micronesia, Federated States of","Moldova, Republic of","Monaco","Mongolia","Montenegro","Montserrat",
161 "Morocco","Mozambique","Myanmar","Namibia","Nauru","Nepal","Netherlands","Netherlands Antilles","New Caledonia",
162 "New Zealand","Nicaragua","Niger","Nigeria","Niue","Norfolk Island","Northern Mariana Islands","Norway","Oman",
163 "Pakistan","Palau","Palestinian Territory, Occupied","Panama","Papua New Guinea","Paraguay","Peru","Philippines",
164 "Pitcairn","Poland","Portugal","Puerto Rico","Qatar","Reunion","Romania","Russian Federation","Rwanda","Saint Helena",
165 "Saint Kitts and Nevis","Saint Lucia","Saint Pierre and Miquelon","Saint Vincent and The Grenadines","Samoa",
166 "San Marino","Sao Tome and Principe","Saudi Arabia","Senegal","Serbia","Seychelles","Sierra Leone","Singapore",
167 "Slovakia","Slovenia","Solomon Islands","Somalia","South Africa","South Georgia and The South Sandwich Islands",
168 "Spain","Sri Lanka","Sudan","Suriname","Svalbard and Jan Mayen","Swaziland","Sweden","Switzerland","Syrian Arab Republic",
169 "Taiwan, Province of China","Tajikistan","Tanzania, United Republic of","Thailand","Timor-leste","Togo","Tokelau",
170 "Tonga","Trinidad and Tobago","Tunisia","Turkey","Turkmenistan","Turks and Caicos Islands","Tuvalu","Uganda","Ukraine",
171 "United Arab Emirates","United Kingdom","United States","United States Minor Outlying Islands","Uruguay","Uzbekistan",
172 "Vanuatu","Venezuela","Viet Nam","Virgin Islands, British","Virgin Islands, U.S.","Wallis and Futuna","Western Sahara",
173 "Yemen","Zambia","Zimbabwe" );
174
175 add_option( 'wpforo_countries', $countries );
176
177 #################################################################
178 // Forum Navigation and Menu ////////////////////////////////////
179 $menu_name = wpforo_phrase('wpForo Navigation', false, 'orig');
180 $menu_location = 'wpforo-menu';
181 $menu_exists = wp_get_nav_menu_object( $menu_name );
182 if(!$menu_exists){
183 $id = array();
184 $menu_id = wp_create_nav_menu($menu_name);
185 $id['wpforo-home'] = wp_update_nav_menu_item($menu_id, 0, array(
186 'menu-item-title' => wpforo_phrase('Forums', false),
187 'menu-item-classes' => 'wpforo-home',
188 'menu-item-url' => '/%wpforo-home%/',
189 'menu-item-status' => 'publish',
190 'menu-item-parent-id' => 0,
191 'menu-item-position' => 0));
192
193 $id['wpforo-members'] = wp_update_nav_menu_item($menu_id, 0, array(
194 'menu-item-title' => wpforo_phrase('Members', false),
195 'menu-item-classes' => 'wpforo-members',
196 'menu-item-url' => '/%wpforo-members%/',
197 'menu-item-status' => 'publish',
198 'menu-item-parent-id' => 0,
199 'menu-item-position' => 0));
200
201 $id['wpforo-profile'] = wp_update_nav_menu_item($menu_id, 0, array(
202 'menu-item-title' => wpforo_phrase('My Profile', false),
203 'menu-item-classes' => 'wpforo-profile',
204 'menu-item-url' => '/%wpforo-profile-home%/',
205 'menu-item-status' => 'publish',
206 'menu-item-parent-id' => 0,
207 'menu-item-position' => 0));
208
209 if(isset($id['wpforo-profile']) && $id['wpforo-profile']){
210 $id['wpforo-profile-account'] = wp_update_nav_menu_item($menu_id, 0, array(
211 'menu-item-title' => wpforo_phrase('Account', false),
212 'menu-item-classes' => 'wpforo-profile-account',
213 'menu-item-url' => '/%wpforo-profile-account%/',
214 'menu-item-status' => 'publish',
215 'menu-item-parent-id' => $id['wpforo-profile'],
216 'menu-item-position' => 1)
217 );
218 $id['wpforo-profile-activity'] = wp_update_nav_menu_item($menu_id, 0, array(
219 'menu-item-title' => wpforo_phrase('Activity', false),
220 'menu-item-classes' => 'wpforo-profile-activity',
221 'menu-item-url' => '/%wpforo-profile-activity%/',
222 'menu-item-status' => 'publish',
223 'menu-item-parent-id' => $id['wpforo-profile'],
224 'menu-item-position' => 1)
225 );
226 $id['wpforo-profile-subscriptions'] = wp_update_nav_menu_item($menu_id, 0, array(
227 'menu-item-title' => wpforo_phrase('Subscriptions', false),
228 'menu-item-classes' => 'wpforo-profile-subscriptions',
229 'menu-item-url' => '/%wpforo-profile-subscriptions%/',
230 'menu-item-status' => 'publish',
231 'menu-item-parent-id' => $id['wpforo-profile'],
232 'menu-item-position' => 2)
233 );
234 }
235
236 $id['wpforo-register'] = wp_update_nav_menu_item($menu_id, 0, array(
237 'menu-item-title' => wpforo_phrase('Register', false),
238 'menu-item-classes' => 'wpforo-register',
239 'menu-item-url' => '/%wpforo-register%/',
240 'menu-item-status' => 'publish',
241 'menu-item-parent-id' => 0,
242 'menu-item-position' => 0));
243
244 $id['wpforo-login'] = wp_update_nav_menu_item($menu_id, 0, array(
245 'menu-item-title' => wpforo_phrase('Login', false),
246 'menu-item-classes' => 'wpforo-login',
247 'menu-item-url' => '/%wpforo-login%/',
248 'menu-item-status' => 'publish',
249 'menu-item-parent-id' => 0,
250 'menu-item-position' => 0));
251
252 $id['wpforo-logout'] = wp_update_nav_menu_item($menu_id, 0, array(
253 'menu-item-title' => wpforo_phrase('Logout', false),
254 'menu-item-classes' => 'wpforo-logout',
255 'menu-item-url' => '/%wpforo-logout%/',
256 'menu-item-status' => 'publish',
257 'menu-item-parent-id' => 0,
258 'menu-item-position' => 0));
259
260 if( !has_nav_menu( $menu_location ) ){
261 $locations = get_theme_mod('nav_menu_locations');
262 if(empty($locations)) $locations = array();
263 $locations[$menu_location] = $menu_id;
264 set_theme_mod( 'nav_menu_locations', $locations );
265 }
266 }
267
268 #################################################################
269 // Forum Access Array ///////////////////////////////////////////
270 $forum_cans = array (
271 'vf' => 'Can view forum',
272 'ct' => 'Can create topic',
273 'vt' => 'Can view topic',
274 'et' => 'Can edit topic',
275 'dt' => 'Can delete topic',
276 'cr' => 'Can post reply',
277 'vr' => 'Can view replies',
278 'er' => 'Can edit replies',
279 'dr' => 'Can delete replies',
280 'eot' => 'Can edit own topic',
281 'eor' => 'Can edit own replay',
282 'dot' => 'Can delete own topic',
283 'dor' => 'Can delete own replay',
284 'l' => 'Can like',
285 'r' => 'Can report',
286 's' => 'Can make topic sticky',
287 'sv' => 'Can make topic solved',
288 'osv' => 'Can make own topic solved',
289 'v' => 'Can vote',
290 'a' => 'Can Attach File',
291 'at' => 'Can make topic answered',
292 'oat' => 'Can make own topic answered',
293 'cot' => 'Can close topic',
294 'mt' => 'Can move topic'
295 );
296 wpforo_update_options( 'wpforo_forum_cans', $forum_cans);
297
298 #################################################################
299 // Access Sets //////////////////////////////////////////////////
300 $cans_n = array('vf' => 0, 'ct' => 0, 'vt' => 0, 'et' => 0, 'dt' => 0,
301 'cr' => 0, 'vr' => 0, 'er' => 0, 'dr' => 0,
302 'eot' => 0, 'eor' => 0, 'dot' => 0, 'dor' => 0,
303 'l' => 0, 'r' => 0, 's' => 0, 'sv' => 0, 'osv' => 0, 'v' => 0, 'a' => 0,
304 'at' => 0, 'oat' => 0, 'cot' => 0, 'mt' => 0);
305 $cans_r = array('vf' => 1, 'ct' => 0, 'vt' => 1, 'et' => 0, 'dt' => 0,
306 'cr' => 0, 'vr' => 1, 'er' => 0, 'dr' => 0,
307 'eot' => 0, 'eor' => 0, 'dot' => 0, 'dor' => 0,
308 'l' => 0, 'r' => 0, 's' => 0, 'sv' => 0, 'osv' => 0, 'v' => 0, 'a' => 0,
309 'at' => 0, 'oat' => 0, 'cot' => 0, 'mt' => 0);
310 $cans_s = array('vf' => 1, 'ct' => 1, 'vt' => 1, 'et' => 0, 'dt' => 0,
311 'cr' => 1, 'vr' => 1, 'er' => 0, 'dr' => 0,
312 'eot' => 1, 'eor' => 1, 'dot' => 1, 'dor' => 1,
313 'l' => 1, 'r' => 1, 's' => 0, 'sv' => 0, 'osv' => 1, 'v' => 1, 'a' => 1,
314 'at' => 0, 'oat' => 1, 'cot' => 0, 'mt' => 0);
315 $cans_m = array('vf' => 1, 'ct' => 1, 'vt' => 1, 'et' => 1, 'dt' => 1,
316 'cr' => 1, 'vr' => 1, 'er' => 1, 'dr' => 1,
317 'eot' => 1, 'eor' => 1, 'dot' => 1, 'dor' => 1,
318 'l' => 1, 'r' => 1, 's' => 1, 'sv' => 1, 'osv' => 1, 'v' => 1, 'a' => 1,
319 'at' => 1, 'oat' => 1, 'cot' => 1, 'mt' => 1);
320 $cans_a = array('vf' => 1, 'ct' => 1, 'vt' => 1, 'et' => 1, 'dt' => 1,
321 'cr' => 1, 'vr' => 1, 'er' => 1, 'dr' => 1,
322 'eot' => 1, 'eor' => 1, 'dot' => 1, 'dor' => 1,
323 'l' => 1, 'r' => 1, 's' => 1, 'sv' => 1, 'osv' => 1, 'v' => 1, 'a' => 1,
324 'at' => 1, 'oat' => 1, 'cot' => 1, 'mt' => 1);
325
326 $sql = "SELECT * FROM `".$wpforo->db->prefix."wpforo_accesses`";
327 $accesses = $wpforo->db->get_results($sql, ARRAY_A);
328 if( empty($accesses) ){
329
330 $cans_n = serialize($cans_n);
331 $cans_r = serialize($cans_r);
332 $cans_s = serialize($cans_s);
333 $cans_m = serialize($cans_m);
334 $cans_a = serialize($cans_a);
335
336 $sql = "INSERT IGNORE INTO `".$wpforo->db->prefix."wpforo_accesses`
337 (`access`, `title`, cans) VALUES
338 ('no_access', 'No access', '". $cans_n ."'),
339 ('read_only', 'Read only access', '". $cans_r ."'),
340 ('standard', 'Standard access', '". $cans_s ."'),
341 ('moderator', 'Moderator access', '".$cans_m."'),
342 ('full', 'Full access', '".$cans_a."')";
343
344 $wpforo->db->query( $sql );
345 }
346 else{
347 foreach($accesses as $access){
348 $default = array();
349 $data_update = array();
350 $current = unserialize($access['cans']);
351 if( strtolower($access['access']) == 'no_access' ) $default = $cans_n;
352 elseif( strtolower($access['access']) == 'read_only' ) $default = $cans_r;
353 elseif( strtolower($access['access']) == 'standard' ) $default = $cans_s;
354 elseif( strtolower($access['access']) == 'moderator' ) $default = $cans_m;
355 elseif( strtolower($access['access']) == 'full' ) $default = $cans_a;
356 if( !empty($default) ){
357 $data_update = array_merge($default, $current);
358 if( !empty($data_update) ){
359 $data_update = serialize($data_update);
360 $wpforo->db->query("UPDATE `".$wpforo->db->prefix."wpforo_accesses` SET `cans` = '" . $wpforo->db->_real_escape($data_update) . "' WHERE `accessid` = " . intval($access['accessid']) );
361 }
362 }
363 }
364 }
365
366
367 #################################################################
368 // Usergroup Cans ///////////////////////////////////////////////
369 $usergroup_cans = array (
370 'cf' => 'Dahsboard - Can create forum',
371 'ef' => 'Dahsboard - Can edit forum',
372 'df' => 'Dahsboard - Can delete forum',
373 'vm' => 'Dahsboard - Members Menu',
374 'em' => 'Dahsboard - Can edit member',
375 'dm' => 'Dahsboard - Can delete member',
376 'vmg' => 'Dahsboard - Usergroup Menu',
377 'vmem' => 'Front - Can view members',
378 'vprf' => 'Front - Can view profiles',
379 'upa' => 'Front - Can upload avatar',
380 'ups' => 'Front - Can have signatur',
381 'va' => 'Front - Can view avatars',
382 'vmu' => 'Front - Can view member username',
383 'vmm' => 'Front - Can view member email',
384 'vmt' => 'Front - Can view member title',
385 'vmct' => 'Front - Can view member custom title',
386 'vmr' => 'Front - Can view member reputation',
387 'vmw' => 'Front - Can view member website',
388 'vmsn' => 'Front - Can view member social networks',
389 'vmrd' => 'Front - Can view member reg. date',
390 'vmlad'=> 'Front - Can view member last active date',
391 'vip' => 'Front - Can view member ip address',
392 'vml' => 'Front - Can view member location',
393 'vmo' => 'Front - Can view member ocumpation',
394 'vms' => 'Front - Can view member signatur',
395 'vmam' => 'Front - Can view member about me',
396 'vmpn' => 'Front - Can view member phone number',
397 'vwpm' => 'Front - Can write PM'
398 );
399 wpforo_update_options( 'wpforo_usergroup_cans', $usergroup_cans );
400
401 #################################################################
402 // Usergroup ////////////////////////////////////////////////////
403 $cans_admin = array('cf' => '1', 'ef' => '1', 'df' => '1', 'vm' => '1', 'em' => '1', 'vmg' => '1', 'vmem' => '1', 'vprf' => '1',
404 'dm' => '1', 'upa' => '1', 'ups' => '1', 'va' => '1',
405 'vmu' => '1', 'vmm' => '1', 'vmt' => '1', 'vmct' => '1',
406 'vmr' => '1', 'vmw' => '1', 'vmsn' => '1', 'vmrd' => '1',
407 'vmlad' => '1', 'vip' => '1', 'vml' => '1', 'vmo' => '1',
408 'vms' => '1', 'vmam' => '1', 'vmpn' => '1', 'vwpm' => '1');
409 $cans_moder = array('cf' => '0', 'ef' => '0', 'df' => '0', 'vm' => '0', 'em' => '0', 'vmg' => '0', 'vmem' => '1', 'vprf' => '1',
410 'dm' => '1', 'upa' => '1', 'ups' => '1', 'va' => '1',
411 'vmu' => '1', 'vmm' => '1', 'vmt' => '1', 'vmct' => '1',
412 'vmr' => '1', 'vmw' => '1', 'vmsn' => '1', 'vmrd' => '1',
413 'vmlad' => '1', 'vip' => '1', 'vml' => '1', 'vmo' => '1',
414 'vms' => '1', 'vmam' => '1', 'vmpn' => '1', 'vwpm' => '1');
415 $cans_reg = array( 'cf' => '0', 'ef' => '0', 'df' => '0', 'vm' => '0', 'em' => '0', 'vmg' => '0', 'vmem' => '1', 'vprf' => '1',
416 'dm' => '0', 'upa' => '1', 'ups' => '1', 'va' => '1',
417 'vmu' => '1', 'vmm' => '0', 'vmt' => '1', 'vmct' => '1',
418 'vmr' => '1', 'vmw' => '1', 'vmsn' => '1', 'vmrd' => '1',
419 'vmlad' => '1', 'vip' => '0', 'vml' => '1', 'vmo' => '1',
420 'vms' => '1', 'vmam' => '1', 'vmpn' => '0', 'vwpm' => '1');
421 $cans_guest = array('cf' => '0', 'ef' => '0', 'df' => '0', 'vm' => '0', 'em' => '0', 'vmg' => '0', 'vmem' => '1', 'vprf' => '1',
422 'dm' => '0', 'upa' => '0', 'ups' => '0', 'va' => '0',
423 'vmu' => '0', 'vmm' => '0', 'vmt' => '0', 'vmct' => '0',
424 'vmr' => '1', 'vmw' => '0', 'vmsn' => '1', 'vmrd' => '0',
425 'vmlad' => '1', 'vip' => '0', 'vml' => '1', 'vmo' => '1',
426 'vms' => '0', 'vmam' => '1', 'vmpn' => '0', 'vwpm' => '0');
427 $cans_customer = array( 'cf' => '0', 'ef' => '0', 'df' => '0', 'vm' => '0', 'em' => '0', 'vmg' => '0', 'vmem' => '1', 'vprf' => '1',
428 'dm' => '0', 'upa' => '1', 'ups' => '1', 'va' => '1',
429 'vmu' => '1', 'vmm' => '0', 'vmt' => '1', 'vmct' => '1',
430 'vmr' => '1', 'vmw' => '1', 'vmsn' => '1', 'vmrd' => '1',
431 'vmlad' => '1', 'vip' => '0', 'vml' => '1', 'vmo' => '1',
432 'vms' => '1', 'vmam' => '1', 'vmpn' => '0', 'vwpm' => '1');
433
434
435 $sql = "SELECT * FROM `".$wpforo->db->prefix."wpforo_usergroups`";
436 $usergroups = $wpforo->db->get_results($sql, ARRAY_A);
437 if( empty($usergroups) ){
438 $cans_admin = serialize( $cans_admin );
439 $cans_moder = serialize( $cans_moder );
440 $cans_reg = serialize( $cans_reg );
441 $cans_guest = serialize( $cans_guest );
442 $cans_customer = serialize( $cans_customer );
443 $sql = "INSERT IGNORE INTO `".$wpforo->db->prefix."wpforo_usergroups`
444 (`name`, `cans`) VALUES ('Admin', '$cans_admin'),('Moderator', '$cans_moder'),('Registered', '$cans_reg'),('Guest', '$cans_guest'),('Customer', '$cans_customer')";
445 $wpforo->db->query($sql);
446 }
447 else{
448 foreach($usergroups as $usergroup){
449 $default = array();
450 $data_update = array();
451 $current = unserialize($usergroup['cans']);
452 if( strtolower($usergroup['name']) == 'admin' ) $default = $cans_admin;
453 elseif( strtolower($usergroup['name']) == 'moderator' ) $default = $cans_moder;
454 elseif( strtolower($usergroup['name']) == 'registered' ) $default = $cans_reg;
455 elseif( strtolower($usergroup['name']) == 'guest' ) $default = $cans_guest;
456 elseif( strtolower($usergroup['name']) == 'customer' ) $default = $cans_customer;
457 if( !empty($default) ){
458 $data_update = array_merge($default, $current);
459 if( !empty($data_update) ){
460 $data_update = serialize($data_update);
461 $wpforo->db->query("UPDATE `".$wpforo->db->prefix."wpforo_usergroups` SET `cans` = '" . $wpforo->db->_real_escape($data_update) . "' WHERE `groupid` = " . intval($usergroup['groupid']) );
462 }
463 }
464 }
465 }
466 $sql = "SELECT COUNT(*) FROM `".$wpforo->db->prefix."wpforo_forums`";
467 $count = $wpforo->db->get_var($sql);
468 if(!$count){
469 if( $parentid = $wpforo->forum->add( array( 'title' => 'Main Category', 'description' => 'This is a simple category / section' ), FALSE ) ){
470 $wpforo->forum->add( array( 'title' => 'Main Forum', 'description' => 'This is a simple parent forum', 'parentid' => $parentid ), FALSE );
471 }
472 }
473
474 #################################################################
475 // Permalink Settings ///////////////////////////////////////////
476 $permalink_structure = get_option( 'permalink_structure' );
477 if( !$permalink_structure ){
478 global $wp_rewrite;
479 $wp_rewrite->set_permalink_structure( '/%postname%/' );
480 }
481
482 #################################################################
483 // Creating Forum Page //////////////////////////////////////////
484 if( !$wpforo->pageid ||
485 !$wpforo->db->get_var("SELECT `ID` FROM `{$wpforo->db->prefix}posts` WHERE `ID` = '".intval($wpforo->pageid)."' AND ( `post_content` LIKE '%[wpforo]%' OR `post_content` LIKE '%[wpforo-index]%' ) AND `post_status` LIKE 'publish' AND `post_type` IN('post', 'page')") ){
486 if( !$page_id = $wpforo->db->get_var("SELECT `ID` FROM `{$wpforo->db->prefix}posts` WHERE `post_content` LIKE '%[wpforo]%' AND `post_status` LIKE 'publish' AND `post_type` IN('post', 'page')") ){
487 $wpforo_page = array(
488 'post_date' => current_time( 'mysql', 1 ),
489 'post_date_gmt' => current_time( 'mysql', 1 ),
490 'post_content' => '[wpforo]',
491 'post_title' => 'Forum',
492 'post_status' => 'publish',
493 'comment_status' => 'close',
494 'ping_status' => 'close',
495 'post_name' => 'community',
496 'post_modified' => current_time( 'mysql', 1 ),
497 'post_modified_gmt' => current_time( 'mysql', 1 ),
498 'post_parent' => 0,
499 'menu_order' => 0,
500 'post_type' => 'page'
501 );
502 $page_id = wp_insert_post( $wpforo_page );
503 }
504 if( $page_id && !is_wp_error($page_id) ){
505 update_option( 'wpforo_pageid', $page_id );
506 update_option( 'wpforo_use_home_url', '0' );
507 $wpforo_url = get_wpf_option('wpforo_url');
508 if( !$wpforo_url ){
509 update_option( 'wpforo_permastruct', 'community' );
510 update_option( 'wpforo_url', esc_url( home_url('/') ) . "community/" );
511 }else{
512 if( !$wpforo->permastruct ){
513 update_option( 'wpforo_permastruct', basename($wpforo_url) );
514 update_option( 'wpforo_url', esc_url( home_url('/') ) . basename($wpforo_url) . "/" );
515 }else{
516 update_option( 'wpforo_url', esc_url( home_url('/') ) . $wpforo->permastruct . "/" );
517 }
518 }
519 }
520 }else{
521 if( !$wpforo->use_home_url ) update_option( 'wpforo_use_home_url', '0' );
522 if( !$wpforo->permastruct ) update_option( 'wpforo_permastruct', basename( get_wpf_option('wpforo_url') ) );
523 $wpforo->db->query("UPDATE `{$wpforo->db->prefix}posts` SET `post_content` = REPLACE(`post_content`, '[wpforo-index]', '[wpforo]') WHERE `ID` = '{$wpforo->pageid}'");
524 }
525
526
527 #################################################################
528 // Importing Language Packs and Phrases /////////////////////////
529 $wpforo->phrase->xml_import('english.xml', 'install');
530
531 #################################################################
532 // Creating wpforo folders //////////////////////////////////////
533 $upload_array = wp_upload_dir();
534 $wpforo_upload_dir = $upload_array['basedir'].'/wpforo/';
535 if (!is_dir($wpforo_upload_dir)) {
536 wp_mkdir_p($wpforo_upload_dir);
537 }
538 $avatars_upload_dir=$upload_array['basedir'].'/wpforo/avatars/';
539 if (!is_dir($avatars_upload_dir)) {
540 wp_mkdir_p($avatars_upload_dir);
541 }
542
543 #################################################################
544 // RESET USER CACHE /////////////////////////////////////////////
545 $wpforo->member->clear_db_cache();
546
547 #################################################################
548 // RESET FUNCTIONS //////////////////////////////////////////////
549 $wpforo->db->query("DELETE FROM " . $wpforo->db->prefix . "options WHERE `option_name` LIKE '%_transient_wpforo_get_phrases_%' OR `option_name` LIKE '%_transient_timeout_wpforo_get_phrases_%'");
550
551 #################################################################
552 // UPDATE VERSION - END /////////////////////////////////////////
553 update_option('wpforo_version', WPFORO_VERSION);
554 $wpforo->notice->clear();
555 }
556
557
558 function wpforo_update() {
559 if ( WPFORO_VERSION !== get_option('wpforo_version') ) wpforo_activation();
560 }
561 add_action('plugins_loaded', 'wpforo_update');
562
563
564 function wpforo_update_options( $option_key, $default, $exlude = array() ) {
565
566 $option = get_option( $option_key, array() );
567
568 if( !empty($option) ){
569 if( !empty($exlude) ){
570 foreach( $exlude as $key ){
571 if( isset($default[$key]) ) unset($default[$key]);
572 }
573 }
574 $option_update = array_merge($default, $option);
575 }
576 else{
577 $option_update = $default;
578 }
579
580 update_option( $option_key, $option_update );
581 }
582
583
584 function wpforo_deactivation() {}
585
586
587 function wpforo_uninstall() {
588
589 global $wpforo, $wpdb;
590
591 if( ! is_admin() ) return;
592 if( ! current_user_can( 'activate_plugins' ) ) return;
593 $QUERY_STRING = trim(preg_replace('|_wpnonce=[^\&\?\=]*|is', '', $_SERVER['QUERY_STRING']), '&');
594
595 if( 'action=wpforo-uninstall' == trim($QUERY_STRING) ){
596
597 $tables = array( $wpdb->prefix . 'wpforo_accesses',
598 $wpdb->prefix . 'wpforo_forums',
599 $wpdb->prefix . 'wpforo_languages',
600 $wpdb->prefix . 'wpforo_likes',
601 $wpdb->prefix . 'wpforo_phrases',
602 $wpdb->prefix . 'wpforo_profiles',
603 $wpdb->prefix . 'wpforo_posts',
604 $wpdb->prefix . 'wpforo_subscribes',
605 $wpdb->prefix . 'wpforo_topics',
606 $wpdb->prefix . 'wpforo_usergroups',
607 $wpdb->prefix . 'wpforo_views',
608 $wpdb->prefix . 'wpforo_votes');
609
610 foreach($tables as $table){
611 if( strpos( $table, '_wpforo_' ) !== FALSE){
612 $sql = "DROP TABLE IF EXISTS `$table`;";
613 $wpdb->query( $sql );
614 }
615 }
616
617 if( isset($wpforo->pageid) && $wpforo->pageid ){
618 wp_delete_post( $wpforo->pageid, true );
619 }
620
621 $options = array( 'wpforo_version',
622 'wpforo_url',
623 'wpforo_general_options',
624 'wpforo_pageid',
625 'wpforo_count_per_page',
626 'wpforo_default_groupid',
627 'wpforo_usergroup_cans',
628 'wpforo_forum_options',
629 'wpforo_forum_cans',
630 'wpforo_post_options',
631 'wpforo_member_options',
632 'wpforo_subscribe_options',
633 'wpforo_countries',
634 'wpforo_theme_options',
635 'wpforo_features',
636 'wpforo_style_options',
637 'wpforo_permastruct',
638 'wpforo_use_home_url'
639 );
640
641 foreach($options as $option){
642 if( strpos( $option, 'wpforo_' ) !== FALSE){
643 delete_option( $option );
644 }
645 }
646
647 $wpdb->query( "DELETE FROM `" . $wpdb->prefix ."usermeta` WHERE `meta_key` = '_wpf_member_obj'" );
648 $wpdb->query( "DELETE FROM `" . $wpdb->prefix ."options` WHERE option_name LIKE 'widget_wpforo_widget_%'" );
649
650 $menu = wp_get_nav_menu_object( 'wpforo-navigation' );
651 wp_delete_nav_menu( $menu->term_id );
652 wp_delete_post($wpforo->pageid, TRUE);
653
654 deactivate_plugins( WPFORO_BASENAME );
655
656 }
657 else{
658 return;
659 }
660 }
661
662 ?>