Changeset 3537
- Timestamp:
- 12/18/2010 04:03:10 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-groups.php
r3536 r3537 52 52 /* This is a single group page. */ 53 53 $bp->is_single_item = true; 54 $bp->groups->current_group = new BP_Groups_Group( $group_id ); 54 $bp->groups->current_group = groups_get_groups( array( 'type' => 'active', 'include' => $group_id ) ); 55 $bp->groups->current_group = $bp->groups->current_group['groups'][0]; 55 56 56 57 /* Using "item" not "group" for generic support in other components. */ … … 292 293 $forum_id = groups_get_groupmeta( $bp->groups->current_group->id, 'forum_id' ); 293 294 295 $user_is_banned = false; 296 if ( !is_super_admin() && groups_is_user_banned( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) 297 $user_is_banned = true; 298 294 299 if ( $topic_slug && $topic_id ) { 295 300 296 301 /* Posting a reply */ 297 if ( ! isset( $bp->action_variables[2] ) && isset( $_POST['submit_reply'] ) ) {302 if ( !$user_is_banned && !isset( $bp->action_variables[2] ) && isset( $_POST['submit_reply'] ) ) { 298 303 /* Check the nonce */ 299 304 check_admin_referer( 'bp_forums_new_reply' ); … … 373 378 374 379 /* Delete a topic */ 375 else if ( isset( $bp->action_variables[2] ) && 'delete' == $bp->action_variables[2] && empty( $bp->action_variables[3] ) ) {380 else if ( !$user_is_banned && isset( $bp->action_variables[2] ) && 'delete' == $bp->action_variables[2] && empty( $bp->action_variables[3] ) ) { 376 381 /* Fetch the topic */ 377 382 $topic = bp_forums_get_topic_details( $topic_id ); … … 387 392 bp_core_add_message( __( 'There was an error deleting the topic', 'buddypress'), 'error' ); 388 393 else 389 bp_core_add_message( __( 'The topic was deleted successfully', 'buddypress') );390 394 391 395 do_action( 'groups_delete_forum_topic', $topic_id ); … … 394 398 395 399 /* Editing a topic */ 396 else if ( isset( $bp->action_variables[2] ) && 'edit' == $bp->action_variables[2] && empty( $bp->action_variables[3] ) ) {400 else if ( !$user_is_banned && isset( $bp->action_variables[2] ) && 'edit' == $bp->action_variables[2] && empty( $bp->action_variables[3] ) ) { 397 401 /* Fetch the topic */ 398 402 $topic = bp_forums_get_topic_details( $topic_id ); … … 419 423 420 424 /* Delete a post */ 421 else if ( isset( $bp->action_variables[2] ) && 'delete' == $bp->action_variables[2] && isset( $bp->action_variables[4] ) && $post_id = $bp->action_variables[4] ) {425 else if ( !$user_is_banned && isset( $bp->action_variables[2] ) && 'delete' == $bp->action_variables[2] && isset( $bp->action_variables[4] ) && $post_id = $bp->action_variables[4] ) { 422 426 /* Fetch the post */ 423 427 $post = bp_forums_get_post( $post_id ); … … 440 444 441 445 /* Editing a post */ 442 else if ( isset( $bp->action_variables[2] ) && 'edit' == $bp->action_variables[2] && isset( $bp->action_variables[4] ) && $post_id = $bp->action_variables[4] ) {446 else if ( !$user_is_banned && isset( $bp->action_variables[2] ) && 'edit' == $bp->action_variables[2] && isset( $bp->action_variables[4] ) && $post_id = $bp->action_variables[4] ) { 443 447 /* Fetch the post */ 444 448 $post = bp_forums_get_post( $bp->action_variables[4] ); … … 469 473 /* Standard topic display */ 470 474 else { 475 if ( $user_is_banned ) 476 bp_core_add_message( __( "You have been banned from this group.", 'buddypress' ) ); 477 471 478 bp_core_load_template( apply_filters( 'groups_template_group_forum_topic', 'groups/single/home' ) ); 472 479 } 473 480 474 481 } else { 475 476 482 /* Posting a topic */ 477 483 if ( isset( $_POST['submit_topic'] ) && function_exists( 'bp_forums_new_topic') ) { … … 479 485 check_admin_referer( 'bp_forums_new_topic' ); 480 486 481 /* Auto join this user if they are not yet a member of this group */ 482 if ( $bp->groups->auto_join && !is_super_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) 487 if ( $user_is_banned ) { 488 $error_message = __( "You have been banned from this group.", 'buddypress' ); 489 490 } elseif ( $bp->groups->auto_join && !is_super_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) { 491 // Auto join this user if they are not yet a member of this group 483 492 groups_join_group( $bp->groups->current_group->id, $bp->loggedin_user->id ); 493 } 484 494 485 495 if ( empty( $_POST['topic_title'] ) ) … … 500 510 } 501 511 } 502 512 503 513 bp_core_redirect( $redirect ); 504 505 514 } 506 515 -
trunk/bp-groups/bp-groups-templatetags.php
r3531 r3537 32 32 $this->groups = groups_get_invites_for_user( $user_id, $this->pag_num, $this->pag_page, $exclude ); 33 33 } else if ( 'single-group' == $type ) { 34 $group = new stdClass; 35 $group->group_id = BP_Groups_Group::get_id_from_slug($slug); 36 $this->groups = array( $group ); 34 $this->groups = array( $bp->groups->current_group ); 37 35 } else { 38 36 $this->groups = groups_get_groups( array( 'type' => $type, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'search_terms' => $search_terms, 'include' => $include, 'exclude' => $exclude, 'populate_extras' => $populate_extras ) ); … … 120 118 $this->in_the_loop = true; 121 119 $this->group = $this->next_group(); 122 123 if ( $this->single_group )124 $this->group = new BP_Groups_Group( $this->group->group_id, true );125 120 126 121 if ( 0 == $this->current_group ) // loop has just started … … 1011 1006 1012 1007 // Site admins always have access 1013 if ( is_super_admin())1008 if ( $bp->loggedin_user->is_super_admin ) 1014 1009 return true; 1015 1010 1016 // Load group if none passed1017 1011 if ( !$group ) 1018 1012 $group =& $groups_template->group; 1019 1013 1020 // Check membership 1021 if ( null == $group->is_member ) 1022 $is_member = false; 1023 else 1024 $is_member = true; 1025 1026 // Return 1027 return apply_filters( 'bp_group_is_member', $is_member ); 1014 return apply_filters( 'bp_group_is_member', !empty( $group->is_member ) ); 1015 } 1016 1017 /** 1018 * Checks if a user is banned from a group. 1019 * 1020 * @global object $bp BuddyPress global settings 1021 * @global BP_Groups_Template $groups_template Group template loop object 1022 * @param object $group Group to check if user is banned from the group 1023 * @param int $user_id 1024 * @return bool If user is banned from the group or not 1025 * @since 1.3 1026 */ 1027 function bp_group_is_user_banned( $group = false, $user_id = false ) { 1028 global $bp, $groups_template; 1029 1030 // Site admins always have access 1031 if ( $bp->loggedin_user->is_super_admin ) 1032 return true; 1033 1034 if ( !$group ) { 1035 $group =& $groups_template->group; 1036 1037 if ( !$user_id ) 1038 return apply_filters( 'bp_group_is_member_banned', !empty( $group->is_banned ) ); 1039 } 1040 1041 if ( !$user_id ) 1042 $user_id = $bp->loggedin_user->id; 1043 1044 return apply_filters( 'bp_group_is_user_banned', groups_is_user_banned( $user_id, $group->id ) ); 1028 1045 } 1029 1046 … … 1103 1120 } 1104 1121 1105 function bp_group_new_topic_button() { 1106 if ( bp_is_group_forum() && is_user_logged_in() && !bp_is_group_forum_topic() ) { 1107 bp_button( array ( 1122 function bp_group_new_topic_button( $group = false ) { 1123 echo bp_get_group_new_topic_button(); 1124 } 1125 function bp_get_group_new_topic_button( $group = false ) { 1126 global $groups_template; 1127 1128 if ( !$group ) 1129 $group =& $groups_template->group; 1130 1131 if ( !is_user_logged_in() || bp_group_is_user_banned() || !bp_is_group_forum() || bp_is_group_forum_topic() ) 1132 return false; 1133 1134 $button = bp_button( array ( 1108 1135 'id' => 'new_topic', 1109 1136 'component' => 'groups', … … 1117 1144 'link_title' => __( 'New Topic', 'buddypress' ), 1118 1145 ) ); 1119 } 1120 } 1146 1147 // Filter and return the HTML button 1148 return bp_get_button( apply_filters( 'bp_get_group_new_topic_button', $button ) ); 1149 } 1121 1150 1122 1151 function bp_group_join_button( $group = false ) { … … 1129 1158 $group =& $groups_template->group; 1130 1159 1131 // If they're not logged in or are banned from the group, no join button. 1132 if ( !is_user_logged_in() || isset( $group->is_banned ) ) 1160 if ( !is_user_logged_in() || bp_group_is_user_banned() ) 1133 1161 return false; 1134 1162 -
trunk/bp-themes/bp-default/groups/single/forum.php
r3460 r3537 19 19 <?php if ( !bp_is_group_forum_topic_edit() && !bp_is_group_forum_topic() ) : ?> 20 20 21 <?php if ( ( is_user_logged_in() && 'public' == bp_get_group_status() ) || bp_group_is_member() ) : ?>21 <?php if ( !bp_group_is_user_banned() && ( ( is_user_logged_in() && 'public' == bp_get_group_status() ) || bp_group_is_member() ) ) : ?> 22 22 23 23 <form action="" method="post" id="forum-topic-form" class="standard-form"> -
trunk/bp-themes/bp-default/groups/single/forum/topic.php
r3460 r3537 79 79 <?php if ( bp_get_the_topic_is_last_page() ) : ?> 80 80 81 <?php if ( bp_get_the_topic_is_topic_open() ) : ?>81 <?php if ( bp_get_the_topic_is_topic_open() && !bp_group_is_user_banned() ) : ?> 82 82 83 83 <div id="post-topic-reply"> … … 103 103 </div> 104 104 105 <?php else : ?>105 <?php elseif ( !bp_group_is_user_banned() ) : ?> 106 106 107 107 <div id="message" class="info">
Note: See TracChangeset
for help on using the changeset viewer.