当前位置: 首页>>代码示例>>PHP>>正文


PHP groups_check_user_has_invite函数代码示例

本文整理汇总了PHP中groups_check_user_has_invite函数的典型用法代码示例。如果您正苦于以下问题:PHP groups_check_user_has_invite函数的具体用法?PHP groups_check_user_has_invite怎么用?PHP groups_check_user_has_invite使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了groups_check_user_has_invite函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: bp_legacy_theme_ajax_get_user_joinleave_group_status_a

function bp_legacy_theme_ajax_get_user_joinleave_group_status_a($group, $my_current_user_id)
{
    // Not a member
    if (!groups_is_user_member(bp_loggedin_user_id(), $group->id)) {
        if ('public' == $group->status) {
            //check_ajax_referer( 'groups_join_group' );
            //if ( ! groups_join_group( $group->id ) ) {
            //        _e( 'Error joining group', 'buddypress' );
            //} else {
            return '<div class="generic-button group-button public" id="groupbutton-' . esc_attr($group->id) . '"><a id="group-' . esc_attr($group->id) . '" class="group-button join-group" rel="join" title="' . __('Join Group', 'buddypress') . '" href="' . wp_nonce_url(bp_get_group_permalink($group) . 'join', 'groups_join_group') . '">' . __('Join Group', 'buddypress') . '</a>' . '</div>';
            //echo '<a id="group-' . esc_attr( $group->id ) . '" class="leave-group" rel="leave" title="' . __( 'Leave Group', 'buddypress' ) . '" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';
            //}
        } elseif ('private' == $group->status) {
            // If the user has already been invited, then this is
            // an Accept Invitation button
            if (groups_check_user_has_invite($my_current_user_id, $group->id)) {
                //check_ajax_referer( 'groups_accept_invite' );
                //if ( ! groups_accept_invite( bp_loggedin_user_id(), $group->id ) ) {
                //        _e( 'Error requesting membership', 'buddypress' );
                //} else {
                return '<div class="generic-button group-button private" id="groupbutton-' . esc_attr($group->id) . '"><a id="group-' . esc_attr($group->id) . '" class="group-button accept-invite" rel="accept-invite" title="' . __('Accept Invitation', 'buddypress') . '" href="' . add_query_arg('redirect_to', bp_get_group_permalink($group), bp_get_group_accept_invite_link($group)) . '">' . __('Accept Invitation', 'buddypress') . '</a>' . '</div>';
                //}
                // The user requested membership and the request is pending
            } else {
                if ($group->is_pending) {
                    return '<div class="generic-button group-button pending private" id="groupbutton-' . esc_attr($group->id) . '"><a id="group-' . esc_attr($group->id) . '" class="group-button membership-requested" rel="membership-requested" title="' . __('Membership Requested', 'buddypress') . '" href="' . bp_get_group_permalink($group) . '">' . __('Membership Requested', 'buddypress') . '</a>' . '</div>';
                    // Otherwise, the user hasn't requested membership yet
                } else {
                    //check_ajax_referer( 'groups_request_membership' );
                    //if ( ! groups_send_membership_request( bp_loggedin_user_id(), $group->id ) ) {
                    //        _e( 'Error requesting membership', 'buddypress' );
                    //} else {
                    return '<div class="generic-button group-button private" id="groupbutton-' . esc_attr($group->id) . '"><a id="group-' . esc_attr($group->id) . '" class="group-button request-membership" rel="request-membership" title="' . __('Request Membership', 'buddypress') . '" href="' . wp_nonce_url(bp_get_group_permalink($group) . 'request-membership', 'groups_request_membership') . '">' . __('Request Membership', 'buddypress') . '</a>' . '</div>';
                    //}
                }
            }
        }
    } else {
        // The user is a member
        //check_ajax_referer( 'groups_leave_group' );
        $myclasstoadd = "";
        //if ( ! groups_leave_group( $group->id ) ) {
        //        _e( 'Error leaving group', 'buddypress' );
        //} elseif ( 'public' == $group->status ) {
        //echo '<a id="group-' . esc_attr( $group->id ) . '" class="join-group" rel="join" title="' . __( 'Join Group', 'buddypress' ) . '" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'join', 'groups_join_group' ) . '">' . __( 'Join Group', 'buddypress' ) . '</a>';
        return '<div class="generic-button group-button ' . $group->status . '" id="groupbutton-' . esc_attr($group->id) . '"><a id="group-' . esc_attr($group->id) . '" class="group-button leave-group" rel="leave" title="' . __('Leave Group', 'buddypress') . '" href="' . wp_nonce_url(bp_get_group_permalink($group) . 'leave-group', 'groups_leave_group') . '">' . __('Leave Group', 'buddypress') . '</a>';
        //} elseif ( 'private' == $group->status ) {
        // echo '<a id="group-' . esc_attr( $group->id ) . '" class="request-membership" rel="join" title="' . __( 'Request Membership', 'buddypress' ) . '" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'request-membership', 'groups_send_membership_request' ) . '">' . __( 'Request Membership', 'buddypress' ) . '</a>';
        //}
    }
    //exit;
}
开发者ID:paulmedwal,项目名称:edxforumspublic,代码行数:52,代码来源:buddypress-functions.php

示例2: groups_screen_group_request_membership

/**
 * Handle the display of a group's Request Membership page.
 */
function groups_screen_group_request_membership()
{
    if (!is_user_logged_in()) {
        return false;
    }
    $bp = buddypress();
    if ('private' != $bp->groups->current_group->status) {
        return false;
    }
    // If the user is already invited, accept invitation.
    if (groups_check_user_has_invite(bp_loggedin_user_id(), $bp->groups->current_group->id)) {
        if (groups_accept_invite(bp_loggedin_user_id(), $bp->groups->current_group->id)) {
            bp_core_add_message(__('Group invite accepted', 'buddypress'));
        } else {
            bp_core_add_message(__('There was an error accepting the group invitation. Please try again.', 'buddypress'), 'error');
        }
        bp_core_redirect(bp_get_group_permalink($bp->groups->current_group));
    }
    // If the user has submitted a request, send it.
    if (isset($_POST['group-request-send'])) {
        // Check the nonce.
        if (!check_admin_referer('groups_request_membership')) {
            return false;
        }
        if (!groups_send_membership_request(bp_loggedin_user_id(), $bp->groups->current_group->id)) {
            bp_core_add_message(__('There was an error sending your group membership request. Please try again.', 'buddypress'), 'error');
        } else {
            bp_core_add_message(__('Your membership request was sent to the group administrator successfully. You will be notified when the group administrator responds to your request.', 'buddypress'));
        }
        bp_core_redirect(bp_get_group_permalink($bp->groups->current_group));
    }
    /**
     * Fires before the loading of a group's Request Memebership page.
     *
     * @since 1.0.0
     *
     * @param int $id ID of the group currently being displayed.
     */
    do_action('groups_screen_group_request_membership', $bp->groups->current_group->id);
    /**
     * Filters the template to load for a group's Request Membership page.
     *
     * @since 1.0.0
     *
     * @param string $value Path to a group's Request Membership template.
     */
    bp_core_load_template(apply_filters('groups_template_group_request_membership', 'groups/single/home'));
}
开发者ID:swissspidy,项目名称:BuddyPress,代码行数:51,代码来源:bp-groups-screens.php

示例3: groups_screen_group_request_membership

/**
 * Handle the display of a group's Request Membership page.
 */
function groups_screen_group_request_membership()
{
    global $bp;
    if (!is_user_logged_in()) {
        return false;
    }
    $bp = buddypress();
    if ('private' != $bp->groups->current_group->status) {
        return false;
    }
    // If the user is already invited, accept invitation
    if (groups_check_user_has_invite(bp_loggedin_user_id(), $bp->groups->current_group->id)) {
        if (groups_accept_invite(bp_loggedin_user_id(), $bp->groups->current_group->id)) {
            bp_core_add_message(__('Group invite accepted', 'buddypress'));
        } else {
            bp_core_add_message(__('There was an error accepting the group invitation. Please try again.', 'buddypress'), 'error');
        }
        bp_core_redirect(bp_get_group_permalink($bp->groups->current_group));
    }
    // If the user has submitted a request, send it.
    if (isset($_POST['group-request-send'])) {
        // Check the nonce
        if (!check_admin_referer('groups_request_membership')) {
            return false;
        }
        if (!groups_send_membership_request(bp_loggedin_user_id(), $bp->groups->current_group->id)) {
            bp_core_add_message(__('There was an error sending your group membership request. Please try again.', 'buddypress'), 'error');
        } else {
            bp_core_add_message(__('Your membership request was sent to the group administrator successfully. You will be notified when the group administrator responds to your request.', 'buddypress'));
        }
        bp_core_redirect(bp_get_group_permalink($bp->groups->current_group));
    }
    do_action('groups_screen_group_request_membership', $bp->groups->current_group->id);
    bp_core_load_template(apply_filters('groups_template_group_request_membership', 'groups/single/home'));
}
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:38,代码来源:bp-groups-screens.php

示例4: setup_nav

 /**
  * Set up component navigation.
  *
  * @since 1.5.0
  *
  * @see BP_Component::setup_nav() for a description of arguments.
  *
  * @param array $main_nav Optional. See BP_Component::setup_nav() for description.
  * @param array $sub_nav  Optional. See BP_Component::setup_nav() for description.
  */
 public function setup_nav($main_nav = array(), $sub_nav = array())
 {
     // Determine user to use.
     if (bp_displayed_user_domain()) {
         $user_domain = bp_displayed_user_domain();
     } elseif (bp_loggedin_user_domain()) {
         $user_domain = bp_loggedin_user_domain();
     } else {
         $user_domain = false;
     }
     // Only grab count if we're on a user page.
     if (bp_is_user()) {
         $count = bp_get_total_group_count_for_user();
         $class = 0 === $count ? 'no-count' : 'count';
         $nav_name = sprintf(_x('Groups <span class="%s">%s</span>', 'Group screen nav with counter', 'buddypress'), esc_attr($class), bp_core_number_format($count));
     } else {
         $nav_name = _x('Groups', 'Group screen nav without counter', 'buddypress');
     }
     $slug = bp_get_groups_slug();
     // Add 'Groups' to the main navigation.
     $main_nav = array('name' => $nav_name, 'slug' => $slug, 'position' => 70, 'screen_function' => 'groups_screen_my_groups', 'default_subnav_slug' => 'my-groups', 'item_css_id' => $this->id);
     if (!empty($user_domain)) {
         $access = bp_core_can_edit_settings();
         $groups_link = trailingslashit($user_domain . $slug);
         // Add the My Groups nav item.
         $sub_nav[] = array('name' => __('Memberships', 'buddypress'), 'slug' => 'my-groups', 'parent_url' => $groups_link, 'parent_slug' => $slug, 'screen_function' => 'groups_screen_my_groups', 'position' => 10, 'item_css_id' => 'groups-my-groups');
         // Add the Group Invites nav item.
         $sub_nav[] = array('name' => __('Invitations', 'buddypress'), 'slug' => 'invites', 'parent_url' => $groups_link, 'parent_slug' => $slug, 'screen_function' => 'groups_screen_group_invites', 'user_has_access' => $access, 'position' => 30);
         parent::setup_nav($main_nav, $sub_nav);
     }
     if (bp_is_groups_component() && bp_is_single_item()) {
         // Reset sub nav.
         $sub_nav = array();
         // Add 'Groups' to the main navigation.
         $main_nav = array('name' => __('Memberships', 'buddypress'), 'slug' => $this->current_group->slug, 'position' => -1, 'screen_function' => 'groups_screen_group_home', 'default_subnav_slug' => $this->default_extension, 'item_css_id' => $this->id);
         $group_link = bp_get_group_permalink($this->current_group);
         // Add the "Home" subnav item, as this will always be present.
         $sub_nav[] = array('name' => _x('Home', 'Group screen navigation title', 'buddypress'), 'slug' => 'home', 'parent_url' => $group_link, 'parent_slug' => $this->current_group->slug, 'screen_function' => 'groups_screen_group_home', 'position' => 10, 'item_css_id' => 'home');
         // If this is a private group, and the user is not a
         // member and does not have an outstanding invitation,
         // show a "Request Membership" nav item.
         if (is_user_logged_in() && !$this->current_group->is_user_member && !groups_check_for_membership_request(bp_loggedin_user_id(), $this->current_group->id) && $this->current_group->status == 'private' && !groups_check_user_has_invite(bp_loggedin_user_id(), $this->current_group->id)) {
             $sub_nav[] = array('name' => _x('Request Membership', 'Group screen nav', 'buddypress'), 'slug' => 'request-membership', 'parent_url' => $group_link, 'parent_slug' => $this->current_group->slug, 'screen_function' => 'groups_screen_group_request_membership', 'position' => 30);
         }
         // Forums are enabled and turned on.
         if ($this->current_group->enable_forum && bp_is_active('forums')) {
             $sub_nav[] = array('name' => _x('Forum', 'My Group screen nav', 'buddypress'), 'slug' => 'forum', 'parent_url' => $group_link, 'parent_slug' => $this->current_group->slug, 'screen_function' => 'groups_screen_group_forum', 'position' => 40, 'user_has_access' => $this->current_group->user_has_access, 'item_css_id' => 'forums');
         }
         if ($this->current_group->front_template || bp_is_active('activity')) {
             /**
              * If the theme is using a custom front, create activity subnav.
              */
             if ($this->current_group->front_template && bp_is_active('activity')) {
                 $sub_nav[] = array('name' => _x('Activity', 'My Group screen nav', 'buddypress'), 'slug' => 'activity', 'parent_url' => $group_link, 'parent_slug' => $this->current_group->slug, 'screen_function' => 'groups_screen_group_activity', 'position' => 11, 'user_has_access' => $this->current_group->user_has_access, 'item_css_id' => 'activity', 'no_access_url' => $group_link);
             }
             /**
              * Only add the members subnav if it's not the home's nav.
              */
             $sub_nav[] = array('name' => sprintf(_x('Members %s', 'My Group screen nav', 'buddypress'), '<span>' . number_format($this->current_group->total_member_count) . '</span>'), 'slug' => 'members', 'parent_url' => $group_link, 'parent_slug' => $this->current_group->slug, 'screen_function' => 'groups_screen_group_members', 'position' => 60, 'user_has_access' => $this->current_group->user_has_access, 'item_css_id' => 'members', 'no_access_url' => $group_link);
         }
         if (bp_is_active('friends') && bp_groups_user_can_send_invites()) {
             $sub_nav[] = array('name' => _x('Send Invites', 'My Group screen nav', 'buddypress'), 'slug' => 'send-invites', 'parent_url' => $group_link, 'parent_slug' => $this->current_group->slug, 'screen_function' => 'groups_screen_group_invite', 'item_css_id' => 'invite', 'position' => 70, 'user_has_access' => $this->current_group->user_has_access, 'no_access_url' => $group_link);
         }
         // If the user is a group admin, then show the group admin nav item.
         if (bp_is_item_admin()) {
             $sub_nav[] = array('name' => _x('Manage', 'My Group screen nav', 'buddypress'), 'slug' => 'admin', 'parent_url' => $group_link, 'parent_slug' => $this->current_group->slug, 'screen_function' => 'groups_screen_group_admin', 'position' => 1000, 'user_has_access' => true, 'item_css_id' => 'admin', 'no_access_url' => $group_link);
             $admin_link = trailingslashit($group_link . 'admin');
             // Common params to all nav items.
             $default_params = array('parent_url' => $admin_link, 'parent_slug' => $this->current_group->slug . '_manage', 'screen_function' => 'groups_screen_group_admin', 'user_has_access' => bp_is_item_admin(), 'show_in_admin_bar' => true);
             $sub_nav[] = array_merge(array('name' => __('Details', 'buddypress'), 'slug' => 'edit-details', 'position' => 0), $default_params);
             $sub_nav[] = array_merge(array('name' => __('Settings', 'buddypress'), 'slug' => 'group-settings', 'position' => 10), $default_params);
             if (!bp_disable_group_avatar_uploads() && buddypress()->avatar->show_avatars) {
                 $sub_nav[] = array_merge(array('name' => __('Photo', 'buddypress'), 'slug' => 'group-avatar', 'position' => 20), $default_params);
             }
             if (bp_group_use_cover_image_header()) {
                 $sub_nav[] = array_merge(array('name' => __('Cover Image', 'buddypress'), 'slug' => 'group-cover-image', 'position' => 25), $default_params);
             }
             $sub_nav[] = array_merge(array('name' => __('Members', 'buddypress'), 'slug' => 'manage-members', 'position' => 30), $default_params);
             if ('private' == $this->current_group->status) {
                 $sub_nav[] = array_merge(array('name' => __('Requests', 'buddypress'), 'slug' => 'membership-requests', 'position' => 40), $default_params);
             }
             $sub_nav[] = array_merge(array('name' => __('Delete', 'buddypress'), 'slug' => 'delete-group', 'position' => 1000), $default_params);
         }
         parent::setup_nav($main_nav, $sub_nav);
     }
     if (isset($this->current_group->user_has_access)) {
         /**
          * Fires at the end of the groups navigation setup if user has access.
          *
          * @since 1.0.2
//.........这里部分代码省略.........
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:101,代码来源:bp-groups-loader.php

示例5: groups_action_join_group

/**
 * Catch and process "Join Group" button clicks.
 */
function groups_action_join_group()
{
    global $bp;
    if (!bp_is_single_item() || !bp_is_groups_component() || !bp_is_current_action('join')) {
        return false;
    }
    // Nonce check
    if (!check_admin_referer('groups_join_group')) {
        return false;
    }
    // Skip if banned or already a member
    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)) {
        // User wants to join a group that is not public
        if ($bp->groups->current_group->status != 'public') {
            if (!groups_check_user_has_invite(bp_loggedin_user_id(), $bp->groups->current_group->id)) {
                bp_core_add_message(__('There was an error joining the group.', 'buddypress'), 'error');
                bp_core_redirect(bp_get_group_permalink($bp->groups->current_group));
            }
        }
        // User wants to join any group
        if (!groups_join_group($bp->groups->current_group->id)) {
            bp_core_add_message(__('There was an error joining the group.', 'buddypress'), 'error');
        } else {
            bp_core_add_message(__('You joined the group!', 'buddypress'));
        }
        bp_core_redirect(bp_get_group_permalink($bp->groups->current_group));
    }
    bp_core_load_template(apply_filters('groups_template_group_home', 'groups/single/home'));
}
开发者ID:eresyyl,项目名称:mk,代码行数:32,代码来源:bp-groups-actions.php

示例6: groups_accept_membership_request

function groups_accept_membership_request($membership_id, $user_id = 0, $group_id = 0)
{
    if (!empty($user_id) && !empty($group_id)) {
        $membership = new BP_Groups_Member($user_id, $group_id);
    } else {
        $membership = new BP_Groups_Member(false, false, $membership_id);
    }
    $membership->accept_request();
    if (!$membership->save()) {
        return false;
    }
    // Check if the user has an outstanding invite, if so delete it.
    if (groups_check_user_has_invite($membership->user_id, $membership->group_id)) {
        groups_delete_invite($membership->user_id, $membership->group_id);
    }
    // Record this in activity streams
    $group = groups_get_group(array('group_id' => $membership->group_id));
    groups_record_activity(array('action' => apply_filters_ref_array('groups_activity_membership_accepted_action', array(sprintf(__('%1$s joined the group %2$s', 'buddypress'), bp_core_get_userlink($membership->user_id), '<a href="' . bp_get_group_permalink($group) . '">' . esc_attr($group->name) . '</a>'), $membership->user_id, &$group)), 'type' => 'joined_group', 'item_id' => $membership->group_id, 'user_id' => $membership->user_id));
    // Send a notification to the user.
    groups_notification_membership_request_completed($membership->user_id, $membership->group_id, true);
    do_action('groups_membership_accepted', $membership->user_id, $membership->group_id);
    return true;
}
开发者ID:novichkovv,项目名称:candoweightloss,代码行数:23,代码来源:bp-groups-functions.php

示例7: setup_nav

 /**
  * Set up component navigation.
  *
  * @since BuddyPress (1.5.0)
  *
  * @see BP_Component::setup_nav() for a description of arguments.
  *
  * @param array $main_nav Optional. See BP_Component::setup_nav() for
  *        description.
  * @param array $sub_nav Optional. See BP_Component::setup_nav() for
  *        description.
  */
 public function setup_nav($main_nav = array(), $sub_nav = array())
 {
     // Only grab count if we're on a user page
     if (bp_is_user()) {
         $count = bp_get_total_group_count_for_user();
         $class = 0 === $count ? 'no-count' : 'count';
         $nav_name = sprintf(_x('Groups <span class="%s">%s</span>', 'Group screen nav with counter', 'buddypress'), esc_attr($class), number_format_i18n($count));
     } else {
         $nav_name = _x('Groups', 'Group screen nav without counter', 'buddypress');
     }
     // Add 'Groups' to the main navigation
     $main_nav = array('name' => $nav_name, 'slug' => $this->slug, 'position' => 70, 'screen_function' => 'groups_screen_my_groups', 'default_subnav_slug' => 'my-groups', 'item_css_id' => $this->id);
     // Determine user to use
     if (bp_displayed_user_domain()) {
         $user_domain = bp_displayed_user_domain();
     } elseif (bp_loggedin_user_domain()) {
         $user_domain = bp_loggedin_user_domain();
     } else {
         $user_domain = false;
     }
     if (!empty($user_domain)) {
         $groups_link = trailingslashit($user_domain . $this->slug);
         // Add the My Groups nav item
         $sub_nav[] = array('name' => __('Memberships', 'buddypress'), 'slug' => 'my-groups', 'parent_url' => $groups_link, 'parent_slug' => $this->slug, 'screen_function' => 'groups_screen_my_groups', 'position' => 10, 'item_css_id' => 'groups-my-groups');
         // Add the Group Invites nav item
         $sub_nav[] = array('name' => __('Invitations', 'buddypress'), 'slug' => 'invites', 'parent_url' => $groups_link, 'parent_slug' => $this->slug, 'screen_function' => 'groups_screen_group_invites', 'user_has_access' => bp_core_can_edit_settings(), 'position' => 30);
         parent::setup_nav($main_nav, $sub_nav);
     }
     if (bp_is_groups_component() && bp_is_single_item()) {
         // Reset sub nav
         $sub_nav = array();
         // Add 'Groups' to the main navigation
         $main_nav = array('name' => __('Memberships', 'buddypress'), 'slug' => $this->current_group->slug, 'position' => -1, 'screen_function' => 'groups_screen_group_home', 'default_subnav_slug' => $this->default_extension, 'item_css_id' => $this->id);
         $group_link = bp_get_group_permalink($this->current_group);
         // Add the "Home" subnav item, as this will always be present
         $sub_nav[] = array('name' => _x('Home', 'Group screen navigation title', 'buddypress'), 'slug' => 'home', 'parent_url' => $group_link, 'parent_slug' => $this->current_group->slug, 'screen_function' => 'groups_screen_group_home', 'position' => 10, 'item_css_id' => 'home');
         // If this is a private group, and the user is not a
         // member and does not have an outstanding invitation,
         // show a "Request Membership" nav item.
         if (is_user_logged_in() && !$this->current_group->is_user_member && !groups_check_for_membership_request(bp_loggedin_user_id(), $this->current_group->id) && $this->current_group->status == 'private' && !groups_check_user_has_invite(bp_loggedin_user_id(), $this->current_group->id)) {
             $sub_nav[] = array('name' => _x('Request Membership', 'Group screen nav', 'buddypress'), 'slug' => 'request-membership', 'parent_url' => $group_link, 'parent_slug' => $this->current_group->slug, 'screen_function' => 'groups_screen_group_request_membership', 'position' => 30);
         }
         // Forums are enabled and turned on
         if ($this->current_group->enable_forum && bp_is_active('forums')) {
             $sub_nav[] = array('name' => _x('Forum', 'My Group screen nav', 'buddypress'), 'slug' => 'forum', 'parent_url' => $group_link, 'parent_slug' => $this->current_group->slug, 'screen_function' => 'groups_screen_group_forum', 'position' => 40, 'user_has_access' => $this->current_group->user_has_access, 'item_css_id' => 'forums');
         }
         $sub_nav[] = array('name' => sprintf(_x('Members <span>%s</span>', 'My Group screen nav', 'buddypress'), number_format($this->current_group->total_member_count)), 'slug' => 'members', 'parent_url' => $group_link, 'parent_slug' => $this->current_group->slug, 'screen_function' => 'groups_screen_group_members', 'position' => 60, 'user_has_access' => $this->current_group->user_has_access, 'item_css_id' => 'members', 'no_access_url' => $group_link);
         if (bp_is_active('friends') && bp_groups_user_can_send_invites()) {
             $sub_nav[] = array('name' => _x('Send Invites', 'My Group screen nav', 'buddypress'), 'slug' => 'send-invites', 'parent_url' => $group_link, 'parent_slug' => $this->current_group->slug, 'screen_function' => 'groups_screen_group_invite', 'item_css_id' => 'invite', 'position' => 70, 'user_has_access' => $this->current_group->user_has_access, 'no_access_url' => $group_link);
         }
         // If the user is a group admin, then show the group admin nav item
         if (bp_is_item_admin()) {
             $sub_nav[] = array('name' => _x('Manage', 'My Group screen nav', 'buddypress'), 'slug' => 'admin', 'parent_url' => $group_link, 'parent_slug' => $this->current_group->slug, 'screen_function' => 'groups_screen_group_admin', 'position' => 1000, 'user_has_access' => true, 'item_css_id' => 'admin', 'no_access_url' => $group_link);
             $admin_link = trailingslashit($group_link . 'admin');
             // Common params to all nav items
             $default_params = array('parent_url' => $admin_link, 'parent_slug' => $this->current_group->slug . '_manage', 'screen_function' => 'groups_screen_group_admin', 'user_has_access' => bp_is_item_admin(), 'show_in_admin_bar' => true);
             $sub_nav[] = array_merge(array('name' => __('Details', 'buddypress'), 'slug' => 'edit-details', 'position' => 0), $default_params);
             $sub_nav[] = array_merge(array('name' => __('Settings', 'buddypress'), 'slug' => 'group-settings', 'position' => 10), $default_params);
             if (!(int) bp_get_option('bp-disable-avatar-uploads') && buddypress()->avatar->show_avatars) {
                 $sub_nav[] = array_merge(array('name' => __('Photo', 'buddypress'), 'slug' => 'group-avatar', 'position' => 20), $default_params);
             }
             $sub_nav[] = array_merge(array('name' => __('Members', 'buddypress'), 'slug' => 'manage-members', 'position' => 30), $default_params);
             if ('private' == $this->current_group->status) {
                 $sub_nav[] = array_merge(array('name' => __('Requests', 'buddypress'), 'slug' => 'membership-requests', 'position' => 40), $default_params);
             }
             $sub_nav[] = array_merge(array('name' => __('Delete', 'buddypress'), 'slug' => 'delete-group', 'position' => 1000), $default_params);
         }
         parent::setup_nav($main_nav, $sub_nav);
     }
     if (isset($this->current_group->user_has_access)) {
         do_action('groups_setup_nav', $this->current_group->user_has_access);
     } else {
         do_action('groups_setup_nav');
     }
 }
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:87,代码来源:bp-groups-loader.php

示例8: bp_group_management_join_group

function bp_group_management_join_group($group_id, $user_id = false)
{
    global $bp;
    if (!$user_id) {
        $user_id = $bp->loggedin_user->id;
    }
    /* Check if the user has an outstanding invite, is so delete it. */
    if (groups_check_user_has_invite($user_id, $group_id)) {
        groups_delete_invite($user_id, $group_id);
    }
    /* Check if the user has an outstanding request, is so delete it. */
    if (groups_check_for_membership_request($user_id, $group_id)) {
        groups_delete_membership_request($user_id, $group_id);
    }
    /* User is already a member, just return true */
    if (groups_is_user_member($user_id, $group_id)) {
        return true;
    }
    if (!$bp->groups->current_group) {
        $bp->groups->current_group = new BP_Groups_Group($group_id);
    }
    $new_member = new BP_Groups_Member();
    $new_member->group_id = $group_id;
    $new_member->user_id = $user_id;
    $new_member->inviter_id = 0;
    $new_member->is_admin = 0;
    $new_member->user_title = '';
    $new_member->date_modified = gmdate("Y-m-d H:i:s");
    $new_member->is_confirmed = 1;
    if (!$new_member->save()) {
        return false;
    }
    /* Record this in activity streams */
    groups_record_activity(array('user_id' => $user_id, 'action' => apply_filters('groups_activity_joined_group', sprintf(__('%s joined the group %s', 'bp-group-management'), bp_core_get_userlink($user_id), '<a href="' . bp_get_group_permalink($bp->groups->current_group) . '">' . esc_html($bp->groups->current_group->name) . '</a>')), 'type' => 'joined_group', 'item_id' => $group_id));
    /* Modify group meta */
    groups_update_groupmeta($group_id, 'total_member_count', (int) groups_get_groupmeta($group_id, 'total_member_count') + 1);
    groups_update_groupmeta($group_id, 'last_activity', gmdate("Y-m-d H:i:s"));
    do_action('groups_join_group', $group_id, $user_id);
    return true;
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:40,代码来源:bp-group-management-aux.php

示例9: friends_get_friends_invite_list

function friends_get_friends_invite_list($user_id = false, $group_id)
{
    global $bp;
    if (!$user_id) {
        $user_id = $bp->loggedin_user->id;
    }
    $friend_ids = friends_get_alphabetically($user_id);
    if ((int) $friend_ids['total'] < 1) {
        return false;
    }
    for ($i = 0; $i < count($friend_ids['friends']); $i++) {
        if (groups_check_user_has_invite($friend_ids['friends'][$i]->user_id, $group_id) || groups_is_user_member($friend_ids['friends'][$i]->user_id, $group_id)) {
            continue;
        }
        $display_name = bp_fetch_user_fullname($friend_ids['friends'][$i]->user_id, false);
        if ($display_name != ' ') {
            $friends[] = array('id' => $friend_ids['friends'][$i]->user_id, 'full_name' => $display_name);
        }
    }
    if (!$friends) {
        return false;
    }
    return $friends;
}
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:24,代码来源:bp-friends.php

示例10: groups_accept_membership_request

/**
 * Accept a pending group membership request.
 *
 * @param int $membership_id ID of the membership object.
 * @param int $user_id Optional. ID of the user who requested membership.
 *        Provide this value along with $group_id to override $membership_id.
 * @param int $group_id Optional. ID of the group to which membership is being
 *        requested. Provide this value along with $user_id to override
 *        $membership_id.
 * @return bool True on success, false on failure.
 */
function groups_accept_membership_request($membership_id, $user_id = 0, $group_id = 0)
{
    if (!empty($user_id) && !empty($group_id)) {
        $membership = new BP_Groups_Member($user_id, $group_id);
    } else {
        $membership = new BP_Groups_Member(false, false, $membership_id);
    }
    $membership->accept_request();
    if (!$membership->save()) {
        return false;
    }
    // Check if the user has an outstanding invite, if so delete it.
    if (groups_check_user_has_invite($membership->user_id, $membership->group_id)) {
        groups_delete_invite($membership->user_id, $membership->group_id);
    }
    do_action('groups_membership_accepted', $membership->user_id, $membership->group_id, true);
    return true;
}
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:29,代码来源:bp-groups-functions.php

示例11: groups_accept_membership_request

function groups_accept_membership_request( $membership_id, $user_id = false, $group_id = false ) {
	global $bp;

	if ( $user_id && $group_id )
		$membership = new BP_Groups_Member( $user_id, $group_id );
	else
		$membership = new BP_Groups_Member( false, false, $membership_id );

	$membership->accept_request();

	if ( !$membership->save() )
		return false;

	/* Check if the user has an outstanding invite, if so delete it. */
	if ( groups_check_user_has_invite( $membership->user_id, $membership->group_id ) )
		groups_delete_invite( $membership->user_id, $membership->group_id );

	/* Modify group member count */
	groups_update_groupmeta( $membership->group_id, 'total_member_count', (int) groups_get_groupmeta( $membership->group_id, 'total_member_count') + 1 );

	/* Record this in activity streams */
	$group = new BP_Groups_Group( $membership->group_id );

	groups_record_activity( array(
		'action'	=> apply_filters( 'groups_activity_membership_accepted_action', sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $membership->user_id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . esc_attr( $group->name ) . '</a>' ), $membership->user_id, &$group ),
		'type'		=> 'joined_group',
		'item_id'	=> $membership->group_id,
		'user_id'	=> $membership->user_id
	) );

	/* Send a notification to the user. */
	require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' );
	groups_notification_membership_request_completed( $membership->user_id, $membership->group_id, true );

	do_action( 'groups_membership_accepted', $membership->user_id, $membership->group_id );

	return true;
}
开发者ID:n-sane,项目名称:zaroka,代码行数:38,代码来源:bp-groups.php

示例12: get_invitable_friend_count

 /**
  * Get a count of a user's friends who can be invited to a given group.
  *
  * Users can invite any of their friends except:
  *
  * - users who are already in the group
  * - users who have a pending invite to the group
  * - users who have been banned from the group
  *
  * @since 1.0.0
  * @todo Need to do a group component check before using group functions.
  *
  * @param int $user_id  ID of the user whose friends are being counted.
  * @param int $group_id ID of the group friends are being invited to.
  * @return int $invitable_count Eligible friend count.
  */
 public static function get_invitable_friend_count($user_id, $group_id)
 {
     // Setup some data we'll use below.
     $is_group_admin = groups_is_user_admin($user_id, $group_id);
     $friend_ids = BP_Friends_Friendship::get_friend_user_ids($user_id);
     $invitable_count = 0;
     for ($i = 0, $count = count($friend_ids); $i < $count; ++$i) {
         // If already a member, they cannot be invited again.
         if (groups_is_user_member((int) $friend_ids[$i], $group_id)) {
             continue;
         }
         // If user already has invite, they cannot be added.
         if (groups_check_user_has_invite((int) $friend_ids[$i], $group_id)) {
             continue;
         }
         // If user is not group admin and friend is banned, they cannot be invited.
         if (false === $is_group_admin && groups_is_user_banned((int) $friend_ids[$i], $group_id)) {
             continue;
         }
         $invitable_count++;
     }
     return $invitable_count;
 }
开发者ID:buddypress,项目名称:BuddyPress-build,代码行数:39,代码来源:class-bp-friends-friendship.php

示例13: groups_join_group

function groups_join_group($group_id, $user_id = false)
{
    global $bp;
    /* Check the nonce */
    if (!check_admin_referer('groups_join_group')) {
        return false;
    }
    if (!$user_id) {
        $user_id = $bp->loggedin_user->id;
    }
    if (groups_check_user_has_invite($user_id, $group_id)) {
        groups_delete_invite($user_id, $group_id);
    }
    $new_member = new BP_Groups_Member();
    $new_member->group_id = $group_id;
    $new_member->user_id = $user_id;
    $new_member->inviter_id = 0;
    $new_member->is_admin = 0;
    $new_member->user_title = '';
    $new_member->date_modified = time();
    $new_member->is_confirmed = 1;
    if (!$new_member->save()) {
        return false;
    }
    /* Record this in activity streams */
    groups_record_activity(array('item_id' => $new_member->group_id, 'component_name' => $bp->groups->slug, 'component_action' => 'joined_group', 'is_private' => 0));
    /* Modify group meta */
    groups_update_groupmeta($group_id, 'total_member_count', (int) groups_get_groupmeta($group_id, 'total_member_count') + 1);
    groups_update_groupmeta($group_id, 'last_activity', time());
    do_action('groups_join_group', $group_id, $bp->loggedin_user->id);
    return true;
}
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:32,代码来源:bp-groups.php

示例14: bp_legacy_theme_ajax_joinleave_group

/**
 * Join or leave a group when clicking the "join/leave" button via a POST request.
 *
 * @return string HTML
 * @since BuddyPress (1.2)
 */
function bp_legacy_theme_ajax_joinleave_group()
{
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    // Cast gid as integer
    $group_id = (int) $_POST['gid'];
    if (groups_is_user_banned(bp_loggedin_user_id(), $group_id)) {
        return;
    }
    if (!($group = groups_get_group(array('group_id' => $group_id)))) {
        return;
    }
    if (!groups_is_user_member(bp_loggedin_user_id(), $group->id)) {
        if ('public' == $group->status) {
            check_ajax_referer('groups_join_group');
            if (!groups_join_group($group->id)) {
                _e('Error joining group', 'buddypress');
            } else {
                echo '<a id="group-' . esc_attr($group->id) . '" class="leave-group" rel="leave" title="' . __('Leave Group', 'buddypress') . '" href="' . wp_nonce_url(bp_get_group_permalink($group) . 'leave-group', 'groups_leave_group') . '">' . __('Leave Group', 'buddypress') . '</a>';
            }
        } elseif ('private' == $group->status) {
            // If the user has already been invited, then this is
            // an Accept Invitation button
            if (groups_check_user_has_invite(bp_loggedin_user_id(), $group->id)) {
                check_ajax_referer('groups_accept_invite');
                if (!groups_accept_invite(bp_loggedin_user_id(), $group->id)) {
                    _e('Error requesting membership', 'buddypress');
                } else {
                    echo '<a id="group-' . esc_attr($group->id) . '" class="leave-group" rel="leave" title="' . __('Leave Group', 'buddypress') . '" href="' . wp_nonce_url(bp_get_group_permalink($group) . 'leave-group', 'groups_leave_group') . '">' . __('Leave Group', 'buddypress') . '</a>';
                }
                // Otherwise, it's a Request Membership button
            } else {
                check_ajax_referer('groups_request_membership');
                if (!groups_send_membership_request(bp_loggedin_user_id(), $group->id)) {
                    _e('Error requesting membership', 'buddypress');
                } else {
                    echo '<a id="group-' . esc_attr($group->id) . '" class="membership-requested" rel="membership-requested" title="' . __('Membership Requested', 'buddypress') . '" href="' . bp_get_group_permalink($group) . '">' . __('Membership Requested', 'buddypress') . '</a>';
                }
            }
        }
    } else {
        check_ajax_referer('groups_leave_group');
        if (!groups_leave_group($group->id)) {
            _e('Error leaving group', 'buddypress');
        } elseif ('public' == $group->status) {
            echo '<a id="group-' . esc_attr($group->id) . '" class="join-group" rel="join" title="' . __('Join Group', 'buddypress') . '" href="' . wp_nonce_url(bp_get_group_permalink($group) . 'join', 'groups_join_group') . '">' . __('Join Group', 'buddypress') . '</a>';
        } elseif ('private' == $group->status) {
            echo '<a id="group-' . esc_attr($group->id) . '" class="request-membership" rel="join" title="' . __('Request Membership', 'buddypress') . '" href="' . wp_nonce_url(bp_get_group_permalink($group) . 'request-membership', 'groups_send_membership_request') . '">' . __('Request Membership', 'buddypress') . '</a>';
        }
    }
    exit;
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:60,代码来源:buddypress-functions.php

示例15: test_groups_accept_invite

 /**
  * @group groups_accept_invite
  * @group group_invitations
  * @group group_membership
  */
 public function test_groups_accept_invite()
 {
     $u1 = $this->factory->user->create();
     $u2 = $this->factory->user->create();
     $g1 = $this->factory->group->create(array('creator_id' => $u1));
     // Create draft invitation
     groups_invite_user(array('user_id' => $u2, 'group_id' => $g1, 'inviter_id' => $u1, 'date_modified' => bp_core_current_time(), 'is_confirmed' => 0));
     // Send the invitation
     groups_send_invites($u1, $g1);
     // Accept the invitation
     groups_accept_invite($u2, $g1);
     // Check that the user is a member of the group.
     $member = groups_is_user_member($u2, $g1);
     $this->assertTrue(is_numeric($member) && $member > 0);
     // Check that the invite has been removed.
     $invite = groups_check_user_has_invite($u2, $g1, 'all');
     $this->assertTrue(is_null($invite));
 }
开发者ID:jasonmcalpin,项目名称:BuddyPress,代码行数:23,代码来源:class-bp-groups-member.php


注:本文中的groups_check_user_has_invite函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。