Changeset 10373
- Timestamp:
- 11/22/2015 04:58:34 AM (9 years ago)
- Location:
- trunk/src/bp-groups
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-groups/bp-groups-actions.php
r10276 r10373 29 29 30 30 if ( ! $user_has_access && 'hidden' !== $current_group->status ) { 31 // Always allow access to home and request-membership 31 // Always allow access to home and request-membership. 32 32 if ( bp_is_current_action( 'home' ) || bp_is_current_action( 'request-membership' ) ) { 33 33 $user_has_access = true; 34 34 35 // User doesn't have access, so set up redirect args 35 // User doesn't have access, so set up redirect args. 36 36 } elseif ( is_user_logged_in() ) { 37 37 $no_access_args = array( … … 43 43 } 44 44 45 // Protect the admin tab from non-admins 45 // Protect the admin tab from non-admins. 46 46 if ( bp_is_current_action( 'admin' ) && ! bp_is_item_admin() ) { 47 47 $user_has_access = false; … … 95 95 function groups_action_create_group() { 96 96 97 // If we're not at domain.org/groups/create/ then return false 97 // If we're not at domain.org/groups/create/ then return false. 98 98 if ( !bp_is_groups_component() || !bp_is_current_action( 'create' ) ) 99 99 return false; … … 109 109 $bp = buddypress(); 110 110 111 // Make sure creation steps are in the right order 111 // Make sure creation steps are in the right order. 112 112 groups_action_sort_creation_steps(); 113 113 114 // If no current step is set, reset everything so we can start a fresh group creation 114 // If no current step is set, reset everything so we can start a fresh group creation. 115 115 $bp->groups->current_create_step = bp_action_variable( 1 ); 116 116 if ( !bp_get_groups_current_create_step() ) { … … 126 126 } 127 127 128 // If this is a creation step that is not recognized, just redirect them back to the first screen 128 // If this is a creation step that is not recognized, just redirect them back to the first screen. 129 129 if ( bp_get_groups_current_create_step() && empty( $bp->groups->group_creation_steps[bp_get_groups_current_create_step()] ) ) { 130 130 bp_core_add_message( __('There was an error saving group details. Please try again.', 'buddypress'), 'error' ); … … 132 132 } 133 133 134 // Fetch the currently completed steps variable 134 // Fetch the currently completed steps variable. 135 135 if ( isset( $_COOKIE['bp_completed_create_steps'] ) && !isset( $reset_steps ) ) 136 136 $bp->groups->completed_create_steps = json_decode( base64_decode( stripslashes( $_COOKIE['bp_completed_create_steps'] ) ) ); 137 137 138 // Set the ID of the new group, if it has already been created in a previous step 138 // Set the ID of the new group, if it has already been created in a previous step. 139 139 if ( isset( $_COOKIE['bp_new_group_id'] ) ) { 140 140 $bp->groups->new_group_id = (int) $_COOKIE['bp_new_group_id']; 141 141 $bp->groups->current_group = groups_get_group( array( 'group_id' => $bp->groups->new_group_id ) ); 142 142 143 // Only allow the group creator to continue to edit the new group 143 // Only allow the group creator to continue to edit the new group. 144 144 if ( ! bp_is_group_creator( $bp->groups->current_group, bp_loggedin_user_id() ) ) { 145 145 bp_core_add_message( __( 'Only the group creator may continue editing this group.', 'buddypress' ), 'error' ); … … 148 148 } 149 149 150 // If the save, upload or skip button is hit, lets calculate what we need to save 150 // If the save, upload or skip button is hit, lets calculate what we need to save. 151 151 if ( isset( $_POST['save'] ) ) { 152 152 153 // Check the nonce 153 // Check the nonce. 154 154 check_admin_referer( 'groups_create_save_' . bp_get_groups_current_create_step() ); 155 155 … … 175 175 $group_enable_forum = 0; 176 176 } else { 177 // Create the forum if enable_forum = 1 177 // Create the forum if enable_forum = 1. 178 178 if ( bp_is_active( 'forums' ) && !groups_get_groupmeta( $bp->groups->new_group_id, 'forum_id' ) ) { 179 179 groups_new_group_forum(); … … 247 247 $bp->groups->completed_create_steps[] = bp_get_groups_current_create_step(); 248 248 249 // Reset cookie info 249 // Reset cookie info. 250 250 setcookie( 'bp_new_group_id', $bp->groups->new_group_id, time()+60*60*24, COOKIEPATH ); 251 251 setcookie( 'bp_completed_create_steps', base64_encode( json_encode( $bp->groups->completed_create_steps ) ), time()+60*60*24, COOKIEPATH ); 252 252 253 253 // If we have completed all steps and hit done on the final step we 254 // can redirect to the completed group 254 // can redirect to the completed group. 255 255 $keys = array_keys( $bp->groups->group_creation_steps ); 256 256 if ( count( $bp->groups->completed_create_steps ) == count( $keys ) && bp_get_groups_current_create_step() == array_pop( $keys ) ) { … … 298 298 } 299 299 300 // Remove invitations 300 // Remove invitations. 301 301 if ( 'group-invites' === bp_get_groups_current_create_step() && ! empty( $_REQUEST['user_id'] ) && is_numeric( $_REQUEST['user_id'] ) ) { 302 302 if ( ! check_admin_referer( 'groups_invite_uninvite_user' ) ) { … … 316 316 } 317 317 318 // Group avatar is handled separately 318 // Group avatar is handled separately. 319 319 if ( 'group-avatar' == bp_get_groups_current_create_step() && isset( $_POST['upload'] ) ) { 320 320 if ( ! isset( $bp->avatar_admin ) ) { … … 323 323 324 324 if ( !empty( $_FILES ) && isset( $_POST['upload'] ) ) { 325 // Normally we would check a nonce here, but the group save nonce is used instead 326 327 // Pass the file to the avatar upload handler 325 // Normally we would check a nonce here, but the group save nonce is used instead. 326 // Pass the file to the avatar upload handler. 328 327 if ( bp_core_avatar_handle_upload( $_FILES, 'groups_avatar_upload_dir' ) ) { 329 328 $bp->avatar_admin->step = 'crop-image'; 330 329 331 // Make sure we include the jQuery jCrop file for image cropping 330 // Make sure we include the jQuery jCrop file for image cropping. 332 331 add_action( 'wp_print_scripts', 'bp_core_add_jquery_cropper' ); 333 332 } 334 333 } 335 334 336 // If the image cropping is done, crop the image and save a full/thumb version 335 // If the image cropping is done, crop the image and save a full/thumb version. 337 336 if ( isset( $_POST['avatar-crop-submit'] ) && isset( $_POST['upload'] ) ) { 338 // Normally we would check a nonce here, but the group save nonce is used instead 339 337 // Normally we would check a nonce here, but the group save nonce is used instead. 340 338 if ( !bp_core_avatar_handle_crop( array( 'object' => 'group', 'avatar_dir' => 'group-avatars', 'item_id' => $bp->groups->current_group->id, 'original_file' => $_POST['image_src'], 'crop_x' => $_POST['x'], 'crop_y' => $_POST['y'], 'crop_w' => $_POST['w'], 'crop_h' => $_POST['h'] ) ) ) 341 339 bp_core_add_message( __( 'There was an error saving the group profile photo, please try uploading again.', 'buddypress' ), 'error' ); … … 364 362 return false; 365 363 366 // Nonce check 364 // Nonce check. 367 365 if ( !check_admin_referer( 'groups_join_group' ) ) 368 366 return false; … … 370 368 $bp = buddypress(); 371 369 372 // Skip if banned or already a member 370 // Skip if banned or already a member. 373 371 if ( !groups_is_user_member( bp_loggedin_user_id(), $bp->groups->current_group->id ) && !groups_is_user_banned( bp_loggedin_user_id(), $bp->groups->current_group->id ) ) { 374 372 375 // User wants to join a group that is not public 373 // User wants to join a group that is not public. 376 374 if ( $bp->groups->current_group->status != 'public' ) { 377 375 if ( !groups_check_user_has_invite( bp_loggedin_user_id(), $bp->groups->current_group->id ) ) { … … 381 379 } 382 380 383 // User wants to join any group 381 // User wants to join any group. 384 382 if ( !groups_join_group( $bp->groups->current_group->id ) ) 385 383 bp_core_add_message( __( 'There was an error joining the group.', 'buddypress' ), 'error' ); … … 417 415 } 418 416 419 // Nonce check 417 // Nonce check. 420 418 if ( ! check_admin_referer( 'groups_leave_group' ) ) { 421 419 return false; 422 420 } 423 421 424 // User wants to leave any group 422 // User wants to leave any group. 425 423 if ( groups_is_user_member( bp_loggedin_user_id(), bp_get_current_group_id() ) ) { 426 424 $bp = buddypress(); 427 425 428 // Stop sole admins from abandoning their group 426 // Stop sole admins from abandoning their group. 429 427 $group_admins = groups_get_group_admins( bp_get_current_group_id() ); 430 428 … … 473 471 } 474 472 475 // Sort the steps by their position key 473 // Sort the steps by their position key. 476 474 ksort($temp); 477 475 unset($bp->groups->group_creation_steps); … … 510 508 function groups_action_group_feed() { 511 509 512 // get current group510 // Get current group. 513 511 $group = groups_get_current_group(); 514 512 … … 516 514 return false; 517 515 518 // if group isn't public or if logged-in user is not a member of the group, do519 // not output the group activity feed 516 // If group isn't public or if logged-in user is not a member of the group, do 517 // not output the group activity feed. 520 518 if ( ! bp_group_is_visible( $group ) ) { 521 519 return false; 522 520 } 523 521 524 // setup the feed522 // Set up the feed. 525 523 buddypress()->activity->feed = new BP_Activity_Feed( array( 526 524 'id' => 'group', -
trunk/src/bp-groups/bp-groups-activity.php
r10148 r10373 54 54 // These actions are for the legacy forums 55 55 // Since the bbPress plugin also shares the same 'forums' identifier, we also 56 // check for the legacy forums loader class to be extra cautious 56 // check for the legacy forums loader class to be extra cautious. 57 57 if ( bp_is_active( 'forums' ) && class_exists( 'BP_Forums_Component' ) ) { 58 58 bp_activity_set_action( … … 91 91 * @param string $action Static activity action. 92 92 * @param object $activity Activity data object. 93 *94 93 * @return string 95 94 */ … … 123 122 * @param string $action Static activity action. 124 123 * @param object $activity Activity data object. 125 *126 124 * @return string 127 125 */ … … 138 136 139 137 // Legacy filters (do not follow parameter patterns of other activity 140 // action filters, and requires apply_filters_ref_array()) 138 // action filters, and requires apply_filters_ref_array()). 141 139 if ( has_filter( 'groups_activity_membership_accepted_action' ) ) { 142 140 $action = apply_filters_ref_array( 'groups_activity_membership_accepted_action', array( $action, $user_link, &$group ) ); 143 141 } 144 142 145 // Another legacy filter 143 // Another legacy filter. 146 144 if ( has_filter( 'groups_activity_accepted_invite_action' ) ) { 147 145 $action = apply_filters_ref_array( 'groups_activity_accepted_invite_action', array( $action, $activity->user_id, &$group ) ); … … 166 164 * @param string $action Static activity action. 167 165 * @param object $activity Activity data object. 168 *169 166 * @return string 170 167 */ … … 221 218 * 222 219 * @param array $activities Array of activity items. 223 *224 220 * @return array 225 221 */ … … 243 239 // TEMPORARY - Once the 'populate_extras' issue is solved 244 240 // in the groups component, we can do this with groups_get_groups() 245 // rather than manually 241 // rather than manually. 246 242 $uncached_ids = array(); 247 243 foreach ( $group_ids as $group_id ) { … … 271 267 * @since 2.2.0 272 268 * 273 * @param array $retval Empty array by default 274 * @param array $filter Current activity arguments 269 * @param array $retval Empty array by default. 270 * @param array $filter Current activity arguments. 275 271 * 276 272 * @return array … … 278 274 function bp_groups_filter_activity_scope( $retval = array(), $filter = array() ) { 279 275 280 // Determine the user_id 276 // Determine the user_id. 281 277 if ( ! empty( $filter['user_id'] ) ) { 282 278 $user_id = $filter['user_id']; … … 287 283 } 288 284 289 // Determine groups of user 285 // Determine groups of user. 290 286 $groups = groups_get_user_groups( $user_id ); 291 287 if ( empty( $groups['groups'] ) ) { … … 318 314 $show_hidden, 319 315 320 // overrides316 // Overrides. 321 317 'override' => array( 322 318 'filter' => array( 'user_id' => 0 ), … … 355 351 } 356 352 357 // Set the default for hide_sitewide by checking the status of the group 353 // Set the default for hide_sitewide by checking the status of the group. 358 354 $hide_sitewide = false; 359 355 if ( !empty( $args['item_id'] ) ) { … … 391 387 * @param int $group_id Optional. The ID of the group whose last_activity is 392 388 * being updated. Default: the current group's ID. 393 *394 389 * @return bool|null False on failure. 395 390 */ … … 419 414 * @param int $user_id ID of the user joining the group. 420 415 * @param int $group_id ID of the group. 421 *422 416 * @return bool|null False on failure. 423 417 */ 424 418 function bp_groups_membership_accepted_add_activity( $user_id, $group_id ) { 425 419 426 // Bail if Activity is not active 420 // Bail if Activity is not active. 427 421 if ( ! bp_is_active( 'activity' ) ) { 428 422 return false; 429 423 } 430 424 431 // Get the group so we can get it's name 425 // Get the group so we can get it's name. 432 426 $group = groups_get_group( array( 'group_id' => $group_id ) ); 433 427 … … 443 437 $action = apply_filters_ref_array( 'groups_activity_membership_accepted_action', array( sprintf( __( '%1$s joined the group %2$s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . esc_attr( $group->name ) . '</a>' ), $user_id, &$group ) ); 444 438 445 // Record in activity streams 439 // Record in activity streams. 446 440 groups_record_activity( array( 447 441 'action' => $action, … … 461 455 * @param BP_Groups_Group $old_group Group object before the details had been changed. 462 456 * @param bool $notify_members True if the admin has opted to notify group members, otherwise false. 463 *464 457 * @return int|bool The ID of the activity on success. False on error. 465 458 */ … … 475 468 } 476 469 477 // If the admin has opted not to notify members, don't post an activity item either 470 // If the admin has opted not to notify members, don't post an activity item either. 478 471 if ( empty( $notify_members ) ) { 479 472 return; … … 557 550 function bp_groups_leave_group_delete_recent_activity( $group_id, $user_id ) { 558 551 559 // Bail if Activity component is not active 552 // Bail if Activity component is not active. 560 553 if ( ! bp_is_active( 'activity' ) ) { 561 554 return; 562 555 } 563 556 564 // Get the member's group membership information 557 // Get the member's group membership information. 565 558 $membership = new BP_Groups_Member( $user_id, $group_id ); 566 559 567 // Check the time period, and maybe delete their recent group activity 560 // Check the time period, and maybe delete their recent group activity. 568 561 if ( time() <= strtotime( '+5 minutes', (int) strtotime( $membership->date_modified ) ) ) { 569 562 bp_activity_delete( array( -
trunk/src/bp-groups/bp-groups-admin.php
r10360 r10373 18 18 if ( !class_exists( 'WP_List_Table' ) ) require( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); 19 19 20 // per_page screen option. Has to be hooked in extremely early.20 // The per_page screen option. Has to be hooked in extremely early. 21 21 if ( is_admin() && ! empty( $_REQUEST['page'] ) && 'bp-groups' == $_REQUEST['page'] ) 22 22 add_filter( 'set-screen-option', 'bp_groups_admin_screen_options', 10, 3 ); … … 29 29 function bp_groups_add_admin_menu() { 30 30 31 // Add our screen 31 // Add our screen. 32 32 $hook = add_menu_page( 33 33 _x( 'Groups', 'Admin Groups page title', 'buddypress' ), … … 53 53 * 54 54 * @param array $custom_menus Array of BP top-level menu items. 55 *56 55 * @return array Menu item array, with Groups added. 57 56 */ … … 76 75 global $bp_groups_list_table; 77 76 78 // Build redirection URL 77 // Build redirection URL. 79 78 $redirect_to = remove_query_arg( array( 'action', 'action2', 'gid', 'deleted', 'error', 'updated', 'success_new', 'error_new', 'success_modified', 'error_modified' ), $_SERVER['REQUEST_URI'] ); 80 79 81 // Decide whether to load the dev version of the CSS and JavaScript 80 // Decide whether to load the dev version of the CSS and JavaScript. 82 81 $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : 'min.'; 83 82 … … 93 92 do_action( 'bp_groups_admin_load', $doaction ); 94 93 95 // Edit screen 94 // Edit screen. 96 95 if ( 'do_delete' == $doaction && ! empty( $_GET['gid'] ) ) { 97 96 … … 112 111 113 112 } elseif ( 'edit' == $doaction && ! empty( $_GET['gid'] ) ) { 114 // columns screen option113 // Columns screen option. 115 114 add_screen_option( 'layout_columns', array( 'default' => 2, 'max' => 2, ) ); 116 115 … … 123 122 ) ); 124 123 125 // Help panel - sidebar links 124 // Help panel - sidebar links. 126 125 get_current_screen()->set_help_sidebar( 127 126 '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' . … … 142 141 do_action( 'bp_groups_admin_meta_boxes' ); 143 142 144 // Enqueue JavaScript files 143 // Enqueue JavaScript files. 145 144 wp_enqueue_script( 'postbox' ); 146 145 wp_enqueue_script( 'dashboard' ); 147 146 148 // Index screen 147 // Index screen. 149 148 } else { 150 // Create the Groups screen list table 149 // Create the Groups screen list table. 151 150 $bp_groups_list_table = new BP_Groups_List_Table(); 152 151 153 // per_page screen option152 // The per_page screen option. 154 153 add_screen_option( 'per_page', array( 'label' => _x( 'Groups', 'Groups per page (screen options)', 'buddypress' )) ); 155 154 156 // Help panel - overview text 155 // Help panel - overview text. 157 156 get_current_screen()->add_help_tab( array( 158 157 'id' => 'bp-groups-overview', … … 171 170 ) ); 172 171 173 // Help panel - sidebar links 172 // Help panel - sidebar links. 174 173 get_current_screen()->set_help_sidebar( 175 174 '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' . … … 180 179 $bp = buddypress(); 181 180 182 // Enqueue CSS and JavaScript 181 // Enqueue CSS and JavaScript. 183 182 wp_enqueue_script( 'bp_groups_admin_js', $bp->plugin_url . "bp-groups/admin/js/admin.{$min}js", array( 'jquery', 'wp-ajax-response', 'jquery-ui-autocomplete' ), bp_get_version(), true ); 184 183 wp_localize_script( 'bp_groups_admin_js', 'BP_Group_Admin', array( … … 195 194 196 195 if ( $doaction && 'save' == $doaction ) { 197 // Get group ID 196 // Get group ID. 198 197 $group_id = isset( $_REQUEST['gid'] ) ? (int) $_REQUEST['gid'] : ''; 199 198 … … 203 202 ), $redirect_to ); 204 203 205 // Check this is a valid form submission 204 // Check this is a valid form submission. 206 205 check_admin_referer( 'edit-group_' . $group_id ); 207 206 208 // Get the group from the database 207 // Get the group from the database. 209 208 $group = groups_get_group( 'group_id=' . $group_id ); 210 209 211 // If the group doesn't exist, just redirect back to the index 210 // If the group doesn't exist, just redirect back to the index. 212 211 if ( empty( $group->slug ) ) { 213 212 wp_redirect( $redirect_to ); … … 215 214 } 216 215 217 // Check the form for the updated properties 218 219 // Store errors 216 // Check the form for the updated properties. 217 // Store errors. 220 218 $error = 0; 221 219 $success_new = $error_new = $success_modified = $error_modified = array(); 222 220 223 221 // Group name and description are handled with 224 // groups_edit_base_group_details() 222 // groups_edit_base_group_details(). 225 223 if ( !groups_edit_base_group_details( $group_id, $_POST['bp-groups-name'], $_POST['bp-groups-description'], 0 ) ) { 226 224 $error = $group_id; 227 225 228 // using negative integers for different error messages... eek!226 // Using negative integers for different error messages... eek! 229 227 if ( empty( $_POST['bp-groups-name'] ) && empty( $_POST['bp-groups-description'] ) ) { 230 228 $error = -3; … … 236 234 } 237 235 238 // Enable discussion forum 236 // Enable discussion forum. 239 237 $enable_forum = ( isset( $_POST['group-show-forum'] ) ) ? 1 : 0; 240 238 … … 263 261 } 264 262 265 // Process new members 263 // Process new members. 266 264 $user_names = array(); 267 265 … … 276 274 277 275 // Make sure the user exists before attempting 278 // to add to the group 276 // to add to the group. 279 277 $user = get_user_by( 'slug', $un ); 280 278 … … 291 289 } 292 290 293 // Process member role changes 291 // Process member role changes. 294 292 if ( ! empty( $_POST['bp-groups-role'] ) && ! empty( $_POST['bp-groups-existing-role'] ) ) { 295 293 296 294 // Before processing anything, make sure you're not 297 // attempting to remove the all user admins 295 // attempting to remove the all user admins. 298 296 $admin_count = 0; 299 297 foreach ( (array) $_POST['bp-groups-role'] as $new_role ) { … … 311 309 } else { 312 310 313 // Process only those users who have had their roles changed 311 // Process only those users who have had their roles changed. 314 312 foreach ( (array) $_POST['bp-groups-role'] as $user_id => $new_role ) { 315 313 … … 321 319 case 'mod' : 322 320 // Admin to mod is a demotion. Demote to 323 // member, then fall through 321 // member, then fall through. 324 322 if ( 'admin' == $existing_role ) { 325 323 groups_demote_member( $user_id, $group_id ); … … 328 326 case 'admin' : 329 327 // If the user was banned, we must 330 // unban first 328 // unban first. 331 329 if ( 'banned' == $existing_role ) { 332 330 groups_unban_member( $user_id, $group_id ); … … 334 332 335 333 // At this point, each existing_role 336 // is a member, so promote 334 // is a member, so promote. 337 335 $result = groups_promote_member( $user_id, $group_id, $new_role ); 338 336 … … 362 360 } 363 361 364 // Store the success or failure 362 // Store the success or failure. 365 363 if ( $result ) { 366 364 $success_modified[] = $user_id; … … 382 380 do_action( 'bp_group_admin_edit_after', $group_id ); 383 381 384 // Create the redirect URL 385 382 // Create the redirect URL. 386 383 if ( $error ) { 387 // This means there was an error updating group details 384 // This means there was an error updating group details. 388 385 $redirect_to = add_query_arg( 'error', (int) $error, $redirect_to ); 389 386 } else { 390 // Group details were update successfully 387 // Group details were update successfully. 391 388 $redirect_to = add_query_arg( 'updated', 1, $redirect_to ); 392 389 } … … 438 435 * @param string $option Screen option name. 439 436 * @param string $new_value Screen option form value. 440 *441 437 * @return string Option value. False to abandon update. 442 438 */ … … 445 441 return $value; 446 442 447 // Per page 443 // Per page. 448 444 $new_value = (int) $new_value; 449 445 if ( $new_value < 1 || $new_value > 999 ) … … 459 455 */ 460 456 function bp_groups_admin() { 461 // Decide whether to load the index or edit screen 457 // Decide whether to load the index or edit screen. 462 458 $doaction = bp_admin_list_table_current_bulk_action(); 463 459 464 // Display the single group edit screen 460 // Display the single group edit screen. 465 461 if ( 'edit' == $doaction && ! empty( $_GET['gid'] ) ) { 466 462 bp_groups_admin_edit(); 467 463 468 // Display the group deletion confirmation screen 464 // Display the group deletion confirmation screen. 469 465 } elseif ( 'delete' == $doaction && ! empty( $_GET['gid'] ) ) { 470 466 bp_groups_admin_delete(); 471 467 472 // Otherwise, display the groups index screen 468 // Otherwise, display the groups index screen. 473 469 } else { 474 470 bp_groups_admin_index(); … … 488 484 $messages = array(); 489 485 490 // If the user has just made a change to a group, build status messages 486 // If the user has just made a change to a group, build status messages. 491 487 if ( !empty( $_REQUEST['no_admins'] ) || ! empty( $_REQUEST['error'] ) || ! empty( $_REQUEST['updated'] ) || ! empty( $_REQUEST['error_new'] ) || ! empty( $_REQUEST['success_new'] ) || ! empty( $_REQUEST['error_modified'] ) || ! empty( $_REQUEST['success_modified'] ) ) { 492 488 $no_admins = ! empty( $_REQUEST['no_admins'] ) ? 1 : 0; … … 546 542 $is_error = ! empty( $no_admins ) || ! empty( $errors ) || ! empty( $error_new ) || ! empty( $error_modified ); 547 543 548 // Get the group from the database 544 // Get the group from the database. 549 545 $group = groups_get_group( 'group_id=' . $_GET['gid'] ); 550 546 … … 552 548 $group_name = isset( $group->name ) ? apply_filters( 'bp_get_group_name', $group->name ) : ''; 553 549 554 // Construct URL for form 550 // Construct URL for form. 555 551 $form_url = remove_query_arg( array( 'action', 'deleted', 'no_admins', 'error', 'error_new', 'success_new', 'error_modified', 'success_modified' ), $_SERVER['REQUEST_URI'] ); 556 552 $form_url = add_query_arg( 'action', 'save', $form_url ); … … 576 572 </h1> 577 573 578 <?php // If the user has just made a change to an group, display the status messages ?>574 <?php // If the user has just made a change to an group, display the status messages. ?> 579 575 <?php if ( !empty( $messages ) ) : ?> 580 576 <div id="moderated" class="<?php echo ( $is_error ) ? 'error' : 'updated'; ?>"><p><?php echo implode( "</p><p>", $messages ); ?></p></div> … … 652 648 'include' => $group_ids, 653 649 'show_hidden' => true, 654 'per_page' => null, // Return all results 650 'per_page' => null, // Return all results. 655 651 ) ); 656 652 657 // Create a new list of group ids, based on those that actually exist 653 // Create a new list of group ids, based on those that actually exist. 658 654 $gids = array(); 659 655 foreach ( $groups['groups'] as $group ) { … … 697 693 $messages = array(); 698 694 699 // If the user has just made a change to a group, build status messages 695 // If the user has just made a change to a group, build status messages. 700 696 if ( ! empty( $_REQUEST['deleted'] ) ) { 701 697 $deleted = ! empty( $_REQUEST['deleted'] ) ? (int) $_REQUEST['deleted'] : 0; … … 706 702 } 707 703 708 // Prepare the group items for display 704 // Prepare the group items for display. 709 705 $bp_groups_list_table->prepare_items(); 710 706 … … 733 729 </h1> 734 730 735 <?php // If the user has just made a change to an group, display the status messages ?>731 <?php // If the user has just made a change to an group, display the status messages. ?> 736 732 <?php if ( !empty( $messages ) ) : ?> 737 733 <div id="moderated" class="<?php echo ( ! empty( $_REQUEST['error'] ) ) ? 'error' : 'updated'; ?>"><p><?php echo implode( "<br/>\n", $messages ); ?></p></div> 738 734 <?php endif; ?> 739 735 740 <?php // Display each group on its own row ?>736 <?php // Display each group on its own row. ?> 741 737 <?php $bp_groups_list_table->views(); ?> 742 738 … … 800 796 * 801 797 * @since 1.7.0 798 * 799 * @param BP_Groups_Group $item The BP_Groups_Group object for the current group. 802 800 */ 803 801 function bp_groups_admin_edit_metabox_add_new_members( $item ) { … … 821 819 // Pull up a list of group members, so we can separate out the types 822 820 // We'll also keep track of group members here to place them into a 823 // JavaScript variable, which will help with group member autocomplete 821 // JavaScript variable, which will help with group member autocomplete. 824 822 $members = array( 825 823 'admin' => array(), … … 851 849 } 852 850 853 // Echo out the JavaScript variable 851 // Echo out the JavaScript variable. 854 852 echo '<script type="text/javascript">var group_id = "' . esc_js( $item->id ) . '";</script>'; 855 853 856 // Loop through each member type 854 // Loop through each member type. 857 855 foreach ( $members as $member_type => $type_users ) : ?> 858 856 … … 1008 1006 * @param BP_Group_Member_Query $query A BP_Group_Member_Query object. 1009 1007 * @param string $member_type member|mod|admin|banned. 1010 *1011 1008 * @return string Pagination links HTML. 1012 1009 */ … … 1018 1015 } 1019 1016 1020 // The key used to paginate this member type in the $_GET global 1017 // The key used to paginate this member type in the $_GET global. 1021 1018 $qs_key = $member_type . '_page'; 1022 1019 $url_base = remove_query_arg( array( $qs_key, 'updated', 'success_modified' ), $_SERVER['REQUEST_URI'] ); … … 1025 1022 $per_page = 10; // @todo Make this customizable? 1026 1023 1027 // Don't show anything if there's no pagination 1024 // Don't show anything if there's no pagination. 1028 1025 if ( 1 === $page && $query->total_users <= $per_page ) { 1029 1026 return $pagination; … … 1065 1062 * 1066 1063 * @param array $user_ids Array of user IDs. 1067 *1068 1064 * @return array Array of user_logins corresponding to $user_ids. 1069 1065 */ … … 1087 1083 function bp_groups_admin_autocomplete_handler() { 1088 1084 1089 // Bail if user user shouldn't be here, or is a large network 1085 // Bail if user user shouldn't be here, or is a large network. 1090 1086 if ( ! current_user_can( 'bp_moderate' ) || ( is_multisite() && wp_is_large_network( 'users' ) ) ) { 1091 1087 wp_die( -1 ); … … 1112 1108 1113 1109 $matches[] = array( 1114 // translators: 1: user_login, 2: user_email1110 // Translators: 1: user_login, 2: user_email. 1115 1111 'label' => sprintf( __( '%1$s (%2$s)', 'buddypress' ), $user->name, $user->ID ), 1116 1112 'value' => $user->ID, … … 1133 1129 * The type of view currently being displayed. 1134 1130 * 1135 * e.g. "All", "Pending", "Approved", "Spam"...1131 * E.g. "All", "Pending", "Approved", "Spam"... 1136 1132 * 1137 1133 * @since 1.7.0 … … 1186 1182 $screen = get_current_screen(); 1187 1183 1188 // Option defaults 1184 // Option defaults. 1189 1185 $include_id = false; 1190 1186 $search_terms = false; 1191 1187 1192 // Set current page 1188 // Set current page. 1193 1189 $page = $this->get_pagenum(); 1194 1190 1195 // Set per page from the screen options 1191 // Set per page from the screen options. 1196 1192 $per_page = $this->get_items_per_page( str_replace( '-', '_', "{$screen->id}_per_page" ) ); 1197 1193 … … 1202 1198 } 1203 1199 1204 // Order by - default to newest 1200 // Order by - default to newest. 1205 1201 $orderby = 'last_activity'; 1206 1202 if ( ! empty( $_REQUEST['orderby'] ) ) { … … 1229 1225 $include_id = (int) $_REQUEST['gid']; 1230 1226 1231 // Set the current view 1227 // Set the current view. 1232 1228 if ( isset( $_GET['group_status'] ) && in_array( $_GET['group_status'], array( 'public', 'private', 'hidden' ) ) ) { 1233 1229 $this->view = $_GET['group_status']; 1234 1230 } 1235 1231 1236 // We'll use the ids of group types for the 'include' param 1232 // We'll use the ids of group types for the 'include' param. 1237 1233 $this->group_type_ids = BP_Groups_Group::get_group_type_ids(); 1238 1234 1239 // Pass a dummy array if there are no groups of this type 1235 // Pass a dummy array if there are no groups of this type. 1240 1236 $include = false; 1241 1237 if ( 'all' != $this->view && isset( $this->group_type_ids[ $this->view ] ) ) { … … 1243 1239 } 1244 1240 1245 // Get group type counts for display in the filter tabs 1241 // Get group type counts for display in the filter tabs. 1246 1242 $this->group_counts = array(); 1247 1243 foreach ( $this->group_type_ids as $group_type => $group_ids ) { … … 1270 1266 } 1271 1267 1272 // Set raw data to display 1268 // Set raw data to display. 1273 1269 $this->items = $groups; 1274 1270 1275 // Store information needed for handling table pagination 1271 // Store information needed for handling table pagination. 1276 1272 $this->set_pagination_args( array( 1277 1273 'per_page' => $per_page, … … 1307 1303 */ 1308 1304 protected function get_default_primary_column_name() { 1309 // comment column is mapped to Group's name1305 // Comment column is mapped to Group's name. 1310 1306 return 'comment'; 1311 1307 } … … 1324 1320 * 1325 1321 * @since 1.7.0 1326 */1322 */ 1327 1323 public function display() { 1328 1324 $this->display_tablenav( 'top' ); ?> … … 1498 1494 * @since 2.3.4 Visibility set to public for compatibility with WP < 4.0.0. 1499 1495 * 1500 * @param array $actions The list of actions1501 * @param bool $always_visible Whether the actions should be always visible1496 * @param array $actions The list of actions. 1497 * @param bool $always_visible Whether the actions should be always visible. 1502 1498 * @return string 1503 1499 */ … … 1559 1555 public function column_comment( $item = array() ) { 1560 1556 1561 // Preorder items: Edit | Delete | View 1557 // Preorder items: Edit | Delete | View. 1562 1558 $actions = array( 1563 1559 'edit' => '', … … 1566 1562 ); 1567 1563 1568 // We need the group object for some BP functions 1564 // We need the group object for some BP functions. 1569 1565 $item_obj = (object) $item; 1570 1566 1571 // Build actions URLs 1567 // Build actions URLs. 1572 1568 $base_url = bp_get_admin_url( 'admin.php?page=bp-groups&gid=' . $item['id'] ); 1573 1569 $delete_url = wp_nonce_url( $base_url . "&action=delete", 'bp-groups-delete' ); … … 1585 1581 $group_name = apply_filters_ref_array( 'bp_get_group_name', array( $item['name'] ), $item ); 1586 1582 1587 // Rollover actions 1588 1589 // Edit 1583 // Rollover actions. 1584 // Edit. 1590 1585 $actions['edit'] = sprintf( '<a href="%s">%s</a>', esc_url( $edit_url ), __( 'Edit', 'buddypress' ) ); 1591 1586 1592 // Delete 1587 // Delete. 1593 1588 $actions['delete'] = sprintf( '<a href="%s">%s</a>', esc_url( $delete_url ), __( 'Delete', 'buddypress' ) ); 1594 1589 1595 // Visit 1590 // Visit. 1596 1591 $actions['view'] = sprintf( '<a href="%s">%s</a>', esc_url( $view_url ), __( 'View', 'buddypress' ) ); 1597 1592 … … 1606 1601 $actions = apply_filters( 'bp_groups_admin_comment_row_actions', array_filter( $actions ), $item ); 1607 1602 1608 // Get group name and avatar 1603 // Get group name and avatar. 1609 1604 $avatar = ''; 1610 1605 … … 1659 1654 1660 1655 // @todo This should be abstracted out somewhere for the whole 1661 // Groups component 1656 // Groups component. 1662 1657 switch ( $status ) { 1663 1658 case 'public' : … … 1732 1727 * @param array $item Information about the current row. 1733 1728 * @param string $column_name The column name. 1734 *1735 1729 * @return string 1736 1730 */ -
trunk/src/bp-groups/bp-groups-adminbar.php
r10148 r10373 26 26 $bp = buddypress(); 27 27 28 // Only show if viewing a group 28 // Only show if viewing a group. 29 29 if ( ! bp_is_group() || bp_is_group_create() ) { 30 30 return false; 31 31 } 32 32 33 // Only show this menu to group admins and super admins 33 // Only show this menu to group admins and super admins. 34 34 if ( ! bp_current_user_can( 'bp_moderate' ) && ! bp_group_is_admin() ) { 35 35 return false; 36 36 } 37 37 38 // Unique ID for the 'Edit Group' menu 38 // Unique ID for the 'Edit Group' menu. 39 39 $bp->group_admin_menu_id = 'group-admin'; 40 40 41 // Add the top-level Group Admin button 41 // Add the top-level Group Admin button. 42 42 $wp_admin_bar->add_menu( array( 43 43 'id' => $bp->group_admin_menu_id, … … 46 46 ) ); 47 47 48 // Index of the Manage tabs parent slug 48 // Index of the Manage tabs parent slug. 49 49 $nav_index = $bp->groups->current_group->slug . '_manage'; 50 50 51 // Check if current group has Manage tabs 51 // Check if current group has Manage tabs. 52 52 if ( empty( $bp->bp_options_nav[ $nav_index ] ) ) { 53 53 return; 54 54 } 55 55 56 // Build the Group Admin menus 56 // Build the Group Admin menus. 57 57 foreach ( $bp->bp_options_nav[ $nav_index ] as $menu ) { 58 58 /** … … 66 66 $title = sprintf( _x( 'Edit Group %s', 'Group WP Admin Bar manage links', 'buddypress' ), $menu['name'] ); 67 67 68 // Title is specific for delete 68 // Title is specific for delete. 69 69 if ( 'delete-group' == $menu['slug'] ) { 70 70 $title = sprintf( _x( '%s Group', 'Group WP Admin Bar delete link', 'buddypress' ), $menu['name'] ); -
trunk/src/bp-groups/bp-groups-cache.php
r10148 r10373 23 23 * $group_ids and adds it to WP cache. This improves efficiency when using 24 24 * groupmeta within a loop context. 25 *26 25 * 27 26 * @param int|string|array|bool $group_ids Accepts a single group_id, or a … … 78 77 * @since 2.0.0 79 78 * 80 * @param int $meta_id 81 * @param int $group_id 79 * @param int $meta_id Meta ID. 80 * @param int $group_id Group ID. 82 81 */ 83 82 function bp_groups_delete_group_cache_on_metadata_change( $meta_id, $group_id ) { … … 96 95 */ 97 96 function bp_groups_clear_group_creator_cache( $group_id, $group_obj ) { 98 // Clears the 'total groups' for this user 97 // Clears the 'total groups' for this user. 99 98 groups_clear_group_user_object_cache( $group_obj->id, $group_obj->creator_id ); 100 99 } … … 110 109 */ 111 110 function bp_groups_clear_group_members_caches( $group_obj, $user_ids ) { 112 // Clears the 'total groups' cache for each member in a group 111 // Clears the 'total groups' cache for each member in a group. 113 112 foreach ( (array) $user_ids as $user_id ) 114 113 groups_clear_group_user_object_cache( $group_obj->id, $user_id ); … … 200 199 * @since 2.1.0 201 200 * 202 * @param BP_Groups_Member $member 201 * @param BP_Groups_Member $member Member object. 203 202 */ 204 203 function groups_clear_group_administrator_cache_on_member_save( BP_Groups_Member $member ) { -
trunk/src/bp-groups/bp-groups-filters.php
r10184 r10373 10 10 defined( 'ABSPATH' ) || exit; 11 11 12 // Filter bbPress template locations 13 12 // Filter bbPress template locations. 14 13 add_filter( 'bp_groups_get_directory_template', 'bp_add_template_locations' ); 15 14 add_filter( 'bp_get_single_group_template', 'bp_add_template_locations' ); … … 51 50 add_filter( 'groups_group_description_before_save', 'force_balance_tags' ); 52 51 53 // Trim trailing spaces from name and description when saving 52 // Trim trailing spaces from name and description when saving. 54 53 add_filter( 'groups_group_name_before_save', 'trim' ); 55 54 add_filter( 'groups_group_description_before_save', 'trim' ); 56 55 57 // Escape output of new group creation details 56 // Escape output of new group creation details. 58 57 add_filter( 'bp_get_new_group_id', 'esc_attr' ); 59 58 add_filter( 'bp_get_new_group_name', 'esc_attr' ); 60 59 add_filter( 'bp_get_new_group_description', 'esc_textarea' ); 61 60 62 // Format numberical output 61 // Format numberical output. 63 62 add_filter( 'bp_get_total_group_count', 'bp_core_number_format' ); 64 63 add_filter( 'bp_get_group_total_for_member', 'bp_core_number_format' ); … … 71 70 * @since 1.1.0 72 71 * 73 * @param string $content 74 * 72 * @param string $content Content to filter. 75 73 * @return string 76 74 */ … … 87 85 $allowed_tags = wp_kses_allowed_html( 'buddypress-groups' ); 88 86 89 // Add our own tags allowed in group descriptions 87 // Add our own tags allowed in group descriptions. 90 88 $allowed_tags['a']['class'] = array(); 91 89 $allowed_tags['img'] = array(); … … 107 105 $tags = apply_filters( 'bp_groups_filter_kses', $allowed_tags ); 108 106 109 // Return KSES'ed content, allowing the above tags 107 // Return KSES'ed content, allowing the above tags. 110 108 return wp_kses( $content, $tags ); 111 109 } … … 126 124 * Add fields to bbPress query for group-specific data. 127 125 * 128 * @param string $sql 129 * 126 * @param string $sql SQL statement to amend. 130 127 * @return string 131 128 */ … … 138 135 * Add JOINed tables to bbPress query for group-specific data. 139 136 * 140 * @param string $sql 141 * 137 * @param string $sql SQL statement to amend. 142 138 * @return string 143 139 */ … … 153 149 * Add WHERE clauses to bbPress query for group-specific data and access protection. 154 150 * 155 * @param string $sql 151 * @param string $sql SQL Statement to amend. 156 152 * 157 153 * @return string … … 159 155 function groups_add_forum_where_sql( $sql = '' ) { 160 156 161 // Define locale variable 157 // Define locale variable. 162 158 $parts = array(); 163 159 164 // Set this for groups 160 // Set this for groups. 165 161 $parts['groups'] = "(gm.meta_key = 'forum_id' AND gm.meta_value = t.forum_id)"; 166 162 … … 173 169 * Decide if private are visible 174 170 */ 171 175 172 // Are we in our own profile? 176 173 if ( bp_is_my_profile() ) … … 181 178 unset( $parts['private'] ); 182 179 183 // No need to filter on a single item 180 // No need to filter on a single item. 184 181 elseif ( bp_is_single_item() ) 185 182 unset( $parts['private'] ); 186 183 187 // Check the SQL filter that was passed 184 // Check the SQL filter that was passed. 188 185 if ( !empty( $sql ) ) 189 186 $parts['passed'] = $sql; 190 187 191 // Assemble Voltron 188 // Assemble Voltron. 192 189 $parts_string = implode( ' AND ', $parts ); 193 190 194 191 $bp = buddypress(); 195 192 196 // Set it to the global filter 193 // Set it to the global filter. 197 194 $bp->groups->filter_sql = $parts_string; 198 195 199 // Return the global filter 196 // Return the global filter. 200 197 return $bp->groups->filter_sql; 201 198 } … … 204 201 * Modify bbPress caps for bp-forums. 205 202 * 206 * @param bool $value207 * @param string $cap 208 * @param array $args203 * @param bool $value Original value for current_user_can check. 204 * @param string $cap Capability checked. 205 * @param array $args Arguments for the caps. 209 206 * 210 207 * @return bool … … 238 235 * 239 236 * @see BB_Query::_filter_sql() 237 * 238 * @param string $sql SQL statement. 239 * @return string 240 240 */ 241 241 function groups_filter_forums_root_page_sql( $sql ) { … … 262 262 * @param bool $load_mentions True to load mentions assets, false otherwise. 263 263 * @param bool $mentions_enabled True if mentions are enabled. 264 *265 264 * @return bool True if mentions scripts should be loaded. 266 265 */ -
trunk/src/bp-groups/bp-groups-forums.php
r10148 r10373 66 66 * 67 67 * @param int $group_id Group id, passed from groups_details_updated. 68 *69 68 * @return mixed 70 69 */ … … 112 111 * @param mixed $page The page number where the new forum post should reside. 113 112 * Default: false. 114 *115 113 * @return mixed The new forum post ID on success. Boolean false on failure. 116 114 */ … … 221 219 * @param string $topic_tags A comma-delimited string of topic tags. 222 220 * @param int $forum_id The forum ID this forum topic resides in. 223 *224 221 * @return mixed The new topic object on success. Boolean false on failure. 225 222 */ … … 342 339 * @param string $topic_text The text for the forum topic. 343 340 * @param mixed $topic_tags A comma-delimited string of topic tags. Optional. 344 *345 341 * @return mixed The topic object on success. Boolean false on failure. 346 342 */ … … 364 360 } 365 361 366 // Get the corresponding activity item 362 // Get the corresponding activity item. 367 363 if ( bp_is_active( 'activity' ) ) { 368 364 $id = bp_activity_get_activity_id( array( … … 421 417 * @param int $topic_id The topic ID of the existing forum topic. 422 418 * @param mixed $page The page number where the new forum post should reside. Optional. 423 *424 419 * @return mixed The forum post ID on success. Boolean false on failure. 425 420 */ … … 454 449 } 455 450 456 // Get the corresponding activity item 451 // Get the corresponding activity item. 457 452 if ( bp_is_active( 'activity' ) ) { 458 453 $id = bp_activity_get_activity_id( array( … … 507 502 * 508 503 * @param int $topic_id The ID of the topic to be deleted. 509 *510 504 * @return bool True if the delete routine went through properly. 511 505 */ … … 513 507 $bp = buddypress(); 514 508 515 // Before deleting the thread, get the post ids so that their activity items can be deleted 509 // Before deleting the thread, get the post ids so that their activity items can be deleted. 516 510 $posts = bp_forums_get_topic_posts( array( 'topic_id' => $topic_id, 'per_page' => -1 ) ); 517 511 $action = bp_forums_delete_topic( array( 'topic_id' => $topic_id ) ); … … 528 522 do_action( 'groups_before_delete_group_forum_topic', $topic_id ); 529 523 530 // Delete the corresponding activity stream items 524 // Delete the corresponding activity stream items. 531 525 if ( bp_is_active( 'activity' ) ) { 532 526 533 // The activity item for the initial topic 527 // The activity item for the initial topic. 534 528 bp_activity_delete( array( 535 529 'item_id' => bp_get_current_group_id(), … … 539 533 ) ); 540 534 541 // The activity item for each post 535 // The activity item for each post. 542 536 foreach ( (array) $posts as $post ) { 543 537 bp_activity_delete( array( … … 574 568 * value isn't used in the function but is passed along 575 569 * to do_action() hooks. 576 *577 570 * @return bool True on success. 578 571 */ … … 593 586 do_action( 'groups_before_delete_group_forum_post', $post_id, $topic_id ); 594 587 595 // Delete the corresponding activity stream item 588 // Delete the corresponding activity stream item. 596 589 if ( bp_is_active( 'activity' ) ) { 597 590 bp_activity_delete( array( … … 624 617 * @param string $type Either 'newest', 'popular', 'unreplied', 'tags'. 625 618 * Default: 'newest'. 626 *627 619 * @return int The topic count. 628 620 */ … … 647 639 * 'all'. Default: 'public'. 648 640 * @param string|bool $search_terms Optional. Limit by a search term. 649 *650 641 * @return int The topic count. 651 642 */ -
trunk/src/bp-groups/bp-groups-functions.php
r10351 r10373 36 36 * 37 37 * @param array|string $args { 38 * 39 * 40 * 41 * 42 * 43 * Default: false.38 * Array of al arguments. 39 * @type int $group_id ID of the group. 40 * @type bool $load_users No longer used. 41 * @type bool $populate_extras Whether to fetch membership data and other 42 * extra information about the group. 43 * Default: false. 44 44 * } 45 45 * @return BP_Groups_Group $group The group object. … … 84 84 * @type string $slug The group slug. 85 85 * @type string $status The group's status. Accepts 'public', 'private' or 86 86 * 'hidden'. Defaults to 'public'. 87 87 * @type int $enable_forum Optional. Whether the group has a forum enabled. 88 88 * If the legacy forums are enabled for this group … … 110 110 extract( $args, EXTR_SKIP ); 111 111 112 // Pass an existing group ID 112 // Pass an existing group ID. 113 113 if ( ! empty( $group_id ) ) { 114 114 $group = groups_get_group( array( 'group_id' => (int) $group_id ) ); … … 117 117 $description = ! empty( $description ) ? $description : $group->description; 118 118 119 // Groups need at least a name 119 // Groups need at least a name. 120 120 if ( empty( $name ) ) { 121 121 return false; 122 122 } 123 123 124 // Create a new group 124 // Create a new group. 125 125 } else { 126 // Instantiate new group object 126 // Instantiate new group object. 127 127 $group = new BP_Groups_Group; 128 128 } 129 129 130 // Set creator ID 130 // Set creator ID. 131 131 if ( $creator_id ) { 132 132 $group->creator_id = (int) $creator_id; … … 139 139 } 140 140 141 // Validate status 141 // Validate status. 142 142 if ( ! groups_is_valid_status( $status ) ) { 143 143 return false; 144 144 } 145 145 146 // Set group name 146 // Set group name. 147 147 $group->name = $name; 148 148 $group->description = $description; … … 152 152 $group->date_created = $date_created; 153 153 154 // Save group 154 // Save group. 155 155 if ( ! $group->save() ) { 156 156 return false; 157 157 } 158 158 159 // If this is a new group, set up the creator as the first member and admin 159 // If this is a new group, set up the creator as the first member and admin. 160 160 if ( empty( $group_id ) ) { 161 161 $member = new BP_Groups_Member; … … 217 217 * @param bool $notify_members Whether to send an email notification to group 218 218 * members about changes in these details. 219 *220 219 * @return bool True on success, false on failure. 221 220 */ … … 263 262 * @param string|bool $invite_status Optional. Who is allowed to send invitations 264 263 * to the group. 'members', 'mods', or 'admins'. 265 *266 264 * @return bool True on success, false on failure. 267 265 */ … … 271 269 $group->enable_forum = $enable_forum; 272 270 273 /** *271 /** 274 272 * Before we potentially switch the group status, if it has been changed to public 275 273 * from private and there are outstanding membership requests, auto-accept those requests. … … 278 276 groups_accept_all_pending_membership_requests( $group->id ); 279 277 280 // Now update the status 278 // Now update the status. 281 279 $group->status = $status; 282 280 … … 291 289 } 292 290 293 // Set the invite status 291 // Set the invite status. 294 292 if ( $invite_status ) 295 293 groups_update_groupmeta( $group->id, 'invite_status', $invite_status ); … … 315 313 * 316 314 * @param int $group_id ID of the group to delete. 317 *318 315 * @return bool True on success, false on failure. 319 316 */ … … 329 326 do_action( 'groups_before_delete_group', $group_id ); 330 327 331 // Get the group object 328 // Get the group object. 332 329 $group = groups_get_group( array( 'group_id' => $group_id ) ); 333 330 334 // Bail if group cannot be deleted 331 // Bail if group cannot be deleted. 335 332 if ( ! $group->delete() ) { 336 333 return false; 337 334 } 338 335 339 // Remove all outstanding invites for this group 336 // Remove all outstanding invites for this group. 340 337 groups_delete_all_group_invites( $group_id ); 341 338 … … 356 353 * 357 354 * @param string $status Status to check. 358 *359 355 * @return bool True if status is allowed, otherwise false. 360 356 */ … … 369 365 * 370 366 * @param string $slug Group slug to check. 371 *372 367 * @return string $slug A unique and sanitized slug. 373 368 */ … … 395 390 * 396 391 * @param int $group_id The numeric ID of the group. 397 *398 392 * @return string The group's slug. 399 393 */ … … 409 403 * 410 404 * @param string $group_slug The group's slug. 411 *412 405 * @return int The ID. 413 406 */ … … 424 417 * @param int $user_id Optional. ID of the user. Defaults to the currently 425 418 * logged-in user. 426 *427 419 * @return bool True on success, false on failure. 428 420 */ … … 465 457 * @param int $user_id Optional. ID of the user. Defaults to the currently 466 458 * logged-in user. 467 *468 459 * @return bool True on success, false on failure. 469 460 */ … … 481 472 groups_delete_membership_request( null, $user_id, $group_id ); 482 473 483 // User is already a member, just return true 474 // User is already a member, just return true. 484 475 if ( groups_is_user_member( $user_id, $group_id ) ) 485 476 return true; … … 504 495 $group = $bp->groups->current_group; 505 496 506 // Record this in activity streams 497 // Record this in activity streams. 507 498 groups_record_activity( array( 508 499 'type' => 'joined_group', … … 530 521 * 531 522 * @param int $group_id ID of the group. 532 *533 523 * @return array Info about group admins (user_id + date_modified). 534 524 */ … … 541 531 * 542 532 * @param int $group_id ID of the group. 543 *544 533 * @return array Info about group admins (user_id + date_modified). 545 534 */ … … 580 569 function groups_get_group_members( $args = array() ) { 581 570 582 // Backward compatibility with old method of passing arguments 571 // Backward compatibility with old method of passing arguments. 583 572 if ( ! is_array( $args ) || func_num_args() > 1 ) { 584 573 _deprecated_argument( __METHOD__, '2.0.0', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) ); … … 612 601 // For legacy users. Use of BP_Groups_Member::get_all_for_group() 613 602 // is deprecated. func_get_args() can't be passed to a function in PHP 614 // 5.2.x, so we create a variable 603 // 5.2.x, so we create a variable. 615 604 $func_args = func_get_args(); 616 605 if ( apply_filters( 'bp_use_legacy_group_member_query', false, __FUNCTION__, $func_args ) ) { … … 618 607 } else { 619 608 620 // exclude_admins_mods and exclude_banned are legacy arguments.621 // Convert to group_role 609 // Both exclude_admins_mods and exclude_banned are legacy arguments. 610 // Convert to group_role. 622 611 if ( empty( $r['group_role'] ) ) { 623 612 $r['group_role'] = array( 'member' ); … … 633 622 } 634 623 635 // Perform the group member query (extends BP_User_Query) 624 // Perform the group member query (extends BP_User_Query). 636 625 $members = new BP_Group_Member_Query( array( 637 626 'group_id' => $r['group_id'], … … 644 633 ) ); 645 634 646 // Structure the return value as expected by the template functions 635 // Structure the return value as expected by the template functions. 647 636 $retval = array( 648 637 'members' => array_values( $members->results ), … … 658 647 * 659 648 * @param int $group_id Group ID. 660 *661 649 * @return int Count of confirmed members for the group. 662 650 */ … … 682 670 683 671 $defaults = array( 684 'type' => false, // active, newest, alphabetical, random, popular, most-forum-topics or most-forum-posts685 'order' => 'DESC', // 'ASC' or 'DESC'686 'orderby' => 'date_created', // date_created, last_activity, total_member_count, name, random 687 'user_id' => false, // Pass a user_id to limit to only groups that this user is a member of688 'include' => false, // Only include these specific groups (group_ids)689 'exclude' => false, // Do not include these specific groups (group_ids)690 'search_terms' => false, // Limit to groups that match these search terms691 'meta_query' => false, // Filter by groupmeta. See WP_Meta_Query for syntax692 'show_hidden' => false, // Show hidden groups to non-admins693 'per_page' => 20, // The number of results to return per page694 'page' => 1, // The page to return if limiting per page695 'populate_extras' => true, // Fetch meta such as is_banned and is_member696 'update_meta_cache' => true, // Pre-fetch groupmeta for queried groups672 'type' => false, // Active, newest, alphabetical, random, popular, most-forum-topics or most-forum-posts. 673 'order' => 'DESC', // 'ASC' or 'DESC' 674 'orderby' => 'date_created', // date_created, last_activity, total_member_count, name, random. 675 'user_id' => false, // Pass a user_id to limit to only groups that this user is a member of. 676 'include' => false, // Only include these specific groups (group_ids). 677 'exclude' => false, // Do not include these specific groups (group_ids). 678 'search_terms' => false, // Limit to groups that match these search terms. 679 'meta_query' => false, // Filter by groupmeta. See WP_Meta_Query for syntax. 680 'show_hidden' => false, // Show hidden groups to non-admins. 681 'per_page' => 20, // The number of results to return per page. 682 'page' => 1, // The page to return if limiting per page. 683 'populate_extras' => true, // Fetch meta such as is_banned and is_member. 684 'update_meta_cache' => true, // Pre-fetch groupmeta for queried groups. 697 685 ); 698 686 … … 769 757 * 770 758 * @param int $user_id Optional. Default: ID of the displayed user. 771 *772 759 * @return int Group count. 773 760 */ … … 816 803 * Generate the avatar upload directory path for a given group. 817 804 * 818 * @param int $group_id Optional. ID of the group. Default: ID of the 819 * current group. 805 * @param int $group_id Optional. ID of the group. Default: ID of the current group. 820 806 * @return string 821 807 */ … … 857 843 * @param int $user_id ID of the user. 858 844 * @param int $group_id ID of the group. 859 *860 845 * @return bool 861 846 */ … … 869 854 * @param int $user_id ID of the user. 870 855 * @param int $group_id ID of the group. 871 *872 856 * @return bool 873 857 */ … … 881 865 * @param int $user_id ID of the user. 882 866 * @param int $group_id ID of the group. 883 *884 867 * @return bool 885 868 */ … … 899 882 * @param int $user_id ID of the user. 900 883 * @param int $group_id ID of the group. 901 *902 884 * @return bool 903 885 */ … … 947 929 return false; 948 930 949 // Record this in activity streams 931 // Record this in activity streams. 950 932 $activity_action = sprintf( __( '%1$s posted an update in the group %2$s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . esc_attr( $bp->groups->current_group->name ) . '</a>' ); 951 933 $activity_content = $content; … … 1000 982 * 1001 983 * @param int $user_id ID of the inviting user. 1002 * @param int|bool $limit Limit to restrict to.1003 * @param int|bool $page 1004 * @param string|array|bool $exclude 1005 * 984 * @param int|bool $limit Limit to restrict to. 985 * @param int|bool $page Optional. Page offset of results to return. 986 * @param string|array|bool $exclude Array of comma-separated list of group IDs 987 * to exclude from results. 1006 988 * @return array $value IDs of users who have been invited to the group by the 1007 989 * user but have not yet accepted. … … 1021 1003 * 1022 1004 * @param int $user_id The user ID. 1023 *1024 1005 * @return int 1025 1006 */ … … 1064 1045 return false; 1065 1046 1066 // if the user has already requested membership, accept the request1047 // If the user has already requested membership, accept the request. 1067 1048 if ( $membership_id = groups_check_for_membership_request( $user_id, $group_id ) ) { 1068 1049 groups_accept_membership_request( $membership_id, $user_id, $group_id ); 1069 1050 1070 // Otherwise, create a new invitation 1051 // Otherwise, create a new invitation. 1071 1052 } elseif ( ! groups_is_user_member( $user_id, $group_id ) && ! groups_check_user_has_invite( $user_id, $group_id, 'all' ) ) { 1072 1053 $invite = new BP_Groups_Member; … … 1100 1081 * @param int $user_id ID of the user. 1101 1082 * @param int $group_id ID of the group. 1102 *1103 1083 * @return bool True on success, false on failure. 1104 1084 */ … … 1128 1108 * @param int $user_id ID of the user. 1129 1109 * @param int $group_id ID of the group. 1130 *1131 1110 * @return bool True when the user is a member of the group, otherwise false. 1132 1111 */ … … 1134 1113 1135 1114 // If the user is already a member (because BP at one point allowed two invitations to 1136 // slip through), delete all existing invitations/requests and return true 1115 // slip through), delete all existing invitations/requests and return true. 1137 1116 if ( groups_is_user_member( $user_id, $group_id ) ) { 1138 1117 if ( groups_check_user_has_invite( $user_id, $group_id ) ) { … … 1154 1133 } 1155 1134 1156 // Remove request to join 1135 // Remove request to join. 1157 1136 if ( $member->check_for_membership_request( $user_id, $group_id ) ) { 1158 1137 $member->delete_request( $user_id, $group_id ); 1159 1138 } 1160 1139 1161 // Modify group meta 1140 // Modify group meta. 1162 1141 groups_update_groupmeta( $group_id, 'last_activity', bp_core_current_time() ); 1163 1142 … … 1180 1159 * @param int $user_id ID of the user. 1181 1160 * @param int $group_id ID of the group. 1182 *1183 1161 * @return bool True on success, false on failure. 1184 1162 */ … … 1205 1183 * @param int $user_id ID of the invited user. 1206 1184 * @param int $group_id ID of the group. 1207 *1208 1185 * @return bool True on success, false on failure. 1209 1186 */ … … 1243 1220 $member = new BP_Groups_Member( $invited_users[$i], $group_id ); 1244 1221 1245 // Send the actual invite 1222 // Send the actual invite. 1246 1223 groups_notification_group_invites( $group, $member, $user_id ); 1247 1224 … … 1268 1245 * @param int $user_id ID of the inviting user. 1269 1246 * @param int $group_id ID of the group. 1270 *1271 1247 * @return array $value IDs of users who have been invited to the group by the 1272 1248 * user but have not yet accepted. … … 1287 1263 * @param string $type Optional. Use 'sent' to check for sent invites, 1288 1264 * 'all' to check for all. Default: 'sent'. 1289 *1290 1265 * @return bool True if an invitation is found, otherwise false. 1291 1266 */ … … 1298 1273 * 1299 1274 * @param int $group_id ID of the group whose invitations are being deleted. 1300 *1301 1275 * @return int|null Number of rows records deleted on success, null on failure. 1302 1276 */ … … 1313 1287 * @param int $group_id ID of the group. 1314 1288 * @param string $status The new status. 'mod' or 'admin'. 1315 *1316 1289 * @return bool True on success, false on failure. 1317 1290 */ … … 1345 1318 * @param int $user_id ID of the user. 1346 1319 * @param int $group_id ID of the group. 1347 *1348 1320 * @return bool True on success, false on failure. 1349 1321 */ … … 1373 1345 * @param int $user_id ID of the user. 1374 1346 * @param int $group_id ID of the group. 1375 *1376 1347 * @return bool True on success, false on failure. 1377 1348 */ … … 1401 1372 * @param int $user_id ID of the user. 1402 1373 * @param int $group_id ID of the group. 1403 *1404 1374 * @return bool True on success, false on failure. 1405 1375 */ … … 1431 1401 * @param int $user_id ID of the user. 1432 1402 * @param int $group_id ID of the group. 1433 *1434 1403 * @return bool True on success, false on failure. 1435 1404 */ … … 1462 1431 * @param int $requesting_user_id ID of the user requesting membership. 1463 1432 * @param int $group_id ID of the group. 1464 *1465 1433 * @return bool True on success, false on failure. 1466 1434 */ 1467 1435 function groups_send_membership_request( $requesting_user_id, $group_id ) { 1468 1436 1469 // Prevent duplicate requests 1437 // Prevent duplicate requests. 1470 1438 if ( groups_check_for_membership_request( $requesting_user_id, $group_id ) ) 1471 1439 return false; 1472 1440 1473 // Check if the user is already a member or is banned 1441 // Check if the user is already a member or is banned. 1474 1442 if ( groups_is_user_member( $requesting_user_id, $group_id ) || groups_is_user_banned( $requesting_user_id, $group_id ) ) 1475 1443 return false; 1476 1444 1477 // Check if the user is already invited - if so, simply accept invite 1445 // Check if the user is already invited - if so, simply accept invite. 1478 1446 if ( groups_check_user_has_invite( $requesting_user_id, $group_id ) ) { 1479 1447 groups_accept_invite( $requesting_user_id, $group_id ); … … 1494 1462 $admins = groups_get_group_admins( $group_id ); 1495 1463 1496 // Saved okay, now send the email notification 1464 // Saved okay, now send the email notification. 1497 1465 for ( $i = 0, $count = count( $admins ); $i < $count; ++$i ) 1498 1466 groups_notification_new_membership_request( $requesting_user_id, $admins[$i]->user_id, $group_id, $requesting_user->id ); … … 1526 1494 * requested. Provide this value along with $user_id to 1527 1495 * override $membership_id. 1528 *1529 1496 * @return bool True on success, false on failure. 1530 1497 */ … … 1572 1539 * requested. Provide this value along with $user_id to 1573 1540 * override $membership_id. 1574 *1575 1541 * @return bool True on success, false on failure. 1576 1542 */ … … 1604 1570 * requested. Provide this value along with $user_id to 1605 1571 * override $membership_id. 1606 *1607 1572 * @return bool True on success, false on failure. 1608 1573 */ … … 1624 1589 * @param int $user_id ID of the user. 1625 1590 * @param int $group_id ID of the group. 1626 *1627 1591 * @return int|null ID of the membership if found, otherwise false. 1628 1592 */ … … 1635 1599 * 1636 1600 * @param int $group_id ID of the group. 1637 *1638 1601 * @return bool True on success, false on failure. 1639 1602 */ … … 1672 1635 * metadata entries for the specified group. 1673 1636 * Default: false. 1674 *1675 1637 * @return bool True on success, false on failure. 1676 1638 */ … … 1678 1640 global $wpdb; 1679 1641 1680 // Legacy - if no meta_key is passed, delete all for the item 1642 // Legacy - if no meta_key is passed, delete all for the item. 1681 1643 if ( empty( $meta_key ) ) { 1682 1644 $keys = $wpdb->get_col( $wpdb->prepare( "SELECT meta_key FROM {$wpdb->groupmeta} WHERE group_id = %d", $group_id ) ); 1683 1645 1684 // With no meta_key, ignore $delete_all 1646 // With no meta_key, ignore $delete_all. 1685 1647 $delete_all = false; 1686 1648 } else { … … 1708 1670 * specified meta_key. This parameter has no effect if 1709 1671 * meta_key is empty. 1710 *1711 1672 * @return mixed Metadata value. 1712 1673 */ … … 1728 1689 * metadata entries with the specified value. 1729 1690 * Otherwise, update all entries. 1730 *1731 1691 * @return bool|int $retval Returns false on failure. On successful update of existing 1732 1692 * metadata, returns true. On successful creation of new metadata, … … 1753 1713 * has a value for the key, no change will be made. 1754 1714 * Default: false. 1755 *1756 1715 * @return int|bool The meta ID on successful update, false on failure. 1757 1716 */ -
trunk/src/bp-groups/bp-groups-loader.php
r10262 r10373 14 14 defined( 'ABSPATH' ) || exit; 15 15 16 /** 17 * Creates our Groups component. 18 */ 16 19 class BP_Groups_Component extends BP_Component { 17 20 … … 37 40 * @since 1.6.0 38 41 * @todo Is this used anywhere? Is this a duplicate of $default_extension? 42 * @var string 39 43 */ 40 44 var $default_component; … … 136 140 $bp = buddypress(); 137 141 138 // Define a slug, if necessary 142 // Define a slug, if necessary. 139 143 if ( ! defined( 'BP_GROUPS_SLUG' ) ) { 140 144 define( 'BP_GROUPS_SLUG', $this->id ); 141 145 } 142 146 143 // Global tables for groups component 147 // Global tables for groups component. 144 148 $global_tables = array( 145 149 'table_name' => $bp->table_prefix . 'bp_groups', … … 148 152 ); 149 153 150 // Metadata tables for groups component 154 // Metadata tables for groups component. 151 155 $meta_tables = array( 152 156 'group' => $bp->table_prefix . 'bp_groups_groupmeta', … … 168 172 parent::setup_globals( $args ); 169 173 170 /* *Single Group Globals **********************************************/174 /* Single Group Globals **********************************************/ 171 175 172 176 // Are we viewing a single group? … … 215 219 } 216 220 217 // If the user is not an admin, check if they are a moderator 221 // If the user is not an admin, check if they are a moderator. 218 222 if ( ! bp_is_item_admin() ) { 219 223 bp_update_is_item_mod ( groups_is_user_mod ( bp_loggedin_user_id(), $this->current_group->id ), 'groups' ); … … 245 249 } 246 250 247 // Check once if the current group has a custom front template 251 // Check once if the current group has a custom front template. 248 252 $this->current_group->front_template = bp_groups_get_front_template( $this->current_group ); 249 253 250 // Set current_group to 0 to prevent debug errors 254 // Set current_group to 0 to prevent debug errors. 251 255 } else { 252 256 $this->current_group = 0; … … 277 281 ) ); 278 282 279 // If the user was attempting to access a group, but no group by that name was found, 404 283 // If the user was attempting to access a group, but no group by that name was found, 404. 280 284 if ( bp_is_groups_component() && empty( $this->current_group ) && bp_current_action() && !in_array( bp_current_action(), $this->forbidden_names ) ) { 281 285 bp_do_404(); … … 301 305 ) ); 302 306 303 // If avatar uploads are not disabled, add avatar option 307 // If avatar uploads are not disabled, add avatar option. 304 308 $disabled_avatar_uploads = (int) bp_disable_group_avatar_uploads(); 305 309 if ( ! $disabled_avatar_uploads && $bp->avatar->show_avatars ) { … … 317 321 } 318 322 319 // If friends component is active, add invitations 323 // If friends component is active, add invitations. 320 324 if ( bp_is_active( 'friends' ) ) { 321 325 $this->group_creation_steps['group-invites'] = array( … … 338 342 ) ); 339 343 340 // Auto join group when non group member performs group activity 344 // Auto join group when non group member performs group activity. 341 345 $this->auto_join = defined( 'BP_DISABLE_AUTO_GROUP_JOIN' ) && BP_DISABLE_AUTO_GROUP_JOIN ? false : true; 342 346 } … … 368 372 $bp = buddypress(); 369 373 370 // If the activity component is not active and the current group has no custom front, members are displayed in the home nav 374 // If the activity component is not active and the current group has no custom front, members are displayed in the home nav. 371 375 if ( 'members' === $this->default_extension && ! bp_is_active( 'activity' ) && ! $this->current_group->front_template ) { 372 376 $this->default_extension = 'home'; … … 377 381 } 378 382 379 // Prepare for a redirect to the canonical URL 383 // Prepare for a redirect to the canonical URL. 380 384 $bp->canonical_stack['base_url'] = bp_get_group_permalink( $this->current_group ); 381 385 … … 401 405 // When viewing the default extension, the canonical URL should not have 402 406 // that extension's slug, unless more has been tacked onto the URL via 403 // action variables 407 // action variables. 404 408 if ( bp_is_current_action( $this->default_extension ) && empty( $bp->action_variables ) ) { 405 409 unset( $bp->canonical_stack['action'] ); … … 419 423 public function setup_nav( $main_nav = array(), $sub_nav = array() ) { 420 424 421 // Determine user to use 425 // Determine user to use. 422 426 if ( bp_displayed_user_domain() ) { 423 427 $user_domain = bp_displayed_user_domain(); … … 428 432 } 429 433 430 // Only grab count if we're on a user page 434 // Only grab count if we're on a user page. 431 435 if ( bp_is_user() ) { 432 436 $count = bp_get_total_group_count_for_user(); … … 439 443 $slug = bp_get_groups_slug(); 440 444 441 // Add 'Groups' to the main navigation 445 // Add 'Groups' to the main navigation. 442 446 $main_nav = array( 443 447 'name' => $nav_name, … … 453 457 $groups_link = trailingslashit( $user_domain . $slug ); 454 458 455 // Add the My Groups nav item 459 // Add the My Groups nav item. 456 460 $sub_nav[] = array( 457 461 'name' => __( 'Memberships', 'buddypress' ), … … 464 468 ); 465 469 466 // Add the Group Invites nav item 470 // Add the Group Invites nav item. 467 471 $sub_nav[] = array( 468 472 'name' => __( 'Invitations', 'buddypress' ), … … 480 484 if ( bp_is_groups_component() && bp_is_single_item() ) { 481 485 482 // Reset sub nav 486 // Reset sub nav. 483 487 $sub_nav = array(); 484 488 485 // Add 'Groups' to the main navigation 489 // Add 'Groups' to the main navigation. 486 490 $main_nav = array( 487 491 'name' => __( 'Memberships', 'buddypress' ), 488 492 'slug' => $this->current_group->slug, 489 'position' => -1, // Do not show in BuddyBar 493 'position' => -1, // Do not show in BuddyBar. 490 494 'screen_function' => 'groups_screen_group_home', 491 495 'default_subnav_slug' => $this->default_extension, … … 495 499 $group_link = bp_get_group_permalink( $this->current_group ); 496 500 497 // Add the "Home" subnav item, as this will always be present 501 // Add the "Home" subnav item, as this will always be present. 498 502 $sub_nav[] = array( 499 503 'name' => _x( 'Home', 'Group screen navigation title', 'buddypress' ), … … 526 530 } 527 531 528 // Forums are enabled and turned on 532 // Forums are enabled and turned on. 529 533 if ( $this->current_group->enable_forum && bp_is_active( 'forums' ) ) { 530 534 $sub_nav[] = array( … … 559 563 560 564 /** 561 * Only add the members subnav if it's not the home's nav 565 * Only add the members subnav if it's not the home's nav. 562 566 */ 563 567 $sub_nav[] = array( … … 588 592 } 589 593 590 // If the user is a group admin, then show the group admin nav item 594 // If the user is a group admin, then show the group admin nav item. 591 595 if ( bp_is_item_admin() ) { 592 596 $sub_nav[] = array( … … 604 608 $admin_link = trailingslashit( $group_link . 'admin' ); 605 609 606 // Common params to all nav items 610 // Common params to all nav items. 607 611 $default_params = array( 608 612 'parent_url' => $admin_link, … … 692 696 public function setup_admin_bar( $wp_admin_nav = array() ) { 693 697 694 // Menus for logged in user 698 // Menus for logged in user. 695 699 if ( is_user_logged_in() ) { 696 700 697 // Setup the logged in user variables 701 // Setup the logged in user variables. 698 702 $groups_link = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() ); 699 703 700 // Pending group invites 704 // Pending group invites. 701 705 $count = groups_get_invite_count_for_user(); 702 706 $title = _x( 'Groups', 'My Account Groups', 'buddypress' ); … … 708 712 } 709 713 710 // Add the "My Account" sub menus 714 // Add the "My Account" sub menus. 711 715 $wp_admin_nav[] = array( 712 716 'parent' => buddypress()->my_account_menu_id, … … 716 720 ); 717 721 718 // My Groups 722 // My Groups. 719 723 $wp_admin_nav[] = array( 720 724 'parent' => 'my-account-' . $this->id, … … 724 728 ); 725 729 726 // Invitations 730 // Invitations. 727 731 $wp_admin_nav[] = array( 728 732 'parent' => 'my-account-' . $this->id, … … 732 736 ); 733 737 734 // Create a Group 738 // Create a Group. 735 739 if ( bp_user_can_create_groups() ) { 736 740 $wp_admin_nav[] = array( … … 793 797 public function setup_cache_groups() { 794 798 795 // Global groups 799 // Global groups. 796 800 wp_cache_add_global_groups( array( 797 801 'bp_groups', -
trunk/src/bp-groups/bp-groups-notifications.php
r10148 r10373 66 66 foreach ( (array) $user_ids as $user_id ) { 67 67 68 // Continue if member opted out of receiving this email 68 // Continue if member opted out of receiving this email. 69 69 if ( 'no' === bp_get_user_meta( $user_id, 'notification_groups_group_updated', true ) ) { 70 70 continue; … … 73 73 $ud = bp_core_get_core_userdata( $user_id ); 74 74 75 // Set up and send the message 75 // Set up and send the message. 76 76 $to = $ud->user_email; 77 77 … … 150 150 * @param int $group_id ID of the group. 151 151 * @param int $membership_id ID of the group membership object. 152 *153 152 * @return false|null False on failure. 154 153 */ 155 154 function groups_notification_new_membership_request( $requesting_user_id = 0, $admin_id = 0, $group_id = 0, $membership_id = 0 ) { 156 155 157 // Trigger a BuddyPress Notification 156 // Trigger a BuddyPress Notification. 158 157 if ( bp_is_active( 'notifications' ) ) { 159 158 bp_notifications_add_notification( array( … … 166 165 } 167 166 168 // Bail if member opted out of receiving this email 167 // Bail if member opted out of receiving this email. 169 168 if ( 'no' === bp_get_user_meta( $admin_id, 'notification_groups_membership_request', true ) ) { 170 169 return false; 171 170 } 172 171 173 // Username of the user requesting a membership: %1$s in mail 172 // Username of the user requesting a membership: %1$s in mail. 174 173 $requesting_user_name = bp_core_get_user_displayname( $requesting_user_id ); 175 174 $group = groups_get_group( array( 'group_id' => $group_id ) ); 176 175 177 // Group Administrator user's data 176 // Group Administrator user's data. 178 177 $ud = bp_core_get_core_userdata( $admin_id ); 179 178 $group_requests = bp_get_group_permalink( $group ) . 'admin/membership-requests'; 180 179 181 // Link to the user's profile who's requesting a membership: %3$s in mail 180 // Link to the user's profile who's requesting a membership: %3$s in mail. 182 181 $profile_link = bp_core_get_user_domain( $requesting_user_id ); 183 182 184 183 $settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings'; 185 // Link to the group administrator email settings: %s in "disable notifications" part of the email 184 // Link to the group administrator email settings: %s in "disable notifications" part of the email. 186 185 $settings_link = bp_core_get_user_domain( $admin_id ) . $settings_slug . '/notifications/'; 187 186 … … 189 188 $membership = new BP_Groups_Member( false, false, $membership_id ); 190 189 191 // Set up and send the message 190 // Set up and send the message. 192 191 $to = $ud->user_email; 193 192 $subject = bp_get_email_subject( array( 'text' => sprintf( __( 'Membership request for group: %s', 'buddypress' ), $group->name ) ) ); … … 225 224 } 226 225 227 // Only show the disable notifications line if the settings component is enabled 226 // Only show the disable notifications line if the settings component is enabled. 228 227 if ( bp_is_active( 'settings' ) ) { 229 228 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); … … 289 288 * @param bool $accepted Optional. Whether the membership request was accepted. 290 289 * Default: true. 291 *292 290 * @return false|null 293 291 */ 294 292 function groups_notification_membership_request_completed( $requesting_user_id = 0, $group_id = 0, $accepted = true ) { 295 293 296 // Trigger a BuddyPress Notification 294 // Trigger a BuddyPress Notification. 297 295 if ( bp_is_active( 'notifications' ) ) { 298 296 299 // What type of acknowledgement 297 // What type of acknowledgement. 300 298 $type = ! empty( $accepted ) 301 299 ? 'membership_request_accepted' … … 310 308 } 311 309 312 // Bail if member opted out of receiving this email 310 // Bail if member opted out of receiving this email. 313 311 if ( 'no' === bp_get_user_meta( $requesting_user_id, 'notification_membership_request_completed', true ) ) { 314 312 return false; … … 322 320 $to = $ud->user_email; 323 321 324 // Set up and send the message 322 // Set up and send the message. 325 323 if ( ! empty( $accepted ) ) { 326 324 $subject = bp_get_email_subject( array( 'text' => sprintf( __( 'Membership request for group "%s" accepted', 'buddypress' ), $group->name ) ) ); … … 344 342 } 345 343 346 // Only show the disable notifications line if the settings component is enabled 344 // Only show the disable notifications line if the settings component is enabled. 347 345 if ( bp_is_active( 'settings' ) ) { 348 346 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); … … 404 402 * @param int $user_id ID of the user. 405 403 * @param int $group_id ID of the group. 406 *407 404 * @return false|null False on failure. 408 405 */ … … 418 415 } 419 416 420 // Trigger a BuddyPress Notification 417 // Trigger a BuddyPress Notification. 421 418 if ( bp_is_active( 'notifications' ) ) { 422 419 bp_notifications_add_notification( array( … … 428 425 } 429 426 430 // Bail if admin opted out of receiving this email 427 // Bail if admin opted out of receiving this email. 431 428 if ( 'no' === bp_get_user_meta( $user_id, 'notification_groups_admin_promotion', true ) ) { 432 429 return false; … … 439 436 $settings_link = bp_core_get_user_domain( $user_id ) . $settings_slug . '/notifications/'; 440 437 441 // Set up and send the message 438 // Set up and send the message. 442 439 $to = $ud->user_email; 443 440 $subject = bp_get_email_subject( array( 'text' => sprintf( __( 'You have been promoted in the group: "%s"', 'buddypress' ), $group->name ) ) ); … … 450 447 ', 'buddypress' ), $promoted_to, $group->name, $group_link ); 451 448 452 // Only show the disable notifications line if the settings component is enabled 449 // Only show the disable notifications line if the settings component is enabled. 453 450 if ( bp_is_active( 'settings' ) ) { 454 451 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); … … 511 508 * @param BP_Groups_Member $member Member object. 512 509 * @param int $inviter_user_id ID of the user who sent the invite. 513 *514 510 * @return null|false False on failure. 515 511 */ 516 512 function groups_notification_group_invites( &$group, &$member, $inviter_user_id ) { 517 513 518 // Bail if member has already been invited 514 // Bail if member has already been invited. 519 515 if ( ! empty( $member->invite_sent ) ) { 520 516 return; … … 527 523 $group_link = bp_get_group_permalink( $group ); 528 524 529 // Setup the ID for the invited user 525 // Setup the ID for the invited user. 530 526 $invited_user_id = $member->user_id; 531 527 532 // Trigger a BuddyPress Notification 528 // Trigger a BuddyPress Notification. 533 529 if ( bp_is_active( 'notifications' ) ) { 534 530 bp_notifications_add_notification( array( … … 540 536 } 541 537 542 // Bail if member opted out of receiving this email 538 // Bail if member opted out of receiving this email. 543 539 if ( 'no' === bp_get_user_meta( $invited_user_id, 'notification_groups_invite', true ) ) { 544 540 return false; … … 551 547 $invites_link = trailingslashit( $invited_link . bp_get_groups_slug() . '/invites' ); 552 548 553 // Set up and send the message 549 // Set up and send the message. 554 550 $to = $invited_ud->user_email; 555 551 $subject = bp_get_email_subject( array( 'text' => sprintf( __( 'You have an invitation to the group: "%s"', 'buddypress' ), $group->name ) ) ); … … 566 562 ', 'buddypress' ), $inviter_name, $group->name, $invites_link, $group_link, $inviter_name, $inviter_link ); 567 563 568 // Only show the disable notifications line if the settings component is enabled 564 // Only show the disable notifications line if the settings component is enabled. 569 565 if ( bp_is_active( 'settings' ) ) { 570 566 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); … … 634 630 * @param string $format 'string' for BuddyBar-compatible notifications; 'array' 635 631 * for WP Toolbar. Default: 'string'. 636 *637 632 * @return string 638 633 */ … … 649 644 650 645 // Set up the string and the filter 651 // Because different values are passed to the filters, we'll return the652 // values inline646 // because different values are passed to the filters, 647 // we'll return values inline. 653 648 if ( (int) $total_items > 1 ) { 654 649 $text = sprintf( __( '%1$d new membership requests for the group "%2$s"', 'buddypress' ), (int) $total_items, $group->name ); … … 1261 1256 function bp_groups_screen_my_groups_mark_notifications() { 1262 1257 1263 // Delete group request notifications for the user 1258 // Delete group request notifications for the user. 1264 1259 if ( isset( $_GET['n'] ) && bp_is_active( 'notifications' ) ) { 1265 1260 1266 // Get the necessary ID's 1261 // Get the necessary ID's. 1267 1262 $group_id = buddypress()->groups->id; 1268 1263 $user_id = bp_loggedin_user_id(); 1269 1264 1270 // Mark notifications read 1265 // Mark notifications read. 1271 1266 bp_notifications_mark_notifications_by_type( $user_id, $group_id, 'membership_request_accepted' ); 1272 1267 bp_notifications_mark_notifications_by_type( $user_id, $group_id, 'membership_request_rejected' ); -
trunk/src/bp-groups/bp-groups-screens.php
r10276 r10373 69 69 70 70 if ( bp_is_action_variable( 'accept' ) && is_numeric( $group_id ) ) { 71 // Check the nonce 71 // Check the nonce. 72 72 if ( !check_admin_referer( 'groups_accept_invite' ) ) 73 73 return false; … … 78 78 bp_core_add_message( __('Group invite accepted', 'buddypress') ); 79 79 80 // Record this in activity streams 80 // Record this in activity streams. 81 81 $group = groups_get_group( array( 'group_id' => $group_id ) ); 82 82 … … 96 96 97 97 } elseif ( bp_is_action_variable( 'reject' ) && is_numeric( $group_id ) ) { 98 // Check the nonce 98 // Check the nonce. 99 99 if ( !check_admin_referer( 'groups_reject_invite' ) ) 100 100 return false; … … 183 183 return false; 184 184 185 // Fetch the details we need 185 // Fetch the details we need. 186 186 $topic_slug = (string)bp_action_variable( 1 ); 187 187 $topic_id = bp_forums_get_topic_id_from_slug( $topic_slug ); … … 194 194 if ( !empty( $topic_slug ) && !empty( $topic_id ) ) { 195 195 196 // Posting a reply 196 // Posting a reply. 197 197 if ( !$user_is_banned && !bp_action_variable( 2 ) && isset( $_POST['submit_reply'] ) ) { 198 // Check the nonce 198 // Check the nonce. 199 199 check_admin_referer( 'bp_forums_new_reply' ); 200 200 201 // Auto join this user if they are not yet a member of this group 201 // Auto join this user if they are not yet a member of this group. 202 202 if ( bp_groups_auto_join() && !bp_current_user_can( 'bp_moderate' ) && 'public' == $bp->groups->current_group->status && !groups_is_user_member( bp_loggedin_user_id(), $bp->groups->current_group->id ) ) { 203 203 groups_join_group( $bp->groups->current_group->id, bp_loggedin_user_id() ); … … 206 206 $topic_page = isset( $_GET['topic_page'] ) ? $_GET['topic_page'] : false; 207 207 208 // Don't allow reply flooding 208 // Don't allow reply flooding. 209 209 if ( bp_forums_reply_exists( $_POST['reply_text'], $topic_id, bp_loggedin_user_id() ) ) { 210 210 bp_core_add_message( __( 'It looks like you\'ve already said that!', 'buddypress' ), 'error' ); … … 228 228 } 229 229 230 // Sticky a topic 230 // Sticky a topic. 231 231 elseif ( bp_is_action_variable( 'stick', 2 ) && ( bp_is_item_admin() || bp_is_item_mod() ) ) { 232 // Check the nonce 232 // Check the nonce. 233 233 check_admin_referer( 'bp_forums_stick_topic' ); 234 234 … … 250 250 } 251 251 252 // Un-Sticky a topic 252 // Un-Sticky a topic. 253 253 elseif ( bp_is_action_variable( 'unstick', 2 ) && ( bp_is_item_admin() || bp_is_item_mod() ) ) { 254 // Check the nonce 254 // Check the nonce. 255 255 check_admin_referer( 'bp_forums_unstick_topic' ); 256 256 … … 272 272 } 273 273 274 // Close a topic 274 // Close a topic. 275 275 elseif ( bp_is_action_variable( 'close', 2 ) && ( bp_is_item_admin() || bp_is_item_mod() ) ) { 276 // Check the nonce 276 // Check the nonce. 277 277 check_admin_referer( 'bp_forums_close_topic' ); 278 278 … … 294 294 } 295 295 296 // Open a topic 296 // Open a topic. 297 297 elseif ( bp_is_action_variable( 'open', 2 ) && ( bp_is_item_admin() || bp_is_item_mod() ) ) { 298 // Check the nonce 298 // Check the nonce. 299 299 check_admin_referer( 'bp_forums_open_topic' ); 300 300 … … 316 316 } 317 317 318 // Delete a topic 318 // Delete a topic. 319 319 elseif ( empty( $user_is_banned ) && bp_is_action_variable( 'delete', 2 ) && !bp_action_variable( 3 ) ) { 320 // Fetch the topic 320 // Fetch the topic. 321 321 $topic = bp_forums_get_topic_details( $topic_id ); 322 322 … … 326 326 } 327 327 328 // Check the nonce 328 // Check the nonce. 329 329 check_admin_referer( 'bp_forums_delete_topic' ); 330 330 … … 355 355 } 356 356 357 // Editing a topic 357 // Editing a topic. 358 358 elseif ( empty( $user_is_banned ) && bp_is_action_variable( 'edit', 2 ) && !bp_action_variable( 3 ) ) { 359 // Fetch the topic 359 // Fetch the topic. 360 360 $topic = bp_forums_get_topic_details( $topic_id ); 361 361 362 // Check the logged in user can edit this topic 362 // Check the logged in user can edit this topic. 363 363 if ( ! bp_is_item_admin() && ! bp_is_item_mod() && ( (int) bp_loggedin_user_id() != (int) $topic->topic_poster ) ) { 364 364 bp_core_redirect( wp_get_referer() ); … … 366 366 367 367 if ( isset( $_POST['save_changes'] ) ) { 368 // Check the nonce 368 // Check the nonce. 369 369 check_admin_referer( 'bp_forums_edit_topic' ); 370 370 … … 397 397 bp_core_load_template( apply_filters( 'groups_template_group_forum_topic_edit', 'groups/single/home' ) ); 398 398 399 // Delete a post 399 // Delete a post. 400 400 } elseif ( empty( $user_is_banned ) && bp_is_action_variable( 'delete', 2 ) && $post_id = bp_action_variable( 4 ) ) { 401 // Fetch the post 401 // Fetch the post. 402 402 $post = bp_forums_get_post( $post_id ); 403 403 404 // Check the logged in user can edit this topic 404 // Check the logged in user can edit this topic. 405 405 if ( ! bp_is_item_admin() && ! bp_is_item_mod() && ( (int) bp_loggedin_user_id() != (int) $post->poster_id ) ) { 406 406 bp_core_redirect( wp_get_referer() ); 407 407 } 408 408 409 // Check the nonce 409 // Check the nonce. 410 410 check_admin_referer( 'bp_forums_delete_post' ); 411 411 … … 435 435 bp_core_redirect( wp_get_referer() ); 436 436 437 // Editing a post 437 // Editing a post. 438 438 } elseif ( empty( $user_is_banned ) && bp_is_action_variable( 'edit', 2 ) && $post_id = bp_action_variable( 4 ) ) { 439 439 440 // Fetch the post 440 // Fetch the post. 441 441 $post = bp_forums_get_post( $post_id ); 442 442 443 // Check the logged in user can edit this topic 443 // Check the logged in user can edit this topic. 444 444 if ( ! bp_is_item_admin() && ! bp_is_item_mod() && ( (int) bp_loggedin_user_id() != (int) $post->poster_id ) ) { 445 445 bp_core_redirect( wp_get_referer() ); … … 447 447 448 448 if ( isset( $_POST['save_changes'] ) ) { 449 // Check the nonce 449 // Check the nonce. 450 450 check_admin_referer( 'bp_forums_edit_post' ); 451 451 … … 476 476 bp_core_load_template( apply_filters( 'groups_template_group_forum_topic_edit', 'groups/single/home' ) ); 477 477 478 // Standard topic display 478 // Standard topic display. 479 479 } else { 480 480 if ( !empty( $user_is_banned ) ) { … … 492 492 } 493 493 494 // Forum topic does not exist 494 // Forum topic does not exist. 495 495 } elseif ( !empty( $topic_slug ) && empty( $topic_id ) ) { 496 496 bp_do_404(); … … 498 498 499 499 } else { 500 // Posting a topic 500 // Posting a topic. 501 501 if ( isset( $_POST['submit_topic'] ) && bp_is_active( 'forums' ) ) { 502 502 503 // Check the nonce 503 // Check the nonce. 504 504 check_admin_referer( 'bp_forums_new_topic' ); 505 505 … … 508 508 509 509 } elseif ( bp_groups_auto_join() && !bp_current_user_can( 'bp_moderate' ) && 'public' == $bp->groups->current_group->status && !groups_is_user_member( bp_loggedin_user_id(), $bp->groups->current_group->id ) ) { 510 // Auto join this user if they are not yet a member of this group 510 // Auto join this user if they are not yet a member of this group. 511 511 groups_join_group( $bp->groups->current_group->id, bp_loggedin_user_id() ); 512 512 } … … 569 569 $bp = buddypress(); 570 570 571 // Refresh the group member count meta 571 // Refresh the group member count meta. 572 572 groups_update_groupmeta( $bp->groups->current_group->id, 'total_member_count', groups_get_total_member_count( $bp->groups->current_group->id ) ); 573 573 … … 698 698 return false; 699 699 700 // If the user is already invited, accept invitation 700 // If the user is already invited, accept invitation. 701 701 if ( groups_check_user_has_invite( bp_loggedin_user_id(), $bp->groups->current_group->id ) ) { 702 702 if ( groups_accept_invite( bp_loggedin_user_id(), $bp->groups->current_group->id ) ) … … 710 710 if ( isset( $_POST['group-request-send']) ) { 711 711 712 // Check the nonce 712 // Check the nonce. 713 713 if ( !check_admin_referer( 'groups_request_membership' ) ) 714 714 return false; … … 809 809 $bp = buddypress(); 810 810 811 // If the edit form has been submitted, save the edited details 811 // If the edit form has been submitted, save the edited details. 812 812 if ( isset( $_POST['save'] ) ) { 813 // Check the nonce 813 // Check the nonce. 814 814 if ( !check_admin_referer( 'groups_edit_group_details' ) ) 815 815 return false; … … 869 869 $bp = buddypress(); 870 870 871 // If the edit form has been submitted, save the edited details 871 // If the edit form has been submitted, save the edited details. 872 872 if ( isset( $_POST['save'] ) ) { 873 873 $enable_forum = ( isset($_POST['group-show-forum'] ) ) ? 1 : 0; 874 874 875 // Checked against a whitelist for security 875 // Checked against a whitelist for security. 876 876 /** This filter is documented in bp-groups/bp-groups-admin.php */ 877 877 $allowed_status = apply_filters( 'groups_allowed_status', array( 'public', 'private', 'hidden' ) ); 878 878 $status = ( in_array( $_POST['group-status'], (array) $allowed_status ) ) ? $_POST['group-status'] : 'public'; 879 879 880 // Checked against a whitelist for security 880 // Checked against a whitelist for security. 881 881 /** This filter is documented in bp-groups/bp-groups-admin.php */ 882 882 $allowed_invite_status = apply_filters( 'groups_allowed_invite_status', array( 'members', 'mods', 'admins' ) ); 883 883 $invite_status = isset( $_POST['group-invite-status'] ) && in_array( $_POST['group-invite-status'], (array) $allowed_invite_status ) ? $_POST['group-invite-status'] : 'members'; 884 884 885 // Check the nonce 885 // Check the nonce. 886 886 if ( !check_admin_referer( 'groups_edit_group_settings' ) ) 887 887 return false; … … 933 933 return false; 934 934 935 // If the logged-in user doesn't have permission or if avatar uploads are disabled, then stop here 935 // If the logged-in user doesn't have permission or if avatar uploads are disabled, then stop here. 936 936 if ( ! bp_is_item_admin() || bp_disable_group_avatar_uploads() || ! buddypress()->avatar->show_avatars ) 937 937 return false; … … 939 939 $bp = buddypress(); 940 940 941 // If the group admin has deleted the admin avatar 941 // If the group admin has deleted the admin avatar. 942 942 if ( bp_is_action_variable( 'delete', 1 ) ) { 943 943 944 // Check the nonce 944 // Check the nonce. 945 945 check_admin_referer( 'bp_group_avatar_delete' ); 946 946 … … 960 960 if ( !empty( $_FILES ) ) { 961 961 962 // Check the nonce 962 // Check the nonce. 963 963 check_admin_referer( 'bp_avatar_upload' ); 964 964 965 // Pass the file to the avatar upload handler 965 // Pass the file to the avatar upload handler. 966 966 if ( bp_core_avatar_handle_upload( $_FILES, 'groups_avatar_upload_dir' ) ) { 967 967 $bp->avatar_admin->step = 'crop-image'; 968 968 969 // Make sure we include the jQuery jCrop file for image cropping 969 // Make sure we include the jQuery jCrop file for image cropping. 970 970 add_action( 'wp_print_scripts', 'bp_core_add_jquery_cropper' ); 971 971 } … … 973 973 } 974 974 975 // If the image cropping is done, crop the image and save a full/thumb version 975 // If the image cropping is done, crop the image and save a full/thumb version. 976 976 if ( isset( $_POST['avatar-crop-submit'] ) ) { 977 977 978 // Check the nonce 978 // Check the nonce. 979 979 check_admin_referer( 'bp_avatar_cropstore' ); 980 980 … … 1027 1027 } 1028 1028 1029 // If the logged-in user doesn't have permission or if cover image uploads are disabled, then stop here 1029 // If the logged-in user doesn't have permission or if cover image uploads are disabled, then stop here. 1030 1030 if ( ! bp_is_item_admin() || ! bp_group_use_cover_image_header() ) { 1031 1031 return false; … … 1102 1102 return false; 1103 1103 1104 // Stop sole admins from abandoning their group 1104 // Stop sole admins from abandoning their group. 1105 1105 $group_admins = groups_get_group_admins( $bp->groups->current_group->id ); 1106 1106 if ( 1 == count( $group_admins ) && $group_admins[0]->user_id == $user_id ) … … 1249 1249 return false; 1250 1250 1251 // Accept the membership request 1251 // Accept the membership request. 1252 1252 if ( !groups_accept_membership_request( $membership_id ) ) 1253 1253 bp_core_add_message( __( 'There was an error accepting the membership request. Please try again.', 'buddypress' ), 'error' ); … … 1260 1260 return false; 1261 1261 1262 // Reject the membership request 1262 // Reject the membership request. 1263 1263 if ( !groups_reject_membership_request( $membership_id ) ) 1264 1264 bp_core_add_message( __( 'There was an error rejecting the membership request. Please try again.', 'buddypress' ), 'error' ); … … 1467 1467 public function is_group() { 1468 1468 1469 // Bail if not looking at a group 1469 // Bail if not looking at a group. 1470 1470 if ( ! bp_is_groups_component() ) 1471 1471 return; 1472 1472 1473 // Group Directory 1473 // Group Directory. 1474 1474 if ( ! bp_current_action() && ! bp_current_item() ) { 1475 1475 bp_update_is_directory( true, 'groups' ); … … 1486 1486 add_filter( 'bp_replace_the_content', array( $this, 'directory_content' ) ); 1487 1487 1488 // Creating a group 1488 // Creating a group. 1489 1489 } elseif ( bp_is_groups_component() && bp_is_current_action( 'create' ) ) { 1490 1490 add_filter( 'bp_get_buddypress_template', array( $this, 'create_template_hierarchy' ) ); … … 1492 1492 add_filter( 'bp_replace_the_content', array( $this, 'create_content' ) ); 1493 1493 1494 // Group page 1494 // Group page. 1495 1495 } elseif ( bp_is_single_item() ) { 1496 1496 add_filter( 'bp_get_buddypress_template', array( $this, 'single_template_hierarchy' ) ); … … 1527 1527 ) ); 1528 1528 1529 // Merge new templates with existing stack 1530 // @see bp_get_theme_compat_templates() 1529 // Merge new templates with existing stack. 1530 // @see bp_get_theme_compat_templates(). 1531 1531 $templates = array_merge( (array) $new_templates, $templates ); 1532 1532 … … 1573 1573 * 1574 1574 * @param string $templates The templates from bp_get_theme_compat_templates(). 1575 *1576 1575 * @return array $templates Array of custom templates to look for. 1577 1576 */ … … 1589 1588 ) ); 1590 1589 1591 // Merge new templates with existing stack 1592 // @see bp_get_theme_compat_templates() 1590 // Merge new templates with existing stack. 1591 // @see bp_get_theme_compat_templates(). 1593 1592 $templates = array_merge( $new_templates, $templates ); 1594 1593 … … 1641 1640 */ 1642 1641 public function single_template_hierarchy( $templates ) { 1643 // Setup some variables we're going to reference in our custom templates 1642 // Setup some variables we're going to reference in our custom templates. 1644 1643 $group = groups_get_current_group(); 1645 1644 … … 1659 1658 ) ); 1660 1659 1661 // Merge new templates with existing stack 1662 // @see bp_get_theme_compat_templates() 1660 // Merge new templates with existing stack. 1661 // @see bp_get_theme_compat_templates(). 1663 1662 $templates = array_merge( (array) $new_templates, $templates ); 1664 1663 -
trunk/src/bp-groups/bp-groups-template.php
r10342 r10373 197 197 function __construct( $args = array() ){ 198 198 199 // Backward compatibility with old method of passing arguments 199 // Backward compatibility with old method of passing arguments. 200 200 if ( ! is_array( $args ) || func_num_args() > 1 ) { 201 201 _deprecated_argument( __METHOD__, '1.7', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) ); … … 265 265 } 266 266 267 // backwards compatibility - the 'group_id' variable is not part of the267 // Backwards compatibility - the 'group_id' variable is not part of the 268 268 // BP_Groups_Group object, but we add it here for devs doing checks against it 269 269 // … … 271 271 // 272 272 // this is subject to removal in a future release; devs should check against 273 // $group->id instead 273 // $group->id instead. 274 274 $group->group_id = $group->id; 275 275 … … 326 326 } 327 327 328 // Build pagination links 328 // Build pagination links. 329 329 if ( (int) $this->total_group_count && (int) $this->pag_num ) { 330 330 $pag_args = array( … … 420 420 */ 421 421 do_action('group_loop_end'); 422 // Do some cleaning up after the loop 422 // Do some cleaning up after the loop. 423 423 $this->rewind_groups(); 424 424 } … … 499 499 global $groups_template; 500 500 501 /* **501 /* 502 502 * Defaults based on the current page & overridden by parsed $args 503 503 */ … … 506 506 $search_terms = false; 507 507 508 // When looking your own groups, check for two action variables 508 // When looking your own groups, check for two action variables. 509 509 if ( bp_is_current_action( 'my-groups' ) ) { 510 510 if ( bp_is_action_variable( 'most-popular', 0 ) ) { … … 514 514 } 515 515 516 // When looking at invites, set type to invites 516 // When looking at invites, set type to invites. 517 517 } elseif ( bp_is_current_action( 'invites' ) ) { 518 518 $type = 'invites'; 519 519 520 // When looking at a single group, set the type and slug 520 // When looking at a single group, set the type and slug. 521 521 } elseif ( bp_get_current_group_slug() ) { 522 522 $type = 'single-group'; … … 524 524 } 525 525 526 // Default search string (too soon to escape here) 526 // Default search string (too soon to escape here). 527 527 $search_query_arg = bp_core_get_component_search_query_arg( 'groups' ); 528 528 if ( ! empty( $_REQUEST[ $search_query_arg ] ) ) { … … 534 534 } 535 535 536 // Parse defaults and requested arguments 536 // Parse defaults and requested arguments. 537 537 $r = bp_parse_args( $args, array( 538 538 'type' => $type, … … 554 554 ), 'has_groups' ); 555 555 556 // Setup the Groups template global 556 // Setup the Groups template global. 557 557 $groups_template = new BP_Groups_Template( array( 558 558 'type' => $r['type'], … … 610 610 * 611 611 * @param object|bool $group Optional. Group object. Default: current group in loop. 612 *613 612 * @return bool 614 613 */ … … 648 647 * @param object|bool $group Optional. Group object. 649 648 * Default: current group in loop. 650 *651 649 * @return int 652 650 */ … … 684 682 * 685 683 * @param array $classes Array of custom classes. 686 *687 684 * @return string Row class of the group. 688 685 */ … … 690 687 global $groups_template; 691 688 692 // Add even/odd classes, but only if there's more than 1 group 689 // Add even/odd classes, but only if there's more than 1 group. 693 690 if ( $groups_template->group_count > 1 ) { 694 691 $pos_in_loop = (int) $groups_template->current_group; 695 692 $classes[] = ( $pos_in_loop % 2 ) ? 'even' : 'odd'; 696 693 697 // If we've only one group in the loop, don't bother with odd and even 694 // If we've only one group in the loop, don't bother with odd and even. 698 695 } else { 699 696 $classes[] = 'bp-single-group'; … … 703 700 $classes[] = sanitize_key( $groups_template->group->status ); 704 701 705 // User's group role 702 // User's group role. 706 703 if ( bp_is_user_active() ) { 707 704 708 // Admin 705 // Admin. 709 706 if ( bp_group_is_admin() ) { 710 707 $classes[] = 'is-admin'; 711 708 } 712 709 713 // Moderator 710 // Moderator. 714 711 if ( bp_group_is_mod() ) { 715 712 $classes[] = 'is-mod'; 716 713 } 717 714 718 // Member 715 // Member. 719 716 if ( bp_group_is_member() ) { 720 717 $classes[] = 'is-member'; … … 757 754 * @param object|bool $group Optional. Group object. 758 755 * Default: current group in loop. 759 *760 756 * @return string 761 757 */ … … 792 788 * @param object|bool $group Optional. Group object. 793 789 * Default: current group in loop. 794 *795 790 * @return string 796 791 */ … … 835 830 * @param object|bool $group Optional. Group object. 836 831 * Default: current group in loop. 837 *838 832 * @return string 839 833 */ … … 874 868 * @see bp_core_fetch_avatar() For a description of arguments and return values. 875 869 876 * @param array $args{870 * @param array|string $args { 877 871 * Arguments are listed here with an explanation of their defaults. 878 872 * For more information about the arguments, see {@link bp_core_fetch_avatar()}. … … 895 889 } 896 890 897 // Parse the arguments 891 // Parse the arguments. 898 892 $r = bp_parse_args( $args, array( 899 893 'type' => 'full', … … 905 899 ) ); 906 900 907 // Fetch the avatar from the folder 901 // Fetch the avatar from the folder. 908 902 $avatar = bp_core_fetch_avatar( array( 909 903 'item_id' => $groups_template->group->id, … … 919 913 ) ); 920 914 921 // If No avatar found, provide some backwards compatibility 915 // If No avatar found, provide some backwards compatibility. 922 916 if ( empty( $avatar ) ) { 923 917 $avatar = '<img src="' . esc_url( $groups_template->group->avatar_thumb ) . '" class="avatar" alt="' . esc_attr( $groups_template->group->name ) . '" />'; … … 953 947 * @param object|bool $group Optional. Group object. 954 948 * Default: current group in loop. 955 *956 949 * @return string 957 950 */ … … 981 974 * @param object|bool $group Optional. Group object. 982 975 * Default: current group in loop. 983 *984 976 * @return string 985 977 */ … … 996 988 997 989 /** 998 * Should we use the group's cover image header 990 * Should we use the group's cover image header. 999 991 * 1000 992 * @since 2.4.0 … … 1021 1013 * @param object|bool $group Optional. Group object. 1022 1014 * Default: current group in loop. 1023 *1024 1015 * @return string 1025 1016 */ … … 1066 1057 * @param object|bool $group Optional. Group object. 1067 1058 * Default: current group in loop. 1068 *1069 1059 * @return string 1070 1060 */ … … 1100 1090 * @param object|bool $group Optional. Group object. 1101 1091 * Default: current group in loop. 1102 *1103 1092 * @return string 1104 1093 */ … … 1134 1123 * @param object|bool $group Optional. Group object. 1135 1124 * Default: current group in loop. 1136 *1137 1125 * @return string 1138 1126 */ … … 1168 1156 * @param object|bool $group Optional. Group object. 1169 1157 * Default: current group in loop. 1170 *1171 1158 * @return string 1172 1159 */ … … 1206 1193 * @param object|bool $group Optional. Group object. 1207 1194 * Default: current group in loop. 1208 *1209 1195 * @return string 1210 1196 */ … … 1246 1232 * Defaults to the group currently being 1247 1233 * iterated on in the groups loop. 1248 *1249 1234 * @return string Excerpt. 1250 1235 */ … … 1285 1270 * @param object|bool $group Optional. Group object. 1286 1271 * Default: current group in loop. 1287 *1288 1272 * @return string 1289 1273 */ … … 1320 1304 * @param object|bool $group Optional. Group object. 1321 1305 * Default: current group in loop. 1322 * 1323 * @return unknown 1306 * @return mixed 1324 1307 */ 1325 1308 function bp_get_group_is_public( $group = false ) { … … 1347 1330 * @param object|bool $group Optional. Group object. 1348 1331 * Default: current group in loop. 1349 *1350 1332 * @return string 1351 1333 */ … … 1381 1363 * @param object|bool $group Optional. Group object. 1382 1364 * Default: current group in loop. 1383 *1384 1365 * @return string 1385 1366 */ … … 1415 1396 * @param object|bool $group Optional. Group object. 1416 1397 * Default: current group in loop. 1417 *1418 1398 * @return int 1419 1399 */ … … 1449 1429 * @param object|bool $group Optional. Group object. 1450 1430 * Default: current group in loop. 1451 *1452 1431 * @return string 1453 1432 */ … … 1475 1454 * Default: current group in loop. 1476 1455 * @param int $user_id ID of the user. 1477 *1478 1456 * @return bool 1479 1457 */ … … 1589 1567 } 1590 1568 1591 // fetch group admins if 'populate_extras' flag is false1569 // Fetch group admins if 'populate_extras' flag is false. 1592 1570 if ( empty( $group->args['populate_extras'] ) ) { 1593 1571 $query = new BP_Group_Member_Query( array( … … 1629 1607 } 1630 1608 1631 // fetch group mods if 'populate_extras' flag is false1609 // Fetch group mods if 'populate_extras' flag is false. 1632 1610 if ( empty( $group->args['populate_extras'] ) ) { 1633 1611 $query = new BP_Group_Member_Query( array( … … 1759 1737 * @param object|bool $group Optional. Group object. 1760 1738 * Default: current group in loop. 1761 *1762 1739 * @return string 1763 1740 */ … … 1784 1761 * No longer used in BuddyPress. 1785 1762 * 1786 * @todo Deprecate 1763 * @todo Deprecate. 1787 1764 */ 1788 1765 function bp_group_search_form() { … … 1807 1784 * No longer used in BuddyPress. 1808 1785 * 1809 * @todo Deprecate 1786 * @todo Deprecate. 1810 1787 * 1811 1788 * @return bool True if the displayed user has no groups, otherwise false. … … 1932 1909 * @param object|bool $group Optional. Group object. 1933 1910 * Default: current group in loop. 1934 *1935 1911 * @return int 1936 1912 */ … … 1995 1971 * @param object|bool $group Optional. Group object. 1996 1972 * Default: current group in loop. 1997 *1998 1973 * @return string 1999 1974 */ … … 2201 2176 * 2202 2177 * @param string $setting The setting you want to check against ('members', 2203 * 2178 * 'mods', or 'admins'). 2204 2179 * @param object|bool $group Optional. Group object. Default: current group in loop. 2205 2180 */ … … 2230 2205 * check. Default: the displayed group, or the current group 2231 2206 * in the loop. 2232 *2233 2207 * @return bool|string Returns false when no group can be found. Otherwise 2234 2208 * returns the group invite status, from among 'members', … … 2242 2216 2243 2217 if ( isset( $bp->groups->current_group->id ) ) { 2244 // Default to the current group first 2218 // Default to the current group first. 2245 2219 $group_id = $bp->groups->current_group->id; 2246 2220 } elseif ( isset( $groups_template->group->id ) ) { 2247 // Then see if we're in the loop 2221 // Then see if we're in the loop. 2248 2222 $group_id = $groups_template->group->id; 2249 2223 } else { … … 2254 2228 $invite_status = groups_get_groupmeta( $group_id, 'invite_status' ); 2255 2229 2256 // Backward compatibility. When 'invite_status' is not set, fall back to a default value 2230 // Backward compatibility. When 'invite_status' is not set, fall back to a default value. 2257 2231 if ( !$invite_status ) { 2258 2232 $invite_status = apply_filters( 'bp_group_invite_status_fallback', 'members' ); … … 2297 2271 2298 2272 if ( $user_id ) { 2299 // Users with the 'bp_moderate' cap can always send invitations 2273 // Users with the 'bp_moderate' cap can always send invitations. 2300 2274 if ( user_can( $user_id, 'bp_moderate' ) ) { 2301 2275 $can_send_invites = true; … … 2497 2471 * 2498 2472 * @param object|bool $group Optional. Group object. Default: current group in loop. 2499 *2500 2473 * @return array Info about group admins (user_id + date_modified). 2501 2474 */ … … 2616 2589 * member in a member loop. 2617 2590 * @param object|bool $group Optional. Group object. Default: current group. 2618 *2619 2591 * @return string 2620 2592 */ … … 2661 2633 * Default: current member in a member loop. 2662 2634 * @param object|bool $group Optional. Group object. Default: current group. 2663 *2664 2635 * @return string 2665 2636 */ … … 2702 2673 * Default: current member in a member loop. 2703 2674 * @param object|bool $group Optional. Group object. Default: current group. 2704 *2705 2675 * @return string 2706 2676 */ … … 2747 2717 * Default: current member in a member loop. 2748 2718 * @param object|bool $group Optional. Group object. Default: current group. 2749 *2750 2719 * @return string 2751 2720 */ … … 2800 2769 * @param string $subnav_item subnav item params. 2801 2770 * @param string $selected_item Surrent selected tab. 2802 *2803 2771 * @return string HTML output 2804 2772 */ … … 2862 2830 * @param object|bool $group Optional. Group object. 2863 2831 * Default: current group in the loop. 2864 *2865 2832 * @return string 2866 2833 */ … … 2896 2863 * @param object|bool $group Optional. Group object. 2897 2864 * Default: current group in the loop. 2898 *2899 2865 * @return string 2900 2866 */ … … 2925 2891 * @param object|bool $group Optional. Group object. 2926 2892 * Default: current group in the loop. 2927 *2928 2893 * @return bool 2929 2894 */ … … 2949 2914 * @param object|bool $group Optional. Group to check is_member. 2950 2915 * Default: current group in the loop. 2951 *2952 2916 * @return bool If user is member of group or not. 2953 2917 */ … … 2955 2919 global $groups_template; 2956 2920 2957 // Site admins always have access 2921 // Site admins always have access. 2958 2922 if ( bp_current_user_can( 'bp_moderate' ) ) { 2959 2923 return true; … … 2979 2943 * @param object|bool $group Optional. Group data object. 2980 2944 * Default: the current group in the groups loop. 2981 *2982 2945 * @return bool True if the user has an outstanding invite, otherwise false. 2983 2946 */ … … 3018 2981 * @param BP_Groups_Group|bool $group Group to check if user is banned. 3019 2982 * @param int $user_id The user ID to check. 3020 *3021 2983 * @return bool True if user is banned. False if user isn't banned. 3022 2984 */ … … 3024 2986 global $groups_template; 3025 2987 3026 // Site admins always have access 2988 // Site admins always have access. 3027 2989 if ( bp_current_user_can( 'bp_moderate' ) ) { 3028 2990 return false; 3029 2991 } 3030 2992 3031 // check groups loop first3032 // @see BP_Groups_Group::get_group_extras() 2993 // Check groups loop first 2994 // @see BP_Groups_Group::get_group_extras(). 3033 2995 if ( ! empty( $groups_template->in_the_loop ) && isset( $groups_template->group->is_banned ) ) { 3034 2996 $retval = $groups_template->group->is_banned; 3035 2997 3036 // not in loop2998 // Not in loop. 3037 2999 } else { 3038 // Default to not banned 3000 // Default to not banned. 3039 3001 $retval = false; 3040 3002 … … 3073 3035 * @param object|bool $group Optional. Group object. 3074 3036 * Default: Current group in the loop. 3075 *3076 3037 * @return string 3077 3038 */ … … 3106 3067 * @param object|bool $group Optional. Group object. 3107 3068 * Default: Current group in the loop. 3108 *3109 3069 * @return string 3110 3070 */ … … 3139 3099 * @param object|bool $group Optional. Group object. 3140 3100 * Default: Current group in the loop. 3141 *3142 3101 * @return string 3143 3102 */ … … 3170 3129 * @param object|bool $group Optional. Group object. 3171 3130 * Default: Current group in the loop. 3172 *3173 3131 * @return string 3174 3132 */ … … 3201 3159 * @param object|bool $group Optional. Group object. 3202 3160 * Default: current group in the loop. 3203 *3204 3161 * @return string 3205 3162 */ … … 3226 3183 * @param object|bool $group Optional. Group object. 3227 3184 * Default: current group in the loop. 3228 *3229 3185 * @return bool 3230 3186 */ … … 3266 3222 * @param BP_Groups_Group|bool $group The BP Groups_Group object if 3267 3223 * passed, boolean false if not passed. 3268 *3269 3224 * @return string HTML code for the button. 3270 3225 */ … … 3319 3274 * 3320 3275 * @param object|bool $group Single group object. 3321 *3322 3276 * @return mixed 3323 3277 */ … … 3325 3279 global $groups_template; 3326 3280 3327 // Set group to current loop group if none passed 3281 // Set group to current loop group if none passed. 3328 3282 if ( empty( $group ) ) { 3329 3283 $group =& $groups_template->group; 3330 3284 } 3331 3285 3332 // Don't show button if not logged in or previously banned 3286 // Don't show button if not logged in or previously banned. 3333 3287 if ( ! is_user_logged_in() || bp_group_is_user_banned( $group ) ) { 3334 3288 return false; 3335 3289 } 3336 3290 3337 // Group creation was not completed or status is unknown 3291 // Group creation was not completed or status is unknown. 3338 3292 if ( empty( $group->status ) ) { 3339 3293 return false; 3340 3294 } 3341 3295 3342 // Already a member 3296 // Already a member. 3343 3297 if ( ! empty( $group->is_member ) ) { 3344 3298 3345 // Stop sole admins from abandoning their group 3299 // Stop sole admins from abandoning their group. 3346 3300 $group_admins = groups_get_group_admins( $group->id ); 3347 3301 if ( ( 1 == count( $group_admins ) ) && ( bp_loggedin_user_id() === (int) $group_admins[0]->user_id ) ) { … … 3349 3303 } 3350 3304 3351 // Setup button attributes 3305 // Setup button attributes. 3352 3306 $button = array( 3353 3307 'id' => 'leave_group', … … 3363 3317 ); 3364 3318 3365 // Not a member 3319 // Not a member. 3366 3320 } else { 3367 3321 3368 // Show different buttons based on group status 3322 // Show different buttons based on group status. 3369 3323 switch ( $group->status ) { 3370 3324 case 'hidden' : … … 3389 3343 3390 3344 // Member has outstanding invitation - 3391 // show an "Accept Invitation" button 3345 // show an "Accept Invitation" button. 3392 3346 if ( $group->is_invited ) { 3393 3347 $button = array( … … 3405 3359 3406 3360 // Member has requested membership but request is pending - 3407 // show a "Request Sent" button 3361 // show a "Request Sent" button. 3408 3362 } elseif ( $group->is_pending ) { 3409 3363 $button = array( … … 3421 3375 3422 3376 // Member has not requested membership yet - 3423 // show a "Request Membership" button 3377 // show a "Request Membership" button. 3424 3378 } else { 3425 3379 $button = array( … … 3515 3469 */ 3516 3470 function bp_get_group_create_nav_item() { 3517 // Get the create a group button 3471 // Get the create a group button. 3518 3472 $create_group_button = bp_get_group_create_button(); 3519 3473 3520 // Make sure the button is available 3474 // Make sure the button is available. 3521 3475 if ( empty( $create_group_button ) ) { 3522 3476 return; … … 3541 3495 * @since 2.2.0 3542 3496 * 3543 * @uses bp_group_create_nav_item() to output the create a Group nav item. 3497 * @uses bp_group_create_nav_item() to output the create a Group nav item. 3498 * 3544 3499 * @return string HTML Output 3545 3500 */ 3546 3501 function bp_group_backcompat_create_nav_item() { 3547 // Bail if the Groups nav item is already used by bp-legacy 3502 // Bail if the Groups nav item is already used by bp-legacy. 3548 3503 if ( has_action( 'bp_groups_directory_group_filter', 'bp_legacy_theme_group_create_nav', 999 ) ) { 3549 3504 return; 3550 3505 } 3551 3506 3552 // Bail if the theme is not filtering the Groups directory title 3507 // Bail if the theme is not filtering the Groups directory title. 3553 3508 if ( ! has_filter( 'bp_groups_directory_header' ) ) { 3554 3509 return; … … 3566 3521 * 3567 3522 * @global BP_Groups_Template $groups_template Groups template object. 3523 * 3568 3524 * @param object $group Group to get status message for. Optional; defaults to current group. 3569 3525 */ … … 3571 3527 global $groups_template; 3572 3528 3573 // Group not passed so look for loop 3529 // Group not passed so look for loop. 3574 3530 if ( empty( $group ) ) { 3575 3531 $group =& $groups_template->group; 3576 3532 } 3577 3533 3578 // Group status is not set (maybe outside of group loop?) 3534 // Group status is not set (maybe outside of group loop?). 3579 3535 if ( empty( $group->status ) ) { 3580 3536 $message = __( 'This group is not currently accessible.', 'buddypress' ); 3581 3537 3582 // Group has a status 3538 // Group has a status. 3583 3539 } else { 3584 3540 switch( $group->status ) { 3585 3541 3586 // Private group 3542 // Private group. 3587 3543 case 'private' : 3588 3544 if ( ! bp_group_has_requested_membership( $group ) ) { … … 3602 3558 break; 3603 3559 3604 // Hidden group 3560 // Hidden group. 3605 3561 case 'hidden' : 3606 3562 default : … … 3656 3612 * 3657 3613 * @since 1.0.0 3614 * 3658 3615 * @return type 3659 3616 */ … … 3688 3645 * 3689 3646 * @param int $user_id User ID to get group membership count. 3690 *3691 3647 * @return int 3692 3648 */ … … 3705 3661 } 3706 3662 3707 /* *Group Members *************************************************************/3663 /* Group Members *************************************************************/ 3708 3664 3709 3665 class BP_Groups_Group_Members_Template { … … 3726 3682 * An array of optional arguments. 3727 3683 * @type int $group_id ID of the group whose members are being 3728 * 3684 * queried. Default: current group ID. 3729 3685 * @type int $page Page of results to be queried. Default: 1. 3730 3686 * @type int $per_page Number of items to return per page of … … 3742 3698 public function __construct( $args = array() ) { 3743 3699 3744 // Backward compatibility with old method of passing arguments 3700 // Backward compatibility with old method of passing arguments. 3745 3701 if ( ! is_array( $args ) || func_num_args() > 1 ) { 3746 3702 _deprecated_argument( __METHOD__, '2.0.0', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) ); … … 3787 3743 } 3788 3744 3789 // Assemble the base URL for pagination 3745 // Assemble the base URL for pagination. 3790 3746 $base_url = trailingslashit( bp_get_group_permalink( $current_group ) . bp_current_action() ); 3791 3747 if ( bp_action_variable() ) { … … 3798 3754 $members_args['per_page'] = $this->pag_num; 3799 3755 3800 // Get group members for this loop 3756 // Get group members for this loop. 3801 3757 $this->members = groups_get_group_members( $members_args ); 3802 3758 … … 3807 3763 } 3808 3764 3809 // Reset members array for subsequent looping 3765 // Reset members array for subsequent looping. 3810 3766 $this->members = $this->members['members']; 3811 3767 … … 3866 3822 do_action( 'loop_end', $this ); 3867 3823 3868 // Do some cleaning up after the loop 3824 // Do some cleaning up after the loop. 3869 3825 $this->rewind_members(); 3870 3826 } … … 3878 3834 $this->member = $this->next_member(); 3879 3835 3880 // loop has just started3836 // Loop has just started. 3881 3837 if ( 0 == $this->current_member ) { 3882 3838 … … 3977 3933 * @since 1.0.0 3978 3934 * 3979 * @param array|string $args {@see bp_core_fetch_avatar()} 3935 * @param array|string $args {@see bp_core_fetch_avatar()}. 3980 3936 */ 3981 3937 function bp_group_member_avatar( $args = '' ) { … … 3987 3943 * @since 1.0.0 3988 3944 * 3989 * @param array|string $args {@see bp_core_fetch_avatar()} 3990 * 3945 * @param array|string $args {@see bp_core_fetch_avatar()}. 3991 3946 * @return string 3992 3947 */ … … 4017 3972 * @since 1.0.0 4018 3973 * 4019 * @param array|string $args {@see bp_core_fetch_avatar()} 4020 */ 4021 3974 * @param array|string $args {@see bp_core_fetch_avatar()}. 3975 */ 4022 3976 function bp_group_member_avatar_thumb( $args = '' ) { 4023 3977 echo bp_get_group_member_avatar_thumb( $args ); … … 4028 3982 * @since 1.0.0 4029 3983 * 4030 * @param array|string $args {@see bp_core_fetch_avatar()} 4031 * 3984 * @param array|string $args {@see bp_core_fetch_avatar()}. 4032 3985 * @return string 4033 3986 */ … … 4071 4024 * @param int $width Width of avatar to fetch. 4072 4025 * @param int $height Height of avatar to fetch. 4073 *4074 4026 * @return string 4075 4027 */ … … 4399 4351 * 4400 4352 * @since 2.0.0 4401 *4402 * @return string html output4403 4353 */ 4404 4354 function bp_groups_members_template_part() { … … 4437 4387 * 4438 4388 * @since 2.0.0 4439 *4440 * @return string html output4441 4389 */ 4442 4390 function bp_groups_members_filter() { … … 4470 4418 } 4471 4419 4472 /* **************************************************************************4420 /* 4473 4421 * Group Creation Process Template Tags 4474 * */4422 */ 4475 4423 4476 4424 /** … … 4482 4430 * @uses bp_get_option() To retrieve value of 'bp_restrict_group_creation'. Defaults to 0. 4483 4431 * @uses bp_current_user_can() To determine if current user if super admin. 4484 *4485 4432 * @return bool True if user can create groups. False otherwise. 4486 4433 */ 4487 4434 function bp_user_can_create_groups() { 4488 4435 4489 // Super admin can always create groups 4436 // Super admin can always create groups. 4490 4437 if ( bp_current_user_can( 'bp_moderate' ) ) { 4491 4438 return true; 4492 4439 } 4493 4440 4494 // Get group creation option, default to 0 (allowed) 4441 // Get group creation option, default to 0 (allowed). 4495 4442 $restricted = (int) bp_get_option( 'bp_restrict_group_creation', 0 ); 4496 4443 4497 // Allow by default 4444 // Allow by default. 4498 4445 $can_create = true; 4499 4446 … … 4581 4528 function bp_is_group_creation_step( $step_slug ) { 4582 4529 4583 // Make sure we are in the groups component 4530 // Make sure we are in the groups component. 4584 4531 if ( ! bp_is_groups_component() || ! bp_is_current_action( 'create' ) ) { 4585 4532 return false; … … 4588 4535 $bp = buddypress(); 4589 4536 4590 // If this the first step, we can just accept and return true 4537 // If this the first step, we can just accept and return true. 4591 4538 $keys = array_keys( $bp->groups->group_creation_steps ); 4592 4539 if ( !bp_action_variable( 1 ) && array_shift( $keys ) == $step_slug ) { … … 4595 4542 4596 4543 // Before allowing a user to see a group creation step we must make sure 4597 // previous steps are completed 4544 // previous steps are completed. 4598 4545 if ( !bp_is_first_group_creation_step() ) { 4599 4546 if ( !bp_are_previous_group_creation_steps_complete( $step_slug ) ) { … … 4602 4549 } 4603 4550 4604 // Check the current step against the step parameter 4551 // Check the current step against the step parameter. 4605 4552 if ( bp_is_action_variable( $step_slug ) ) { 4606 4553 return true; … … 4637 4584 $bp = buddypress(); 4638 4585 4639 // If this is the first group creation step, return true 4586 // If this is the first group creation step, return true. 4640 4587 $keys = array_keys( $bp->groups->group_creation_steps ); 4641 4588 if ( array_shift( $keys ) == $step_slug ) { … … 4647 4594 $previous_steps = array(); 4648 4595 4649 // Get previous steps 4596 // Get previous steps. 4650 4597 foreach ( (array) $bp->groups->group_creation_steps as $slug => $name ) { 4651 4598 if ( $slug === $step_slug ) { … … 4761 4708 * @see bp_core_fetch_avatar() For more information on accepted arguments 4762 4709 * 4763 * @param array $args See bp_core_fetch_avatar()4710 * @param array|string $args See bp_core_fetch_avatar(). 4764 4711 */ 4765 4712 function bp_new_group_avatar( $args = '' ) { … … 4773 4720 * @see bp_core_fetch_avatar() For a description of arguments and return values. 4774 4721 * 4775 * @param array $args{4722 * @param array|string $args { 4776 4723 * Arguments are listed here with an explanation of their defaults. 4777 4724 * For more information about the arguments, see {@link bp_core_fetch_avatar()}. … … 4788 4735 function bp_get_new_group_avatar( $args = '' ) { 4789 4736 4790 // Parse arguments 4737 // Parse arguments. 4791 4738 $r = bp_parse_args( $args, array( 4792 4739 'type' => 'full', … … 4799 4746 ), 'get_new_group_avatar' ); 4800 4747 4801 // Merge parsed arguments with object specific data 4748 // Merge parsed arguments with object specific data. 4802 4749 $r = array_merge( $r, array( 4803 4750 'item_id' => bp_get_current_group_id(), … … 4806 4753 ) ); 4807 4754 4808 // Get the avatar 4755 // Get the avatar. 4809 4756 $avatar = bp_core_fetch_avatar( $r ); 4810 4757 … … 4840 4787 $steps = array_keys( $bp->groups->group_creation_steps ); 4841 4788 4842 // Loop through steps 4789 // Loop through steps. 4843 4790 foreach ( $steps as $slug ) { 4844 4791 4845 // Break when the current step is found 4792 // Break when the current step is found. 4846 4793 if ( bp_is_action_variable( $slug ) ) { 4847 4794 break; 4848 4795 } 4849 4796 4850 // Add slug to previous steps 4797 // Add slug to previous steps. 4851 4798 $previous_steps[] = $slug; 4852 4799 } 4853 4800 4854 // Generate the URL for the previous step 4801 // Generate the URL for the previous step. 4855 4802 $group_directory = bp_get_groups_directory_permalink(); 4856 4803 $create_step = 'create/step/'; … … 4911 4858 * @since 1.1.0 4912 4859 * 4913 * @param string $step Step to compare4914 * @return bool 4860 * @param string $step Step to compare. 4861 * @return bool True if yes, False if no 4915 4862 */ 4916 4863 function bp_is_last_group_creation_step( $step = '' ) { 4917 4864 4918 // Use current step, if no step passed 4865 // Use current step, if no step passed. 4919 4866 if ( empty( $step ) ) { 4920 4867 $step = bp_get_groups_current_create_step(); 4921 4868 } 4922 4869 4923 // Get the last step 4870 // Get the last step. 4924 4871 $bp = buddypress(); 4925 4872 $steps = array_keys( $bp->groups->group_creation_steps ); 4926 4873 $l_step = array_pop( $steps ); 4927 4874 4928 // Compare last step to step 4875 // Compare last step to step. 4929 4876 $retval = ( $l_step === $step ); 4930 4877 … … 4946 4893 * @since 1.1.0 4947 4894 * 4948 * @param string $step Step to compare4949 * @return bool 4895 * @param string $step Step to compare. 4896 * @return bool True if yes, False if no 4950 4897 */ 4951 4898 function bp_is_first_group_creation_step( $step = '' ) { 4952 4899 4953 // Use current step, if no step passed 4900 // Use current step, if no step passed. 4954 4901 if ( empty( $step ) ) { 4955 4902 $step = bp_get_groups_current_create_step(); 4956 4903 } 4957 4904 4958 // Get the first step 4905 // Get the first step. 4959 4906 $bp = buddypress(); 4960 4907 $steps = array_keys( $bp->groups->group_creation_steps ); 4961 4908 $f_step = array_shift( $steps ); 4962 4909 4963 // Compare first step to step 4910 // Compare first step to step. 4964 4911 $retval = ( $f_step === $step ); 4965 4912 … … 4980 4927 * 4981 4928 * @since 1.0.0 4929 * 4930 * @param array $args Array of arguments for friends list output. 4982 4931 */ 4983 4932 function bp_new_group_invite_friend_list( $args = array() ) { … … 4989 4938 * @since 1.0.0 4990 4939 * 4991 * @param array $args4940 * @param array $args Array of arguments for friends list output. 4992 4941 * @return mixed HTML list of checkboxes, or false 4993 4942 */ 4994 4943 function bp_get_new_group_invite_friend_list( $args = array() ) { 4995 4944 4996 // Bail if no friends component 4945 // Bail if no friends component. 4997 4946 if ( ! bp_is_active( 'friends' ) ) { 4998 4947 return false; 4999 4948 } 5000 4949 5001 // Parse arguments 4950 // Parse arguments. 5002 4951 $r = wp_parse_args( $args, array( 5003 4952 'user_id' => bp_loggedin_user_id(), … … 5006 4955 ) ); 5007 4956 5008 // No group passed, so look for new or current group ID's 4957 // No group passed, so look for new or current group ID's. 5009 4958 if ( empty( $r['group_id'] ) ) { 5010 4959 $bp = buddypress(); … … 5014 4963 } 5015 4964 5016 // Setup empty items array 4965 // Setup empty items array. 5017 4966 $items = array(); 5018 4967 5019 // Get user's friends who are not in this group already 4968 // Get user's friends who are not in this group already. 5020 4969 $friends = friends_get_friends_invite_list( $r['user_id'], $r['group_id'] ); 5021 4970 5022 4971 if ( ! empty( $friends ) ) { 5023 4972 5024 // Get already invited users 4973 // Get already invited users. 5025 4974 $invites = groups_get_invites_for_group( $r['user_id'], $r['group_id'] ); 5026 4975 … … 5132 5081 * @since 1.1.0 5133 5082 * 5134 * @param string $slug 5135 * 5083 * @param string $slug Admin screen slug. 5136 5084 * @return bool 5137 5085 */ … … 5180 5128 * 5181 5129 * @since 1.0.0 5182 * @param string $type thumb or full ?5130 * 5183 5131 * @uses bp_get_group_current_avatar() to get the avatar of the current group. 5132 * 5133 * @param string $type Thumb or full. 5184 5134 */ 5185 5135 function bp_group_current_avatar( $type = 'thumb' ) { … … 5191 5141 * @since 2.0.0 5192 5142 * 5193 * @param string $type thumb or full ?5143 * @param string $type Thumb or full. 5194 5144 * @return string $tab The current tab's slug. 5195 5145 */ … … 5220 5170 * @since 1.1.0 5221 5171 * 5222 * @param int|bool $group_id 5223 * 5172 * @param int|bool $group_id Group ID to check. 5224 5173 * @return boolean 5225 5174 */ … … 5276 5225 } 5277 5226 5278 /* *Group Membership Requests *************************************************/5227 /* Group Membership Requests *************************************************/ 5279 5228 5280 5229 class BP_Groups_Membership_Requests_Template { … … 5305 5254 public function __construct( $args = array() ) { 5306 5255 5307 // Backward compatibility with old method of passing arguments 5256 // Backward compatibility with old method of passing arguments. 5308 5257 if ( ! is_array( $args ) || func_num_args() > 1 ) { 5309 5258 _deprecated_argument( __METHOD__, '2.0.0', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) ); … … 5338 5287 'page' => $this->pag_page, 5339 5288 5340 // These filters ensure we only get pending requests 5289 // These filters ensure we only get pending requests. 5341 5290 'is_confirmed' => false, 5342 5291 'inviter_id' => 0, … … 5346 5295 $this->request_count = count( $this->requests ); 5347 5296 5348 // Compatibility with legacy format of request data objects 5297 // Compatibility with legacy format of request data objects. 5349 5298 foreach ( $this->requests as $rk => $rv ) { 5350 5299 // For legacy reasons, the 'id' property of each 5351 5300 // request must match the membership id, not the ID of 5352 // the user (as it's returned by BP_Group_Member_Query) 5301 // the user (as it's returned by BP_Group_Member_Query). 5353 5302 $this->requests[ $rk ]->user_id = $rv->ID; 5354 5303 $this->requests[ $rk ]->id = $rv->membership_id; 5355 5304 5356 // Miscellaneous values 5305 // Miscellaneous values. 5357 5306 $this->requests[ $rk ]->group_id = $r['group_id']; 5358 5307 } … … 5417 5366 */ 5418 5367 do_action( 'group_request_loop_end' ); 5419 // Do some cleaning up after the loop 5368 // Do some cleaning up after the loop. 5420 5369 $this->rewind_requests(); 5421 5370 } … … 5429 5378 $this->request = $this->next_request(); 5430 5379 5431 // loop has just started5380 // Loop has just started. 5432 5381 if ( 0 == $this->current_request ) { 5433 5382 … … 5664 5613 public function __construct( $args = array() ) { 5665 5614 5666 // Backward compatibility with old method of passing arguments 5615 // Backward compatibility with old method of passing arguments. 5667 5616 if ( ! is_array( $args ) || func_num_args() > 1 ) { 5668 5617 _deprecated_argument( __METHOD__, '2.0.0', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) ); … … 5695 5644 'page' => $this->pag_page, 5696 5645 5697 // These filters ensure we get only pending invites 5646 // These filters ensure we get only pending invites. 5698 5647 'is_confirmed' => false, 5699 5648 'inviter_id' => $r['user_id'], … … 5706 5655 5707 5656 // If per_page is set to 0 (show all results), don't generate 5708 // pag_links 5657 // pag_links. 5709 5658 if ( ! empty( $this->pag_num ) ) { 5710 5659 $this->pag_links = paginate_links( array( … … 5841 5790 } 5842 5791 5843 // Set the global (for use in BP_Groups_Invite_Template::the_invite()) 5792 // Set the global (for use in BP_Groups_Invite_Template::the_invite()). 5844 5793 if ( empty( $group_id ) ) { 5845 5794 $group_id = $r['group_id']; … … 6026 5975 function bp_groups_activity_feed() { 6027 5976 6028 // Bail if not viewing a single group or activity is not active 5977 // Bail if not viewing a single group or activity is not active. 6029 5978 if ( ! bp_is_active( 'groups' ) || ! bp_is_active( 'activity' ) || ! bp_is_group() ) { 6030 5979 return; … … 6049 5998 * 6050 5999 * @since 1.5.0 6000 * 6051 6001 * @return string 6052 6002 */ … … 6214 6164 * @param string $query_args 6215 6165 * @param bool $nonce 6216 *6217 6166 * @return string 6218 6167 */ … … 6228 6177 * @param string $query_args 6229 6178 * @param bool $nonce 6230 *6231 6179 * @return string 6232 6180 */ … … 6236 6184 $url = ''; 6237 6185 6238 // Must be a group 6186 // Must be a group. 6239 6187 if ( ! empty( $current_group->id ) ) { 6240 6188 … … 6246 6194 } 6247 6195 6248 // Add a slash at the end of our user url 6196 // Add a slash at the end of our user url. 6249 6197 $url = trailingslashit( $url ); 6250 6198 6251 // Add possible query args 6199 // Add possible query args. 6252 6200 if ( !empty( $query_args ) && is_array( $query_args ) ) { 6253 6201 $url = add_query_arg( $query_args, $url ); -
trunk/src/bp-groups/bp-groups-widgets.php
r10148 r10373 10 10 defined( 'ABSPATH' ) || exit; 11 11 12 /* Register widgets for groups component */ 12 /** 13 * Register widgets for groups component 14 */ 13 15 function groups_register_widgets() { 14 16 add_action('widgets_init', create_function('', 'return register_widget("BP_Groups_Widget");') ); … … 16 18 add_action( 'bp_register_widgets', 'groups_register_widgets' ); 17 19 18 /*** GROUPS WIDGET *****************/ 19 20 /** 21 * GROUPS WIDGET 22 */ 20 23 class BP_Groups_Widget extends WP_Widget { 24 25 /** 26 * Working as a group, we get things done better. 27 */ 21 28 function __construct() { 22 29 $widget_ops = array( … … 41 48 } 42 49 50 /** 51 * Extends our frontend output method. 52 * 53 * @param array $args Array of arguments for the widget. 54 * @param array $instance Widget instance data. 55 */ 43 56 function widget( $args, $instance ) { 44 57 … … 146 159 } 147 160 161 /** 162 * Extends our update method. 163 * 164 * @param array $new_instance New instance data. 165 * @param array $old_instance Original instance data. 166 * @return array 167 */ 148 168 function update( $new_instance, $old_instance ) { 149 169 $instance = $old_instance; … … 157 177 } 158 178 179 /** 180 * Extends our form method. 181 * 182 * @param array $instance Current instance. 183 * @return mixed 184 */ 159 185 function form( $instance ) { 160 186 $defaults = array( -
trunk/src/bp-groups/classes/class-bp-group-extension.php
r10248 r10373 36 36 * of your main extension tab. Defaults to 'groups/single/plugins.php'. 37 37 * - 'screens' A multi-dimensional array, described below. 38 * 39 * 38 * - 'access' Which users can visit the plugin's tab. 39 * - 'show_tab' Which users can see the plugin's navigation tab. 40 40 * 41 41 * BP_Group_Extension uses the concept of "settings screens". There are three … … 63 63 * 'screens' => array( 64 64 * 'create' => array( 65 * 66 * 67 * 68 * 69 * 70 * 71 * 65 * 'slug' => 'foo', 66 * 'name' => 'Foo', 67 * 'position' => 55, 68 * 'screen_callback' => 'my_create_screen_callback', 69 * 'screen_save_callback' => 'my_create_screen_save_callback', 70 * ), 71 * 'edit' => array( // ... 72 72 * ), 73 73 * Only provide those arguments that you actually want to change from the … … 272 272 * The content of the group tab. 273 273 * 274 * @param int|null $group_id 274 * @param int|null $group_id ID of the group to display. 275 275 */ 276 276 public function display( $group_id = null ) {} … … 281 281 public function widget_display() {} 282 282 283 // *_screen() displays the settings form for the given context 284 // *_screen_save() processes data submitted via the settings form 285 // The settings_* methods are generic fallbacks, which can optionally 286 // be overridden by the more specific edit_*, create_*, and admin_* 287 // versions. 283 /* 284 * *_screen() displays the settings form for the given context 285 * *_screen_save() processes data submitted via the settings form 286 * The settings_* methods are generic fallbacks, which can optionally 287 * be overridden by the more specific edit_*, create_*, and admin_* 288 * versions. 289 */ 288 290 public function settings_screen( $group_id = null ) {} 289 291 public function settings_screen_save( $group_id = null ) {} … … 354 356 */ 355 357 public function init( $args = array() ) { 356 // Store the raw arguments 358 // Store the raw arguments. 357 359 $this->params_raw = $args; 358 360 … … 361 363 // compatibility with these plugins, we detect whether this is 362 364 // one of those legacy plugins, and parse any legacy arguments 363 // with those passed to init() 365 // with those passed to init(). 364 366 $this->parse_legacy_properties(); 365 367 $args = $this->parse_args_r( $args, $this->legacy_properties_converted ); 366 368 367 // Parse with defaults 369 // Parse with defaults. 368 370 $this->params = $this->parse_args_r( $args, array( 369 371 'slug' => $this->slug, … … 399 401 public function _register() { 400 402 401 // Detect and parse properties set by legacy extensions 403 // Detect and parse properties set by legacy extensions. 402 404 $this->parse_legacy_properties(); 403 405 404 406 // Initialize, if necessary. This should only happen for 405 // legacy extensions that don't call parent::init() themselves 407 // legacy extensions that don't call parent::init() themselves. 406 408 if ( true !== $this->initialized ) { 407 409 $this->init(); 408 410 } 409 411 410 // Set some config values, based on the parsed params 412 // Set some config values, based on the parsed params. 411 413 $this->group_id = $this->get_group_id(); 412 414 $this->slug = $this->params['slug']; … … 418 420 $this->template_file = $this->params['template_file']; 419 421 420 // Configure 'screens': create, admin, and edit contexts 422 // Configure 'screens': create, admin, and edit contexts. 421 423 $this->setup_screens(); 422 424 423 // Configure access-related settings 425 // Configure access-related settings. 424 426 $this->setup_access_settings(); 425 427 426 428 // Mirror configuration data so it's accessible to plugins 427 // that look for it in its old locations 429 // that look for it in its old locations. 428 430 $this->setup_legacy_properties(); 429 431 430 // Hook the extension into BuddyPress 432 // Hook the extension into BuddyPress. 431 433 $this->setup_display_hooks(); 432 434 $this->setup_create_hooks(); … … 468 470 public static function get_group_id() { 469 471 470 // Usually this will work 472 // Usually this will work. 471 473 $group_id = bp_get_current_group_id(); 472 474 473 // On the admin, get the group id out of the $_GET params 475 // On the admin, get the group id out of the $_GET params. 474 476 if ( empty( $group_id ) && is_admin() && ( isset( $_GET['page'] ) && ( 'bp-groups' === $_GET['page'] ) ) && ! empty( $_GET['gid'] ) ) { 475 477 $group_id = (int) $_GET['gid']; … … 477 479 478 480 // This fallback will only be hit when the create step is very 479 // early 481 // early. 480 482 if ( empty( $group_id ) && bp_get_new_group_id() ) { 481 483 $group_id = bp_get_new_group_id(); … … 484 486 // On some setups, the group id has to be fetched out of the 485 487 // $_POST array 486 // @todo Figure out why this is happening during group creation 488 // @todo Figure out why this is happening during group creation. 487 489 if ( empty( $group_id ) && isset( $_POST['group_id'] ) ) { 488 490 $group_id = (int) $_POST['group_id']; … … 552 554 */ 553 555 protected function setup_access_settings() { 554 // Bail if no group ID is available 556 // Bail if no group ID is available. 555 557 if ( empty( $this->group_id ) ) { 556 558 return; 557 559 } 558 560 559 // Backward compatibility 561 // Backward compatibility. 560 562 if ( isset( $this->params['enable_nav_item'] ) ) { 561 563 $this->enable_nav_item = (bool) $this->params['enable_nav_item']; 562 564 } 563 565 564 // Tab Access 566 // Tab Access. 565 567 $this->user_can_visit = false; 566 568 567 569 // Backward compatibility for components that do not provide 568 // explicit 'access' parameter 570 // explicit 'access' parameter. 569 571 if ( empty( $this->params['access'] ) ) { 570 572 if ( false === $this->enable_nav_item ) { … … 576 578 577 579 if ( ! empty( $group->status ) && 'public' === $group->status ) { 578 // Tabs in public groups are accessible to anyone by default 580 // Tabs in public groups are accessible to anyone by default. 579 581 $this->params['access'] = 'anyone'; 580 582 } else { 581 // All other groups have members-only as the default 583 // All other groups have members-only as the default. 582 584 $this->params['access'] = 'member'; 583 585 } … … 585 587 } 586 588 587 // Parse multiple access conditions into an array 589 // Parse multiple access conditions into an array. 588 590 $access_conditions = $this->params['access']; 589 591 if ( ! is_array( $access_conditions ) ) { … … 592 594 593 595 // If the current user meets at least one condition, the 594 // get access 596 // get access. 595 597 foreach ( $access_conditions as $access_condition ) { 596 598 if ( $this->user_meets_access_condition( $access_condition ) ) { … … 600 602 } 601 603 602 // Tab Visibility 604 // Tab Visibility. 603 605 $this->user_can_see_nav_item = false; 604 606 605 607 // Backward compatibility for components that do not provide 606 // explicit 'show_tab' parameter 608 // explicit 'show_tab' parameter. 607 609 if ( empty( $this->params['show_tab'] ) ) { 608 610 if ( false === $this->params['enable_nav_item'] ) { 609 // enable_nav_itemis only false if it's been611 // The enable_nav_item index is only false if it's been 610 612 // defined explicitly as such in the 611 // constructor. So we always trust this value 613 // constructor. So we always trust this value. 612 614 $this->params['show_tab'] = 'noone'; 613 615 … … 616 618 // we assume this is a legacy extension. 617 619 // Legacy behavior is that enable_nav_item=true + 618 // visibility=private implies members-only 620 // visibility=private implies members-only. 619 621 if ( 'public' !== $this->visibility ) { 620 622 $this->params['show_tab'] = 'member'; … … 625 627 } else { 626 628 // No show_tab or enable_nav_item value is 627 // available, so match the value of 'access' 629 // available, so match the value of 'access'. 628 630 $this->params['show_tab'] = $this->params['access']; 629 631 } 630 632 } 631 633 632 // Parse multiple access conditions into an array 634 // Parse multiple access conditions into an array. 633 635 $access_conditions = $this->params['show_tab']; 634 636 if ( ! is_array( $access_conditions ) ) { … … 637 639 638 640 // If the current user meets at least one condition, the 639 // get access 641 // get access. 640 642 foreach ( $access_conditions as $access_condition ) { 641 643 if ( $this->user_meets_access_condition( $access_condition ) ) { … … 697 699 protected function setup_display_hooks() { 698 700 699 // Bail if not a group 701 // Bail if not a group. 700 702 if ( ! bp_is_group() ) { 701 703 return; 702 704 } 703 705 704 // Backward compatibility only 706 // Backward compatibility only. 705 707 if ( ( 'public' !== $this->visibility ) && ! buddypress()->groups->current_group->user_has_access ) { 706 708 return; … … 740 742 ) ); 741 743 742 // When we are viewing the extension display page, set the title and options title 744 // When we are viewing the extension display page, set the title and options title. 743 745 if ( bp_is_current_action( $this->slug ) ) { 744 746 add_filter( 'bp_group_user_has_access', array( $this, 'group_access_protection' ), 10, 2 ); … … 748 750 } 749 751 750 // Hook the group home widget 752 // Hook the group home widget. 751 753 if ( ! bp_current_action() && bp_is_current_action( 'home' ) ) { 752 754 add_action( $this->display_hook, array( &$this, 'widget_display' ) ); … … 790 792 * @since 2.1.0 791 793 * 792 * @param bool $user_can_see_nav_item 793 * 794 * @param bool $user_can_see_nav_item Whether or not the user can see the nav item. 794 795 * @return bool 795 796 */ … … 807 808 * @since 2.1.0 808 809 * 809 * @param bool $user_can_visit 810 * 810 * @param bool $user_can_visit Whether or not the user can visit the tab. 811 811 * @return bool 812 812 */ … … 828 828 * @since 2.1.0 829 829 * 830 * @param bool $user_can_visit 831 * @param array $no_access_args 832 * 830 * @param bool $user_can_visit Whether or not the user can visit the tab. 831 * @param array $no_access_args Array of args to help determine access. 833 832 * @return bool 834 833 */ … … 864 863 $screen = $this->screens['create']; 865 864 866 // Insert the group creation step for the new group extension 865 // Insert the group creation step for the new group extension. 867 866 buddypress()->groups->group_creation_steps[ $screen['slug'] ] = array( 868 867 'name' => $screen['name'], … … 875 874 // correct group creation step). Hooked in separate 876 875 // methods because current creation step info not yet 877 // available at this point 876 // available at this point. 878 877 add_action( 'groups_custom_create_steps', array( $this, 'maybe_create_screen' ) ); 879 878 add_action( 'groups_create_group_step_save_' . $screen['slug'], array( $this, 'maybe_create_screen_save' ) ); … … 894 893 895 894 // The create screen requires an additional nonce field 896 // due to a quirk in the way the templates are built 895 // due to a quirk in the way the templates are built. 897 896 wp_nonce_field( 'groups_create_save_' . bp_get_groups_current_create_step(), '_wpnonce', false ); 898 897 } … … 920 919 */ 921 920 protected function setup_edit_hooks() { 922 // Bail if not in a group 921 // Bail if not in a group. 923 922 if ( ! bp_is_group() ) { 924 923 return; 925 924 } 926 925 927 // Bail if not an edit screen 926 // Bail if not an edit screen. 928 927 if ( ! $this->is_screen_enabled( 'edit' ) || ! bp_is_item_admin() ) { 929 928 return; … … 948 947 ); 949 948 950 // Should we add a menu to the Group's WP Admin Bar 949 // Should we add a menu to the Group's WP Admin Bar. 951 950 if ( ! empty( $screen['show_in_admin_bar'] ) ) { 952 951 $subnav_args['show_in_admin_bar'] = true; 953 952 } 954 953 955 // Add the tab to the manage navigation 954 // Add the tab to the manage navigation. 956 955 bp_core_new_subnav_item( $subnav_args ); 957 956 958 // Catch the edit screen and forward it to the plugin template 957 // Catch the edit screen and forward it to the plugin template. 959 958 if ( bp_is_groups_component() && bp_is_current_action( 'admin' ) && bp_is_action_variable( $screen['slug'], 0 ) ) { 960 959 $this->call_edit_screen_save( $this->group_id ); … … 963 962 964 963 // Determine the proper template and save for later 965 // loading 964 // loading. 966 965 if ( '' !== bp_locate_template( array( 'groups/single/home.php' ), false ) ) { 967 966 $this->edit_screen_template = '/groups/single/home'; … … 973 972 974 973 // We load the template at bp_screens, to give all 975 // extensions a chance to load 974 // extensions a chance to load. 976 975 add_action( 'bp_screens', array( $this, 'call_edit_screen_template_loader' ) ); 977 976 } … … 1015 1014 1016 1015 // When DOING_AJAX, the POST global will be populated, but we 1017 // should assume it's a save 1016 // should assume it's a save. 1018 1017 if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { 1019 1018 return; … … 1023 1022 1024 1023 // Detect whether the screen_save_callback is performing a 1025 // redirect, so that we don't do one of our own 1024 // redirect, so that we don't do one of our own. 1026 1025 add_filter( 'wp_redirect', array( $this, 'detect_post_save_redirect' ) ); 1027 1026 1028 // Call the extension's save routine 1027 // Call the extension's save routine. 1029 1028 call_user_func( $this->screens['edit']['screen_save_callback'], $this->group_id ); 1030 1029 1031 // Clean up detection filters 1030 // Clean up detection filters. 1032 1031 remove_filter( 'wp_redirect', array( $this, 'detect_post_save_redirect' ) ); 1033 1032 1034 // Perform a redirect only if one has not already taken place 1033 // Perform a redirect only if one has not already taken place. 1035 1034 if ( empty( $this->post_save_redirect ) ) { 1036 1035 … … 1082 1081 * @param string $screen The screen markup, captured in the output 1083 1082 * buffer. 1084 *1085 1083 * @return string $screen The same markup, with a submit button added. 1086 1084 */ … … 1104 1102 * 1105 1103 * @param string $screen The markup to check. 1106 *1107 1104 * @return bool True if a Submit button is found, otherwise false. 1108 1105 */ … … 1118 1115 * @since 2.1.0 1119 1116 * 1120 * @param string $redirect 1121 * 1117 * @param string $redirect Redirect string. 1122 1118 * @return string 1123 1119 */ … … 1142 1138 } 1143 1139 1144 // Hook the admin screen markup function to the content hook 1140 // Hook the admin screen markup function to the content hook. 1145 1141 add_action( 'bp_groups_admin_meta_box_content_' . $this->slug, array( $this, 'call_admin_screen' ) ); 1146 1142 1147 // Initialize the metabox 1143 // Initialize the metabox. 1148 1144 add_action( 'bp_groups_admin_meta_boxes', array( $this, '_meta_box_display_callback' ) ); 1149 1145 1150 // Catch the metabox save 1146 // Catch the metabox save. 1151 1147 add_action( 'bp_group_admin_edit_after', array( $this, 'call_admin_screen_save' ), 10 ); 1152 1148 } … … 1232 1228 * 1233 1229 * @param string $context Screen context. 'create', 'edit', or 'admin'. 1234 *1235 1230 * @return bool True if the screen is enabled, otherwise false. 1236 1231 */ … … 1282 1277 * @param string $type Screen type. 'screen' or 'screen_save'. Default: 1283 1278 * 'screen'. 1284 *1285 1279 * @return callable A callable function handle. 1286 1280 */ … … 1288 1282 $callback = ''; 1289 1283 1290 // Try the context-specific callback first 1284 // Try the context-specific callback first. 1291 1285 $method = $context . '_' . $type; 1292 1286 $rmethod = $this->class_reflection->getMethod( $method ); … … 1332 1326 * @param array $a First set of arguments. 1333 1327 * @param array $b Second set of arguments. 1334 *1335 1328 * @return array Parsed arguments. 1336 1329 */ … … 1376 1369 * 1377 1370 * @param string $key Property name. 1378 *1379 1371 * @return mixed The value if found, otherwise null. 1380 1372 */ … … 1401 1393 * 1402 1394 * @param string $key Property name. 1403 *1404 1395 * @return bool True if the value is set, otherwise false. 1405 1396 */ … … 1425 1416 * 1426 1417 * @param string $key Property name. 1427 * @param mixed $value Property value.1418 * @param mixed $value Property value. 1428 1419 */ 1429 1420 public function __set( $key, $value ) { … … 1450 1441 break; 1451 1442 1452 // Note: 'admin' becomes 'edit' to distinguish from Dashboard 'admin' 1443 // Note: 'admin' becomes 'edit' to distinguish from Dashboard 'admin'. 1453 1444 case 'admin_name' : 1454 1445 $this->screens['edit']['name'] = $value; … … 1527 1518 protected function parse_legacy_properties() { 1528 1519 1529 // Only run this one time 1520 // Only run this one time. 1530 1521 if ( ! empty( $this->legacy_properties_converted ) ) { 1531 1522 return; … … 1534 1525 $properties = $this->get_legacy_property_list(); 1535 1526 1536 // By-reference variable for convenience 1527 // By-reference variable for convenience. 1537 1528 $lpc =& $this->legacy_properties_converted; 1538 1529 1539 1530 foreach ( $properties as $property ) { 1540 1531 1541 // No legacy config exists for this key 1532 // No legacy config exists for this key. 1542 1533 if ( ! isset( $this->{$property} ) ) { 1543 1534 continue; 1544 1535 } 1545 1536 1546 // Grab the value and record it as appropriate 1537 // Grab the value and record it as appropriate. 1547 1538 $value = $this->{$property}; 1548 1539 … … 1564 1555 break; 1565 1556 1566 // Note: 'admin' becomes 'edit' to distinguish from Dashboard 'admin' 1557 // Note: 'admin' becomes 'edit' to distinguish from Dashboard 'admin'. 1567 1558 case 'admin_name' : 1568 1559 $lpc['screens']['edit']['name'] = $value; … … 1610 1601 protected function setup_legacy_properties() { 1611 1602 1612 // Only run this one time 1603 // Only run this one time. 1613 1604 if ( ! empty( $this->legacy_properties ) ) { 1614 1605 return; … … 1637 1628 break; 1638 1629 1639 // Note: 'admin' becomes 'edit' to distinguish from Dashboard 'admin' 1630 // Note: 'admin' becomes 'edit' to distinguish from Dashboard 'admin'. 1640 1631 case 'admin_name' : 1641 1632 $lp['admin_name'] = $params['screens']['edit']['name']; … … 1663 1654 1664 1655 default : 1665 // All other items get moved over 1656 // All other items get moved over. 1666 1657 $lp[ $property ] = $params[ $property ]; 1667 1658 1668 // Also reapply to the object, for backpat 1659 // Also reapply to the object, for backpat. 1669 1660 $this->{$property} = $params[ $property ]; 1670 1661 … … 1678 1669 * Register a new Group Extension. 1679 1670 * 1680 * @param string Name of the Extension class.1671 * @param string $group_extension_class Name of the Extension class. 1681 1672 * @return false|null Returns false on failure, otherwise null. 1682 1673 */ -
trunk/src/bp-groups/classes/class-bp-group-member-query.php
r10248 r10373 58 58 // Take this early opportunity to set the default 'type' param 59 59 // to 'last_joined', which will ensure that BP_User_Query 60 // trusts our order and does not try to apply its own 60 // trusts our order and does not try to apply its own. 61 61 if ( empty( $this->query_vars_raw['type'] ) ) { 62 62 $this->query_vars_raw['type'] = 'last_joined'; 63 63 } 64 64 65 // Set the sort order 65 // Set the sort order. 66 66 add_action( 'bp_pre_user_query', array( $this, 'set_orderby' ) ); 67 67 68 // Set up our populate_extras method 68 // Set up our populate_extras method. 69 69 add_action( 'bp_user_query_populate_extras', array( $this, 'populate_group_member_extras' ), 10, 2 ); 70 70 } … … 100 100 101 101 // If the group member query returned no users, bail with an 102 // array that will guarantee no matches for BP_User_Query 102 // array that will guarantee no matches for BP_User_Query. 103 103 if ( empty( $group_member_ids ) ) { 104 104 return array( 0 ); … … 134 134 ); 135 135 136 /* *WHERE clauses *****************************************************/137 138 // Group id 136 /* WHERE clauses *****************************************************/ 137 138 // Group id. 139 139 $sql['where'][] = $wpdb->prepare( "group_id = %d", $this->query_vars['group_id'] ); 140 140 141 // is_confirmed141 // If is_confirmed. 142 142 $is_confirmed = ! empty( $this->query_vars['is_confirmed'] ) ? 1 : 0; 143 143 $sql['where'][] = $wpdb->prepare( "is_confirmed = %d", $is_confirmed ); 144 144 145 // invite_sent145 // If invite_sent. 146 146 if ( ! is_null( $this->query_vars['invite_sent'] ) ) { 147 147 $invite_sent = ! empty( $this->query_vars['invite_sent'] ) ? 1 : 0; … … 149 149 } 150 150 151 // inviter_id151 // If inviter_id. 152 152 if ( ! is_null( $this->query_vars['inviter_id'] ) ) { 153 153 $inviter_id = $this->query_vars['inviter_id']; 154 154 155 // Empty: inviter_id = 0. (pass false, 0, or empty array) 155 // Empty: inviter_id = 0. (pass false, 0, or empty array). 156 156 if ( empty( $inviter_id ) ) { 157 157 $sql['where'][] = "inviter_id = 0"; 158 158 159 // The string 'any' matches any non-zero value (inviter_id != 0) 159 // The string 'any' matches any non-zero value (inviter_id != 0). 160 160 } elseif ( 'any' === $inviter_id ) { 161 161 $sql['where'][] = "inviter_id != 0"; 162 162 163 // Assume that a list of inviter IDs has been passed 163 // Assume that a list of inviter IDs has been passed. 164 164 } else { 165 // Parse and sanitize 165 // Parse and sanitize. 166 166 $inviter_ids = wp_parse_id_list( $inviter_id ); 167 167 if ( ! empty( $inviter_ids ) ) { … … 180 180 } 181 181 182 // Sanitize: Only 'admin', 'mod', 'member', and 'banned' are valid 182 // Sanitize: Only 'admin', 'mod', 'member', and 'banned' are valid. 183 183 $allowed_roles = array( 'admin', 'mod', 'member', 'banned' ); 184 184 foreach ( $roles as $role_key => $role_value ) { … … 192 192 // When querying for a set of roles containing 'member' (for 193 193 // which there is no dedicated is_ column), figure out a list 194 // of columns *not* to match 194 // of columns *not* to match. 195 195 $roles_sql = ''; 196 196 if ( in_array( 'member', $roles ) ) { … … 205 205 206 206 // When querying for a set of roles *not* containing 'member', 207 // simply construct a list of is_* = 1 clauses 207 // simply construct a list of is_* = 1 clauses. 208 208 } else { 209 209 $role_columns = array(); … … 226 226 // of 'type'. If the 'type' value is not 'last_joined' or 227 227 // 'first_joined', the order will be overridden in 228 // BP_Group_Member_Query::set_orderby() 228 // BP_Group_Member_Query::set_orderby(). 229 229 $sql['orderby'] = "ORDER BY date_modified"; 230 230 $sql['order'] = 'first_joined' === $this->query_vars['type'] ? 'ASC' : 'DESC'; … … 272 272 if ( in_array( $query->query_vars['type'], array( 'last_joined', 'first_joined', 'group_activity' ) ) ) { 273 273 274 // Group Activity DESC 274 // Group Activity DESC. 275 275 if ( 'group_activity' == $query->query_vars['type'] ) { 276 276 $gm_ids = $this->get_gm_ids_ordered_by_activity( $query, $gm_ids ); 277 277 } 278 278 279 // The first param in the FIELD() clause is the sort column id 279 // The first param in the FIELD() clause is the sort column id. 280 280 $gm_ids = array_merge( array( 'u.id' ), wp_parse_id_list( $gm_ids ) ); 281 281 $gm_ids_sql = implode( ',', $gm_ids ); … … 285 285 286 286 // Prevent this filter from running on future BP_User_Query 287 // instances on the same page 287 // instances on the same page. 288 288 remove_action( 'bp_pre_user_query', array( $this, 'set_orderby' ) ); 289 289 } … … 293 293 * 294 294 * Additional data fetched: 295 *296 295 * - is_banned 297 296 * - date_modified … … 313 312 foreach ( (array) $extras as $extra ) { 314 313 if ( isset( $this->results[ $extra->user_id ] ) ) { 315 // user_id is provided for backward compatibility314 // The user_id is provided for backward compatibility. 316 315 $this->results[ $extra->user_id ]->user_id = (int) $extra->user_id; 317 316 $this->results[ $extra->user_id ]->is_admin = (int) $extra->is_admin; … … 328 327 } 329 328 330 // Don't filter other BP_User_Query objects on the same page 329 // Don't filter other BP_User_Query objects on the same page. 331 330 remove_action( 'bp_user_query_populate_extras', array( $this, 'populate_group_member_extras' ), 10, 2 ); 332 331 } … … 339 338 * @param BP_User_Query $query BP_User_Query object. 340 339 * @param array $gm_ids array of group member ids. 341 *342 340 * @return array 343 341 */ -
trunk/src/bp-groups/classes/class-bp-groups-group.php
r10248 r10373 145 145 * Constructor method. 146 146 * 147 * @param int|null $id Optional. If the ID of an existing group is provided,148 * the object will be pre-popu