本文整理汇总了PHP中bp_update_is_item_admin函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_update_is_item_admin函数的具体用法?PHP bp_update_is_item_admin怎么用?PHP bp_update_is_item_admin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bp_update_is_item_admin函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: setup_globals
/**
* Set up bp-core global settings.
*
* Sets up a majority of the BuddyPress globals that require a minimal
* amount of processing, meaning they cannot be set in the BuddyPress class.
*
* @since BuddyPress (1.5.0)
*
* @see BP_Component::setup_globals() for description of parameters.
*
* @param array $args See {@link BP_Component::setup_globals()}.
*/
public function setup_globals($args = array())
{
$bp = buddypress();
/** Database **********************************************************/
// Get the base database prefix
if (empty($bp->table_prefix)) {
$bp->table_prefix = bp_core_get_table_prefix();
}
// The domain for the root of the site where the main blog resides
if (empty($bp->root_domain)) {
$bp->root_domain = bp_core_get_root_domain();
}
// Fetches all of the core BuddyPress settings in one fell swoop
if (empty($bp->site_options)) {
$bp->site_options = bp_core_get_root_options();
}
// The names of the core WordPress pages used to display BuddyPress content
if (empty($bp->pages)) {
$bp->pages = bp_core_get_directory_pages();
}
/** Basic current user data *******************************************/
// Logged in user is the 'current_user'
$current_user = wp_get_current_user();
// The user ID of the user who is currently logged in.
$bp->loggedin_user = new stdClass();
$bp->loggedin_user->id = isset($current_user->ID) ? $current_user->ID : 0;
/** Avatars ***********************************************************/
// Fetches the default Gravatar image to use if the user/group/blog has no avatar or gravatar
$bp->grav_default = new stdClass();
$bp->grav_default->user = apply_filters('bp_user_gravatar_default', $bp->site_options['avatar_default']);
$bp->grav_default->group = apply_filters('bp_group_gravatar_default', $bp->grav_default->user);
$bp->grav_default->blog = apply_filters('bp_blog_gravatar_default', $bp->grav_default->user);
// Notifications table. Included here for legacy purposes. Use
// bp-notifications instead.
$bp->core->table_name_notifications = $bp->table_prefix . 'bp_notifications';
/**
* Used to determine if user has admin rights on current content. If the
* logged in user is viewing their own profile and wants to delete
* something, is_item_admin is used. This is a generic variable so it
* can be used by other components. It can also be modified, so when
* viewing a group 'is_item_admin' would be 'true' if they are a group
* admin, and 'false' if they are not.
*/
bp_update_is_item_admin(bp_user_has_access(), 'core');
// Is the logged in user is a mod for the current item?
bp_update_is_item_mod(false, 'core');
do_action('bp_core_setup_globals');
}
开发者ID:danielcoats,项目名称:schoolpress,代码行数:60,代码来源:bp-core-loader.php
示例2: test_groups_get_group_mods_cache
/**
* @group groups_get_group_mods
*/
public function test_groups_get_group_mods_cache()
{
$u1 = $this->factory->user->create();
$u2 = $this->factory->user->create();
$g = $this->factory->group->create(array('creator_id' => $u1));
// User 2 joins the group
groups_join_group($g, $u2);
// prime cache
groups_get_group_mods($g);
// promote user 2 to an admin
bp_update_is_item_admin(true);
groups_promote_member($u2, $g, 'mod');
// assert new cached value
$this->assertEquals(1, count(groups_get_group_mods($g)));
}
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:18,代码来源:cache.php
示例3: 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
示例4: bp_activity_screen_mentions
/**
* Load the 'Mentions' activity page.
*
* @since 1.2.0
*
* @uses bp_update_is_item_admin()
* @uses bp_current_user_can()
* @uses do_action() To call the 'bp_activity_screen_mentions' hook.
* @uses bp_core_load_template()
* @uses apply_filters() To call the 'bp_activity_template_mention_activity' hook.
*/
function bp_activity_screen_mentions()
{
bp_update_is_item_admin(bp_current_user_can('bp_moderate'), 'activity');
/**
* Fires right before the loading of the "Mentions" screen template file.
*
* @since 1.2.0
*/
do_action('bp_activity_screen_mentions');
/**
* Filters the template to load for the "Mentions" screen.
*
* @since 1.2.0
*
* @param string $template Path to the activity template to load.
*/
bp_core_load_template(apply_filters('bp_activity_template_mention_activity', 'members/single/home'));
}
开发者ID:dcavins,项目名称:buddypress-svn,代码行数:29,代码来源:bp-activity-screens.php
示例5: bp_activity_screen_mentions
/**
* Activity screen 'mentions' index
*
* @since BuddyPress (1.2)
*
* @uses bp_update_is_item_admin()
* @uses bp_current_user_can()
* @uses do_action() To call the 'bp_activity_screen_mentions' hook
* @uses bp_core_load_template()
* @uses apply_filters() To call the 'bp_activity_template_mention_activity' hook
*/
function bp_activity_screen_mentions()
{
bp_update_is_item_admin(bp_current_user_can('bp_moderate'), 'activity');
do_action('bp_activity_screen_mentions');
bp_core_load_template(apply_filters('bp_activity_template_mention_activity', 'members/single/home'));
}
开发者ID:pyropictures,项目名称:wordpress-plugins,代码行数:17,代码来源:bp-activity-screens.php
示例6: bp_follow_screen_activity_following
/**
* Catches any visits to the "Activity > Following" tab on a users profile.
*
* @uses bp_core_load_template() Loads a template file.
*/
function bp_follow_screen_activity_following()
{
bp_update_is_item_admin(is_super_admin(), 'activity');
do_action('bp_activity_screen_following');
bp_core_load_template(apply_filters('bp_activity_template_following', 'members/single/home'));
}
开发者ID:vilmark,项目名称:vilmark_main,代码行数:11,代码来源:bp-follow-screens.php
示例7: setup_globals
/**
* Setup globals
*
* The BP_GROUPS_SLUG constant is deprecated, and only used here for
* backwards compatibility.
*
* @since BuddyPress (1.5)
* @global BuddyPress $bp The one true BuddyPress instance
*/
function setup_globals()
{
global $bp;
// Define a slug, if necessary
if (!defined('BP_GROUPS_SLUG')) {
define('BP_GROUPS_SLUG', $this->id);
}
// Global tables for messaging 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');
// All globals for messaging component.
// Note that global_tables is included in this array.
$globals = array('slug' => BP_GROUPS_SLUG, 'root_slug' => isset($bp->pages->groups->slug) ? $bp->pages->groups->slug : BP_GROUPS_SLUG, 'has_directory' => true, 'notification_callback' => 'groups_format_notifications', 'search_string' => __('Search Groups...', 'buddypress'), 'global_tables' => $global_tables);
parent::setup_globals($globals);
/** 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;
$current_group_class = apply_filters('bp_groups_current_group_class', 'BP_Groups_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;
}
// Set current_group to 0 to prevent debug errors
} else {
$this->current_group = 0;
}
// Illegal group names/slugs
$this->forbidden_names = apply_filters('groups_forbidden_names', array('my-groups', 'create', 'invites', 'send-invites', 'forum', 'delete', 'add', 'admin', 'request-membership', 'members', 'settings', 'avatar', $this->slug, $this->root_slug));
// If the user was attempting to access a group, but no group by that name was found, 404
if (bp_is_groups_component() && empty($this->current_group) && bp_current_action() && !in_array(bp_current_action(), $this->forbidden_names)) {
bp_do_404();
return;
}
if (bp_is_groups_component() && !empty($this->current_group)) {
$this->default_extension = apply_filters('bp_groups_default_extension', defined('BP_GROUPS_DEFAULT_EXTENSION') ? BP_GROUPS_DEFAULT_EXTENSION : 'home');
if (!bp_current_action()) {
$bp->current_action = $this->default_extension;
}
// Prepare for a redirect to the canonical URL
$bp->canonical_stack['base_url'] = bp_get_group_permalink($this->current_group);
if (bp_current_action()) {
$bp->canonical_stack['action'] = bp_current_action();
}
if (!empty($bp->action_variables)) {
$bp->canonical_stack['action_variables'] = bp_action_variables();
}
// When viewing the default extension, the canonical URL should not have
// that extension's slug, unless more has been tacked onto the URL via
// action variables
if (bp_is_current_action($this->default_extension) && empty($bp->action_variables)) {
unset($bp->canonical_stack['action']);
}
}
// Group access control
if (bp_is_groups_component() && !empty($this->current_group)) {
if (!$this->current_group->user_has_access) {
// Hidden groups should return a 404 for non-members.
//.........这里部分代码省略.........
开发者ID:adisonc,项目名称:MaineLearning,代码行数:101,代码来源:bp-groups-loader.php
示例8: setup_globals
function setup_globals()
{
global $bp;
/** Database **********************************************************/
// Get the base database prefix
if (empty($bp->table_prefix)) {
$bp->table_prefix = bp_core_get_table_prefix();
}
// The domain for the root of the site where the main blog resides
if (empty($bp->root_domain)) {
$bp->root_domain = bp_core_get_root_domain();
}
// Fetches all of the core BuddyPress settings in one fell swoop
if (empty($bp->site_options)) {
$bp->site_options = bp_core_get_root_options();
}
// The names of the core NXTClass pages used to display BuddyPress content
if (empty($bp->pages)) {
$bp->pages = bp_core_get_directory_pages();
}
/** Admin Bar *********************************************************/
// Set the 'My Account' global to prevent debug notices
$bp->my_account_menu_id = false;
/** Component and Action **********************************************/
// Used for overriding the 2nd level navigation menu so it can be used to
// display custom navigation for an item (for example a group)
$bp->is_single_item = false;
// Sets up the array container for the component navigation rendered
// by bp_get_nav()
$bp->bp_nav = array();
// Sets up the array container for the component options navigation
// rendered by bp_get_options_nav()
$bp->bp_options_nav = array();
// Contains an array of all the active components. The key is the slug,
// value the internal ID of the component.
//$bp->active_components = array();
/** Basic current user data *******************************************/
// Logged in user is the 'current_user'
$current_user = nxt_get_current_user();
// The user ID of the user who is currently logged in.
$bp->loggedin_user->id = $current_user->ID;
/** Avatars ***********************************************************/
// Fetches the default Gravatar image to use if the user/group/blog has no avatar or gravatar
$bp->grav_default->user = apply_filters('bp_user_gravatar_default', $bp->site_options['avatar_default']);
$bp->grav_default->group = apply_filters('bp_group_gravatar_default', $bp->grav_default->user);
$bp->grav_default->blog = apply_filters('bp_blog_gravatar_default', $bp->grav_default->user);
// Notifications Table
$bp->core->table_name_notifications = $bp->table_prefix . 'bp_notifications';
/**
* Used to determine if user has admin rights on current content. If the
* logged in user is viewing their own profile and wants to delete
* something, is_item_admin is used. This is a generic variable so it
* can be used by other components. It can also be modified, so when
* viewing a group 'is_item_admin' would be 'true' if they are a group
* admin, and 'false' if they are not.
*/
bp_update_is_item_admin(bp_user_has_access(), 'core');
// Is the logged in user is a mod for the current item?
bp_update_is_item_mod(false, 'core');
do_action('bp_core_setup_globals');
}
开发者ID:nxtclass,项目名称:NXTClass-Plugin,代码行数:61,代码来源:bp-core-loader.php
示例9: bp_course_my_course_activity
function bp_course_my_course_activity()
{
if (!bp_is_active('course')) {
return false;
}
bp_update_is_item_admin(bp_current_user_can('bp_moderate'), 'activity');
/**
* Fires right before the loading of the "My Groups" screen template file.
*
* @since 1.2.0
*/
do_action('bp_activity_screen_course');
/**
* Filters the template to load for the "My Groups" screen.
*
* @since 1.2.0
*
* @param string $template Path to the activity template to load.
*/
bp_core_load_template(apply_filters('bp_activity_template_course_activity', 'members/single/home'));
}
开发者ID:nikitansk,项目名称:devschool,代码行数:21,代码来源:bp-course-activity.php
注:本文中的bp_update_is_item_admin函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论