本文整理汇总了PHP中BP_Groups_Member::get_all_for_group方法的典型用法代码示例。如果您正苦于以下问题:PHP BP_Groups_Member::get_all_for_group方法的具体用法?PHP BP_Groups_Member::get_all_for_group怎么用?PHP BP_Groups_Member::get_all_for_group使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BP_Groups_Member
的用法示例。
在下文中一共展示了BP_Groups_Member::get_all_for_group方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
function __construct($group_id, $per_page, $max, $exclude_admins_mods, $exclude_banned, $exclude)
{
global $bp;
$this->pag_page = isset($_REQUEST['mlpage']) ? intval($_REQUEST['mlpage']) : 1;
$this->pag_num = isset($_REQUEST['num']) ? intval($_REQUEST['num']) : $per_page;
$this->members = BP_Groups_Member::get_all_for_group($group_id, $this->pag_num, $this->pag_page, $exclude_admins_mods, $exclude_banned, $exclude);
if (!$max || $max >= (int) $this->members['count']) {
$this->total_member_count = (int) $this->members['count'];
} else {
$this->total_member_count = (int) $max;
}
$this->members = $this->members['members'];
if ($max) {
if ($max >= count($this->members)) {
$this->member_count = count($this->members);
} else {
$this->member_count = (int) $max;
}
} else {
$this->member_count = count($this->members);
}
$this->pag_links = paginate_links(array('base' => add_query_arg('mlpage', '%#%'), 'format' => '', 'total' => ceil($this->total_member_count / $this->pag_num), 'current' => $this->pag_page, 'prev_text' => '←', 'next_text' => '→', 'mid_size' => 1));
}
示例2: groups_get_group_members
/**
* Fetch the members of a group.
*
* Since BuddyPress 1.8, a procedural wrapper for BP_Group_Member_Query.
* Previously called BP_Groups_Member::get_all_for_group().
*
* To use the legacy query, filter 'bp_use_legacy_group_member_query',
* returning true.
*
* @param array $args {
* An array of optional arguments.
* @type int $group_id ID of the group whose members are being queried.
* Default: current group ID.
* @type int $page Page of results to be queried. Default: 1.
* @type int $per_page Number of items to return per page of results.
* Default: 20.
* @type int $max Optional. Max number of items to return.
* @type array $exclude Optional. Array of user IDs to exclude.
* @type bool|int $value True (or 1) to exclude admins and mods from results.
* Default: 1.
* @type bool|int $value True (or 1) to exclude banned users from results.
* Default: 1.
* @type array $group_role Optional. Array of group roles to include.
* @type string $search_terms Optional. Filter results by a search string.
* @type string $type Optional. Sort the order of results. 'last_joined',
* 'first_joined', or any of the $type params available
* in {@link BP_User_Query}. Default: 'last_joined'.
* }
* @return array Multi-d array of 'members' list and 'count'.
*/
function groups_get_group_members($args = array())
{
// Backward compatibility with old method of passing arguments
if (!is_array($args) || func_num_args() > 1) {
_deprecated_argument(__METHOD__, '2.0.0', sprintf(__('Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress'), __METHOD__, __FILE__));
$old_args_keys = array(0 => 'group_id', 1 => 'per_page', 2 => 'page', 3 => 'exclude_admins_mods', 4 => 'exclude_banned', 5 => 'exclude', 6 => 'group_role');
$func_args = func_get_args();
$args = bp_core_parse_args_array($old_args_keys, $func_args);
}
$r = wp_parse_args($args, array('group_id' => bp_get_current_group_id(), 'per_page' => false, 'page' => false, 'exclude_admins_mods' => true, 'exclude_banned' => true, 'exclude' => false, 'group_role' => array(), 'search_terms' => false, 'type' => 'last_joined'));
// For legacy users. Use of BP_Groups_Member::get_all_for_group()
// is deprecated. func_get_args() can't be passed to a function in PHP
// 5.2.x, so we create a variable
$func_args = func_get_args();
if (apply_filters('bp_use_legacy_group_member_query', false, __FUNCTION__, $func_args)) {
$retval = BP_Groups_Member::get_all_for_group($r['group_id'], $r['per_page'], $r['page'], $r['exclude_admins_mods'], $r['exclude_banned'], $r['exclude']);
} else {
// exclude_admins_mods and exclude_banned are legacy arguments.
// Convert to group_role
if (empty($r['group_role'])) {
$r['group_role'] = array('member');
if (!$r['exclude_admins_mods']) {
$r['group_role'][] = 'mod';
$r['group_role'][] = 'admin';
}
if (!$r['exclude_banned']) {
$r['group_role'][] = 'banned';
}
}
// Perform the group member query (extends BP_User_Query)
$members = new BP_Group_Member_Query(array('group_id' => $r['group_id'], 'per_page' => $r['per_page'], 'page' => $r['page'], 'group_role' => $r['group_role'], 'exclude' => $r['exclude'], 'search_terms' => $r['search_terms'], 'type' => $r['type']));
// Structure the return value as expected by the template functions
$retval = array('members' => array_values($members->results), 'count' => $members->total_users);
}
return $retval;
}
示例3: gradebook_screen
/**
* gradebook_screen( $vars )
*
* Hooks into screen_handler
* Adds a UI to assignments for gradebook management.
*
* @param Array $vars a set of variables received for this screen template
* @return Array $vars a set of variable passed to this screen template
*/
function gradebook_screen($vars)
{
global $bp;
$nonce_name = 'gradebook_nonce';
$nonce_import_name = 'gradebook_import_nonce';
$nonce_clear_name = 'gradebook_clear_nonce';
if (!$this->has_gradebook_caps($bp->loggedin_user->id) && !is_super_admin()) {
$vars['die'] = __('BuddyPress Courseware Error while forbidden user tried to manage gradebook.', 'bpsp');
return $vars;
}
$students = BP_Groups_Member::get_all_for_group($bp->groups->current_group->id);
if (isset($_POST['_nxtnonce'])) {
$is_nonce = nxt_verify_nonce($_POST['_nxtnonce'], $nonce_name);
}
if (isset($_POST['_nxtnonce']) && true != $is_nonce) {
$vars['die'] = __('BuddyPress Courseware Nonce Error while updating gradebook.', 'bpsp');
return $vars;
}
$gradebook_id = $this->has_gradebook($this->current_assignment);
if (!$gradebook_id) {
$vars['die'] = __('BuddyPress Courseware Error while creating gradebook.', 'bpsp');
return $vars;
}
if (!empty($_POST['grade'])) {
foreach ($_POST['grade'] as $grade) {
if (!empty($grade) && !empty($grade['uid']) && !empty($grade['value'])) {
# If grade was added or updated!
$status = $this->save_grade($gradebook_id, $grade);
if ($status !== null) {
$data = array('grade' => $grade, 'teacher' => $bp->loggedin_user->userdata, 'assignment' => $this->current_assignment);
if ($status == true) {
do_action('courseware_grade_added', $data);
} else {
do_action('courseware_grade_updated', $data);
}
}
}
}
$vars['message'] = __('Gradebook saved.', 'bpsp');
}
$vars['name'] = 'gradebook';
$vars['students'] = $students['members'];
if (empty($vars['grades'])) {
$vars['grades'] = $this->load_grades($gradebook_id, true);
}
$vars['bpsp_gradebook_format'] = get_option('bpsp_gradebook_format');
$vars['assignment'] = BPSP_Assignments::is_assignment($this->current_assignment);
$vars['gradebook_permalink'] = $vars['assignment_permalink'] . '/gradebook';
$vars['clear_gradebook_permalink'] = add_query_arg('_nxtnonce', nxt_create_nonce($nonce_clear_name), $vars['gradebook_permalink'] . '/clear');
$vars['import_gradebook_nonce'] = nxt_nonce_field($nonce_import_name, '_nxtnonce', true, false);
$vars['nonce'] = nxt_nonce_field($nonce_name, '_nxtnonce', true, false);
return $vars;
}
示例4: groups_get_group_members
/**
* Fetch the members of a group
*
* Since BuddyPress 1.8, a procedural wrapper for BP_Group_Member_Query.
* Previously called BP_Groups_Member::get_all_for_group().
*
* To use the legacy query, filter 'bp_use_legacy_group_member_query',
* returning true.
*
* @param int $group_id
* @param int $limit Maximum members to return
* @param int $page The page of results to return (requires $limit)
* @param bool $exclude_admins_mods Whether to exclude admins and mods
* @param bool $exclude_banned Whether to exclude banned users
* @param array|string $exclude Array or comma-sep list of users to exclude
* @return array Multi-d array of 'members' list and 'count'
*/
function groups_get_group_members($group_id, $limit = false, $page = false, $exclude_admins_mods = true, $exclude_banned = true, $exclude = false, $group_role = false)
{
// For legacy users. Use of BP_Groups_Member::get_all_for_group()
// is deprecated. func_get_args() can't be passed to a function in PHP
// 5.2.x, so we create a variable
$func_args = func_get_args();
if (apply_filters('bp_use_legacy_group_member_query', false, __FUNCTION__, $func_args)) {
$retval = BP_Groups_Member::get_all_for_group($group_id, $limit, $page, $exclude_admins_mods, $exclude_banned, $exclude);
} else {
// exclude_admins_mods and exclude_banned are legacy arguments.
// Convert to group_role
if (empty($group_role)) {
$group_role = array('member');
if (!$exclude_admins_mods) {
$group_role[] = 'mod';
$group_role[] = 'admin';
}
if (!$exclude_banned) {
$group_role[] = 'banned';
}
}
// Perform the group member query (extends BP_User_Query)
$members = new BP_Group_Member_Query(array('group_id' => $group_id, 'per_page' => $limit, 'page' => $page, 'group_role' => $group_role, 'exclude' => $exclude, 'type' => 'last_modified'));
// Structure the return value as expected by the template functions
$retval = array('members' => array_values($members->results), 'count' => $members->total_users);
}
return $retval;
}
示例5: test_get_all_for_group_with_exclude
/**
* @expectedDeprecated BP_Groups_Member::get_all_for_group
*/
public function test_get_all_for_group_with_exclude()
{
$g1 = $this->factory->group->create();
$u1 = $this->factory->user->create();
$u2 = $this->factory->user->create();
self::add_user_to_group($u1, $g1);
self::add_user_to_group($u2, $g1);
$members = BP_Groups_Member::get_all_for_group($g1, false, false, true, true, array($u1));
$mm = (array) $members['members'];
$ids = wp_list_pluck($mm, 'user_id');
$this->assertEquals(array($u2), $ids);
}
示例6: groups_get_group_members
function groups_get_group_members($group_id, $limit = false, $page = false)
{
return BP_Groups_Member::get_all_for_group($group_id, $limit, $page);
}
示例7: ass_manage_all_members_email_update
function ass_manage_all_members_email_update()
{
global $bp;
if (bp_is_groups_component() && bp_is_action_variable('manage-members', 0)) {
if (!is_super_admin()) {
return false;
}
$action = bp_action_variable(2);
if (bp_is_action_variable('email-all', 1) && ('no' == $action || 'sum' == $action || 'dig' == $action || 'sub' == $action || 'supersub' == $action)) {
if (!check_admin_referer('ass_change_all_email_sub')) {
return false;
}
$result = BP_Groups_Member::get_all_for_group(bp_get_current_group_id(), 0, 0, 0);
// set the last value to 1 to exclude admins
$members = $result['members'];
foreach ($members as $member) {
ass_group_subscription($action, $member->user_id, bp_get_current_group_id());
}
bp_core_add_message(__('All user email status\'s changed successfully', 'bp-ass'));
bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'admin/manage-members/');
}
}
}