Changeset 1021 for trunk/bp-groups.php
- Timestamp:
- 02/06/2009 03:07:48 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-groups.php
r1017 r1021 30 30 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; 31 31 32 $sql[] = "CREATE TABLE ". $bp['groups']['table_name'] ."(32 $sql[] = "CREATE TABLE {$bp->groups->table_name} ( 33 33 id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, 34 34 creator_id int(11) NOT NULL, … … 51 51 ) {$charset_collate};"; 52 52 53 $sql[] = "CREATE TABLE ". $bp['groups']['table_name_members'] ."(53 $sql[] = "CREATE TABLE {$bp->groups->table_name_members} ( 54 54 id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, 55 55 group_id int(11) NOT NULL, … … 72 72 ) {$charset_collate};"; 73 73 74 $sql[] = "CREATE TABLE ". $bp['groups']['table_name_groupmeta'] ."(74 $sql[] = "CREATE TABLE {$bp->groups->table_name_groupmeta} ( 75 75 id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, 76 76 group_id int(11) NOT NULL, … … 93 93 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; 94 94 95 $sql[] = "CREATE TABLE ". $bp['groups']['table_name_wire'] ."(95 $sql[] = "CREATE TABLE {$bp->groups->table_name_wire} ( 96 96 id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, 97 97 item_id int(11) NOT NULL, … … 121 121 global $bp; 122 122 123 $bp['groups'] = array( 124 'table_name' => $wpdb->base_prefix . 'bp_groups', 125 'table_name_members' => $wpdb->base_prefix . 'bp_groups_members', 126 'table_name_groupmeta' => $wpdb->base_prefix . 'bp_groups_groupmeta', 127 'image_base' => site_url( MUPLUGINDIR . '/bp-groups/images' ), 128 'format_activity_function' => 'groups_format_activity', 129 'slug' => BP_GROUPS_SLUG 130 ); 131 123 $bp->groups->table_name = $wpdb->base_prefix . 'bp_groups'; 124 $bp->groups->table_name_members = $wpdb->base_prefix . 'bp_groups_members'; 125 $bp->groups->table_name_groupmeta = $wpdb->base_prefix . 'bp_groups_groupmeta'; 126 $bp->groups->image_base = site_url( MUPLUGINDIR . '/bp-groups/images' ); 127 $bp->groups->format_activity_function = 'groups_format_activity'; 128 $bp->groups->slug = BP_GROUPS_SLUG; 129 132 130 if ( function_exists('bp_wire_install') ) 133 $bp ['groups']['table_name_wire']= $wpdb->base_prefix . 'bp_groups_wire';134 135 $bp ['groups']['forbidden_names']= array( 'my-groups', 'group-finder', 'create', 'invites', 'delete', 'add', 'admin', 'request-membership' );136 $bp ['version_numbers'][$bp['groups']['slug']]= BP_GROUPS_VERSION;137 131 $bp->groups->table_name_wire = $wpdb->base_prefix . 'bp_groups_wire'; 132 133 $bp->groups->forbidden_names = array( 'my-groups', 'group-finder', 'create', 'invites', 'delete', 'add', 'admin', 'request-membership' ); 134 $bp->version_numbers->groups = BP_GROUPS_VERSION; 135 138 136 return $bp; 139 137 } … … 152 150 if ( is_site_admin() ) { 153 151 /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */ 154 if ( ( $wpdb->get_var("SHOW TABLES LIKE '%" . $bp ['groups']['table_name']. "%'") == false ) || ( get_site_option('bp-groups-db-version') < BP_GROUPS_DB_VERSION ) )152 if ( ( $wpdb->get_var("SHOW TABLES LIKE '%" . $bp->groups->table_name . "%'") == false ) || ( get_site_option('bp-groups-db-version') < BP_GROUPS_DB_VERSION ) ) 155 153 groups_install(); 156 154 157 if ( ( function_exists('bp_wire_install') && $wpdb->get_var("SHOW TABLES LIKE '%" . $bp ['groups']['table_name_wire']. "%'") == false ) || ( get_site_option('bp-groups-db-version') < BP_GROUPS_DB_VERSION ) )155 if ( ( function_exists('bp_wire_install') && $wpdb->get_var("SHOW TABLES LIKE '%" . $bp->groups->table_name_wire . "%'") == false ) || ( get_site_option('bp-groups-db-version') < BP_GROUPS_DB_VERSION ) ) 158 156 groups_wire_install(); 159 157 } … … 182 180 global $group_obj, $is_single_group; 183 181 184 if ( $group_id = BP_Groups_Group::group_exists($bp ['current_action']) ) {182 if ( $group_id = BP_Groups_Group::group_exists($bp->current_action) ) { 185 183 /* This is a single group page. */ 186 184 $is_single_group = true; … … 189 187 /* Using "item" not "group" for generic support in other components. */ 190 188 if ( is_site_admin() ) 191 $bp ['is_item_admin']= 1;189 $bp->is_item_admin = 1; 192 190 else 193 $bp ['is_item_admin'] = groups_is_user_admin( $bp['loggedin_userid'], $group_obj->id );191 $bp->is_item_admin = groups_is_user_admin( $bp->loggedin_user->id, $group_obj->id ); 194 192 195 193 /* If the user is not an admin, check if they are a moderator */ 196 if ( !$bp ['is_item_admin'])197 $bp ['is_item_mod'] = groups_is_user_mod( $bp['loggedin_userid'], $group_obj->id );194 if ( !$bp->is_item_admin ) 195 $bp->is_item_mod = groups_is_user_mod( $bp->loggedin_user->id, $group_obj->id ); 198 196 199 197 /* Is the logged in user a member of the group? */ 200 $is_member = ( groups_is_user_member( $bp ['loggedin_userid'], $group_obj->id ) ) ? true : false;198 $is_member = ( groups_is_user_member( $bp->loggedin_user->id, $group_obj->id ) ) ? true : false; 201 199 202 200 /* Should this group be visible to the logged in user? */ … … 205 203 206 204 /* Add 'Groups' to the main navigation */ 207 bp_core_add_nav_item( __('Groups', 'buddypress'), $bp ['groups']['slug']);208 209 if ( $bp ['current_userid'])210 bp_core_add_nav_default( $bp ['groups']['slug'], 'groups_screen_my_groups', 'my-groups' );211 212 $groups_link = $bp ['loggedin_domain'] . $bp['groups']['slug']. '/';205 bp_core_add_nav_item( __('Groups', 'buddypress'), $bp->groups->slug ); 206 207 if ( $bp->displayed_user->id ) 208 bp_core_add_nav_default( $bp->groups->slug, 'groups_screen_my_groups', 'my-groups' ); 209 210 $groups_link = $bp->loggedin_user->domain . $bp->groups->slug . '/'; 213 211 214 212 /* Add the subnav items to the groups nav item */ 215 bp_core_add_subnav_item( $bp ['groups']['slug'], 'my-groups', __('My Groups', 'buddypress'), $groups_link, 'groups_screen_my_groups', 'my-groups-list' );216 bp_core_add_subnav_item( $bp ['groups']['slug'], 'create', __('Create a Group', 'buddypress'), $groups_link, 'groups_screen_create_group', false, bp_is_home() );217 bp_core_add_subnav_item( $bp ['groups']['slug'], 'invites', __('Invites', 'buddypress'), $groups_link, 'groups_screen_group_invites', false, bp_is_home() );218 219 if ( $bp ['current_component'] == $bp['groups']['slug']) {213 bp_core_add_subnav_item( $bp->groups->slug, 'my-groups', __('My Groups', 'buddypress'), $groups_link, 'groups_screen_my_groups', 'my-groups-list' ); 214 bp_core_add_subnav_item( $bp->groups->slug, 'create', __('Create a Group', 'buddypress'), $groups_link, 'groups_screen_create_group', false, bp_is_home() ); 215 bp_core_add_subnav_item( $bp->groups->slug, 'invites', __('Invites', 'buddypress'), $groups_link, 'groups_screen_group_invites', false, bp_is_home() ); 216 217 if ( $bp->current_component == $bp->groups->slug ) { 220 218 221 219 if ( bp_is_home() && !$is_single_group ) { 222 220 223 $bp ['bp_options_title']= __('My Groups', 'buddypress');221 $bp->bp_options_title = __('My Groups', 'buddypress'); 224 222 225 223 } else if ( !bp_is_home() && !$is_single_group ) { 226 224 227 $bp ['bp_options_avatar'] = bp_core_get_avatar( $bp['current_userid'], 1 );228 $bp ['bp_options_title'] = $bp['current_fullname'];225 $bp->bp_options_avatar = bp_core_get_avatar( $bp->displayed_user->id, 1 ); 226 $bp->bp_options_title = $bp->displayed_user->fullname; 229 227 230 228 } else if ( $is_single_group ) { … … 234 232 /* When in a single group, the first action is bumped down one because of the 235 233 group name, so we need to adjust this and set the group name to current_item. */ 236 $bp ['current_item'] = $bp['current_action'];237 $bp ['current_action'] = $bp['action_variables'][0];238 array_shift($bp ['action_variables']);234 $bp->current_item = $bp->current_action; 235 $bp->current_action = $bp->action_variables[0]; 236 array_shift($bp->action_variables); 239 237 240 $bp ['bp_options_title']= bp_create_excerpt( $group_obj->name, 1 );241 $bp ['bp_options_avatar']= '<img src="' . $group_obj->avatar_thumb . '" alt="Group Avatar Thumbnail" />';242 243 $group_link = $bp ['root_domain'] . '/' . $bp['groups']['slug']. '/' . $group_obj->slug . '/';238 $bp->bp_options_title = bp_create_excerpt( $group_obj->name, 1 ); 239 $bp->bp_options_avatar = '<img src="' . $group_obj->avatar_thumb . '" alt="Group Avatar Thumbnail" />'; 240 241 $group_link = $bp->root_domain . '/' . $bp->groups->slug . '/' . $group_obj->slug . '/'; 244 242 245 243 // If this is a private or hidden group, does the user have access? 246 244 if ( $group_obj->status == 'private' || $group_obj->status == 'hidden' ) { 247 if ( groups_is_user_member( $bp ['loggedin_userid'], $group_obj->id ) && is_user_logged_in() )245 if ( groups_is_user_member( $bp->loggedin_user->id, $group_obj->id ) && is_user_logged_in() ) 248 246 $has_access = true; 249 247 else … … 254 252 255 253 // Reset the existing subnav items 256 bp_core_reset_subnav_items($bp ['groups']['slug']);257 258 bp_core_add_nav_default( $bp ['groups']['slug'], 'groups_screen_group_home', 'home' );259 bp_core_add_subnav_item( $bp ['groups']['slug'], 'home', __('Home', 'buddypress'), $group_link, 'groups_screen_group_home', 'group-home' );254 bp_core_reset_subnav_items($bp->groups->slug); 255 256 bp_core_add_nav_default( $bp->groups->slug, 'groups_screen_group_home', 'home' ); 257 bp_core_add_subnav_item( $bp->groups->slug, 'home', __('Home', 'buddypress'), $group_link, 'groups_screen_group_home', 'group-home' ); 260 258 261 259 // If the user is a group mod or more, then show the group admin nav item */ 262 if ( $bp ['is_item_mod'] || $bp['is_item_admin'])263 bp_core_add_subnav_item( $bp ['groups']['slug'], 'admin', __('Admin', 'buddypress'), $group_link , 'groups_screen_group_admin', 'group-admin', ( $bp['is_item_admin'] + (int)$bp['is_item_mod']) );260 if ( $bp->is_item_mod || $bp->is_item_admin ) 261 bp_core_add_subnav_item( $bp->groups->slug, 'admin', __('Admin', 'buddypress'), $group_link , 'groups_screen_group_admin', 'group-admin', ( $bp->is_item_admin + (int)$bp->is_item_mod ) ); 264 262 265 263 // If this is a private group, and the user is not a member, show a "Request Membership" nav item. 266 if ( !$has_access && !groups_check_for_membership_request( $bp ['loggedin_userid'], $group_obj->id ) )267 bp_core_add_subnav_item( $bp ['groups']['slug'], 'request-membership', __('Request Membership', 'buddypress'), $group_link , 'groups_screen_group_request_membership', 'request-membership' );264 if ( !$has_access && !groups_check_for_membership_request( $bp->loggedin_user->id, $group_obj->id ) ) 265 bp_core_add_subnav_item( $bp->groups->slug, 'request-membership', __('Request Membership', 'buddypress'), $group_link , 'groups_screen_group_request_membership', 'request-membership' ); 268 266 269 267 if ( $has_access && $group_obj->enable_forum && function_exists('bp_forums_setup') ) 270 bp_core_add_subnav_item( $bp ['groups']['slug'], 'forum', __('Forum', 'buddypress'), $group_link , 'groups_screen_group_forum', 'group-forum', $is_visible);268 bp_core_add_subnav_item( $bp->groups->slug, 'forum', __('Forum', 'buddypress'), $group_link , 'groups_screen_group_forum', 'group-forum', $is_visible); 271 269 272 270 if ( $has_access && $group_obj->enable_wire && function_exists('bp_wire_install') ) 273 bp_core_add_subnav_item( $bp ['groups']['slug'], 'wire', __('Wire', 'buddypress'), $group_link, 'groups_screen_group_wire', 'group-wire', $is_visible );271 bp_core_add_subnav_item( $bp->groups->slug, 'wire', __('Wire', 'buddypress'), $group_link, 'groups_screen_group_wire', 'group-wire', $is_visible ); 274 272 275 273 if ( $has_access && $group_obj->enable_photos && function_exists('bp_gallery_install') ) 276 bp_core_add_subnav_item( $bp ['groups']['slug'], 'photos', __('Photos', 'buddypress'), $group_link, 'groups_screen_group_photos', 'group-photos', $is_visible );274 bp_core_add_subnav_item( $bp->groups->slug, 'photos', __('Photos', 'buddypress'), $group_link, 'groups_screen_group_photos', 'group-photos', $is_visible ); 277 275 278 276 if ( $has_access ) 279 bp_core_add_subnav_item( $bp ['groups']['slug'], 'members', __('Members', 'buddypress'), $group_link, 'groups_screen_group_members', 'group-members', $is_visible );280 281 if ( is_user_logged_in() && groups_is_user_member( $bp ['loggedin_userid'], $group_obj->id ) ) {277 bp_core_add_subnav_item( $bp->groups->slug, 'members', __('Members', 'buddypress'), $group_link, 'groups_screen_group_members', 'group-members', $is_visible ); 278 279 if ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $group_obj->id ) ) { 282 280 if ( function_exists('friends_install') ) 283 bp_core_add_subnav_item( $bp ['groups']['slug'], 'send-invites', __('Send Invites', 'buddypress'), $group_link, 'groups_screen_group_invite', 'group-invite', $is_member );281 bp_core_add_subnav_item( $bp->groups->slug, 'send-invites', __('Send Invites', 'buddypress'), $group_link, 'groups_screen_group_invite', 'group-invite', $is_member ); 284 282 285 bp_core_add_subnav_item( $bp ['groups']['slug'], 'leave-group', __('Leave Group', 'buddypress'), $group_link, 'groups_screen_group_leave', 'group-leave', $is_member );283 bp_core_add_subnav_item( $bp->groups->slug, 'leave-group', __('Leave Group', 'buddypress'), $group_link, 'groups_screen_group_leave', 'group-leave', $is_member ); 286 284 } 287 285 } … … 297 295 global $bp; 298 296 299 bp_core_delete_notifications_for_user_by_type( $bp ['loggedin_userid'], 'groups', 'member_promoted_to_mod' );300 bp_core_delete_notifications_for_user_by_type( $bp ['loggedin_userid'], 'groups', 'member_promoted_to_admin' );297 bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, 'groups', 'member_promoted_to_mod' ); 298 bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, 'groups', 'member_promoted_to_admin' ); 301 299 302 300 do_action( 'groups_screen_my_groups' ); … … 308 306 global $bp; 309 307 310 $group_id = $bp ['action_variables'][1];311 312 if ( isset($bp ['action_variables']) && in_array( 'accept', $bp['action_variables']) && is_numeric($group_id) ) {313 314 if ( !groups_accept_invite( $bp ['loggedin_userid'], $group_id ) ) {308 $group_id = $bp->action_variables[1]; 309 310 if ( isset($bp->action_variables) && in_array( 'accept', $bp->action_variables ) && is_numeric($group_id) ) { 311 312 if ( !groups_accept_invite( $bp->loggedin_user->id, $group_id ) ) { 315 313 bp_core_add_message( __('Group invite could not be accepted', 'buddypress'), 'error' ); 316 314 } else { … … 321 319 } 322 320 323 bp_core_redirect( $bp ['loggedin_domain'] . $bp['current_component'] . '/' . $bp['current_action']);324 325 } else if ( isset($bp ['action_variables']) && in_array( 'reject', $bp['action_variables']) && is_numeric($group_id) ) {326 327 if ( !groups_reject_invite( $group_id, $bp ['loggedin_userid']) ) {321 bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action ); 322 323 } else if ( isset($bp->action_variables) && in_array( 'reject', $bp->action_variables ) && is_numeric($group_id) ) { 324 325 if ( !groups_reject_invite( $group_id, $bp->loggedin_user->id ) ) { 328 326 bp_core_add_message( __('Group invite could not be rejected', 'buddypress'), 'error' ); 329 327 } else { … … 331 329 } 332 330 333 bp_core_redirect( $bp ['loggedin_domain'] . $bp['current_component'] . '/' . $bp['current_action']);331 bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action ); 334 332 } 335 333 336 334 // Remove notifications 337 bp_core_delete_notifications_for_user_by_type( $bp ['loggedin_userid'], 'groups', 'group_invite' );335 bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, 'groups', 'group_invite' ); 338 336 339 337 do_action( 'groups_screen_group_invites', $group_id ); … … 349 347 $reset_steps = false; 350 348 351 if ( !$create_group_step = $bp ['action_variables'][1] ) {349 if ( !$create_group_step = $bp->action_variables[1] ) { 352 350 $create_group_step = '1'; 353 351 $completed_to_step = 0; … … 380 378 if ( !$group_id = groups_create_group( $create_group_step, $_SESSION['group_obj_id'] ) ) { 381 379 bp_core_add_message( __('There was an error saving group details. Please try again.', 'buddypress'), 'error' ); 382 bp_core_redirect( $bp ['loggedin_domain'] . $bp['groups']['slug']. '/create/step/' . $create_group_step );380 bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $create_group_step ); 383 381 } else { 384 382 $create_group_step++; … … 403 401 if ( isset($_GET['new']) ) { 404 402 // Delete group request notifications for the user 405 bp_core_delete_notifications_for_user_by_type( $bp ['loggedin_userid'], 'groups', 'membership_request_accepted' );406 bp_core_delete_notifications_for_user_by_type( $bp ['loggedin_userid'], 'groups', 'membership_request_rejected' );407 bp_core_delete_notifications_for_user_by_type( $bp ['loggedin_userid'], 'groups', 'member_promoted_to_mod' );408 bp_core_delete_notifications_for_user_by_type( $bp ['loggedin_userid'], 'groups', 'member_promoted_to_admin' );403 bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, 'groups', 'membership_request_accepted' ); 404 bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, 'groups', 'membership_request_rejected' ); 405 bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, 'groups', 'member_promoted_to_mod' ); 406 bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, 'groups', 'member_promoted_to_admin' ); 409 407 } 410 408 … … 419 417 420 418 if ( $is_single_group ) { 421 $topic_id = $bp ['action_variables'][1];419 $topic_id = $bp->action_variables[1]; 422 420 $forum_id = groups_get_groupmeta( $group_obj->id, 'forum_id' ); 423 421 … … 454 452 global $is_single_group, $group_obj; 455 453 456 $wire_action = $bp ['action_variables'][0];454 $wire_action = $bp->action_variables[0]; 457 455 458 456 if ( $is_single_group ) { 459 if ( $wire_action == 'post' && BP_Groups_Member::check_is_member( $bp ['loggedin_userid'], $group_obj->id ) ) {457 if ( $wire_action == 'post' && BP_Groups_Member::check_is_member( $bp->loggedin_user->id, $group_obj->id ) ) { 460 458 461 459 if ( !groups_new_wire_post( $group_obj->id, $_POST['wire-post-textarea'] ) ) { … … 465 463 } 466 464 467 if ( !strpos( $_SERVER['HTTP_REFERER'], $bp ['wire']['slug']) ) {465 if ( !strpos( $_SERVER['HTTP_REFERER'], $bp->wire->slug ) ) { 468 466 bp_core_redirect( bp_group_permalink( $group_obj, false ) ); 469 467 } else { 470 bp_core_redirect( bp_group_permalink( $group_obj, false ) . '/' . $bp ['wire']['slug']);471 } 472 473 } else if ( $wire_action == 'delete' && BP_Groups_Member::check_is_member( $bp ['loggedin_userid'], $group_obj->id ) ) {474 $wire_message_id = $bp ['action_variables'][1];475 476 if ( !groups_delete_wire_post( $wire_message_id, $bp ['groups']['table_name_wire']) ) {468 bp_core_redirect( bp_group_permalink( $group_obj, false ) . '/' . $bp->wire->slug ); 469 } 470 471 } else if ( $wire_action == 'delete' && BP_Groups_Member::check_is_member( $bp->loggedin_user->id, $group_obj->id ) ) { 472 $wire_message_id = $bp->action_variables[1]; 473 474 if ( !groups_delete_wire_post( $wire_message_id, $bp->groups->table_name_wire ) ) { 477 475 bp_core_add_message( __('There was an error deleting the wire message.', 'buddypress'), 'error' ); 478 476 } else { … … 480 478 } 481 479 482 if ( !strpos( $_SERVER['HTTP_REFERER'], $bp ['wire']['slug']) ) {480 if ( !strpos( $_SERVER['HTTP_REFERER'], $bp->wire->slug ) ) { 483 481 bp_core_redirect( bp_group_permalink( $group_obj, false ) ); 484 482 } else { 485 bp_core_redirect( bp_group_permalink( $group_obj, false ) . '/' . $bp ['wire']['slug']);486 } 487 488 } else if ( ( !$wire_action || $bp ['action_variables'][1] == 'latest' ) ) {483 bp_core_redirect( bp_group_permalink( $group_obj, false ) . '/' . $bp->wire->slug ); 484 } 485 486 } else if ( ( !$wire_action || $bp->action_variables[1] == 'latest' ) ) { 489 487 bp_core_load_template( 'groups/wire' ); 490 488 } else { … … 520 518 521 519 if ( $is_single_group ) { 522 if ( isset($bp ['action_variables']) && $bp['action_variables'][0] == 'send' ) {520 if ( isset($bp->action_variables) && $bp->action_variables[0] == 'send' ) { 523 521 // Send the invites. 524 522 groups_send_invites($group_obj); … … 540 538 541 539 if ( $is_single_group ) { 542 if ( isset($bp ['action_variables']) && $bp['action_variables'][0] == 'yes' ) {540 if ( isset($bp->action_variables) && $bp->action_variables[0] == 'yes' ) { 543 541 544 542 // Check if the user is the group admin first. 545 if ( groups_is_group_admin( $bp ['loggedin_userid'], $group_obj->id ) ) {543 if ( groups_is_group_admin( $bp->loggedin_user->id, $group_obj->id ) ) { 546 544 bp_core_add_message( __('As the only group administrator, you cannot leave this group.', 'buddypress'), 'error' ); 547 545 bp_core_redirect( bp_group_permalink( $group_obj, false) ); … … 554 552 } else { 555 553 bp_core_add_message( __('You left the group successfully.', 'buddypress') ); 556 bp_core_redirect( $bp ['loggedin_domain'] . $bp['groups']['slug']);557 } 558 559 } else if ( isset($bp ['action_variables']) && $bp['action_variables'][0] == 'no' ) {554 bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug ); 555 } 556 557 } else if ( isset($bp->action_variables) && $bp->action_variables[0] == 'no' ) { 560 558 561 559 bp_core_redirect( bp_group_permalink( $group_obj, false) ); … … 581 579 // If the user has submitted a request, send it. 582 580 if ( isset( $_POST['group-request-send']) ) { 583 if ( !groups_send_membership_request( $bp ['loggedin_userid'], $group_obj->id ) ) {581 if ( !groups_send_membership_request( $bp->loggedin_user->id, $group_obj->id ) ) { 584 582 bp_core_add_message( __( 'There was an error sending your group membership request, please try again.', 'buddypress' ), 'error' ); 585 583 } else { … … 598 596 global $bp, $group_obj; 599 597 600 if ( $bp ['current_component'] == $bp['groups']['slug'] && !$bp['action_variables']) {598 if ( $bp->current_component == $bp->groups->slug && !$bp->action_variables ) { 601 599 602 600 do_action( 'groups_screen_group_admin', $group_obj->id ); … … 610 608 global $bp, $group_obj; 611 609 612 if ( $bp ['current_component'] == $bp['groups']['slug'] && $bp['action_variables'][0] == 'edit-details' ) {613 614 if ( $bp ['is_item_admin'] || $bp['is_item_mod']) {610 if ( $bp->current_component == $bp->groups->slug && $bp->action_variables[0] == 'edit-details' ) { 611 612 if ( $bp->is_item_admin || $bp->is_item_mod ) { 615 613 616 614 // If the edit form has been submitted, save the edited details … … 624 622 do_action( 'groups_group_details_edited', $group_obj->id ); 625 623 626 bp_core_redirect( site_url() . '/' . $bp ['current_component'] . '/' . $bp['current_item']. '/admin/edit-details' );624 bp_core_redirect( site_url() . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/edit-details' ); 627 625 } 628 626 … … 640 638 global $bp, $group_obj; 641 639 642 if ( $bp ['current_component'] == $bp['groups']['slug'] && $bp['action_variables'][0] == 'group-settings' ) {643 644 if ( !$bp ['is_item_admin'])640 if ( $bp->current_component == $bp->groups->slug && $bp->action_variables[0] == 'group-settings' ) { 641 642 if ( !$bp->is_item_admin ) 645 643 return false; 646 644 … … 661 659 do_action( 'groups_group_settings_edited', $group_obj->id ); 662 660 663 bp_core_redirect( site_url() . '/' . $bp ['current_component'] . '/' . $bp['current_item']. '/admin/group-settings' );661 bp_core_redirect( site_url() . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/group-settings' ); 664 662 } 665 663 … … 674 672 global $bp, $group_obj; 675 673 676 if ( $bp ['current_component'] == $bp['groups']['slug'] && $bp['action_variables'][0] == 'group-avatar' ) {677 678 if ( !$bp ['is_item_admin'])674 if ( $bp->current_component == $bp->groups->slug && $bp->action_variables[0] == 'group-avatar' ) { 675 676 if ( !$bp->is_item_admin ) 679 677 return false; 680 678 … … 706 704 do_action( 'groups_group_avatar_edited', $group_obj->id ); 707 705 708 bp_core_redirect( site_url() . '/' . $bp ['current_component'] . '/' . $bp['current_item']. '/admin/group-avatar' );706 bp_core_redirect( site_url() . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/group-avatar' ); 709 707 } 710 708 … … 719 717 global $bp, $group_obj; 720 718 721 if ( $bp ['current_component'] == $bp['groups']['slug'] && $bp['action_variables'][0] == 'manage-members' ) {722 723 if ( !$bp ['is_item_admin'])719 if ( $bp->current_component == $bp->groups->slug && $bp->action_variables[0] == 'manage-members' ) { 720 721 if ( !$bp->is_item_admin ) 724 722 return false; 725 723 726 if ( $bp ['action_variables'][1] == 'promote' && is_numeric( $bp['action_variables'][2] ) ) {727 $user_id = $bp ['action_variables'][2];724 if ( $bp->action_variables[1] == 'promote' && is_numeric( $bp->action_variables[2] ) ) { 725 $user_id = $bp->action_variables[2]; 728 726 729 727 // Promote a user. … … 736 734 do_action( 'groups_promoted_member', $user_id, $group_obj->id ); 737 735 738 bp_core_redirect( site_url() . '/' . $bp ['current_component'] . '/' . $bp['current_item']. '/admin/manage-members' );739 } 740 741 if ( $bp ['action_variables'][1] == 'demote' && is_numeric( $bp['action_variables'][2] ) ) {742 $user_id = $bp ['action_variables'][2];736 bp_core_redirect( site_url() . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/manage-members' ); 737 } 738 739 if ( $bp->action_variables[1] == 'demote' && is_numeric( $bp->action_variables[2] ) ) { 740 $user_id = $bp->action_variables[2]; 743 741 744 742 // Demote a user. … … 751 749 do_action( 'groups_demoted_member', $user_id, $group_obj->id ); 752 750 753 bp_core_redirect( site_url() . '/' . $bp ['current_component'] . '/' . $bp['current_item']. '/admin/manage-members' );754 } 755 756 if ( $bp ['action_variables'][1] == 'ban' && is_numeric( $bp['action_variables'][2] ) ) {757 $user_id = $bp ['action_variables'][2];751 bp_core_redirect( site_url() . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/manage-members' ); 752 } 753 754 if ( $bp->action_variables[1] == 'ban' && is_numeric( $bp->action_variables[2] ) ) { 755 $user_id = $bp->action_variables[2]; 758 756 759 757 // Ban a user. … … 766 764 do_action( 'groups_banned_member', $user_id, $group_obj->id ); 767 765 768 bp_core_redirect( site_url() . '/' . $bp ['current_component'] . '/' . $bp['current_item']. '/admin/manage-members' );769 } 770 771 if ( $bp ['action_variables'][1] == 'unban' && is_numeric( $bp['action_variables'][2] ) ) {772 $user_id = $bp ['action_variables'][2];766 bp_core_redirect( site_url() . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/manage-members' ); 767 } 768 769 if ( $bp->action_variables[1] == 'unban' && is_numeric( $bp->action_variables[2] ) ) { 770 $user_id = $bp->action_variables[2]; 773 771 774 772 // Remove a ban for user. … … 781 779 do_action( 'groups_unbanned_member', $user_id, $group_obj->id ); 782 780 783 bp_core_redirect( site_url() . '/' . $bp ['current_component'] . '/' . $bp['current_item']. '/admin/manage-members' );781 bp_core_redirect( site_url() . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/manage-members' ); 784 782 } 785 783 … … 795 793 global $bp, $group_obj; 796 794 797 if ( $bp ['current_component'] == $bp['groups']['slug'] && $bp['action_variables'][0] == 'membership-requests' ) {798 799 if ( !$bp ['is_item_admin']|| $group_obj->status == 'public' )795 if ( $bp->current_component == $bp->groups->slug && $bp->action_variables[0] == 'membership-requests' ) { 796 797 if ( !$bp->is_item_admin || $group_obj->status == 'public' ) 800 798 return false; 801 799 802 800 // Remove any screen notifications 803 bp_core_delete_notifications_for_user_by_type( $bp ['loggedin_userid'], 'groups', 'new_membership_request' );804 805 $request_action = $bp ['action_variables'][1];806 $membership_id = $bp ['action_variables'][2];801 bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, 'groups', 'new_membership_request' ); 802 803 $request_action = $bp->action_variables[1]; 804 $membership_id = $bp->action_variables[2]; 807 805 808 806 if ( isset($request_action) && isset($membership_id) ) { … … 829 827 do_action( 'groups_group_request_managed', $group_obj->id, $request_action, $membership_id ); 830 828 831 bp_core_redirect( site_url() . '/' . $bp ['current_component'] . '/' . $bp['current_item']. '/admin/membership-requests' );829 bp_core_redirect( site_url() . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/membership-requests' ); 832 830 } 833 831 … … 842 840 global $bp, $group_obj; 843 841 844 if ( $bp ['current_component'] == $bp['groups']['slug'] && $bp['action_variables'][0] == 'delete-group' ) {845 846 if ( !$bp ['is_item_admin'])842 if ( $bp->current_component == $bp->groups->slug && $bp->action_variables[0] == 'delete-group' ) { 843 844 if ( !$bp->is_item_admin ) 847 845 return false; 848 846 … … 853 851 } else { 854 852 bp_core_add_message( __( 'The group was deleted successfully', 'buddypress' ) ); 855 bp_core_redirect( site_url() . '/' . $bp ['groups']['slug']. '/' );853 bp_core_redirect( site_url() . '/' . $bp->groups->slug . '/' ); 856 854 } 857 855 858 856 do_action( 'groups_group_deleted', $_POST['group-id'] ); 859 857 860 bp_core_redirect( $bp ['loggedin_domain'] . $bp['current_component']);858 bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component ); 861 859 } else { 862 860 do_action( 'groups_screen_group_admin_delete_group', $group_obj->id ); … … 923 921 global $is_single_group, $group_obj; 924 922 925 if ( !$is_single_group || $bp ['current_component'] != $bp['groups']['slug'] || $bp['current_action']!= 'join' )923 if ( !$is_single_group || $bp->current_component != $bp->groups->slug || $bp->current_action != 'join' ) 926 924 return false; 927 925 928 926 // user wants to join a group 929 if ( !groups_is_user_member( $bp ['loggedin_userid'], $group_obj->id ) && !groups_is_user_banned( $bp['loggedin_userid'], $group_obj->id ) ) {927 if ( !groups_is_user_member( $bp->loggedin_user->id, $group_obj->id ) && !groups_is_user_banned( $bp->loggedin_user->id, $group_obj->id ) ) { 930 928 if ( !groups_join_group($group_obj->id) ) { 931 929 bp_core_add_message( __('There was an error joining the group.', 'buddypress'), 'error' ); … … 1008 1006 break; 1009 1007 case 'new_wire_post': 1010 $wire_post = new BP_Wire_Post( $bp ['groups']['table_name_wire'], $item_id );1008 $wire_post = new BP_Wire_Post( $bp->groups->table_name_wire, $item_id ); 1011 1009 $group = new BP_Groups_Group( $wire_post->item_id ); 1012 1010 … … 1112 1110 1113 1111 if ( (int)$total_items > 1 ) { 1114 return apply_filters( 'bp_groups_multiple_membership_request_accepted_notification', '<a href="' . $bp ['loggedin_domain'] . $bp['groups']['slug']. '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('%d accepted group membership requests'), (int)$total_items, $group->name ) . '</a>', $total_items, $group_name );1112 return apply_filters( 'bp_groups_multiple_membership_request_accepted_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('%d accepted group membership requests'), (int)$total_items, $group->name ) . '</a>', $total_items, $group_name ); 1115 1113 } else { 1116 1114 return apply_filters( 'bp_groups_single_membership_request_accepted_notification', '<a href="' . $group_link . '">' . sprintf( __('Membership for group "%s" accepted'), $group->name ) . '</a>', $group_link, $group->name ); … … 1125 1123 1126 1124 if ( (int)$total_items > 1 ) { 1127 return apply_filters( 'bp_groups_multiple_membership_request_rejected_notification', '<a href="' . site_url() . '/' . MEMBERS_SLUG . '/' . $bp ['groups']['slug']. '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('%d rejected group membership requests'), (int)$total_items, $group->name ) . '</a>', $total_items, $group->name );1125 return apply_filters( 'bp_groups_multiple_membership_request_rejected_notification', '<a href="' . site_url() . '/' . MEMBERS_SLUG . '/' . $bp->groups->slug . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('%d rejected group membership requests'), (int)$total_items, $group->name ) . '</a>', $total_items, $group->name ); 1128 1126 } else { 1129 1127 return apply_filters( 'bp_groups_single_membership_request_rejected_notification', '<a href="' . $group_link . '">' . sprintf( __('Membership for group "%s" rejected'), $group->name ) . '</a>', $group_link, $group->name ); … … 1139 1137 1140 1138 if ( (int)$total_items > 1 ) { 1141 return apply_filters( 'bp_groups_multiple_member_promoted_to_admin_notification', '<a href="' . $bp ['loggedin_domain'] . $bp['groups']['slug']. '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('You were promoted to an admin in %d groups'), (int)$total_items ) . '</a>', $total_items );1139 return apply_filters( 'bp_groups_multiple_member_promoted_to_admin_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('You were promoted to an admin in %d groups'), (int)$total_items ) . '</a>', $total_items ); 1142 1140 } else { 1143 1141 return apply_filters( 'bp_groups_single_member_promoted_to_admin_notification', '<a href="' . $group_link . '">' . sprintf( __('You were promoted to an admin in the group %s'), $group->name ) . '</a>', $group_link, $group->name ); … … 1152 1150 1153 1151 if ( (int)$total_items > 1 ) { 1154 return apply_filters( 'bp_groups_multiple_member_promoted_to_mod_notification', '<a href="' . $bp ['loggedin_domain'] . $bp['groups']['slug']. '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('You were promoted to a mod in %d groups'), (int)$total_items ) . '</a>', $total_items );1152 return apply_filters( 'bp_groups_multiple_member_promoted_to_mod_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('You were promoted to a mod in %d groups'), (int)$total_items ) . '</a>', $total_items ); 1155 1153 } else { 1156 1154 return apply_filters( 'bp_groups_single_member_promoted_to_mod_notification', '<a href="' . $group_link . '">' . sprintf( __('You were promoted to a mod in the group %s'), $group->name ) . '</a>', $group_link, $group->name ); … … 1165 1163 1166 1164 if ( (int)$total_items > 1 ) { 1167 return apply_filters( 'bp_groups_multiple_group_invite_notification', '<a href="' . $bp ['loggedin_domain'] . $bp['groups']['slug']. '/invites" title="' . __( 'Group Invites', 'buddypress' ) . '">' . sprintf( __('You have %d new group invitations'), (int)$total_items ) . '</a>', $total_items );1165 return apply_filters( 'bp_groups_multiple_group_invite_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/invites" title="' . __( 'Group Invites', 'buddypress' ) . '">' . sprintf( __('You have %d new group invitations'), (int)$total_items ) . '</a>', $total_items ); 1168 1166 } else { 1169 return apply_filters( 'bp_groups_single_group_invite_notification', '<a href="' . $bp ['loggedin_domain'] . $bp['groups']['slug']. '/invites" title="' . __( 'Group Invites', 'buddypress' ) . '">' . sprintf( __('You have an invitation to the group: %s'), $group->name ) . '</a>', $group->name );1167 return apply_filters( 'bp_groups_single_group_invite_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/invites" title="' . __( 'Group Invites', 'buddypress' ) . '">' . sprintf( __('You have an invitation to the group: %s'), $group->name ) . '</a>', $group->name ); 1170 1168 } 1171 1169 break; … … 1207 1205 global $bp; 1208 1206 1209 $groups = BP_Groups_Member::get_group_ids( $bp ['current_userid'], $pag_num, $pag_page );1207 $groups = BP_Groups_Member::get_group_ids( $bp->displayed_user->id, $pag_num, $pag_page ); 1210 1208 1211 1209 return array( 'groups' => $groups['ids'], 'total' => $groups['total'] ); … … 1292 1290 bp_core_render_avatar_upload_form( '', true ); 1293 1291 } else { 1294 bp_core_render_avatar_cropper( $original, $canvas, null, null, false, $bp ['loggedin_domain']);1292 bp_core_render_avatar_cropper( $original, $canvas, null, null, false, $bp->loggedin_user->domain ); 1295 1293 } 1296 1294 } … … 1306 1304 global $bp; 1307 1305 1308 $src = $bp ['root_domain']. '/';1306 $src = $bp->root_domain . '/'; 1309 1307 1310 1308 $thumb_href = str_replace( ABSPATH, $src, stripslashes( $avatars['v1_out'] ) ); … … 1317 1315 global $bp; 1318 1316 1319 $src = $bp ['root_domain']. '/';1317 $src = $bp->root_domain . '/'; 1320 1318 1321 1319 $path = str_replace( $src, ABSPATH, stripslashes( $avatar ) ); … … 1348 1346 case '1': 1349 1347 if ( $_POST['group-name'] != '' && $_POST['group-desc'] != '' ) { 1350 $group_obj->creator_id = $bp ['loggedin_userid'];1348 $group_obj->creator_id = $bp->loggedin_user->id; 1351 1349 $group_obj->name = stripslashes($_POST['group-name']); 1352 1350 $group_obj->description = stripslashes($_POST['group-desc']); … … 1368 1366 1369 1367 // Save the creator as the group administrator 1370 $admin = new BP_Groups_Member( $bp ['loggedin_userid'], $group_obj->id );1368 $admin = new BP_Groups_Member( $bp->loggedin_user->id, $group_obj->id ); 1371 1369 $admin->is_admin = 1; 1372 1370 $admin->user_title = __('Group Admin', 'buddypress'); … … 1410 1408 } else { 1411 1409 /* Create the forum if enable_forum = 1 */ 1412 if ( function_exists( 'bp_forums_setup' ) && groups_get_groupmeta( $group_obj->id, 'forum_id' ) == '') {1410 if ( function_exists( 'bp_forums_setup' ) && '' == groups_get_groupmeta( $group_obj->id, 'forum_id' ) ) { 1413 1411 groups_new_group_forum(); 1414 1412 } … … 1471 1469 global $bp; 1472 1470 1473 if ( in_array( $slug, $bp ['groups']['forbidden_names']) ) {1471 if ( in_array( $slug, $bp->groups->forbidden_names ) ) { 1474 1472 $slug = $slug . '-' . rand(); 1475 1473 } … … 1574 1572 $invite->user_id = $user_id; 1575 1573 $invite->date_modified = time(); 1576 $invite->inviter_id = $bp ['loggedin_userid'];1574 $invite->inviter_id = $bp->loggedin_user->id; 1577 1575 $invite->is_confirmed = 0; 1578 1576 … … 1635 1633 1636 1634 if ( !$user_id ) 1637 $user_id = $bp ['loggedin_userid'];1635 $user_id = $bp->loggedin_user->id; 1638 1636 1639 1637 return BP_Groups_Member::get_invites( $user_id ); … … 1644 1642 1645 1643 // Send friend invites. 1646 $invited_users = groups_get_invites_for_group( $bp ['loggedin_userid'], $group_obj->id );1644 $invited_users = groups_get_invites_for_group( $bp->loggedin_user->id, $group_obj->id ); 1647 1645 1648 1646 for ( $i = 0; $i < count( $invited_users ); $i++ ) { … … 1652 1650 } 1653 1651 1654 groups_notification_group_invites( $group_obj->id, $invited_users, $bp ['loggedin_userid']);1652 groups_notification_group_invites( $group_obj->id, $invited_users, $bp->loggedin_user->id ); 1655 1653 1656 1654 do_action( 'groups_send_invites', $group_obj->id, $invited_users ); … … 1665 1663 1666 1664 if ( !$user_id ) 1667 $user_id = $bp ['loggedin_userid'];1665 $user_id = $bp->loggedin_user->id; 1668 1666 1669 1667 // Admins cannot leave a group, that is until promotion to admin support is implemented. … … 1675 1673 return false; 1676 1674 1677 do_action( 'groups_leave_group', $group_id, $bp ['loggedin_userid']);1675 do_action( 'groups_leave_group', $group_id, $bp->loggedin_user->id ); 1678 1676 1679 1677 /* Modify group member count */ … … 1687 1685 1688 1686 if ( !$user_id ) 1689 $user_id = $bp ['loggedin_userid'];1687 $user_id = $bp->loggedin_user->id; 1690 1688 1691 1689 $new_member = new BP_Groups_Member; … … 1708 1706 groups_update_groupmeta( $group_id, 'last_activity', time() ); 1709 1707 1710 do_action( 'groups_join_group', $group_id, $bp ['loggedin_userid']);1708 do_action( 'groups_join_group', $group_id, $bp->loggedin_user->id ); 1711 1709 1712 1710 return true; … … 1763 1761 global $bp; 1764 1762 1765 if ( $group_name == '' || $group_desc == '')1763 if ( empty( $group_name ) || empty( $group_desc ) ) 1766 1764 return false; 1767 1765 … … 1797 1795 /* If forums have been enabled, and a forum does not yet exist, we need to create one. */ 1798 1796 if ( $group->enable_forum ) { 1799 if ( function_exists( 'bp_forums_setup' ) && groups_get_groupmeta( $group->id, 'forum_id' ) == '') {1797 if ( function_exists( 'bp_forums_setup' ) && '' == groups_get_groupmeta( $group->id, 'forum_id' ) ) { 1800 1798 groups_new_group_forum( $group->id, $group->name, $group->description ); 1801 1799 } … … 1810 1808 global $bp; 1811 1809 1812 if ( !$bp ['is_item_admin'])1810 if ( !$bp->is_item_admin ) 1813 1811 return false; 1814 1812 … … 1823 1821 global $bp; 1824 1822 1825 if ( !$bp ['is_item_admin'])1823 if ( !$bp->is_item_admin ) 1826 1824 return false; 1827 1825 … … 1836 1834 global $bp; 1837 1835 1838 if ( !$bp ['is_item_admin'])1836 if ( !$bp->is_item_admin ) 1839 1837 return false; 1840 1838 … … 1849 1847 global $bp; 1850 1848 1851 if ( !$bp ['is_item_admin'])1849 if ( !$bp->is_item_admin ) 1852 1850 return false; 1853 1851 … … 1926 1924 global $bp, $wpdb; 1927 1925 1928 if ( $bp ['current_component'] == $bp['groups']['slug']&& isset( $_GET['random'] ) ) {1926 if ( $bp->current_component == $bp->groups->slug && isset( $_GET['random'] ) ) { 1929 1927 $group = groups_get_random_group(); 1930 1928 1931 bp_core_redirect( $bp ['root_domain'] . '/' . $bp['groups']['slug']. '/' . $group['groups'][0]->slug );1929 bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/' . $group['groups'][0]->slug ); 1932 1930 } 1933 1931 } … … 1938 1936 1939 1937 // Check the user is the group admin. 1940 if ( !$bp ['is_item_admin'])1938 if ( !$bp->is_item_admin ) 1941 1939 return false; 1942 1940 … … 1948 1946 1949 1947 // Remove the activity stream item 1950 groups_delete_activity( array( 'item_id' => $group_id, 'component_name' => 'groups', 'component_action' => 'created_group', 'user_id' => $bp ['loggedin_userid']) );1948 groups_delete_activity( array( 'item_id' => $group_id, 'component_name' => 'groups', 'component_action' => 'created_group', 'user_id' => $bp->loggedin_user->id ) ); 1951 1949 1952 1950 do_action( 'groups_delete_group', $group_id ); … … 1997 1995 1998 1996 if ( !$meta_key ) { 1999 $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp ['groups']['table_name_groupmeta']. " WHERE group_id = %d", $group_id ) );1997 $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d", $group_id ) ); 2000 1998 } else if ( !$meta_value ) { 2001 $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp ['groups']['table_name_groupmeta']. " WHERE group_id = %d AND meta_key = %s AND meta_value = %s", $group_id, $meta_key, $meta_value ) );1999 $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d AND meta_key = %s AND meta_value = %s", $group_id, $meta_key, $meta_value ) ); 2002 2000 } else { 2003 $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp ['groups']['table_name_groupmeta']. " WHERE group_id = %d AND meta_key = %s", $group_id, $meta_key ) );2001 $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d AND meta_key = %s", $group_id, $meta_key ) ); 2004 2002 } 2005 2003 … … 2028 2026 // $metas = array($user->$meta_key); 2029 2027 //else 2030 $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM " . $bp ['groups']['table_name_groupmeta']. " WHERE group_id = %d AND meta_key = %s", $group_id, $meta_key) );2028 $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d AND meta_key = %s", $group_id, $meta_key) ); 2031 2029 } else { 2032 $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM " . $bp ['groups']['table_name_groupmeta']. " WHERE group_id = %d", $group_id) );2030 $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d", $group_id) ); 2033 2031 } 2034 2032 … … 2066 2064 } 2067 2065 2068 $cur = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . $bp ['groups']['table_name_groupmeta']. " WHERE group_id = %d AND meta_key = %s", $group_id, $meta_key ) );2066 $cur = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d AND meta_key = %s", $group_id, $meta_key ) ); 2069 2067 2070 2068 if ( !$cur ) { 2071 $wpdb->query( $wpdb->prepare( "INSERT INTO " . $bp ['groups']['table_name_groupmeta']. " ( group_id, meta_key, meta_value ) VALUES ( %d, %s, %s )", $group_id, $meta_key, $meta_value ) );2069 $wpdb->query( $wpdb->prepare( "INSERT INTO " . $bp->groups->table_name_groupmeta . " ( group_id, meta_key, meta_value ) VALUES ( %d, %s, %s )", $group_id, $meta_key, $meta_value ) ); 2072 2070 } else if ( $cur->meta_value != $meta_value ) { 2073 $wpdb->query( $wpdb->prepare( "UPDATE " . $bp ['groups']['table_name_groupmeta']. " SET meta_value = %s WHERE group_id = %d AND meta_key = %s", $meta_value, $group_id, $meta_key ) );2071 $wpdb->query( $wpdb->prepare( "UPDATE " . $bp->groups->table_name_groupmeta . " SET meta_value = %s WHERE group_id = %d AND meta_key = %s", $meta_value, $group_id, $meta_key ) ); 2074 2072 } else { 2075 2073 return false; … … 2088 2086 function groups_force_buddypress_theme( $template ) { 2089 2087 global $current_component, $current_action; 2090 global $is_member_page ;2091 2088 global $is_member_page, $bp; 2089 2092 2090 $groups_bp = groups_setup_globals(true); 2093 2091 2094 if ( $current_component != $groups_bp ['groups']['slug'])2092 if ( $current_component != $groups_bp->groups->slug ) 2095 2093 return $template; 2096 2094 2097 2095 $member_theme = get_site_option('active-member-theme'); 2098 2096 2099 if ( $member_theme == '')2097 if ( empty($member_theme) ) 2100 2098 $member_theme = 'buddypress-member'; 2101 2099 … … 2104 2102 bp_core_set_uri_globals(); 2105 2103 2106 if ( $current_component == $groups_bp ['groups']['slug'])2107 $is_single_group = BP_Groups_Group::group_exists( $current_action, $groups_bp ['groups']['table_name']);2104 if ( $current_component == $groups_bp->groups->slug ) 2105 $is_single_group = BP_Groups_Group::group_exists( $current_action, $groups_bp->groups->table_name ); 2108 2106 2109 2107 if ( $is_single_group ) { … … 2123 2121 global $bp, $is_single_group, $is_member_page, $current_component; 2124 2122 2125 if ( $current_component != $bp ['groups']['slug'])2123 if ( $current_component != $bp->groups->slug ) 2126 2124 return $stylesheet; 2127 2125 2128 2126 $member_theme = get_site_option('active-member-theme'); 2129 2127 2130 if ( $member_theme == '')2128 if ( empty( $member_theme ) ) 2131 2129 $member_theme = 'buddypress-member'; 2132 2130
Note: See TracChangeset
for help on using the changeset viewer.