[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-groups/screens/user/ -> invites.php (source)

   1  <?php
   2  /**
   3   * Groups: User's "Groups > Invites" screen handler
   4   *
   5   * @package BuddyPress
   6   * @subpackage GroupScreens
   7   * @since 3.0.0
   8   */
   9  
  10  /**
  11   * Handle the loading of a user's Groups > Invites page.
  12   *
  13   * @since 1.0.0
  14   */
  15  function groups_screen_group_invites() {
  16      $group_id = (int) bp_action_variable( 1 );
  17  
  18      if ( bp_is_action_variable( 'accept' ) && is_numeric( $group_id ) ) {
  19          // Check the nonce.
  20          if ( ! check_admin_referer( 'groups_accept_invite' ) ) {
  21              return false;
  22          }
  23  
  24          if ( ! groups_accept_invite( bp_displayed_user_id(), $group_id ) ) {
  25              bp_core_add_message( __('Group invite could not be accepted', 'buddypress'), 'error' );
  26          } else {
  27              // Record this in activity streams.
  28              $group = groups_get_group( $group_id );
  29  
  30              /* translators: %s: group link */
  31              bp_core_add_message( sprintf( __( 'Group invite accepted. Visit %s.', 'buddypress' ), bp_get_group_link( $group ) ) );
  32  
  33              if ( bp_is_active( 'activity' ) ) {
  34                  groups_record_activity( array(
  35                      'type'    => 'joined_group',
  36                      'item_id' => $group->id
  37                  ) );
  38              }
  39          }
  40  
  41          if ( isset( $_GET['redirect_to'] ) ) {
  42              $redirect_to = urldecode( $_GET['redirect_to'] );
  43          } else {
  44              $redirect_to = trailingslashit( bp_displayed_user_domain() . bp_get_groups_slug() . '/' . bp_current_action() );
  45          }
  46  
  47          bp_core_redirect( $redirect_to );
  48  
  49      } elseif ( bp_is_action_variable( 'reject' ) && is_numeric( $group_id ) ) {
  50          // Check the nonce.
  51          if ( !check_admin_referer( 'groups_reject_invite' ) )
  52              return false;
  53  
  54          if ( ! groups_reject_invite( bp_displayed_user_id(), $group_id ) ) {
  55              bp_core_add_message( __( 'Group invite could not be rejected', 'buddypress' ), 'error' );
  56          } else {
  57              bp_core_add_message( __( 'Group invite rejected', 'buddypress' ) );
  58          }
  59  
  60          if ( isset( $_GET['redirect_to'] ) ) {
  61              $redirect_to = urldecode( $_GET['redirect_to'] );
  62          } else {
  63              $redirect_to = trailingslashit( bp_displayed_user_domain() . bp_get_groups_slug() . '/' . bp_current_action() );
  64          }
  65  
  66          bp_core_redirect( $redirect_to );
  67      }
  68  
  69      /**
  70       * Fires before the loading of a users Groups > Invites template.
  71       *
  72       * @since 1.0.0
  73       *
  74       * @param int $group_id ID of the group being displayed
  75       */
  76      do_action( 'groups_screen_group_invites', $group_id );
  77  
  78      /**
  79       * Filters the template to load for a users Groups > Invites page.
  80       *
  81       * @since 1.0.0
  82       *
  83       * @param string $value Path to a users Groups > Invites page template.
  84       */
  85      bp_core_load_template( apply_filters( 'groups_template_group_invites', 'members/single/home' ) );
  86  }


Generated: Fri Nov 22 01:00:56 2024 Cross-referenced by PHPXref 0.7.1