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