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


PHP groups_is_user_banned函数代码示例

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


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

示例1: test_groups_is_user_banned_should_return_true_for_banned_member

 public function test_groups_is_user_banned_should_return_true_for_banned_member()
 {
     $this->add_user_to_group(self::$user, self::$groups[1]);
     $m = new BP_Groups_Member(self::$user, self::$groups[1]);
     $m->ban();
     $this->assertNotEmpty(groups_is_user_banned(self::$user, self::$groups[1]));
 }
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:7,代码来源:groupsIsUser.php

示例2: bp_legacy_theme_ajax_get_joinleave_group_status

/**
 * Get a user's membership status in multiple groups. The group ids should be in provided as post arguments ('grpids').
 *
 * @return string HTML
 * @since BuddyPress (1.2)
 */
function bp_legacy_theme_ajax_get_joinleave_group_status()
{
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    error_log("og joileavegroup " . groups_get_id("students"));
    $myretval = array();
    // Cast gid as integer
    $my_group_ids = $_POST['grpids'];
    error_log("og group status:" . print_r($my_group_ids, true));
    for ($myidx = 0; $myidx < count($my_group_ids); $myidx++) {
        $group_id = (int) $my_group_ids[$myidx];
        //$_POST['gid'];
        error_log("og group id:" . $group_id . " ");
        $bp_loggedin_user_id = bp_loggedin_user_id();
        if (groups_is_user_banned($bp_loggedin_user_id, $group_id)) {
            $myretval[$my_group_ids[$myidx]] = "";
        } else {
            if ($group = groups_get_group(array('group_id' => $group_id, 'populate_extras' => true))) {
                //return;
                //$htmlstrtoreturn = bp_legacy_theme_ajax_get_user_joinleave_group_status($group, $bp_loggedin_user_id);
                $htmlstrtoreturn = bp_legacy_theme_ajax_get_user_joinleave_group_status($group);
                $myretval[$my_group_ids[$myidx]] = $htmlstrtoreturn;
            }
        }
    }
    echo json_encode($myretval);
    exit;
}
开发者ID:paulmedwal,项目名称:edxforumspublic,代码行数:36,代码来源:buddypress-functions.php

示例3: friends_get_friends_invite_list

/**
 * Get a list of friends that a user can invite into this group.
 *
 * Excludes friends that are already in the group, and banned friends if the
 * user is not a group admin.
 *
 * @since BuddyPress (1.0.0)
 *
 * @param int $user_id User ID whose friends to see can be invited. Default:
 *        ID of the logged-in user.
 * @param int $group_id Group to check possible invitations against.
 * @return mixed False if no friends, array of users if friends.
 */
function friends_get_friends_invite_list($user_id = 0, $group_id = 0)
{
    // Default to logged in user id
    if (empty($user_id)) {
        $user_id = bp_loggedin_user_id();
    }
    // Only group admins can invited previously banned users
    $user_is_admin = (bool) groups_is_user_admin($user_id, $group_id);
    // Assume no friends
    $friends = array();
    // Default args
    $args = apply_filters('bp_friends_pre_get_invite_list', array('user_id' => $user_id, 'type' => 'alphabetical', 'per_page' => 0));
    // User has friends
    if (bp_has_members($args)) {
        /**
         * Loop through all friends and try to add them to the invitation list.
         *
         * Exclude friends that:
         *     1. are already members of the group
         *     2. are banned from this group if the current user is also not a
         *        group admin.
         */
        while (bp_members()) {
            // Load the member
            bp_the_member();
            // Get the user ID of the friend
            $friend_user_id = bp_get_member_user_id();
            // Skip friend if already in the group
            if (groups_is_user_member($friend_user_id, $group_id)) {
                continue;
            }
            // Skip friend if not group admin and user banned from group
            if (false === $user_is_admin && groups_is_user_banned($friend_user_id, $group_id)) {
                continue;
            }
            // Friend is safe, so add it to the array of possible friends
            $friends[] = array('id' => $friend_user_id, 'full_name' => bp_get_member_name());
        }
    }
    // If no friends, explicitly set to false
    if (empty($friends)) {
        $friends = false;
    }
    // Allow friends to be filtered
    return apply_filters('bp_friends_get_invite_list', $friends, $user_id, $group_id);
}
开发者ID:eresyyl,项目名称:mk,代码行数:59,代码来源:bp-friends-functions.php

示例4: bp_dtheme_ajax_joinleave_group

function bp_dtheme_ajax_joinleave_group()
{
    global $bp;
    if (groups_is_user_banned($bp->loggedin_user->id, $_POST['gid'])) {
        return false;
    }
    if (!($group = new BP_Groups_Group($_POST['gid'], false, false))) {
        return false;
    }
    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>';
            }
        } else {
            if ('private' == $group->status) {
                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');
        } else {
            if ('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>';
            } else {
                if ('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>';
                }
            }
        }
    }
}
开发者ID:hscale,项目名称:webento,代码行数:42,代码来源:ajax.php

示例5: bp_get_group_member_is_banned

function bp_get_group_member_is_banned()
{
    global $members_template, $groups_template;
    return apply_filters('bp_get_group_member_is_banned', groups_is_user_banned($members_template->member->user_id, $groups_template->group->id));
}
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:5,代码来源:bp-groups-templatetags.php

示例6: bp_group_is_user_banned

/**
 * Check if a user is banned from a group.
 *
 * If this function is invoked inside the groups template loop, then we check
 * $groups_template->group->is_banned instead of using {@link groups_is_user_banned()}
 * and making another SQL query.
 *
 * In BuddyPress 2.1, to standardize this function, we are defaulting the
 * return value to a boolean.  In previous versions, using this function would
 * return either a string of the integer (0 or 1) or null if a result couldn't
 * be found from the database.  If the logged-in user had the 'bp_moderate'
 * capability, the return value would be boolean false.
 *
 * @since BuddyPress (1.5.0)
 *
 * @global BP_Groups_Template $groups_template Group template loop object
 * @param BP_Groups_Group $group Group to check if user is banned
 * @param int $user_id The user ID to check
 * @return bool True if user is banned.  False if user isn't banned.
 */
function bp_group_is_user_banned($group = false, $user_id = 0)
{
    global $groups_template;
    // Site admins always have access
    if (bp_current_user_can('bp_moderate')) {
        return false;
    }
    // check groups loop first
    // @see BP_Groups_Group::get_group_extras()
    if (!empty($groups_template->in_the_loop) && isset($groups_template->group->is_banned)) {
        $retval = $groups_template->group->is_banned;
        // not in loop
    } else {
        // Default to not banned
        $retval = false;
        if (empty($group)) {
            $group = $groups_template->group;
        }
        if (empty($user_id)) {
            $user_id = bp_loggedin_user_id();
        }
        if (!empty($user_id) && !empty($group->id)) {
            $retval = groups_is_user_banned($user_id, $group->id);
        }
    }
    return (bool) apply_filters('bp_group_is_user_banned', $retval);
}
开发者ID:eresyyl,项目名称:mk,代码行数:47,代码来源:bp-groups-template.php

示例7: bp_group_is_user_banned

/**
 * Check if a user is banned from a group.
 *
 * If this function is invoked inside the groups template loop, then we check
 * $groups_template->group->is_banned instead of using {@link groups_is_user_banned()}
 * and making another SQL query.
 *
 * In BuddyPress 2.1, to standardize this function, we are defaulting the
 * return value to a boolean.  In previous versions, using this function would
 * return either a string of the integer (0 or 1) or null if a result couldn't
 * be found from the database.  If the logged-in user had the 'bp_moderate'
 * capability, the return value would be boolean false.
 *
 * @since 1.5.0
 *
 * @global BP_Groups_Template $groups_template Group template loop object.
 *
 * @param BP_Groups_Group|bool $group   Group to check if user is banned.
 * @param int                  $user_id The user ID to check.
 * @return bool True if user is banned.  False if user isn't banned.
 */
function bp_group_is_user_banned($group = false, $user_id = 0)
{
    global $groups_template;
    // Site admins always have access.
    if (bp_current_user_can('bp_moderate')) {
        return false;
    }
    // Check groups loop first
    // @see BP_Groups_Group::get_group_extras().
    if (!empty($groups_template->in_the_loop) && isset($groups_template->group->is_banned)) {
        $retval = $groups_template->group->is_banned;
        // Not in loop.
    } else {
        // Default to not banned.
        $retval = false;
        if (empty($group)) {
            $group = $groups_template->group;
        }
        if (empty($user_id)) {
            $user_id = bp_loggedin_user_id();
        }
        if (!empty($user_id) && !empty($group->id)) {
            $retval = groups_is_user_banned($user_id, $group->id);
        }
    }
    /**
     * Filters whether current user has been banned from current group in loop.
     *
     * @since 1.5.0
     * @since 2.5.0 Added the `$group` parameter.
     *
     * @param bool   $is_invited If user has been from current group.
     * @param object $group      Group object.
     */
    return (bool) apply_filters('bp_group_is_user_banned', $retval, $group);
}
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:57,代码来源:bp-groups-template.php

示例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;
}
开发者ID:n-sane,项目名称:zaroka,代码行数:38,代码来源:bp-groups.php

示例9: groups_screen_group_forum

/**
 * This screen function handles actions related to group forums
 *
 * @package BuddyPress
 */
function groups_screen_group_forum()
{
    global $bp;
    if (!bp_is_active('forums') || !bp_forums_is_installed_correctly()) {
        return false;
    }
    if (bp_action_variable(0) && !bp_is_action_variable('topic', 0)) {
        bp_do_404();
        return;
    }
    if (!$bp->groups->current_group->user_has_access) {
        bp_core_no_access();
        return;
    }
    if (bp_is_single_item()) {
        // Fetch the details we need
        $topic_slug = (string) bp_action_variable(1);
        $topic_id = bp_forums_get_topic_id_from_slug($topic_slug);
        $forum_id = groups_get_groupmeta($bp->groups->current_group->id, 'forum_id');
        $user_is_banned = false;
        if (!bp_current_user_can('bp_moderate') && groups_is_user_banned(bp_loggedin_user_id(), $bp->groups->current_group->id)) {
            $user_is_banned = true;
        }
        if (!empty($topic_slug) && !empty($topic_id)) {
            // Posting a reply
            if (!$user_is_banned && !bp_action_variable(2) && isset($_POST['submit_reply'])) {
                // Check the nonce
                check_admin_referer('bp_forums_new_reply');
                // Auto join this user if they are not yet a member of this group
                if (bp_groups_auto_join() && !bp_current_user_can('bp_moderate') && 'public' == $bp->groups->current_group->status && !groups_is_user_member(bp_loggedin_user_id(), $bp->groups->current_group->id)) {
                    groups_join_group($bp->groups->current_group->id, bp_loggedin_user_id());
                }
                $topic_page = isset($_GET['topic_page']) ? $_GET['topic_page'] : false;
                if (!($post_id = groups_new_group_forum_post($_POST['reply_text'], $topic_id, $topic_page))) {
                    bp_core_add_message(__('There was an error when replying to that topic', 'buddypress'), 'error');
                } else {
                    bp_core_add_message(__('Your reply was posted successfully', 'buddypress'));
                }
                if (isset($_SERVER['QUERY_STRING'])) {
                    $query_vars = '?' . $_SERVER['QUERY_STRING'];
                }
                bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'forum/topic/' . $topic_slug . '/' . $query_vars . '#post-' . $post_id);
            } else {
                if (bp_is_action_variable('stick', 2) && (isset($bp->is_item_admin) || isset($bp->is_item_mod))) {
                    // Check the nonce
                    check_admin_referer('bp_forums_stick_topic');
                    if (!bp_forums_sticky_topic(array('topic_id' => $topic_id))) {
                        bp_core_add_message(__('There was an error when making that topic a sticky', 'buddypress'), 'error');
                    } else {
                        bp_core_add_message(__('The topic was made sticky successfully', 'buddypress'));
                    }
                    do_action('groups_stick_forum_topic', $topic_id);
                    bp_core_redirect(wp_get_referer());
                } else {
                    if (bp_is_action_variable('unstick', 2) && (isset($bp->is_item_admin) || isset($bp->is_item_mod))) {
                        // Check the nonce
                        check_admin_referer('bp_forums_unstick_topic');
                        if (!bp_forums_sticky_topic(array('topic_id' => $topic_id, 'mode' => 'unstick'))) {
                            bp_core_add_message(__('There was an error when unsticking that topic', 'buddypress'), 'error');
                        } else {
                            bp_core_add_message(__('The topic was unstuck successfully', 'buddypress'));
                        }
                        do_action('groups_unstick_forum_topic', $topic_id);
                        bp_core_redirect(wp_get_referer());
                    } else {
                        if (bp_is_action_variable('close', 2) && (isset($bp->is_item_admin) || isset($bp->is_item_mod))) {
                            // Check the nonce
                            check_admin_referer('bp_forums_close_topic');
                            if (!bp_forums_openclose_topic(array('topic_id' => $topic_id))) {
                                bp_core_add_message(__('There was an error when closing that topic', 'buddypress'), 'error');
                            } else {
                                bp_core_add_message(__('The topic was closed successfully', 'buddypress'));
                            }
                            do_action('groups_close_forum_topic', $topic_id);
                            bp_core_redirect(wp_get_referer());
                        } else {
                            if (bp_is_action_variable('open', 2) && (isset($bp->is_item_admin) || isset($bp->is_item_mod))) {
                                // Check the nonce
                                check_admin_referer('bp_forums_open_topic');
                                if (!bp_forums_openclose_topic(array('topic_id' => $topic_id, 'mode' => 'open'))) {
                                    bp_core_add_message(__('There was an error when opening that topic', 'buddypress'), 'error');
                                } else {
                                    bp_core_add_message(__('The topic was opened successfully', 'buddypress'));
                                }
                                do_action('groups_open_forum_topic', $topic_id);
                                bp_core_redirect(wp_get_referer());
                            } else {
                                if (empty($user_is_banned) && bp_is_action_variable('delete', 2) && !bp_action_variable(3)) {
                                    // Fetch the topic
                                    $topic = bp_forums_get_topic_details($topic_id);
                                    /* Check the logged in user can delete this topic */
                                    if (!$bp->is_item_admin && !$bp->is_item_mod && (int) bp_loggedin_user_id() != (int) $topic->topic_poster) {
                                        bp_core_redirect(wp_get_referer());
                                    }
                                    // Check the nonce
//.........这里部分代码省略.........
开发者ID:newington,项目名称:buddypress,代码行数:101,代码来源:bp-groups-screens.php

示例10: bp_group_management_add_member_list

function bp_group_management_add_member_list($id)
{
    global $wpdb;
    $settings = get_option('bp_gm_settings');
    if (!($per_page = $settings['members_per_page'])) {
        $per_page = 50;
    }
    ?>

	<div class="bp-gm-add-members">
		<h3><?php 
    _e('Add members to group', 'bp-group-management');
    ?>
</h3>
		<ul>
		<?php 
    $query = "SELECT `ID` FROM {$wpdb->users}";
    if (is_multisite()) {
        $query .= " WHERE spam = 0";
    }
    $members = $wpdb->get_results($query, ARRAY_A);
    foreach ($members as $key => $m) {
        if (groups_is_user_member($m['ID'], $id)) {
            unset($members[$key]);
        }
        if (groups_is_user_banned($m['ID'], $id)) {
            unset($members[$key]);
        }
    }
    $members = array_values($members);
    if (isset($_GET['members_page'])) {
        $start = ($_GET['members_page'] - 1) * $per_page;
    } else {
        $start = 0;
    }
    //print "<pre>";
    //print_r($members);
    $pag_links = paginate_links(array('base' => add_query_arg('members_page', '%#%'), 'format' => '', 'total' => ceil(count($members) / $per_page), 'current' => isset($_GET['members_page']) ? $_GET['members_page'] : false, 'show_all' => false, 'prev_next' => true, 'prev_text' => '&larr;', 'next_text' => '&rarr;', 'mid_size' => 4, 'type' => 'list'));
    echo '<div class="tablenav"> <div class="tablenav-pages">';
    echo $pag_links;
    echo '</div></div>';
    echo '<ul>';
    for ($i = $start; $i < $start + $per_page; $i++) {
        if (empty($members[$i])) {
            break;
        }
        $addlink = "admin.php?page=bp-group-management&amp;action=edit&amp;id=" . $id . "&amp;member_id=" . $members[$i]['ID'] . "&amp;member_action=add";
        if (isset($_GET['members_page'])) {
            $addlink .= "&amp;members_page=" . $_GET['members_page'];
        }
        $addlink = function_exists('wp_nonce_url') ? wp_nonce_url($addlink, 'bp-group-management-action_add') : $addlink;
        ?>
			<li>
				<strong><a href="<?php 
        echo $addlink;
        ?>
"><?php 
        _e('Add', 'bp-group-management');
        ?>
</a></strong> - <?php 
        echo bp_core_get_userlink($members[$i]['ID']);
        ?>
			</li>



			<?php 
    }
    echo '</ul>';
    ?>
		</ul>

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

		<div style="clear: both;"> </div>

		<a class="button" id="bp-gm-settings-link" href="admin.php?page=bp-group-management&action=settings">Plugin settings</a>
	</div>
<?php 
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:82,代码来源:bp-group-management-bp-functions.php

示例11: bbp_group_is_banned

/**
 * Is the current user banned from the current group
 *
 * @since bbPress (r4632)
 *
 * @uses is_user_logged_in()
 * @uses bp_is_group()
 * @uses bbpress()
 * @uses get_current_user_id()
 * @uses bp_get_current_group_id()
 * @uses groups_is_user_admin()
 * @return bool If current user is banned from the current group
 */
function bbp_group_is_banned()
{
    // Bail if user is not logged in or not looking at a group
    if (!is_user_logged_in() || !bp_is_group()) {
        return false;
    }
    $bbp = bbpress();
    // Set the global if not set
    if (!isset($bbp->current_user->is_group_banned)) {
        $bbp->current_user->is_group_banned = groups_is_user_banned(get_current_user_id(), bp_get_current_group_id());
    }
    // Return the value
    return (bool) $bbp->current_user->is_group_banned;
}
开发者ID:ReLiFeD,项目名称:irreversible.eu,代码行数:27,代码来源:functions.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_action_join_group

function groups_action_join_group()
{
    global $bp;
    global $group_obj;
    if (!$bp->is_single_item || $bp->current_component != $bp->groups->slug || $bp->current_action != 'join') {
        return false;
    }
    // user wants to join a group
    if (!groups_is_user_member($bp->loggedin_user->id, $group_obj->id) && !groups_is_user_banned($bp->loggedin_user->id, $group_obj->id)) {
        if (!groups_join_group($group_obj->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($group_obj));
    }
    bp_core_load_template(apply_filters('groups_template_group_home', 'groups/group-home'));
}
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:18,代码来源:bp-groups.php

示例14: post


//.........这里部分代码省略.........
             return new WP_Error('bp_doc_parent_comment_deleted', '', $data);
         }
         // parent comment status checks
         switch ($comment->comment_approved) {
             case 'spam':
                 //do_action( 'bp_rbe_imap_no_match', $connection, $i, $headers, 'bp_doc_parent_comment_spam' );
                 return new WP_Error('bp_doc_parent_comment_spam', '', $data);
                 break;
             case 'trash':
                 //do_action( 'bp_rbe_imap_no_match', $connection, $i, $headers, 'bp_doc_parent_comment_deleted' );
                 return new WP_Error('bp_doc_parent_comment_deleted', '', $data);
                 break;
             case '0':
                 //do_action( 'bp_rbe_imap_no_match', $connection, $i, $headers, 'bp_doc_parent_comment_unapproved' );
                 return new WP_Error('bp_doc_parent_comment_unapproved', '', $data);
                 break;
         }
         // get doc settings
         $doc_settings = get_post_meta($comment->comment_post_ID, 'bp_docs_settings', true);
         // set temporary variable
         $bp->rbe = $bp->rbe->temp = new stdClass();
         // get group ID
         // $bp->rbe->temp->group_id gets passed to BP_Reply_By_Email::set_group_id()
         $group_id = $bp->rbe->temp->group_id = $params[$this->item_id_param];
         // get user ID
         $user_id = $data['user_id'];
         // check to see if the user can post comments for the group doc in question
         //
         // bp_docs_user_can( 'post_comments', $user_id, $group_id ) doesn't work the way I want it to
         // using the doc's comment settings as a guideline
         // check the comment settings for the doc
         switch ($doc_settings['post_comments']) {
             // this means that the comment settings for the doc recently switched to 'no-one'
             case 'no-one':
                 //do_action( 'bp_rbe_imap_no_match', $connection, $i, $headers, 'bp_doc_comment_change_to_noone' );
                 return new WP_Error('bp_doc_comment_change_to_noone', '', $data);
                 break;
                 // if the doc only allows group admins and mods to comment, return false for regular group members
             // if the doc only allows group admins and mods to comment, return false for regular group members
             case 'admins-mods':
                 // get the email address of the replier
                 $user_email = BP_Reply_By_Email_Parser::get_header($data['headers'], 'From');
                 // get an array of group admin / mod email addresses
                 // note: email addresses are set as key, not value
                 $admin_mod_emails = $this->get_admin_mod_user_emails($group_id);
                 // if the replier's email address does not match a group admin or mod, stop now!
                 if (!isset($admin_mod_emails[$user_email])) {
                     //do_action( 'bp_rbe_imap_no_match', $connection, $i, $headers, 'bp_doc_user_not_admin_mod' );
                     return new WP_Error('bp_doc_user_not_admin_mod', '', $data);
                 }
                 break;
                 // if the doc allows any group member to comment, check if member is still part of
                 // the group and not banned
             // if the doc allows any group member to comment, check if member is still part of
             // the group and not banned
             case 'group-members':
                 if (!groups_is_user_member($user_id, $group_id)) {
                     //do_action( 'bp_rbe_imap_no_match', $connection, $i, $headers, 'bp_doc_user_not_member' );
                     return new WP_Error('bp_doc_user_not_member', '', $data);
                 }
                 if (groups_is_user_banned($user_id, $group_id)) {
                     //do_action( 'bp_rbe_imap_no_match', $connection, $i, $headers, 'bp_doc_user_banned' );
                     return new WP_Error('bp_doc_user_banned', '', $data);
                 }
                 break;
         }
         /* okay! we should be good to post now! */
         // get the userdata
         $userdata = get_userdata($user_id);
         // we're using wp_insert_comment() instead of wp_new_comment()
         // why? because wp_insert_comment() bypasses all the WP comment hooks, which is good for us!
         $new_comment_id = wp_insert_comment(array('user_id' => $user_id, 'comment_post_ID' => $comment->comment_post_ID, 'comment_content' => $data['content'], 'comment_parent' => $comment_id, 'comment_author' => $userdata->user_nicename, 'comment_author_url' => '', 'comment_author_email' => $userdata->user_email, 'comment_author_IP' => '', 'comment_agent' => '', 'comment_type' => ''));
         // comment successfully posted!
         if (!empty($new_comment_id)) {
             // more internal logging
             bp_rbe_log('Message #' . $i . ': BP Doc comment reply successfully posted!');
             /* now let's record the activity item for this comment */
             // override BP Docs' default comment activity action
             add_filter('bp_docs_comment_activity_action', array($this, 'comment_activity_action'));
             // now post the activity item with BP Docs' special class method
             if (class_exists('BP_Docs_BP_Integration')) {
                 // BP Docs v1.1.x support
                 $activity_id = BP_Docs_BP_Integration::post_comment_activity($new_comment_id);
             } else {
                 // BP Docs v1.2.x support
                 $activity_id = BP_Docs_Component::post_comment_activity($new_comment_id);
             }
             // special hook for RBE activity items
             // if you're adding an activity entry in this method, remember to add this hook after posting
             // your activity item in this method!
             do_action('bp_rbe_new_activity', array('activity_id' => $activity_id, 'type' => $this->activity_type, 'user_id' => $user_id, 'item_id' => $group_id, 'secondary_item_id' => $comment_id, 'content' => $data['content']));
             // remove the filter after posting
             remove_filter('bp_docs_comment_activity_action', array($this, 'comment_activity_action'));
             return array('bp_doc_comment_id' => $new_comment_id);
         } else {
             //do_action( 'bp_rbe_imap_no_match', $connection, $i, $headers, 'bp_doc_new_comment_fail' );
             return new WP_Error('bp_doc_new_comment_fail', '', $data);
         }
     }
 }
开发者ID:r-a-y,项目名称:bp-reply-by-email,代码行数:101,代码来源:bp-rbe-extend-bpdocs.php

示例15: bp_dtheme_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_dtheme_ajax_joinleave_group()
{
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    if (groups_is_user_banned(bp_loggedin_user_id(), $_POST['gid'])) {
        return;
    }
    if (!($group = groups_get_group(array('group_id' => $_POST['gid'])))) {
        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', 'logicalboneshug');
            } else {
                echo '<a id="group-' . esc_attr($group->id) . '" class="leave-group" rel="leave" title="' . __('Leave Group', 'logicalboneshug') . '" href="' . wp_nonce_url(bp_get_group_permalink($group) . 'leave-group', 'groups_leave_group') . '">' . __('Leave Group', 'logicalboneshug') . '</a>';
            }
        } elseif ('private' == $group->status) {
            check_ajax_referer('groups_request_membership');
            if (!groups_send_membership_request(bp_loggedin_user_id(), $group->id)) {
                _e('Error requesting membership', 'logicalboneshug');
            } else {
                echo '<a id="group-' . esc_attr($group->id) . '" class="membership-requested" rel="membership-requested" title="' . __('Membership Requested', 'logicalboneshug') . '" href="' . bp_get_group_permalink($group) . '">' . __('Membership Requested', 'logicalboneshug') . '</a>';
            }
        }
    } else {
        check_ajax_referer('groups_leave_group');
        if (!groups_leave_group($group->id)) {
            _e('Error leaving group', 'logicalboneshug');
        } elseif ('public' == $group->status) {
            echo '<a id="group-' . esc_attr($group->id) . '" class="join-group" rel="join" title="' . __('Join Group', 'logicalboneshug') . '" href="' . wp_nonce_url(bp_get_group_permalink($group) . 'join', 'groups_join_group') . '">' . __('Join Group', 'logicalboneshug') . '</a>';
        } elseif ('private' == $group->status) {
            echo '<a id="group-' . esc_attr($group->id) . '" class="request-membership" rel="join" title="' . __('Request Membership', 'logicalboneshug') . '" href="' . wp_nonce_url(bp_get_group_permalink($group) . 'request-membership', 'groups_send_membership_request') . '">' . __('Request Membership', 'logicalboneshug') . '</a>';
        }
    }
    exit;
}
开发者ID:raminjan,项目名称:logicalbones_hug,代码行数:46,代码来源:ajax.php


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