Changeset 10373 for trunk/src/bp-groups/bp-groups-actions.php
- Timestamp:
- 11/22/2015 04:58:34 AM (9 years ago)
- File:
-
- 1 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',
Note: See TracChangeset
for help on using the changeset viewer.