本文整理汇总了PHP中groups_is_user_member函数的典型用法代码示例。如果您正苦于以下问题:PHP groups_is_user_member函数的具体用法?PHP groups_is_user_member怎么用?PHP groups_is_user_member使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了groups_is_user_member函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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]));
}
示例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;
}
示例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'));
}
}
示例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']);
}
示例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);
}
示例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');
}
}
}
}
示例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;
}
示例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' ) );
}
}
示例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);
}
示例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
}
}
示例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'));
}
}
示例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.
//.........这里部分代码省略.........
示例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;
}
示例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.
//.........这里部分代码省略.........