PluginProbe
wpForo Forum / 1.0.0
wpForo Forum v1.0.0
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.0, at wpf-includes/functions-installation.php

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