本文整理汇总了PHP中bp_is_item_admin函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_is_item_admin函数的具体用法?PHP bp_is_item_admin怎么用?PHP bp_is_item_admin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bp_is_item_admin函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bp_groups_group_access_protection
/**
* Protect access to single groups.
*
* @since BuddyPress (2.1.0)
*/
function bp_groups_group_access_protection()
{
if (!bp_is_group()) {
return;
}
$current_group = groups_get_current_group();
$user_has_access = $current_group->user_has_access;
$no_access_args = array();
if (!$user_has_access && 'hidden' !== $current_group->status) {
// Always allow access to home and request-membership
if (bp_is_current_action('home') || bp_is_current_action('request-membership')) {
$user_has_access = true;
// User doesn't have access, so set up redirect args
} else {
if (is_user_logged_in()) {
$no_access_args = array('message' => __('You do not have access to this group.', 'buddypress'), 'root' => bp_get_group_permalink($current_group) . 'home/', 'redirect' => false);
}
}
}
// Protect the admin tab from non-admins
if (bp_is_current_action('admin') && !bp_is_item_admin()) {
$user_has_access = false;
$no_access_args = array('message' => __('You are not an admin of this group.', 'buddypress'), 'root' => bp_get_group_permalink($current_group), 'redirect' => false);
}
/**
* Allow plugins to filter whether the current user has access to this group content.
*
* Note that if a plugin sets $user_has_access to false, it may also
* want to change the $no_access_args, to avoid problems such as
* logged-in users being redirected to wp-login.php.
*
* @since BuddyPress (2.1.0)
*
* @param bool $user_has_access True if the user has access to the
* content, otherwise false.
* @param array $no_access_args Arguments to be passed to
* bp_core_no_access() in case of no access. Note that this
* value is passed by reference, so it can be modified by the
* filter callback.
*/
$user_has_access = apply_filters_ref_array('bp_group_user_has_access', array($user_has_access, &$no_access_args));
// If user has access, we return rather than redirect
if ($user_has_access) {
return;
}
// Hidden groups should return a 404 for non-members.
// Unset the current group so that you're not redirected
// to the default group tab
if ('hidden' == $current_group->status) {
buddypress()->groups->current_group = 0;
buddypress()->is_single_item = false;
bp_do_404();
return;
} else {
bp_core_no_access($no_access_args);
}
}
示例2: bp_groups_adminbar_admin_menu
/**
* Add menu items to the BuddyBar.
*
* @since BuddyPress (1.0.0)
*
* @global BuddyPress $bp
*/
function bp_groups_adminbar_admin_menu()
{
global $bp;
if (empty($bp->groups->current_group)) {
return false;
}
// Only group admins and site admins can see this menu
if (!current_user_can('edit_users') && !bp_current_user_can('bp_moderate') && !bp_is_item_admin()) {
return false;
}
?>
<li id="bp-adminbar-adminoptions-menu">
<a href="<?php
bp_groups_action_link('admin');
?>
"><?php
_e('Admin Options', 'buddypress');
?>
</a>
<ul>
<li><a href="<?php
bp_groups_action_link('admin/edit-details');
?>
"><?php
_e('Edit Details', 'buddypress');
?>
</a></li>
<li><a href="<?php
bp_groups_action_link('admin/group-settings');
?>
"><?php
_e('Group Settings', 'buddypress');
?>
</a></li>
<?php
if (!(int) bp_get_option('bp-disable-avatar-uploads')) {
?>
<li><a href="<?php
bp_groups_action_link('admin/group-avatar');
?>
"><?php
_e('Group Avatar', 'buddypress');
?>
</a></li>
<?php
}
?>
<?php
if (bp_is_active('friends')) {
?>
<li><a href="<?php
bp_groups_action_link('send-invites');
?>
"><?php
_e('Manage Invitations', 'buddypress');
?>
</a></li>
<?php
}
?>
<li><a href="<?php
bp_groups_action_link('admin/manage-members');
?>
"><?php
_e('Manage Members', 'buddypress');
?>
</a></li>
<?php
if ($bp->groups->current_group->status == 'private') {
?>
<li><a href="<?php
bp_groups_action_link('admin/membership-requests');
?>
"><?php
_e('Membership Requests', 'buddypress');
?>
</a></li>
<?php
}
?>
//.........这里部分代码省略.........
示例3: groups_remove_member
function groups_remove_member($user_id, $group_id)
{
if (!bp_is_item_admin()) {
return false;
}
$member = new BP_Groups_Member($user_id, $group_id);
do_action('groups_remove_member', $group_id, $user_id);
return $member->remove();
}
示例4: topic_row_actions
/**
* Add topic row action HTML when viewing group forum admin
*
* @since bbPress (r3653)
* @uses bp_is_item_admin()
* @uses bbp_get_forum_id()
*/
public function topic_row_actions()
{
// Only admins can take actions on forums
if (is_super_admin() || current_user_can('moderate') || bp_is_item_admin() || bp_is_item_mod()) {
?>
<div class="row-actions">
<?php
echo 'Edit | View | Trash | Close | Stick (To Front) | Spam';
?>
</div>
<?php
}
}
示例5: groups_remove_member
/**
* Remove a member from a group.
*
* @param int $user_id ID of the user.
* @param int $group_id ID of the group.
*
* @return bool True on success, false on failure.
*/
function groups_remove_member($user_id, $group_id)
{
if (!bp_is_item_admin()) {
// bp_is_item_admin may not be set if this function is called outside of group context.
// Site admins and group admins can remove a member from a group.
// A member may also request to remove herself from a group.
if (!current_user_can('bp_moderate') && !groups_is_user_admin(bp_loggedin_user_id(), $group_id) && $user_id != bp_loggedin_user_id()) {
return false;
}
}
$member = new BP_Groups_Member($user_id, $group_id);
/**
* Fires before the removal of a member from a group.
*
* @since 1.2.6
*
* @param int $group_id ID of the group being removed from.
* @param int $user_id ID of the user being removed.
*/
do_action('groups_remove_member', $group_id, $user_id);
return $member->remove();
}
示例6: bp_get_the_topic_admin_links
/**
* Return the admin links for the current topic in the loop.
*
* @param array $args {
* @type string $seperator The character to use when separating
* links. Default: '|'.
* }
* @return HTML string containing the admin links for the current topic.
*/
function bp_get_the_topic_admin_links($args = '')
{
global $forum_template;
$defaults = array('seperator' => '|');
$r = wp_parse_args($args, $defaults);
extract($r, EXTR_SKIP);
$links[] = '<a href="' . wp_nonce_url(bp_get_the_topic_permalink() . 'edit', 'bp_forums_edit_topic') . '">' . __('Edit Topic', 'buddypress') . '</a>';
if (bp_is_item_admin() || bp_is_item_mod() || bp_current_user_can('bp_moderate')) {
if (0 == (int) $forum_template->topic->topic_sticky) {
$links[] = '<a href="' . wp_nonce_url(bp_get_the_topic_permalink() . 'stick', 'bp_forums_stick_topic') . '">' . __('Sticky Topic', 'buddypress') . '</a>';
} else {
$links[] = '<a href="' . wp_nonce_url(bp_get_the_topic_permalink() . 'unstick', 'bp_forums_unstick_topic') . '">' . __('Un-stick Topic', 'buddypress') . '</a>';
}
if (0 == (int) $forum_template->topic->topic_open) {
$links[] = '<a href="' . wp_nonce_url(bp_get_the_topic_permalink() . 'open', 'bp_forums_open_topic') . '">' . __('Open Topic', 'buddypress') . '</a>';
} else {
$links[] = '<a href="' . wp_nonce_url(bp_get_the_topic_permalink() . 'close', 'bp_forums_close_topic') . '">' . __('Close Topic', 'buddypress') . '</a>';
}
$links[] = '<a class="confirm" id="topic-delete-link" href="' . wp_nonce_url(bp_get_the_topic_permalink() . 'delete', 'bp_forums_delete_topic') . '">' . __('Delete Topic', 'buddypress') . '</a>';
}
return implode(' ' . $seperator . ' ', (array) $links);
}
示例7: bp_attachments_current_user_can
/**
* Check the current user's capability to edit an avatar for a given object.
*
* @since 2.3.0
*
* @param string $capability The capability to check.
* @param array $args An array containing the item_id and the object to check.
*
* @return bool
*/
function bp_attachments_current_user_can($capability, $args = array())
{
$can = false;
if ('edit_avatar' === $capability || 'edit_cover_image' === $capability) {
/**
* Needed avatar arguments are set.
*/
if (isset($args['item_id']) && isset($args['object'])) {
// Group profile photo
if (bp_is_active('groups') && 'group' === $args['object']) {
if (bp_is_group_create()) {
$can = (bool) groups_is_user_creator(bp_loggedin_user_id(), $args['item_id']) || bp_current_user_can('bp_moderate');
} else {
$can = (bool) groups_is_user_admin(bp_loggedin_user_id(), $args['item_id']) || bp_current_user_can('bp_moderate');
}
// User profile photo
} elseif (bp_is_active('xprofile') && 'user' === $args['object']) {
$can = bp_loggedin_user_id() === (int) $args['item_id'] || bp_current_user_can('bp_moderate');
}
/**
* No avatar arguments, fallback to bp_user_can_create_groups()
* or bp_is_item_admin()
*/
} else {
if (bp_is_group_create()) {
$can = bp_user_can_create_groups();
} else {
$can = bp_is_item_admin();
}
}
}
return apply_filters('bp_attachments_current_user_can', $can, $capability, $args);
}
示例8: bp_link_is_admin
function bp_link_is_admin()
{
return true === bp_is_item_admin() || true === bp_links_is_admin();
}
示例9: bp_activity_user_can_delete
/**
* Determine if the current user can delete an activity item.
*
* @since BuddyPress (1.2.0)
*
* @global object $activities_template {@link BP_Activity_Template}
* @uses apply_filters() To call the 'bp_activity_user_can_delete' hook
*
* @param object $activity Optional. Falls back on the current item in the loop.
* @return bool True if can delete, false otherwise.
*/
function bp_activity_user_can_delete($activity = false)
{
global $activities_template;
// Try to use current activity if none was passed
if (empty($activity) && !empty($activities_template->activity)) {
$activity = $activities_template->activity;
}
// If current_comment is set, we'll use that in place of the main activity
if (isset($activity->current_comment)) {
$activity = $activity->current_comment;
}
// Assume the user cannot delete the activity item
$can_delete = false;
// Only logged in users can delete activity
if (is_user_logged_in()) {
// Community moderators can always delete activity (at least for now)
if (bp_current_user_can('bp_moderate')) {
$can_delete = true;
}
// Users are allowed to delete their own activity. This is actually
// quite powerful, because doing so also deletes all comments to that
// activity item. We should revisit this eventually.
if (isset($activity->user_id) && (int) $activity->user_id === bp_loggedin_user_id()) {
$can_delete = true;
}
// Viewing a single item, and this user is an admin of that item
if (bp_is_single_item() && bp_is_item_admin()) {
$can_delete = true;
}
}
/**
* Filters whether the current user can delete an activity item.
*
* @since BuddyPress (1.5.0)
*
* @param bool $can_delete Whether the user can delete the item.
* @param object $activity Current activity item object.
*/
return (bool) apply_filters('bp_activity_user_can_delete', $can_delete, $activity);
}
示例10: bp_activity_user_can_delete
/**
* Determine if the current user can delete an activity item.
*
* @since BuddyPress (1.2)
*
* @global object $activities_template {@link BP_Activity_Template}
* @uses apply_filters() To call the 'bp_activity_user_can_delete' hook
*
* @param object $activity Optional. Falls back on the current item in the loop.
* @return bool True if can delete, false otherwise.
*/
function bp_activity_user_can_delete($activity = false)
{
global $activities_template;
if (!$activity) {
$activity = $activities_template->activity;
}
if (isset($activity->current_comment)) {
$activity = $activity->current_comment;
}
$can_delete = false;
if (bp_current_user_can('bp_moderate')) {
$can_delete = true;
}
if (is_user_logged_in() && $activity->user_id == bp_loggedin_user_id()) {
$can_delete = true;
}
if (bp_is_item_admin() && bp_is_single_item()) {
$can_delete = true;
}
return apply_filters('bp_activity_user_can_delete', $can_delete, $activity);
}
示例11: group_actions
/**
* Handles group's moderating actions about ideas
*
* @package WP Idea Stream
* @subpackage buddypress/groups
*
* @since 2.0.0
*
* @uses bp_is_group() to check a group is displayed
* @uses bp_is_current_action() to check the group's current action
* @uses wp_idea_stream_root_slug() to get the IdeaStream root slug
* @uses wp_idea_stream_action_get_slug() to get the IdeaStream's action slug
* @uses bp_action_variable() to get a specific action variable
* @uses groups_get_current_group() to get the current group's object
* @uses WP_Idea_Stream_Group->group_ideas_archive_url() to get the group's IdeaStream archive page
* @uses check_admin_referer() to check the request was made on the site
* @uses wp_idea_stream_user_can() to check user's capability
* @uses WP_Idea_Stream_Group->remove_from_group() to remove one or more ideas from a group
* @uses wp_get_referer() to get the url the user came from
* @uses wp_spam_comment() to spam a comment made on an idea
* @uses wp_trash_comment() to trash a comment made on an idea
* @uses wp_idea_stream_add_message() to add a feedback to display to the user once redirected
* @uses bp_core_redirect() to safely redirect the user
*/
public function group_actions()
{
if (!bp_is_group()) {
return;
}
$group = groups_get_current_group();
// This part is to catch the group status before it might be updated
if ('group-settings' == bp_get_group_current_admin_tab() && bp_is_item_admin()) {
$this->group_update_ideas_stati = $group;
if (!empty($_POST['group-status']) && in_array($_POST['group-status'], array('public', 'private', 'hidden'))) {
$this->group_update_ideas_stati->new_status = $_POST['group-status'];
}
}
// This part is for ideastream moderation actions.
if (!(bp_is_current_action(wp_idea_stream_root_slug()) && wp_idea_stream_action_get_slug() == bp_action_variable(0) && bp_action_variable(1))) {
return;
}
$feedback = array();
// Default to group's home
$redirect = $this->group_ideas_archive_url($group, true);
switch (bp_action_variable(1)) {
case 'remove-idea':
check_admin_referer('group-remove-idea');
if (!bp_action_variable(2)) {
$feedback['type'] = 'error';
$feedback['content'] = __('Removing the idea failed.', 'wp-idea-stream');
break;
}
$idea_id = absint(bp_action_variable(2));
if (!wp_idea_stream_user_can('remove_group_ideas')) {
$feedback['type'] = 'error';
$feedback['content'] = __('Removing the idea failed. You do not have the capability to remove ideas.', 'wp-idea-stream');
break;
}
if (false === $this->remove_from_group($idea_id, $group->id)) {
$feedback['type'] = 'error';
$feedback['content'] = __('Removing the idea failed.', 'wp-idea-stream');
$redirect = wp_get_referer();
} else {
$feedback['type'] = 'success';
$feedback['content'] = __('The idea was successfully removed.', 'wp-idea-stream');
}
break;
case 'spam-comment':
check_admin_referer('group-spam-comment');
$redirect = wp_get_referer();
if (!bp_action_variable(2)) {
$feedback['type'] = 'error';
$feedback['content'] = __('Spamming the comment failed.', 'wp-idea-stream');
break;
}
$comment_id = absint(bp_action_variable(2));
if (!wp_idea_stream_user_can('spam_group_idea_comments')) {
$feedback['type'] = 'error';
$feedback['content'] = __('Spamming the comment failed. You do not have the capability to spam comments.', 'wp-idea-stream');
break;
}
if (false === wp_spam_comment($comment_id)) {
$feedback['type'] = 'error';
$feedback['content'] = __('Spamming the comment failed.', 'wp-idea-stream');
} else {
$feedback['type'] = 'success';
$feedback['content'] = __('The comment was successfully marked as spam.', 'wp-idea-stream');
}
break;
case 'trash-comment':
check_admin_referer('group-trash-comment');
$redirect = wp_get_referer();
if (!bp_action_variable(2)) {
$feedback['type'] = 'error';
$feedback['content'] = __('Deleting the comment failed.', 'wp-idea-stream');
break;
}
$comment_id = absint(bp_action_variable(2));
if (!wp_idea_stream_user_can('trash_group_idea_comments')) {
$feedback['type'] = 'error';
//.........这里部分代码省略.........
示例12: setup_globals
/**
* A hierarchy-aware copy of the setup_globals function from BP_Groups_Component
*/
function setup_globals($args = array())
{
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');
// Metadata tables for groups component
$meta_tables = array('group' => $bp->table_prefix . 'bp_groups_groupmeta');
// All globals for messaging component.
// Note that global_tables is included in this array.
$globals = array('path' => BP_PLUGIN_DIR, '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, 'meta_tables' => $meta_tables);
call_user_func(array(get_parent_class(get_parent_class($this)), 'setup_globals'), $globals);
/** Single Group Globals **********************************************/
// Are we viewing a single group?
if (bp_is_groups_component() && ($group_id = BP_Groups_Hierarchy::group_exists(bp_current_action()))) {
$bp->is_single_item = true;
$current_group_class = apply_filters('bp_groups_current_group_class', 'BP_Groups_Hierarchy');
if ('BP_Groups_Hierarchy' == $current_group_class) {
$this->current_group = new BP_Groups_Hierarchy($group_id, 0, array('populate_extras' => true));
} else {
$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 (is_super_admin() || function_exists('bp_current_user_can') && 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() || is_super_admin() || function_exists('bp_current_user_can') && 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.
//.........这里部分代码省略.........
示例13: groups_remove_member
/**
* Remove a member from a group.
*
* @since 1.2.6
*
* @param int $user_id ID of the user.
* @param int $group_id ID of the group.
* @return bool True on success, false on failure.
*/
function groups_remove_member($user_id, $group_id)
{
if (!bp_is_item_admin()) {
return false;
}
$member = new BP_Groups_Member($user_id, $group_id);
/**
* Fires before the removal of a member from a group.
*
* @since 1.2.6
*
* @param int $group_id ID of the group being removed from.
* @param int $user_id ID of the user being removed.
*/
do_action('groups_remove_member', $group_id, $user_id);
return $member->remove();
}
示例14: array
<?php
if (!bp_is_item_admin()) {
die;
}
?>
<div class="item-list-tabs no-ajax" id="subnav" role="tablist">
<ul class="nav nav-pills" id="nav-sub">
<?php
/*
* Note that for the including of templates, we follow that the files
* so make sure that file naming matches the keys
*/
$admin_menu = array('edit-details' => 'Details', 'group-settings' => 'Settings', 'group-avatar' => 'Photo', 'manage-members' => 'Members', 'membership-requests' => 'Requests', 'delete-group' => 'Delete');
$current_tab = bp_get_group_current_admin_tab();
$group = groups_get_current_group();
foreach ($admin_menu as $url_key => $name) {
if ($group->status !== 'private' && $url_key == 'membership-requests') {
continue;
}
$url = trailingslashit(bp_get_group_permalink($group)) . 'admin/' . $url_key;
$tpl = $current_tab == $url_key ? "<li class=\"active\">" : "<li>";
$tpl .= "<a href=\"%s\">%s</a>";
$tpl .= "</li>";
printf($tpl, $url, $name);
}
?>
</ul>
示例15: show_front_page
/**
* Should we show the group's custom front page ?
*/
private function show_front_page()
{
$retval = false;
if (bp_is_group_create()) {
return $retval;
}
if (!bp_is_group()) {
return $retval;
}
$group_id = bp_get_current_group_id();
if (empty($group_id)) {
return $retval;
}
if (bp_is_item_admin()) {
return $retval;
}
if (!groups_is_user_member(bp_loggedin_user_id(), $group_id) && $this->has_front_page($group_id)) {
$retval = true;
}
return $retval;
}