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


PHP bp_groups_user_can_send_invites函数代码示例

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


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

示例1: bp_dtheme_ajax_invite_user

function bp_dtheme_ajax_invite_user()
{
    global $bp;
    check_ajax_referer('groups_invite_uninvite_user');
    if (!$_POST['friend_id'] || !$_POST['friend_action'] || !$_POST['group_id']) {
        return false;
    }
    if (!bp_groups_user_can_send_invites($_POST['group_id']) || !friends_check_friendship($bp->loggedin_user->id, $_POST['friend_id'])) {
        return false;
    }
    if ('invite' == $_POST['friend_action']) {
        if (!groups_invite_user(array('user_id' => $_POST['friend_id'], 'group_id' => $_POST['group_id']))) {
            return false;
        }
        $user = new BP_Core_User($_POST['friend_id']);
        echo '<li id="uid-' . $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($bp->loggedin_user->domain . bp_get_groups_slug() . '/' . $_POST['group_id'] . '/invites/remove/' . $user->id, 'groups_invite_uninvite_user') . '" id="uid-' . esc_attr($user->id) . '">' . __('Remove Invite', 'buddypress') . '</a>
			  </div>';
        echo '</li>';
    } else {
        if ('uninvite' == $_POST['friend_action']) {
            return (bool) groups_uninvite_user($_POST['friend_id'], $_POST['group_id']);
        } else {
            return false;
        }
    }
}
开发者ID:hscale,项目名称:webento,代码行数:31,代码来源:ajax.php

示例2: bp_legacy_theme_ajax_invite_user

/**
 * Invites a friend to join a group via a POST request.
 *
 * @since BuddyPress (1.2)
 * @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 (BP_Groups_Member::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;
    }
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:66,代码来源:buddypress-functions.php

示例3: enable_nav_item

 function enable_nav_item()
 {
     global $bp;
     // Group-specific settings always override
     if (!bp_groups_user_can_send_invites()) {
         return false;
     }
     if (invite_anyone_group_invite_access_test() == 'anyone') {
         return true;
     } else {
         return false;
     }
 }
开发者ID:kd5ytx,项目名称:Empirical-Wordpress,代码行数:13,代码来源:group-invites.php

示例4: bp_dtheme_ajax_invite_user

/**
 * Invites a friend to join a group via a POST request.
 *
 * @return unknown
 * @since BuddyPress (1.2)
 * @todo Audit return types
 */
function bp_dtheme_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;
    }
    if ('invite' == $_POST['friend_action']) {
        if (!groups_invite_user(array('user_id' => $_POST['friend_id'], 'group_id' => $_POST['group_id']))) {
            return;
        }
        $user = new BP_Core_User($_POST['friend_id']);
        echo '<li id="uid-' . $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(bp_loggedin_user_domain() . bp_get_groups_slug() . '/' . $_POST['group_id'] . '/invites/remove/' . $user->id, 'groups_invite_uninvite_user') . '" id="uid-' . esc_attr($user->id) . '">' . __('Remove Invite', 'logicalboneshug') . '</a>
			  </div>';
        echo '</li>';
        exit;
    } elseif ('uninvite' == $_POST['friend_action']) {
        if (!groups_uninvite_user($_POST['friend_id'], $_POST['group_id'])) {
            return;
        }
        exit;
    } else {
        return;
    }
}
开发者ID:raminjan,项目名称:logicalbones_hug,代码行数:46,代码来源:ajax.php

示例5: 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 (BP_Groups_Member::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);
}
开发者ID:swissspidy,项目名称:BuddyPress,代码行数:37,代码来源:bp-groups-screens.php

示例6: invite_anyone_screen_one_content


//.........这里部分代码省略.........
        ?>
				<label for="invite-anyone-custom-message"><?php 
        _e('Message:', 'invite-anyone');
        ?>
</label>
					<textarea name="invite_anyone_custom_message" id="invite-anyone-custom-message" disabled="disabled"><?php 
        echo invite_anyone_invitation_message($returned_message);
        ?>
</textarea>

				<input type="hidden" name="invite_anyone_custom_message" value="<?php 
        echo invite_anyone_invitation_message();
        ?>
" />
			<?php 
    }
    ?>

		</li>

		<?php 
    if (invite_anyone_are_groups_running()) {
        ?>
			<?php 
        if ($iaoptions['can_send_group_invites_email'] == 'yes' && bp_has_groups("per_page=10000&type=alphabetical&user_id=" . bp_loggedin_user_id())) {
            ?>
			<li>
				<p><?php 
            _e('(optional) Select some groups. Invitees will receive invitations to these groups when they join the site.', 'invite-anyone');
            ?>
</p>
				<ul id="invite-anyone-group-list">
					<?php 
            while (bp_groups()) {
                bp_the_group();
                ?>
						<?php 
                // Enforce per-group invitation settings
                if (!bp_groups_user_can_send_invites(bp_get_group_id()) || 'anyone' !== invite_anyone_group_invite_access_test(bp_get_group_id())) {
                    continue;
                }
                ?>
						<li>
						<input type="checkbox" name="invite_anyone_groups[]" id="invite_anyone_groups-<?php 
                bp_group_id();
                ?>
" value="<?php 
                bp_group_id();
                ?>
" <?php 
                if ($from_group == bp_get_group_id() || array_search(bp_get_group_id(), $returned_groups)) {
                    ?>
checked<?php 
                }
                ?>
 />

						<label for="invite_anyone_groups-<?php 
                bp_group_id();
                ?>
" class="invite-anyone-group-name"><?php 
                bp_group_avatar_mini();
                ?>
 <span><?php 
                bp_group_name();
                ?>
</span></label>

						</li>
					<?php 
            }
            ?>

				</ul>
			</li>
			<?php 
        }
        ?>

		<?php 
    }
    ?>

		<?php 
    do_action('invite_anyone_addl_fields');
    ?>

	</ol>

	<div class="submit">
		<input type="submit" name="invite-anyone-submit" id="invite-anyone-submit" value="<?php 
    _e('Send Invites', 'buddypress');
    ?>
 " />
	</div>


	</form>
	<?php 
}
开发者ID:kd5ytx,项目名称:Empirical-Wordpress,代码行数:101,代码来源:by-email.php

示例7: 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

示例8: test_bp_groups_user_can_send_invites

 /**
  * @group bp_groups_user_can_send_invites
  */
 public function test_bp_groups_user_can_send_invites()
 {
     $u_nonmembers = $this->factory->user->create();
     $u_members = $this->factory->user->create();
     $u_mods = $this->factory->user->create();
     $u_admins = $this->factory->user->create();
     $u_siteadmin = $this->factory->user->create();
     $user_siteadmin = new WP_User($u_siteadmin);
     $user_siteadmin->add_role('administrator');
     $g = $this->factory->group->create();
     $time = time() - 60;
     $old_current_user = get_current_user_id();
     // Create member-level user
     $this->add_user_to_group($u_members, $g, array('date_modified' => date('Y-m-d H:i:s', $time)));
     // Create mod-level user
     $this->add_user_to_group($u_mods, $g, array('date_modified' => date('Y-m-d H:i:s', $time)));
     $m_mod = new BP_Groups_Member($u_mods, $g);
     $m_mod->promote('mod');
     // Create admin-level user
     $this->add_user_to_group($u_admins, $g, array('date_modified' => date('Y-m-d H:i:s', $time)));
     $m_admin = new BP_Groups_Member($u_admins, $g);
     $m_admin->promote('admin');
     // Test with no status
     // In bp_group_get_invite_status(), no status falls back to "members"
     $this->assertTrue('' == groups_get_groupmeta($g, 'invite_status'));
     $this->assertFalse(bp_groups_user_can_send_invites($g, $u_nonmembers));
     $this->assertTrue(bp_groups_user_can_send_invites($g, $u_members));
     $this->assertTrue(bp_groups_user_can_send_invites($g, $u_mods));
     $this->assertTrue(bp_groups_user_can_send_invites($g, $u_admins));
     $this->assertTrue(bp_groups_user_can_send_invites($g, $u_siteadmin));
     // Test with members status
     groups_update_groupmeta($g, 'invite_status', 'members');
     $this->assertFalse(bp_groups_user_can_send_invites($g, $u_nonmembers));
     $this->assertTrue(bp_groups_user_can_send_invites($g, $u_members));
     $this->assertTrue(bp_groups_user_can_send_invites($g, $u_mods));
     $this->assertTrue(bp_groups_user_can_send_invites($g, $u_admins));
     $this->assertTrue(bp_groups_user_can_send_invites($g, $u_siteadmin));
     // Falling back to current user
     $this->set_current_user($u_members);
     $this->assertTrue(bp_groups_user_can_send_invites($g, null));
     // Test with mod status
     groups_update_groupmeta($g, 'invite_status', 'mods');
     $this->assertFalse(bp_groups_user_can_send_invites($g, $u_nonmembers));
     $this->assertFalse(bp_groups_user_can_send_invites($g, $u_members));
     $this->assertTrue(bp_groups_user_can_send_invites($g, $u_mods));
     $this->assertTrue(bp_groups_user_can_send_invites($g, $u_admins));
     $this->assertTrue(bp_groups_user_can_send_invites($g, $u_siteadmin));
     // Falling back to current user
     $this->set_current_user($u_members);
     $this->assertFalse(bp_groups_user_can_send_invites($g, null));
     $this->set_current_user($u_mods);
     $this->assertTrue(bp_groups_user_can_send_invites($g, null));
     // Test with admin status
     groups_update_groupmeta($g, 'invite_status', 'admins');
     $this->assertFalse(bp_groups_user_can_send_invites($g, $u_nonmembers));
     $this->assertFalse(bp_groups_user_can_send_invites($g, $u_members));
     $this->assertFalse(bp_groups_user_can_send_invites($g, $u_mods));
     $this->assertTrue(bp_groups_user_can_send_invites($g, $u_admins));
     $this->assertTrue(bp_groups_user_can_send_invites($g, $u_siteadmin));
     // Falling back to current user
     $this->set_current_user($u_mods);
     $this->assertFalse(bp_groups_user_can_send_invites($g, null));
     $this->set_current_user($u_admins);
     $this->assertTrue(bp_groups_user_can_send_invites($g, null));
     // Bad or null parameters
     $this->assertFalse(bp_groups_user_can_send_invites(59876454257, $u_members));
     $this->assertFalse(bp_groups_user_can_send_invites($g, 958647515));
     // Not in group context
     $this->assertFalse(bp_groups_user_can_send_invites(null, $u_members));
     // In group context
     $g_obj = groups_get_group(array('group_id' => $g));
     $this->go_to(bp_get_group_permalink($g_obj));
     groups_update_groupmeta($g, 'invite_status', 'mods');
     $this->assertFalse(bp_groups_user_can_send_invites(null, $u_nonmembers));
     $this->assertFalse(bp_groups_user_can_send_invites(null, $u_members));
     $this->assertTrue(bp_groups_user_can_send_invites(null, $u_mods));
     $this->set_current_user($old_current_user);
 }
开发者ID:jasonmcalpin,项目名称:BuddyPress,代码行数:81,代码来源:class-bp-groups-member.php

示例9: 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

示例10: 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');
     }
 }
开发者ID:adisonc,项目名称:MaineLearning,代码行数:49,代码来源:bp-groups-loader.php


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