Ticket #2005: 2005.001.diff
File 2005.001.diff, 17.0 KB (added by , 14 years ago) |
---|
-
bp-core/admin/bp-core-schema.php
function bp_core_install_groups() { 110 110 slug varchar(200) NOT NULL, 111 111 description longtext NOT NULL, 112 112 status varchar(10) NOT NULL DEFAULT 'public', 113 invite_status varchar(10) NOT NULL DEFAULT 'members', 113 114 enable_forum tinyint(1) NOT NULL DEFAULT '1', 114 115 date_created datetime NOT NULL, 115 116 KEY creator_id (creator_id), -
bp-groups/bp-groups-actions.php
function groups_action_create_group() { 96 96 $group_status = 'private'; 97 97 else if ( 'hidden' == $_POST['group-status'] ) 98 98 $group_status = 'hidden'; 99 100 $allowed_invite_status = apply_filters( 'groups_allowed_invite_status', array( 'members', 'mods', 'admins' ) ); 101 $group_invite_status = in_array( $_POST['group-invite-status'], (array)$allowed_invite_status ) ? $_POST['group-invite-status'] : 'members'; 99 102 100 if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $bp->groups->new_group_id, 'status' => $group_status, ' enable_forum' => $group_enable_forum ) ) ) {103 if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $bp->groups->new_group_id, 'status' => $group_status, 'invite_status' => $group_invite_status, 'enable_forum' => $group_enable_forum ) ) ) { 101 104 bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' ); 102 105 bp_core_redirect( bp_get_root_domain() . '/' . $bp->groups->root_slug . '/create/step/' . $bp->groups->current_create_step . '/' ); 103 106 } -
bp-groups/bp-groups-classes.php
Class BP_Groups_Group { 7 7 var $slug; 8 8 var $description; 9 9 var $status; 10 var $invite_status; 10 11 var $enable_forum; 11 12 var $date_created; 12 13 … … Class BP_Groups_Group { 35 36 $this->slug = $group->slug; 36 37 $this->description = stripslashes($group->description); 37 38 $this->status = $group->status; 39 $this->invite_status = $group->invite_status; 38 40 $this->enable_forum = $group->enable_forum; 39 41 $this->date_created = $group->date_created; 40 42 $this->last_activity = $group->last_activity; … … Class BP_Groups_Group { 55 57 function save() { 56 58 global $wpdb, $bp; 57 59 58 $this->creator_id = apply_filters( 'groups_group_creator_id_before_save', $this->creator_id, $this->id ); 59 $this->name = apply_filters( 'groups_group_name_before_save', $this->name, $this->id ); 60 $this->slug = apply_filters( 'groups_group_slug_before_save', $this->slug, $this->id ); 61 $this->description = apply_filters( 'groups_group_description_before_save', $this->description, $this->id ); 62 $this->status = apply_filters( 'groups_group_status_before_save', $this->status, $this->id ); 63 $this->enable_forum = apply_filters( 'groups_group_enable_forum_before_save', $this->enable_forum, $this->id ); 64 $this->date_created = apply_filters( 'groups_group_date_created_before_save', $this->date_created, $this->id ); 60 $this->creator_id = apply_filters( 'groups_group_creator_id_before_save', $this->creator_id, $this->id ); 61 $this->name = apply_filters( 'groups_group_name_before_save', $this->name, $this->id ); 62 $this->slug = apply_filters( 'groups_group_slug_before_save', $this->slug, $this->id ); 63 $this->description = apply_filters( 'groups_group_description_before_save', $this->description, $this->id ); 64 $this->status = apply_filters( 'groups_group_status_before_save', $this->status, $this->id ); 65 $this->invite_status = apply_filters( 'groups_group_invite_status_before_save', $this->invite_status, $this->id ); 66 $this->enable_forum = apply_filters( 'groups_group_enable_forum_before_save', $this->enable_forum, $this->id ); 67 $this->date_created = apply_filters( 'groups_group_date_created_before_save', $this->date_created, $this->id ); 65 68 66 69 do_action_ref_array( 'groups_group_before_save', array( &$this ) ); 67 70 … … Class BP_Groups_Group { 73 76 slug = %s, 74 77 description = %s, 75 78 status = %s, 79 invite_status = %s, 76 80 enable_forum = %d, 77 81 date_created = %s 78 82 WHERE … … Class BP_Groups_Group { 83 87 $this->slug, 84 88 $this->description, 85 89 $this->status, 90 $this->invite_status, 86 91 $this->enable_forum, 87 92 $this->date_created, 88 93 $this->id … … Class BP_Groups_Group { 95 100 slug, 96 101 description, 97 102 status, 103 invite_status, 98 104 enable_forum, 99 105 date_created 100 106 ) VALUES ( 101 %d, %s, %s, %s, %s, % d, %s107 %d, %s, %s, %s, %s, %s, %d, %s 102 108 )", 103 109 $this->creator_id, 104 110 $this->name, 105 111 $this->slug, 106 112 $this->description, 107 113 $this->status, 114 $this->invite_status, 108 115 $this->enable_forum, 109 116 $this->date_created 110 117 ); -
bp-groups/bp-groups-functions.php
function groups_create_group( $args = '' ) { 34 34 * 'description' 35 35 * 'slug' 36 36 * 'status' 37 * 'invite_status' 37 38 * 'enable_forum' 38 39 * 'date_created' 39 40 */ … … function groups_create_group( $args = '' ) { 61 62 if ( groups_is_valid_status( $status ) ) 62 63 $group->status = $status; 63 64 } 64 65 66 if ( isset( $invite_status ) ) { 67 if ( groups_is_valid_invite_status( $invite_status ) ) 68 $group->invite_status = $invite_status; 69 } 70 65 71 if ( isset( $enable_forum ) ) 66 72 $group->enable_forum = $enable_forum; 67 73 else if ( !$group_id && !isset( $enable_forum ) ) … … function groups_edit_base_group_details( $group_id, $group_name, $group_desc, $n 118 124 return true; 119 125 } 120 126 121 function groups_edit_group_settings( $group_id, $enable_forum, $status ) {127 function groups_edit_group_settings( $group_id, $enable_forum, $status, $invite_status ) { 122 128 global $bp; 123 129 124 130 $group = new BP_Groups_Group( $group_id ); … … function groups_edit_group_settings( $group_id, $enable_forum, $status ) { 132 138 groups_accept_all_pending_membership_requests( $group->id ); 133 139 134 140 // Now update the status 135 $group->status = $status; 141 $group->status = $status; 142 $group->invite_status = $invite_status; 136 143 137 144 if ( !$group->save() ) 138 145 return false; … … function groups_is_valid_status( $status ) { 198 205 return in_array( $status, (array)$bp->groups->valid_status ); 199 206 } 200 207 208 function groups_is_valid_invite_status( $status ) { 209 global $bp; 210 211 return in_array( $status, (array)$bp->groups->valid_invite_status ); 212 } 213 201 214 function groups_check_slug( $slug ) { 202 215 global $bp; 203 216 -
bp-groups/bp-groups-loader.php
class BP_Groups_Component extends BP_Component { 184 184 'private', 185 185 'hidden' 186 186 ) ); 187 188 // Groups invite statuses 189 $this->valid_invite_status = apply_filters( 'groups_valid_invite_status', array( 190 'members', 191 'mods', 192 'admin' 193 ) ); 187 194 188 195 // Auto join group when non group member performs group activity 189 196 $this->auto_join = defined( 'BP_DISABLE_AUTO_GROUP_JOIN' ); … … class BP_Groups_Component extends BP_Component { 316 323 'item_css_id' => 'members' 317 324 ); 318 325 319 if ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $this->current_group->id ) ) { 320 if ( bp_is_active( 'friends' ) ) { 321 $sub_nav[] = array( 322 'name' => __( 'Send Invites', 'buddypress' ), 323 'slug' => 'send-invites', 324 'parent_url' => $group_link, 325 'parent_slug' => $this->current_group->slug, 326 'screen_function' => 'groups_screen_group_invite', 327 'item_css_id' => 'invite', 328 'position' => 70, 329 'user_has_access' => $this->current_group->user_has_access 330 ); 331 } 326 if ( bp_groups_user_can_send_invites() && bp_is_active( 'friends' ) ) { 327 $sub_nav[] = array( 328 'name' => __( 'Send Invites', 'buddypress' ), 329 'slug' => 'send-invites', 330 'parent_url' => $group_link, 331 'parent_slug' => $this->current_group->slug, 332 'screen_function' => 'groups_screen_group_invite', 333 'item_css_id' => 'invite', 334 'position' => 70, 335 'user_has_access' => $this->current_group->user_has_access 336 ); 332 337 } 333 338 334 339 parent::_setup_nav( $main_nav, $sub_nav ); -
bp-groups/bp-groups-screens.php
function groups_screen_group_admin_settings() { 495 495 496 496 // If the edit form has been submitted, save the edited details 497 497 if ( isset( $_POST['save'] ) ) { 498 498 499 $enable_forum = ( isset($_POST['group-show-forum'] ) ) ? 1 : 0; 500 499 501 $allowed_status = apply_filters( 'groups_allowed_status', array( 'public', 'private', 'hidden' ) ); 500 502 $status = ( in_array( $_POST['group-status'], (array)$allowed_status ) ) ? $_POST['group-status'] : 'public'; 501 503 504 $allowed_invite_status = apply_filters( 'groups_allowed_invite_status', array( 'members', 'mods', 'admins' ) ); 505 $invite_status = in_array( $_POST['group-invite-status'], (array)$allowed_invite_status ) ? $_POST['group-invite-status'] : 'members'; 506 502 507 // Check the nonce 503 508 if ( !check_admin_referer( 'groups_edit_group_settings' ) ) 504 509 return false; 505 510 506 if ( !groups_edit_group_settings( $_POST['group-id'], $enable_forum, $status ) ) {511 if ( !groups_edit_group_settings( $_POST['group-id'], $enable_forum, $status, $invite_status ) ) { 507 512 bp_core_add_message( __( 'There was an error updating group settings, please try again.', 'buddypress' ), 'error' ); 508 513 } else { 509 514 bp_core_add_message( __( 'Group settings were successfully updated.', 'buddypress' ) ); -
bp-groups/bp-groups-template.php
function bp_group_show_status_setting( $setting, $group = false ) { 798 798 echo ' checked="checked"'; 799 799 } 800 800 801 function bp_group_show_invite_status_setting( $setting, $group = false ) { 802 global $groups_template; 803 804 if ( !$group ) 805 $group =& $groups_template->group; 806 807 if ( $setting == $group->invite_status ) 808 echo ' checked="checked"'; 809 } 810 801 811 function bp_group_admin_memberlist( $admin_list = false, $group = false ) { 802 812 global $groups_template; 803 813 … … function bp_new_group_status() { 1929 1939 return apply_filters( 'bp_get_new_group_status', $bp->groups->current_group->status ); 1930 1940 } 1931 1941 1942 function bp_new_group_invite_status() { 1943 echo bp_get_new_group_invite_status(); 1944 } 1945 function bp_get_new_group_invite_status() { 1946 global $bp; 1947 return apply_filters( 'bp_get_new_group_invite_status', $bp->groups->current_group->invite_status ); 1948 } 1949 1932 1950 function bp_new_group_avatar( $args = '' ) { 1933 1951 echo bp_get_new_group_avatar( $args ); 1934 1952 } … … function bp_group_invite_user_remove_invite_url() { 2492 2510 return wp_nonce_url( site_url( BP_GROUPS_SLUG . '/' . $invites_template->invite->group_id . '/invites/remove/' . $invites_template->invite->user->id ), 'groups_invite_uninvite_user' ); 2493 2511 } 2494 2512 2513 function bp_groups_user_can_send_invites( $group_id = false ) { 2514 global $bp; 2515 2516 $can_send_invites = false; 2517 $invite_status = false; 2518 2519 if ( is_user_logged_in() ) { 2520 if ( is_super_admin() ) { 2521 // Super admins can always send invitations 2522 $can_send_invites = true; 2523 } else { 2524 if ( $group_id ) { 2525 $group = new BP_Groups_Group( $group_id ); 2526 $invite_status = $group->invite_status; 2527 } else if ( !empty( $bp->groups->current_group ) ) { 2528 $group = $bp->groups->current_group; 2529 } else { 2530 return false; 2531 } 2532 2533 // This provides adjustable fallback support to pre-1.3 installations, 2534 // which had no invite_status 2535 $invite_status = !empty( $group->invite_status ) ? $group->invite_status : apply_filters( 'bp_groups_fallback_invite_status', 'members' ); 2536 2537 switch ( $invite_status ) { 2538 case 'admins' : 2539 if ( groups_is_user_admin( bp_loggedin_user_id(), $group->id ) ) 2540 $can_send_invites = true; 2541 break; 2542 2543 case 'mods' : 2544 if ( groups_is_user_mod( bp_loggedin_user_id(), $group->id ) ) 2545 $can_send_invites = true; 2546 break; 2547 2548 case 'members' : 2549 if ( groups_is_user_member( bp_loggedin_user_id(), $group->id ) ) 2550 $can_send_invites = true; 2551 break; 2552 } 2553 } 2554 } 2555 2556 return apply_filters( 'bp_groups_user_can_send_invites', $can_send_invites, $group_id, $invite_status ); 2557 } 2558 2495 2559 /*** 2496 2560 * Groups RSS Feed Template Tags 2497 2561 */ -
bp-loader.php
if ( !defined( 'BP_VERSION' ) ) 18 18 19 19 // Define the database version 20 20 if ( !defined( 'BP_DB_VERSION' ) ) 21 define( 'BP_DB_VERSION', 370 6);21 define( 'BP_DB_VERSION', 3707 ); 22 22 23 23 // Place your custom code (actions/filters) in a file called 24 24 // '/plugins/bp-custom.php' and it will be loaded before anything else. -
bp-themes/bp-default/_inc/ajax.php
function bp_dtheme_ajax_invite_user() { 356 356 if ( !$_POST['friend_id'] || !$_POST['friend_action'] || !$_POST['group_id'] ) 357 357 return false; 358 358 359 if ( !groups_is_user_admin( $bp->loggedin_user->id, $_POST['group_id'] ) )360 return false;361 362 359 if ( !friends_check_friendship( $bp->loggedin_user->id, $_POST['friend_id'] ) ) 363 360 return false; 364 361 -
bp-themes/bp-default/groups/create.php
105 105 </ul> 106 106 </label> 107 107 </div> 108 109 <hr /> 110 111 <h4><?php _e( 'Group Invitations', 'buddypress' ); ?></h4> 112 113 <p><?php _e( 'Which members of this group are allowed to invite others?', 'buddypress' ) ?></p> 114 115 <div class="radio"> 116 <label> 117 <input type="radio" name="group-invite-status" value="members"<?php if ( 'members' == bp_get_new_group_invite_status() || !bp_get_new_group_invite_status() ) { ?> checked="checked"<?php } ?>/> 118 <strong><?php _e( 'All group members', 'buddypress' ) ?></strong> 119 </label> 120 121 <label> 122 <input type="radio" name="group-invite-status" value="mods"<?php if ( 'mods' == bp_get_new_group_invite_status() ) { ?> checked="checked"<?php } ?>/> 123 <strong><?php _e( 'Group admins and mods only', 'buddypress' ) ?></strong> 124 </label> 125 126 <label> 127 <input type="radio" name="group-invite-status" value="admins"<?php if ( 'mods' == bp_get_new_group_invite_status() ) { ?> checked="checked"<?php } ?>/> 128 <strong><?php _e( 'Group admins only', 'buddypress' ) ?></strong> 129 </label> 130 </div> 108 131 109 132 <?php do_action( 'bp_after_group_settings_creation_step' ); ?> 110 133 -
bp-themes/bp-default/groups/single/admin.php
87 87 </label> 88 88 </div> 89 89 90 <hr /> 91 92 <h4><?php _e( 'Group Invitations', 'buddypress' ); ?></h4> 93 94 <p><?php _e( 'Which members of this group are allowed to invite others?', 'buddypress' ) ?></p> 95 96 <div class="radio"> 97 <label> 98 <input type="radio" name="group-invite-status" value="members"<?php bp_group_show_invite_status_setting( 'members' ) ?> /> 99 <strong><?php _e( 'All group members', 'buddypress' ) ?></strong> 100 </label> 101 102 <label> 103 <input type="radio" name="group-invite-status" value="mods"<?php bp_group_show_invite_status_setting( 'mods' ) ?> /> 104 <strong><?php _e( 'Group admins and mods only', 'buddypress' ) ?></strong> 105 </label> 106 107 <label> 108 <input type="radio" name="group-invite-status" value="admins"<?php bp_group_show_invite_status_setting( 'admins' ) ?> /> 109 <strong><?php _e( 'Group admins only', 'buddypress' ) ?></strong> 110 </label> 111 </div> 112 113 <hr /> 114 90 115 <?php do_action( 'bp_after_group_settings_admin' ); ?> 91 116 92 117 <p><input type="submit" value="<?php _e( 'Save Changes', 'buddypress' ) ?> →" id="save" name="save" /></p>