Changeset 10373 for trunk/src/bp-groups/bp-groups-screens.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-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
Note: See TracChangeset
for help on using the changeset viewer.