本文整理汇总了PHP中groups_check_for_membership_request函数的典型用法代码示例。如果您正苦于以下问题:PHP groups_check_for_membership_request函数的具体用法?PHP groups_check_for_membership_request怎么用?PHP groups_check_for_membership_request使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了groups_check_for_membership_request函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: groups_send_membership_request
/**
* Create a group membership request.
*
* @param int $requesting_user_id ID of the user requesting membership.
* @param int $group_id ID of the group.
*
* @return bool True on success, false on failure.
*/
function groups_send_membership_request($requesting_user_id, $group_id)
{
// Prevent duplicate requests
if (groups_check_for_membership_request($requesting_user_id, $group_id)) {
return false;
}
// Check if the user is already a member or is banned
if (groups_is_user_member($requesting_user_id, $group_id) || groups_is_user_banned($requesting_user_id, $group_id)) {
return false;
}
// Check if the user is already invited - if so, simply accept invite
if (groups_check_user_has_invite($requesting_user_id, $group_id)) {
groups_accept_invite($requesting_user_id, $group_id);
return true;
}
$requesting_user = new BP_Groups_Member();
$requesting_user->group_id = $group_id;
$requesting_user->user_id = $requesting_user_id;
$requesting_user->inviter_id = 0;
$requesting_user->is_admin = 0;
$requesting_user->user_title = '';
$requesting_user->date_modified = bp_core_current_time();
$requesting_user->is_confirmed = 0;
$requesting_user->comments = isset($_POST['group-request-membership-comments']) ? $_POST['group-request-membership-comments'] : '';
if ($requesting_user->save()) {
$admins = groups_get_group_admins($group_id);
// Saved okay, now send the email notification
for ($i = 0, $count = count($admins); $i < $count; ++$i) {
groups_notification_new_membership_request($requesting_user_id, $admins[$i]->user_id, $group_id, $requesting_user->id);
}
/**
* Fires after the creation of a new membership request.
*
* @since 1.0.0
*
* @param int $requesting_user_id ID of the user requesting membership.
* @param array $admins Array of group admins.
* @param int $group_id ID of the group being requested to.
* @param int $requesting_user->id ID of the user requesting membership.
*/
do_action('groups_membership_requested', $requesting_user_id, $admins, $group_id, $requesting_user->id);
return true;
}
return false;
}
示例2: 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
//.........这里部分代码省略.........
示例3: bp_group_has_requested_membership
function bp_group_has_requested_membership($group = false)
{
global $groups_template;
if (empty($group)) {
$group =& $groups_template->group;
}
if (groups_check_for_membership_request(bp_loggedin_user_id(), $group->id)) {
return true;
}
return false;
}
示例4: test_groups_send_membership_request
/**
* @group groups_send_membership_request
* @group group_membership_requests
* @group group_membership
*/
public function test_groups_send_membership_request()
{
$u1 = $this->factory->user->create();
$g1 = $this->factory->group->create();
// Create membership request
groups_send_membership_request($u1, $g1);
$request = groups_check_for_membership_request($u1, $g1);
$this->assertTrue(is_numeric($request) && $request > 0);
}
示例5: groups_send_membership_request
function groups_send_membership_request($requesting_user_id, $group_id)
{
// Prevent duplicate requests
if (groups_check_for_membership_request($requesting_user_id, $group_id)) {
return false;
}
// Check if the user is already a member or is banned
if (groups_is_user_member($requesting_user_id, $group_id) || groups_is_user_banned($requesting_user_id, $group_id)) {
return false;
}
$requesting_user = new BP_Groups_Member();
$requesting_user->group_id = $group_id;
$requesting_user->user_id = $requesting_user_id;
$requesting_user->inviter_id = 0;
$requesting_user->is_admin = 0;
$requesting_user->user_title = '';
$requesting_user->date_modified = bp_core_current_time();
$requesting_user->is_confirmed = 0;
$requesting_user->comments = isset($_POST['group-request-membership-comments']) ? $_POST['group-request-membership-comments'] : '';
if ($requesting_user->save()) {
$admins = groups_get_group_admins($group_id);
// Saved okay, now send the email notification
for ($i = 0, $count = count($admins); $i < $count; ++$i) {
groups_notification_new_membership_request($requesting_user_id, $admins[$i]->user_id, $group_id, $requesting_user->id);
}
do_action('groups_membership_requested', $requesting_user_id, $admins, $group_id, $requesting_user->id);
return true;
}
return false;
}
示例6: 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');
}
}
示例7: bp_group_has_requested_membership
function bp_group_has_requested_membership( $group = false ) {
global $bp, $groups_template;
if ( !$group )
$group =& $groups_template->group;
if ( groups_check_for_membership_request( $bp->loggedin_user->id, $group->id ) )
return true;
return false;
}
示例8: groups_send_membership_request
function groups_send_membership_request( $requesting_user_id, $group_id ) {
global $bp;
/* Prevent duplicate requests */
if ( groups_check_for_membership_request( $requesting_user_id, $group_id ) )
return false;
/* Check if the user is already a member or is banned */
if ( groups_is_user_member( $requesting_user_id, $group_id ) || groups_is_user_banned( $requesting_user_id, $group_id ) )
return false;
$requesting_user = new BP_Groups_Member;
$requesting_user->group_id = $group_id;
$requesting_user->user_id = $requesting_user_id;
$requesting_user->inviter_id = 0;
$requesting_user->is_admin = 0;
$requesting_user->user_title = '';
$requesting_user->date_modified = gmdate( "Y-m-d H:i:s" );
$requesting_user->is_confirmed = 0;
$requesting_user->comments = $_POST['group-request-membership-comments'];
if ( $requesting_user->save() ) {
$admins = groups_get_group_admins( $group_id );
require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' );
for ( $i = 0; $i < count( $admins ); $i++ ) {
// Saved okay, now send the email notification
groups_notification_new_membership_request( $requesting_user_id, $admins[$i]->user_id, $group_id, $requesting_user->id );
}
do_action( 'groups_membership_requested', $requesting_user_id, $admins, $group_id, $requesting_user->id );
return true;
}
return false;
}
示例9: setup_nav
/**
* Setup BuddyBar navigation
*
* @global BuddyPress $bp The one true BuddyPress instance
*/
function setup_nav()
{
// Define local variables
$sub_nav = array();
// Add 'Groups' to the main navigation
$main_nav = array('name' => sprintf(__('Groups <span>%d</span>', 'buddypress'), groups_total_groups_for_user()), 'slug' => $this->slug, 'position' => 70, 'screen_function' => 'groups_screen_my_groups', 'default_subnav_slug' => 'my-groups', 'item_css_id' => $this->id);
$groups_link = trailingslashit(bp_loggedin_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_is_my_profile(), '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 home 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, show a "Request Membership" nav item.
if (is_user_logged_in() && !bp_current_user_can('bp_moderate') && !$this->current_group->is_user_member && !groups_check_for_membership_request(bp_loggedin_user_id(), $this->current_group->id) && $this->current_group->status == 'private') {
$sub_nav[] = array('name' => __('Request Membership', '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' => __('Forum', '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(__('Members <span>%s</span>', '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');
if (bp_is_active('friends') && bp_groups_user_can_send_invites()) {
$sub_nav[] = array('name' => __('Send Invites', '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);
}
// If the user is a group mod or more, then show the group admin nav item
if (bp_is_item_admin() || bp_is_item_mod()) {
$sub_nav[] = array('name' => __('Admin', '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');
}
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');
}
}
示例10: bp_legacy_theme_ajax_invite_user
/**
* Invites a friend to join a group via a POST request.
*
* @since 1.2.0
*
* @todo Audit return types
*/
function bp_legacy_theme_ajax_invite_user()
{
// Bail if not a POST action.
if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
return;
}
check_ajax_referer('groups_invite_uninvite_user');
if (!$_POST['friend_id'] || !$_POST['friend_action'] || !$_POST['group_id']) {
return;
}
if (!bp_groups_user_can_send_invites($_POST['group_id'])) {
return;
}
if (!friends_check_friendship(bp_loggedin_user_id(), $_POST['friend_id'])) {
return;
}
$group_id = (int) $_POST['group_id'];
$friend_id = (int) $_POST['friend_id'];
if ('invite' == $_POST['friend_action']) {
$group = groups_get_group($group_id);
// Users who have previously requested membership do not need
// another invitation created for them.
if (groups_check_for_membership_request($friend_id, $group_id)) {
$user_status = 'is_pending';
// Create the user invitation.
} elseif (groups_invite_user(array('user_id' => $friend_id, 'group_id' => $group_id))) {
$user_status = 'is_invited';
// Miscellaneous failure.
} else {
return;
}
$user = new BP_Core_User($friend_id);
$uninvite_url = bp_is_current_action('create') ? bp_get_groups_directory_permalink() . 'create/step/group-invites/?user_id=' . $friend_id : bp_get_group_permalink($group) . 'send-invites/remove/' . $friend_id;
echo '<li id="uid-' . esc_attr($user->id) . '">';
echo $user->avatar_thumb;
echo '<h4>' . $user->user_link . '</h4>';
echo '<span class="activity">' . esc_attr($user->last_active) . '</span>';
echo '<div class="action">
<a class="button remove" href="' . wp_nonce_url($uninvite_url, 'groups_invite_uninvite_user') . '" id="uid-' . esc_attr($user->id) . '">' . __('Remove Invite', 'buddypress') . '</a>
</div>';
if ('is_pending' == $user_status) {
echo '<p class="description">' . sprintf(__('%s has previously requested to join this group. Sending an invitation will automatically add the member to the group.', 'buddypress'), $user->user_link) . '</p>';
}
echo '</li>';
exit;
} elseif ('uninvite' == $_POST['friend_action']) {
// Users who have previously requested membership should not
// have their requests deleted on the "uninvite" action.
if (BP_Groups_Member::check_for_membership_request($friend_id, $group_id)) {
return;
}
// Remove the unsent invitation.
if (!groups_uninvite_user($friend_id, $group_id)) {
return;
}
exit;
} else {
return;
}
}
示例11: groups_setup_nav
function groups_setup_nav()
{
global $bp, $current_blog;
global $group_obj;
if ($group_id = BP_Groups_Group::group_exists($bp->current_action)) {
/* This is a single group page. */
$bp->is_single_item = true;
$group_obj = new BP_Groups_Group($group_id);
/* Using "item" not "group" for generic support in other components. */
if (is_site_admin()) {
$bp->is_item_admin = 1;
} else {
$bp->is_item_admin = groups_is_user_admin($bp->loggedin_user->id, $group_obj->id);
}
/* If the user is not an admin, check if they are a moderator */
if (!$bp->is_item_admin) {
$bp->is_item_mod = groups_is_user_mod($bp->loggedin_user->id, $group_obj->id);
}
/* Is the logged in user a member of the group? */
$is_member = groups_is_user_member($bp->loggedin_user->id, $group_obj->id) ? true : false;
/* Should this group be visible to the logged in user? */
$is_visible = 'public' == $group_obj->status || $is_member ? true : false;
}
/* Add 'Groups' to the main navigation */
bp_core_add_nav_item(__('Groups', 'buddypress'), $bp->groups->slug);
if ($bp->displayed_user->id) {
bp_core_add_nav_default($bp->groups->slug, 'groups_screen_my_groups', 'my-groups');
}
$groups_link = $bp->loggedin_user->domain . $bp->groups->slug . '/';
/* Add the subnav items to the groups nav item */
bp_core_add_subnav_item($bp->groups->slug, 'my-groups', __('My Groups', 'buddypress'), $groups_link, 'groups_screen_my_groups', 'my-groups-list');
bp_core_add_subnav_item($bp->groups->slug, 'create', __('Create a Group', 'buddypress'), $groups_link, 'groups_screen_create_group', false, bp_is_home());
bp_core_add_subnav_item($bp->groups->slug, 'invites', __('Invites', 'buddypress'), $groups_link, 'groups_screen_group_invites', false, bp_is_home());
if ($bp->current_component == $bp->groups->slug) {
if (bp_is_home() && !$bp->is_single_item) {
$bp->bp_options_title = __('My Groups', 'buddypress');
} else {
if (!bp_is_home() && !$bp->is_single_item) {
$bp->bp_options_avatar = bp_core_get_avatar($bp->displayed_user->id, 1);
$bp->bp_options_title = $bp->displayed_user->fullname;
} else {
if ($bp->is_single_item) {
// We are viewing a single group, so set up the
// group navigation menu using the $group_obj global.
/* When in a single group, the first action is bumped down one because of the
group name, so we need to adjust this and set the group name to current_item. */
$bp->current_item = $bp->current_action;
$bp->current_action = $bp->action_variables[0];
array_shift($bp->action_variables);
$bp->bp_options_title = $group_obj->name;
$bp->bp_options_avatar = '<img src="' . $group_obj->avatar_thumb . '" alt="Group Avatar Thumbnail" />';
$group_link = $bp->root_domain . '/' . $bp->groups->slug . '/' . $group_obj->slug . '/';
// If this is a private or hidden group, does the user have access?
if ('private' == $group_obj->status || 'hidden' == $group_obj->status) {
if (groups_is_user_member($bp->loggedin_user->id, $group_obj->id) && is_user_logged_in()) {
$has_access = true;
} else {
$has_access = false;
}
} else {
$has_access = true;
}
// Reset the existing subnav items
bp_core_reset_subnav_items($bp->groups->slug);
bp_core_add_nav_default($bp->groups->slug, 'groups_screen_group_home', 'home');
bp_core_add_subnav_item($bp->groups->slug, 'home', __('Home', 'buddypress'), $group_link, 'groups_screen_group_home', 'group-home');
// If the user is a group mod or more, then show the group admin nav item */
if ($bp->is_item_mod || $bp->is_item_admin) {
bp_core_add_subnav_item($bp->groups->slug, 'admin', __('Admin', 'buddypress'), $group_link, 'groups_screen_group_admin', 'group-admin', $bp->is_item_admin + (int) $bp->is_item_mod);
}
// If this is a private group, and the user is not a member, show a "Request Membership" nav item.
if (!$has_access && !groups_check_for_membership_request($bp->loggedin_user->id, $group_obj->id) && $group_obj->status == 'private') {
bp_core_add_subnav_item($bp->groups->slug, 'request-membership', __('Request Membership', 'buddypress'), $group_link, 'groups_screen_group_request_membership', 'request-membership');
}
if ($has_access && $group_obj->enable_forum && function_exists('bp_forums_setup')) {
bp_core_add_subnav_item($bp->groups->slug, 'forum', __('Forum', 'buddypress'), $group_link, 'groups_screen_group_forum', 'group-forum', $is_visible);
}
if ($has_access && $group_obj->enable_wire && function_exists('bp_wire_install')) {
bp_core_add_subnav_item($bp->groups->slug, 'wire', __('Wire', 'buddypress'), $group_link, 'groups_screen_group_wire', 'group-wire', $is_visible);
}
if ($has_access && $group_obj->enable_photos && function_exists('bp_gallery_install')) {
bp_core_add_subnav_item($bp->groups->slug, 'photos', __('Photos', 'buddypress'), $group_link, 'groups_screen_group_photos', 'group-photos', $is_visible);
}
if ($has_access) {
bp_core_add_subnav_item($bp->groups->slug, 'members', __('Members', 'buddypress'), $group_link, 'groups_screen_group_members', 'group-members', $is_visible);
}
if (is_user_logged_in() && groups_is_user_member($bp->loggedin_user->id, $group_obj->id)) {
if (function_exists('friends_install')) {
bp_core_add_subnav_item($bp->groups->slug, 'send-invites', __('Send Invites', 'buddypress'), $group_link, 'groups_screen_group_invite', 'group-invite', $is_member);
}
bp_core_add_subnav_item($bp->groups->slug, 'leave-group', __('Leave Group', 'buddypress'), $group_link, 'groups_screen_group_leave', 'group-leave', $is_member);
}
}
}
}
}
}
示例12: 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;
}
示例13: groups_remove_group_invite
/**
* Process group invitation removal requests.
*
* Note that this function is only used when JS is disabled. Normally, clicking
* Remove Invite removes the invitation via AJAX.
*
* @since 2.0.0
*/
function groups_remove_group_invite()
{
if (!bp_is_group_invites()) {
return;
}
if (!bp_is_action_variable('remove', 0) || !is_numeric(bp_action_variable(1))) {
return;
}
if (!check_admin_referer('groups_invite_uninvite_user')) {
return false;
}
$friend_id = intval(bp_action_variable(1));
$group_id = bp_get_current_group_id();
$message = __('Invite successfully removed', 'buddypress');
$redirect = wp_get_referer();
$error = false;
if (!bp_groups_user_can_send_invites($group_id)) {
$message = __('You are not allowed to send or remove invites', 'buddypress');
$error = 'error';
} elseif (groups_check_for_membership_request($friend_id, $group_id)) {
$message = __('The member requested to join the group', 'buddypress');
$error = 'error';
} elseif (!groups_uninvite_user($friend_id, $group_id)) {
$message = __('There was an error removing the invite', 'buddypress');
$error = 'error';
}
bp_core_add_message($message, $error);
bp_core_redirect($redirect);
}
示例14: __get
/**
* Magic getter.
*
* @since 2.7.0
*
* @param string $key Property name.
* @return mixed
*/
public function __get($key)
{
switch ($key) {
case 'last_activity':
case 'total_member_count':
case 'forum_id':
$retval = groups_get_groupmeta($this->id, $key);
if ('last_activity' !== $key) {
$retval = (int) $retval;
}
return $retval;
case 'admins':
return $this->get_admins();
case 'mods':
return $this->get_mods();
case 'is_member':
return $this->get_is_member();
case 'is_invited':
return groups_check_user_has_invite(bp_loggedin_user_id(), $this->id);
case 'is_pending':
return groups_check_for_membership_request(bp_loggedin_user_id(), $this->id);
case 'user_has_access':
return $this->get_user_has_access();
default:
return isset($this->{$key}) ? $this->{$key} : null;
}
}