• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP groups_is_user_member函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: post_review

 function post_review($args = '')
 {
     global $bp;
     $defaults = array('content' => false, 'rating' => false, 'user_id' => $bp->loggedin_user->id, 'group_id' => $bp->groups->current_group->id);
     $r = wp_parse_args($args, $defaults);
     extract($r, EXTR_SKIP);
     if (empty($content) || !strlen(trim($content)) || empty($user_id) || empty($group_id)) {
         return false;
     }
     // Be sure the user is a member of the group before posting.
     if (!is_super_admin() && !groups_is_user_member($user_id, $group_id)) {
         return false;
     }
     // Record this in activity streams
     $activity_action = sprintf(__('%s reviewed %s:', 'bpgr'), bp_core_get_userlink($user_id), '<a href="' . bp_get_group_permalink($bp->groups->current_group) . '">' . esc_html($bp->groups->current_group->name) . '</a>');
     $rating_content = false;
     if (!empty($rating)) {
         $rating_content = '<span class="p-rating">' . bpgr_get_review_rating_html($rating) . '</span>';
     }
     $activity_content = $rating_content . $content;
     $activity_id = groups_record_activity(array('user_id' => $user_id, 'action' => $activity_action, 'content' => $activity_content, 'type' => 'review', 'item_id' => $group_id));
     $this->add_rating(array('score' => $rating, 'activity_id' => $activity_id, 'group_id' => $group_id));
     groups_update_groupmeta($group_id, 'last_activity', gmdate("Y-m-d H:i:s"));
     do_action('bpgr_posted_review', $args, $activity_id);
     return $activity_id;
 }
开发者ID:adisonc,项目名称:MaineLearning,代码行数:26,代码来源:classes.php


示例2: test_groups_is_user_member_should_return_false_when_user_is_also_banned

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


示例3: bp_em_group_event_save

/**
 * @param EM_Event $EM_Event
 */
function bp_em_group_event_save($result, $EM_Event)
{
    if (is_object($EM_Event) && !empty($EM_Event->event_id)) {
        if (!empty($_REQUEST['group_id']) && is_numeric($_REQUEST['group_id']) && bp_is_active('groups')) {
            //we have been requested an event creation tied to a group, so does this group exist, and does this person have admin rights to it?
            if (groups_is_user_admin(get_current_user_id(), $_REQUEST['group_id'])) {
                $EM_Event->group_id = $_REQUEST['group_id'];
            }
            if (!empty($EM_Event->group_id)) {
                //if group is private, make it private
                $group = groups_get_group(array('group_id' => $EM_Event->group_id));
                $is_member = groups_is_user_member(get_current_user_id(), $EM_Event->group_id) || groups_is_user_admin(get_current_user_id(), $EM_Event->group_id) || groups_is_user_mod(get_current_user_id(), $EM_Event->group_id);
                if ($group->status != 'public' && $is_member) {
                    //Make sure event status is private and set post status to private
                    global $wpdb;
                    $EM_Event->event_private = 1;
                    $wpdb->update($wpdb->posts, array('post_status' => 'private'), array('ID' => $EM_Event->post_id));
                    $wpdb->update(EM_EVENTS_TABLE, array('event_private' => 1), array('event_id' => $EM_Event->event_id));
                }
            }
        } else {
            $EM_Event->group_id = null;
        }
    }
    return $result;
}
开发者ID:pyropictures,项目名称:wordpress-plugins,代码行数:29,代码来源:bp-em-groups.php


示例4: bp_forums_directory_forums_setup

/**
 * Load the Forums directory.
 */
function bp_forums_directory_forums_setup()
{
    // Get BuddyPress once
    $bp = buddypress();
    if (bp_is_forums_component() && (!bp_current_action() || 'tag' == bp_current_action() && bp_action_variables()) && !bp_current_item()) {
        if (!bp_forums_has_directory()) {
            return false;
        }
        if (!bp_forums_is_installed_correctly()) {
            bp_core_add_message(__('The forums component has not been set up yet.', 'buddypress'), 'error');
            bp_core_redirect(bp_get_root_domain());
        }
        bp_update_is_directory(true, 'forums');
        do_action('bbpress_init');
        // Check to see if the user has posted a new topic from the forums page.
        if (isset($_POST['submit_topic']) && bp_is_active('forums')) {
            check_admin_referer('bp_forums_new_topic');
            $bp->groups->current_group = groups_get_group(array('group_id' => $_POST['topic_group_id']));
            if (!empty($bp->groups->current_group->id)) {
                // Auto join this user if they are not yet a member of this group
                if (!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);
                }
                $error_message = '';
                $forum_id = groups_get_groupmeta($bp->groups->current_group->id, 'forum_id');
                if (!empty($forum_id)) {
                    if (empty($_POST['topic_title'])) {
                        $error_message = __('Please provide a title for your forum topic.', 'buddypress');
                    } else {
                        if (empty($_POST['topic_text'])) {
                            $error_message = __('Forum posts cannot be empty. Please enter some text.', 'buddypress');
                        }
                    }
                    if ($error_message) {
                        bp_core_add_message($error_message, 'error');
                        $redirect = bp_get_group_permalink($bp->groups->current_group) . 'forum';
                    } else {
                        if (!($topic = groups_new_group_forum_topic($_POST['topic_title'], $_POST['topic_text'], $_POST['topic_tags'], $forum_id))) {
                            bp_core_add_message(__('There was an error when creating the topic', 'buddypress'), 'error');
                            $redirect = bp_get_group_permalink($bp->groups->current_group) . 'forum';
                        } else {
                            bp_core_add_message(__('The topic was created successfully', 'buddypress'));
                            $redirect = bp_get_group_permalink($bp->groups->current_group) . 'forum/topic/' . $topic->topic_slug . '/';
                        }
                    }
                    bp_core_redirect($redirect);
                } else {
                    bp_core_add_message(__('Please pick the group forum where you would like to post this topic.', 'buddypress'), 'error');
                    bp_core_redirect(add_query_arg('new', '', bp_get_forums_directory_permalink()));
                }
            } else {
                bp_core_add_message(__('Please pick the group forum where you would like to post this topic.', 'buddypress'), 'error');
                bp_core_redirect(add_query_arg('new', '', bp_get_forums_directory_permalink()));
            }
        }
        do_action('bp_forums_directory_forums_setup');
        bp_core_load_template(apply_filters('bp_forums_template_directory_forums_setup', 'forums/index'));
    }
}
开发者ID:danielcoats,项目名称:schoolpress,代码行数:62,代码来源:bp-forums-screens.php


示例5: cac_catch_group_doc_request

/**
 * 
 * @return type
 * @since 0.5
 * @version 1.2.2
 * v2, 10/5/2013
 */
function cac_catch_group_doc_request()
{
    $error = false;
    if (empty($_GET['get_group_doc'])) {
        return;
    }
    $doc_id = $_GET['get_group_doc'];
    // Check to see whether the current user has access to the doc in question
    $file_deets = explode('/', $doc_id);
    $group_id = $file_deets[0];
    $group = new BP_Groups_Group($group_id);
    $doc_name = $file_deets[1];
    if (empty($group->id)) {
        $error = array('message' => __('That group does not exist.', 'bp-group-documents'), 'redirect' => bp_get_root_domain());
    } else {
        if ($group->status != 'public') {
            // If the group is not public,
            if (!is_super_admin()) {
                //then the user must be logged in and
                // a member of the group to download the document
                if (!is_user_logged_in() || !groups_is_user_member(bp_loggedin_user_id(), $group_id)) {
                    $error = array('message' => sprintf(__('You must be a logged-in member of the group %s to access this document. If you are a member of the group, please log into the site and try again.', 'bp-group-documents'), $group->name), 'redirect' => bp_get_group_permalink($group));
                }
            }
        }
        // If we have gotten this far without an error, then the download can go through
        if (!$error) {
            $document = new BP_Group_Documents();
            $document->populate_by_file($doc_name);
            $doc_path = $document->get_path();
            clearstatcache();
            if (file_exists($doc_path)) {
                $mime_type = mime_content_type($doc_path);
                $doc_size = filesize($doc_path);
                header("Cache-Control: public, must-revalidate, post-check=0, pre-check=0");
                header("Pragma: hack");
                header("Content-Type: {$mime_type}; name='" . $file_deets[1] . "'");
                header("Content-Length: " . $doc_size);
                header('Content-Disposition: inline; filename="' . $file_deets[1] . '"');
                header("Content-Transfer-Encoding: binary");
                ob_clean();
                flush();
                readfile($doc_path);
                die;
            } else {
                // File does not exist
                $error = array('message' => _e('The file could not be found.', 'bp-group-documents'), 'redirect' => bp_get_group_permalink($group) . 'documents');
            }
        }
    }
    // If we have gotten this far, there was an error. Add a message and redirect
    bp_core_add_message($error['message'], 'error');
    bp_core_redirect($error['redirect']);
}
开发者ID:lilarock3rs,项目名称:bp-group-documents,代码行数:61,代码来源:filters.php


示例6: __construct

 /**
  * Here you can see more customization of the config options
  */
 function __construct()
 {
     global $buddyforms, $buddyforms_user_can;
     $buddyforms_pig = get_option('buddyforms_pig_options');
     $this->post_in_group_form_slug = groups_get_groupmeta(bp_get_current_group_id(), '_bf_pig_form_slug', true);
     $this->buddyforms_pig = groups_get_groupmeta(bp_get_current_group_id(), '_buddyforms_pig', true);
     $buddyforms_user_can = false;
     //$this->enable_create_step       = false;
     $form_slug = $this->post_in_group_form_slug;
     $name = $buddyforms[$form_slug]['name'];
     if (isset($this->buddyforms_pig['create'])) {
         switch ($this->buddyforms_pig['create']) {
             case 'admin':
                 if (groups_is_user_admin(bp_loggedin_user_id(), bp_get_current_group_id())) {
                     $buddyforms_user_can = true;
                 }
                 break;
             case 'mod':
                 if (groups_is_user_mod(bp_loggedin_user_id(), bp_get_current_group_id()) || groups_is_user_admin(bp_loggedin_user_id(), bp_get_current_group_id())) {
                     $buddyforms_user_can = true;
                 }
                 break;
             case 'member':
             default:
                 if (groups_is_user_member(bp_loggedin_user_id(), bp_get_current_group_id())) {
                     $buddyforms_user_can = true;
                 }
                 break;
         }
     }
     $args = array('slug' => $form_slug, 'name' => $name);
     switch ($buddyforms_pig['permission']) {
         case 'all':
             add_action('bp_after_group_settings_admin', array($this, 'bp_pig_after_group_manage_members_admin'), 1, 1);
             add_action('groups_group_settings_edited', array($this, 'bf_pig_groups_group_settings_edited'), 10, 1);
             add_action('bp_after_group_settings_creation_step', array($this, 'bp_pig_after_group_manage_members_admin'), 1, 1);
             add_action('groups_create_group_step_save_group-settings', array($this, 'bf_pig_groups_group_settings_edited'), 10, 1);
             break;
         case 'group-admin':
             add_action('bp_after_group_settings_admin', array($this, 'bp_pig_after_group_manage_members_admin'), 1, 1);
             add_action('groups_group_settings_edited', array($this, 'bf_pig_groups_group_settings_edited'), 10, 1);
             break;
         case 'admin':
             if (is_super_admin()) {
                 add_action('bp_after_group_settings_admin', array($this, 'bp_pig_after_group_manage_members_admin'), 1, 1);
                 add_action('groups_group_settings_edited', array($this, 'bf_pig_groups_group_settings_edited'), 10, 1);
             }
             break;
     }
     parent::init($args);
 }
开发者ID:BuddyForms,项目名称:BuddyForms-Post-in-Groups,代码行数:54,代码来源:buddyforms-post-in-groups.php


示例7: bp_checkins_single_place_check_access

function bp_checkins_single_place_check_access()
{
    if (bp_checkins_if_single_place()) {
        global $wp_query, $bp;
        $redirect = bp_get_checkins_places_home();
        $check_places = wp_cache_get('single_query', 'bp_checkins_single');
        if (false === $check_places) {
            $check_places = new BP_Checkins_Place();
            $check_places->get(array('p' => bp_action_variable(0)));
        }
        $place_id = $check_places->query->post->ID;
        if (empty($place_id)) {
            bp_core_add_message(__('OOps, looks like this place does not exist ! You can try to search for it or browse categories', 'bp-checkins'), 'error');
            bp_core_redirect($redirect);
        } else {
            if (bp_is_active('groups')) {
                // 1. check for group access !!
                $group_id = get_post_meta($place_id, '_bpci_group_id', true);
                $bp->groups->current_group = new BP_Groups_Group($group_id);
                if (isset($bp->groups->current_group->status) && 'public' != $bp->groups->current_group->status) {
                    if (!is_user_logged_in() || !groups_is_user_member($bp->loggedin_user->id, $group_id)) {
                        bp_core_add_message(__('OOps, looks like this place is private ! You can try to search for another one or browse categories', 'bp-checkins'), 'error');
                        bp_core_redirect($redirect);
                    }
                }
            }
            // 2. check for live type to load the timer on the client side !
            if ("live" == get_post_meta($place_id, 'bpci_places_is_live', true)) {
                $start = get_post_meta($place_id, 'bpci_places_live_start', true);
                $end = get_post_meta($place_id, 'bpci_places_live_end', true);
                $start = strtotime($start);
                $end = strtotime($end);
                $now = current_time('timestamp');
                if ($end >= $now && $now >= $start) {
                    add_filter('bp_get_the_body_class', 'bp_checkins_body_class_is_live');
                }
            }
            add_filter('bp_get_the_body_class', 'bp_checkins_body_class_is_single_place');
            // 3. Check for notifications
            if (isset($_GET['n'])) {
                bp_core_delete_notifications_by_item_id($bp->loggedin_user->id, $place_id, 'checkins', 'new_comment');
            }
        }
    }
}
开发者ID:socialray,项目名称:surfied-2-0,代码行数:45,代码来源:bp-checkins-actions.php


示例8: rw_bp_doc_single_group_id

/**
 * copied from boss  theme functions because of code error
 *
 * @return int
 */
function rw_bp_doc_single_group_id($return_dummy = true)
{
    $group_id = false;
    if (function_exists('bp_is_active') && bp_is_active('groups')) {
        if (bp_docs_is_doc_create()) {
            $group_slug = isset($_GET['group']) ? $_GET['group'] : '';
            if ($group_slug) {
                global $bp, $wpdb;
                $group_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM {$bp->groups->table_name} WHERE slug=%s", $group_slug));
            }
            if (!$group_id) {
                if ($return_dummy) {
                    $group_id = 99999999;
                }
            }
            return $group_id;
        }
        $doc_group_ids = bp_docs_get_associated_group_id(get_the_ID(), false, true);
        $doc_groups = array();
        foreach ($doc_group_ids as $dgid) {
            $maybe_group = groups_get_group($dgid);
            // since buddypress 2.7 param should be integer
            // Don't show hidden groups if the
            // current user is not a member
            if (isset($maybe_group->status) && 'hidden' === $maybe_group->status) {
                // @todo this is slow
                if (!current_user_can('bp_moderate') && !groups_is_user_member(bp_loggedin_user_id(), $dgid)) {
                    continue;
                }
            }
            if (!empty($maybe_group->name)) {
                $doc_groups[] = $dgid;
            }
        }
        if (!empty($doc_groups) && count($doc_groups) == 1) {
            $group_id = $doc_groups[0];
        }
    }
    if (!$group_id) {
        if ($return_dummy) {
            $group_id = 99999999;
        }
    }
    return $group_id;
}
开发者ID:rpi-virtuell,项目名称:rw-social-learner,代码行数:50,代码来源:rw_functions.php


示例9: bp_forums_directory_forums_setup

function bp_forums_directory_forums_setup() {
	global $bp;

	if ( $bp->current_component == $bp->forums->slug ) {
		if ( (int) $bp->site_options['bp-disable-forum-directory'] || !function_exists( 'groups_install' ) )
			return false;

		if ( !bp_forums_is_installed_correctly() ) {
			bp_core_add_message( __( 'The forums component has not been set up yet.', 'buddypress' ), 'error' );
			bp_core_redirect( $bp->root_domain );
		}

		$bp->is_directory = true;

		do_action( 'bbpress_init' );

		/* Check to see if the user has posted a new topic from the forums page. */
		if ( isset( $_POST['submit_topic'] ) && function_exists( 'bp_forums_new_topic' ) ) {
			/* Check the nonce */
			check_admin_referer( 'bp_forums_new_topic' );

			if ( $bp->groups->current_group = groups_get_group( array( 'group_id' => $_POST['topic_group_id'] ) ) ) {
				/* Auto join this user if they are not yet a member of this group */
				if ( !is_super_admin() && '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->groups->current_group->id );

				if ( $forum_id = groups_get_groupmeta( $bp->groups->current_group->id, 'forum_id' ) ) {
					if ( !$topic = groups_new_group_forum_topic( $_POST['topic_title'], $_POST['topic_text'], $_POST['topic_tags'], $forum_id ) )
						bp_core_add_message( __( 'There was an error when creating the topic', 'buddypress'), 'error' );
					else
						bp_core_add_message( __( 'The topic was created successfully', 'buddypress') );

					bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic->topic_slug . '/' );
				} else {
					bp_core_add_message( __( 'Please pick the group forum where you would like to post this topic.', 'buddypress' ), 'error' );
				}
			}
		}

		do_action( 'bp_forums_directory_forums_setup' );

		bp_core_load_template( apply_filters( 'bp_forums_template_directory_forums_setup', 'forums/index' ) );
	}
}
开发者ID:n-sane,项目名称:zaroka,代码行数:44,代码来源:bp-forums.php


示例10: group_activity_subscription

 function group_activity_subscription()
 {
     $this->name = __('Email Options', 'bp-ass');
     $this->slug = 'notifications';
     // Only enable the notifications nav item if the user is a member of the group
     if (bp_is_group() && groups_is_user_member(bp_loggedin_user_id(), bp_get_current_group_id())) {
         $this->enable_nav_item = true;
     } else {
         $this->enable_nav_item = false;
     }
     $this->nav_item_position = 91;
     $this->enable_create_step = false;
     if (get_option('ass-admin-can-send-email') == 'no') {
         $this->enable_edit_item = false;
     }
     // hook in the css and js
     add_action('wp_print_styles', array(&$this, 'add_settings_stylesheet'));
     add_action('wp_enqueue_scripts', array(&$this, 'ass_add_javascript'), 1);
 }
开发者ID:adisonc,项目名称:MaineLearning,代码行数:19,代码来源:bp-activity-subscription-main.php


示例11: display

    function display()
    {
        global $bp, $wpmudev_chat;
        if (groups_is_user_member($bp->loggedin_user->id, $bp->groups->current_group->id)) {
            $chat_id = 'bp-group-' . $bp->groups->current_group->id;
            //echo "chat_id=[". $chat_id ."]<br />";
            $atts = groups_get_groupmeta($bp->groups->current_group->id, self::settings_slug);
            if (empty($atts)) {
                $atts = array('id' => $chat_id, 'session_type' => 'bp-group', 'box_input_position' => 'top', 'box-width' => '100%', 'users_list_show' => 'avatar', 'users_list_position' => 'right', 'users_list_width' => '30%', 'users_list_avatar_width' => '50');
            }
            // We changed the key because it was too long for the wp_options optin_name field
            if (!isset($atts['id']) || $atts['id'] != $chat_id) {
                $atts['id'] = $chat_id;
            }
            echo $wpmudev_chat->process_chat_shortcode($atts);
        } else {
            ?>
<p><?php 
            _e('You must be a member of this group to use Chat', $wpmudev_chat->translation_domain);
            ?>
</p><?php 
        }
    }
开发者ID:novichkovv,项目名称:candoweightloss,代码行数:23,代码来源:wpmudec_chat_buddypress_group_1.8.php


示例12: view_single

 public function view_single()
 {
     $bp = buddypress();
     if (function_exists('bp_is_group') && !bp_is_group()) {
         return;
     }
     //do not catch the request for creating new post
     if (bp_is_action_variable('create', 0)) {
         return;
     }
     $current_group = groups_get_current_group();
     if (bcg_is_disabled($current_group->id)) {
         return;
     }
     //if the group is private/hidden and user is not member, return
     if (($current_group->status == 'private' || $current_group->status == 'hidden') && (!is_user_logged_in() || !groups_is_user_member(bp_loggedin_user_id(), $current_group->id))) {
         return;
         //avoid prioivacy troubles
     }
     if (bcg_is_component() && !empty($bp->action_variables[0])) {
         //should we check for the existence of the post?
         add_action('bp_template_content', array($this, 'get_single_post_contents'));
     }
 }
开发者ID:WP--plugins,项目名称:blog-categories-for-groups,代码行数:24,代码来源:bcg-screens.php


示例13: setup_globals

 /**
  * Set up component global data.
  *
  * The BP_GROUPS_SLUG constant is deprecated, and only used here for
  * backwards compatibility.
  *
  * @since 1.5.0
  *
  * @see BP_Component::setup_globals() for a description of arguments.
  *
  * @param array $args See BP_Component::setup_globals() for a description.
  */
 public function setup_globals($args = array())
 {
     $bp = buddypress();
     // Define a slug, if necessary.
     if (!defined('BP_GROUPS_SLUG')) {
         define('BP_GROUPS_SLUG', $this->id);
     }
     // Global tables for groups component.
     $global_tables = array('table_name' => $bp->table_prefix . 'bp_groups', 'table_name_members' => $bp->table_prefix . 'bp_groups_members', 'table_name_groupmeta' => $bp->table_prefix . 'bp_groups_groupmeta');
     // Metadata tables for groups component.
     $meta_tables = array('group' => $bp->table_prefix . 'bp_groups_groupmeta');
     // All globals for groups component.
     // Note that global_tables is included in this array.
     $args = array('slug' => BP_GROUPS_SLUG, 'root_slug' => isset($bp->pages->groups->slug) ? $bp->pages->groups->slug : BP_GROUPS_SLUG, 'has_directory' => true, 'directory_title' => _x('Groups', 'component directory title', 'buddypress'), 'notification_callback' => 'groups_format_notifications', 'search_string' => _x('Search Groups...', 'Component directory search', 'buddypress'), 'global_tables' => $global_tables, 'meta_tables' => $meta_tables);
     parent::setup_globals($args);
     /* Single Group Globals **********************************************/
     // Are we viewing a single group?
     if (bp_is_groups_component() && ($group_id = BP_Groups_Group::group_exists(bp_current_action()))) {
         $bp->is_single_item = true;
         /**
          * Filters the current PHP Class being used.
          *
          * @since 1.5.0
          *
          * @param string $value Name of the class being used.
          */
         $current_group_class = apply_filters('bp_groups_current_group_class', 'BP_Groups_Group');
         if ($current_group_class == 'BP_Groups_Group') {
             $this->current_group = groups_get_group(array('group_id' => $group_id, 'populate_extras' => true));
         } else {
             /**
              * Filters the current group object being instantiated from previous filter.
              *
              * @since 1.5.0
              *
              * @param object $value Newly instantiated object for the group.
              */
             $this->current_group = apply_filters('bp_groups_current_group_object', new $current_group_class($group_id));
         }
         // 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_variable(0);
         array_shift($bp->action_variables);
         // Using "item" not "group" for generic support in other components.
         if (bp_current_user_can('bp_moderate')) {
             bp_update_is_item_admin(true, 'groups');
         } else {
             bp_update_is_item_admin(groups_is_user_admin(bp_loggedin_user_id(), $this->current_group->id), 'groups');
         }
         // If the user is not an admin, check if they are a moderator.
         if (!bp_is_item_admin()) {
             bp_update_is_item_mod(groups_is_user_mod(bp_loggedin_user_id(), $this->current_group->id), 'groups');
         }
         // Is the logged in user a member of the group?
         if (is_user_logged_in() && groups_is_user_member(bp_loggedin_user_id(), $this->current_group->id)) {
             $this->current_group->is_user_member = true;
         } else {
             $this->current_group->is_user_member = false;
         }
         // Should this group be visible to the logged in user?
         if ('public' == $this->current_group->status || $this->current_group->is_user_member) {
             $this->current_group->is_visible = true;
         } else {
             $this->current_group->is_visible = false;
         }
         // If this is a private or hidden group, does the user have access?
         if ('private' == $this->current_group->status || 'hidden' == $this->current_group->status) {
             if ($this->current_group->is_user_member && is_user_logged_in() || bp_current_user_can('bp_moderate')) {
                 $this->current_group->user_has_access = true;
             } else {
                 $this->current_group->user_has_access = false;
             }
         } else {
             $this->current_group->user_has_access = true;
         }
         // Check once if the current group has a custom front template.
         $this->current_group->front_template = bp_groups_get_front_template($this->current_group);
         // Set current_group to 0 to prevent debug errors.
     } else {
         $this->current_group = 0;
     }
     /**
      * Filters the list of illegal groups names/slugs.
      *
      * @since 1.0.0
      *
      * @param array $value Array of illegal group names/slugs.
//.........这里部分代码省略.........
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:101,代码来源:bp-groups-loader.php


示例14: can_user_create_album_in_group

/**
 *
 * @param type $group_id
 * @param type $user_id
 *
 * @return boolean
 */
function can_user_create_album_in_group($group_id = false, $user_id = false)
{
    if ($group_id == false) {
        $group = groups_get_current_group();
        $group_id = $group->id;
    }
    $upload_level = groups_get_groupmeta($group_id, "rt_media_group_control_level");
    if (empty($upload_level)) {
        $upload_level = groups_get_groupmeta($group_id, "bp_media_group_control_level");
        if (empty($upload_level)) {
            $upload_level = "all";
        }
    }
    $user_id = get_current_user_id();
    $display_flag = false;
    if (groups_is_user_member($user_id, $group_id)) {
        if ($upload_level == "admin") {
            if (groups_is_user_admin($user_id, $group_id) > 0) {
                $display_flag = true;
            }
        } else {
            if ($upload_level == "moderators") {
                if (groups_is_user_mod($user_id, $group_id) || groups_is_user_admin($user_id, $group_id)) {
                    $display_flag = true;
                }
            } else {
                $display_flag = true;
            }
        }
    }
    $display_flag = apply_filters('can_user_create_album_in_group', $display_flag);
    return $display_flag;
}
开发者ID:EfncoPlugins,项目名称:rtMedia,代码行数:40,代码来源:rt-template-functions.php


示例15: bp_activity_screen_single_activity_permalink

/**
 * Load the page for a single activity item.
 *
 * @since 1.2.0
 *
 * @uses bp_is_activity_component()
 * @uses bp_activity_get_specific()
 * @uses bp_current_action()
 * @uses bp_action_variables()
 * @uses bp_do_404()
 * @uses bp_is_active()
 * @uses groups_get_group()
 * @uses groups_is_user_member()
 * @uses apply_filters_ref_array() To call the 'bp_activity_permalink_access' hook.
 * @uses do_action() To call the 'bp_activity_screen_single_activity_permalink' hook.
 * @uses bp_core_add_message()
 * @uses is_user_logged_in()
 * @uses bp_core_redirect()
 * @uses site_url()
 * @uses esc_url()
 * @uses bp_get_root_domain()
 * @uses bp_get_activity_root_slug()
 * @uses bp_core_load_template()
 * @uses apply_filters() To call the 'bp_activity_template_profile_activity_permalink' hook.
 */
function bp_activity_screen_single_activity_permalink()
{
    $bp = buddypress();
    // No displayed user or not viewing activity component.
    if (!bp_is_activity_component()) {
        return false;
    }
    if (!bp_current_action() || !is_numeric(bp_current_action())) {
        return false;
    }
    // Get the activity details.
    $activity = bp_activity_get_specific(array('activity_ids' => bp_current_action(), 'show_hidden' => true, 'spam' => 'ham_only'));
    // 404 if activity does not exist
    if (empty($activity['activities'][0]) || bp_action_variables()) {
        bp_do_404();
        return;
    } else {
        $activity = $activity['activities'][0];
    }
    // Default access is true.
    $has_access = true;
    // If activity is from a group, do an extra cap check.
    if (isset($bp->groups->id) && $activity->component == $bp->groups->id) {
        // Activity is from a group, but groups is currently disabled.
        if (!bp_is_active('groups')) {
            bp_do_404();
            return;
        }
        // Check to see if the group is not public, if so, check the
        // user has access to see this activity.
        if ($group = groups_get_group(array('group_id' => $activity->item_id))) {
            // Group is not public.
            if ('public' != $group->status) {
                // User is not a member of group.
                if (!groups_is_user_member(bp_loggedin_user_id(), $group->id)) {
                    $has_access = false;
                }
            }
        }
    }
    /**
     * Filters the access permission for a single activity view.
     *
     * @since 1.2.0
     *
     * @param array $access Array holding the current $has_access value and current activity item instance.
     */
    $has_access = apply_filters_ref_array('bp_activity_permalink_access', array($has_access, &$activity));
    /**
     * Fires before the loading of a single activity template file.
     *
     * @since 1.2.0
     *
     * @param BP_Activity_Activity $activity   Object representing the current activity item being displayed.
     * @param bool                 $has_access Whether or not the current user has access to view activity.
     */
    do_action('bp_activity_screen_single_activity_permalink', $activity, $has_access);
    // Access is specifically disallowed.
    if (false === $has_access) {
        // User feedback.
        bp_core_add_message(__('You do not have access to this activity.', 'buddypress'), 'error');
        // Redirect based on logged in status.
        if (is_user_logged_in()) {
            $url = bp_loggedin_user_domain();
        } else {
            $url = sprintf(site_url('wp-login.php?redirect_to=%s'), urlencode(esc_url_raw(bp_activity_get_permalink((int) bp_current_action()))));
        }
        bp_core_redirect($url);
    }
    /**
     * Filters the template to load for a single activity screen.
     *
     * @since 1.0.0
     *
     * @param string $template Path to the activity template to load.
//.........这里部分代码省略.........
开发者ID:dcavins,项目名称:buddypress-svn,代码行数:101,代码来源:bp-activity-screens.php


示例16: buddydrive_open_buddyfolder

/**
 * Opens a folder and list the files attach to it depending on its privacy
 *
 * @uses buddydrive_get_buddyfile() to get the folder
 * @uses buddydrive_get_folder_post_type() to get the folder post type
 * @uses bp_is_active() to check if friends or groups components are actives
 * @uses friends_check_friendship() to check if current user is a friend of the folder owner
 * @uses groups_is_user_member() to check if the user is a member of the group the folder is attached to
 * @uses buddydrive_get_template() to get the template for bp-default or any theme
 * @return string the list of files
 */
function buddydrive_open_buddyfolder()
{
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    $buddyfolder_id = $_POST['folder'];
    $buddyfolder = buddydrive_get_buddyfile($buddyfolder_id, buddydrive_get_folder_post_type());
    $result = array();
    $access = false;
    $buddyscope = $_POST['scope'];
    if (empty($buddyfolder->ID)) {
        $result[] = '<tr id="no-buddyitems"><td colspan="5"><div id="message" class="info"><p>' . __('Sorry, this folder does not exist anymore.', 'buddydrive') . '</p></div></td></tr>';
    } else {
        switch ($buddyfolder->check_for) {
            case 'private':
                $access = $buddyfolder->user_id == bp_loggedin_user_id() ? true : false;
                break;
            case 'public':
                $access = true;
                break;
            case 'password':
                $access = true;
                break;
            case 'friends':
                if (bp_is_active('friends') && friends_check_friendship($buddyfolder->user_id, bp_loggedin_user_id()) || $buddyfolder->user_id == bp_loggedin_user_id()) {
                    $access = true;
                } else {
                    $access = false;
                }
                break;
            case 'groups':
                if (bp_is_active('groups') && groups_is_user_member(bp_loggedin_user_id(), intval($buddyfolder->group))) {
                    $access = true;
                } else {
                    if ($buddyfolder->user_id == bp_loggedin_user_id()) {
                        $access = true;
                    } else {
                        if (is_super_admin()) {
                            $access = true;
                        } else {
                            $access = false;
                        }
                    }
                }
                break;
        }
        if (!empty($access) || bp_current_user_can('bp_moderate')) {
            ob_start();
            bp_get_template_part('buddydrive-loop');
            $result[] = ob_get_contents();
            ob_end_clean();
        } else {
            $result[] = '<tr id="no-access"><td colspan="5"><div id="message" class="info"><p>' . __('Sorry, this folder is private', 'buddydrive') . '</p></div></td></tr>';
        }
        $name_required = !empty($_POST['foldername']) ? 1 : 0;
        if (!empty($name_required)) {
            $result[] = $buddyfolder->title;
        }
    }
    echo json_encode($result);
    die;
}
开发者ID:MrVibe,项目名称:buddydrive,代码行数:74,代码来源:buddydrive-item-ajax.php


示例17: groups_screen_group_forum

/**
 * This screen function handles actions related to group forums.
 */
function groups_screen_group_forum()
{
    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;
    }
    $bp = buddypress();
    if (!$bp->groups->current_group->user_has_access) {
        bp_core_no_access();
        return;
    }
    if (!bp_is_single_item()) {
        return false;
    }
    // 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;
            // Don't allow reply flooding.
            if (bp_forums_reply_exists($_POST['reply_text'], $topic_id, bp_loggedin_user_id())) {
                bp_core_add_message(__('It looks like you\'ve already said that!', 'buddypress'), 'error');
            } else {
                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'));
                }
            }
            $query_vars = isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '';
            $redirect = bp_get_group_permalink(groups_get_current_group()) . 'forum/topic/' . $topic_slug . '/' . $query_vars;
            if (!empty($post_id)) {
                $redirect .= '#post-' . $post_id;
            }
            bp_core_redirect($redirect);
        } elseif (bp_is_action_variable('stick', 2) && (bp_is_item_admin() || 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'));
            }
            /**
             * Fires after a group forum topic has been stickied.
             *
             * @since 1.1.0
             *
             * @param int $topic_id ID of the topic being stickied.
             */
            do_action('groups_stick_forum_topic', $topic_id);
            bp_core_redirect(wp_get_referer());
        } elseif (bp_is_action_variable('unstick', 2) &&a 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP groups_is_user_mod函数代码示例发布时间:2022-05-15
下一篇:
PHP groups_is_user_banned函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap