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


PHP groups_is_user_mod函数代码示例

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


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

示例1: 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

示例2: bcg_current_user_can_post

/**
 * Can the current user post to group blog
 * @global type $bp
 * @return type 
 */
function bcg_current_user_can_post()
{
    $user_id = bp_loggedin_user_id();
    $group_id = bp_get_current_group_id();
    $can_post = is_user_logged_in() && (groups_is_user_admin($user_id, $group_id) || groups_is_user_mod($user_id, $group_id));
    return apply_filters('bcg_current_user_can_post', $can_post, $group_id, $user_id);
}
开发者ID:WP--plugins,项目名称:blog-categories-for-groups,代码行数:12,代码来源:bcg-permissions.php

示例3: test_groups_is_user_mod_should_return_false_when_user_is_also_banned

 public function test_groups_is_user_mod_should_return_false_when_user_is_also_banned()
 {
     $this->add_user_to_group(self::$user, self::$groups[0], array('is_mod' => false));
     $this->add_user_to_group(self::$user, self::$groups[1], array('is_mod' => true));
     $m = new BP_Groups_Member(self::$user, self::$groups[1]);
     $m->ban();
     $this->assertEquals(false, groups_is_user_mod(self::$user, self::$groups[1]));
 }
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:8,代码来源:groupsIsUser.php

示例4: wpmudev_chat_is_moderator

/**
 * Test whether logged in user is a moderator
 *
 * @param	Array	$moderator_roles Moderator roles
 * @return	bool	$moderator	 True if moderator False if not
 */
function wpmudev_chat_is_moderator($chat_session, $debug = false)
{
    global $current_user, $bp;
    if ($chat_session['session_type'] === "bp-group") {
        if (function_exists('groups_is_user_mod') && function_exists('groups_is_user_admin')) {
            if (groups_is_user_mod($bp->loggedin_user->id, $bp->groups->current_group->id) || groups_is_user_admin($bp->loggedin_user->id, $bp->groups->current_group->id) || is_super_admin()) {
                return true;
            }
        }
        return false;
    }
    if ($chat_session['session_type'] === "private") {
        global $wpmudev_chat;
        if (!isset($chat_session['invite-info']['message']['host']['auth_hash'])) {
            return false;
        } else {
            if (!isset($wpmudev_chat->chat_auth['auth_hash'])) {
                return false;
            } else {
                if ($chat_session['invite-info']['message']['host']['auth_hash'] === $wpmudev_chat->chat_auth['auth_hash']) {
                    return true;
                } else {
                    return false;
                }
            }
        }
    }
    // all others
    // If the chat session doesn't have any defined moderator roles then no need to go further.
    if (!is_array($chat_session['moderator_roles']) || !count($chat_session['moderator_roles'])) {
        return false;
    }
    if (!is_multisite()) {
        if ($current_user->ID) {
            foreach ($chat_session['moderator_roles'] as $role) {
                if (in_array($role, $current_user->roles)) {
                    return true;
                }
            }
        }
    } else {
        // We only consider super admins IF the normal 'administrator' role is set.
        if (is_super_admin() && array_search('administrator', $chat_session['moderator_roles']) !== false) {
            return true;
        }
        if ($current_user->ID) {
            foreach ($chat_session['moderator_roles'] as $role) {
                if (in_array($role, $current_user->roles)) {
                    return true;
                }
            }
        }
    }
    return false;
}
开发者ID:novichkovv,项目名称:candoweightloss,代码行数:61,代码来源:wpmudev_chat_utilities.php

示例5: rtmedia_media_actions_backbone

 function rtmedia_media_actions_backbone($media_array)
 {
     $context_id = $media_array->context_id;
     $user_id = get_current_user_id();
     if (is_rt_admin() || function_exists('groups_is_user_mod') && groups_is_user_mod($user_id, $context_id) || $media_array->media_author == get_current_user_id()) {
         $media_array->media_actions = "<div class='rtmedia-gallery-item-actions'><a href='" . $media_array->rt_permalink . "edit' class='no-popup' target='_blank' title='" . __('Edit this media', 'buddypress-media') . "'><i class='dashicons dashicons-edit rtmicon'></i>" . __('Edit', 'buddypress-media') . "</a><a href='#' class='no-popup rtm-delete-media' title='" . __('Delete this media', 'buddypress-media') . "' ><i class='dashicons dashicons-trash rtmicon'></i>" . __('Delete', 'buddypress-media') . "</a></div>";
     } else {
         $media_array->media_actions = "";
     }
     return $media_array;
 }
开发者ID:fs-contributor,项目名称:rtMedia,代码行数:11,代码来源:RTMediaGalleryItemAction.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: before_render

 function before_render()
 {
     if (!class_exists('BuddyPress') || !bp_is_active('groups')) {
         return false;
     }
     $this->get();
     // if group id is not set, don't render "Set featured"
     if (empty($this->group_id)) {
         return false;
     }
     $user_id = get_current_user_id();
     // if current is not group moderator or group admin, don't render "Set featured"
     if (!groups_is_user_mod($user_id, $this->group_id) && !groups_is_user_admin($user_id, $this->group_id) && !is_rt_admin()) {
         return false;
     }
     // if current media is not any group media, don't render "Set featured"
     if (!(isset($this->settings[$this->media->media_type]) && $this->settings[$this->media->media_type]) || isset($this->media->context) && 'group' != $this->media->context) {
         return false;
     }
     if (isset($this->action_query) && isset($this->action_query->id) && $this->action_query->id == $this->featured) {
         $this->label = $this->undo_label;
     }
 }
开发者ID:socialray,项目名称:surfied-2-0,代码行数:23,代码来源:RTMediaGroupFeatured.php

示例8: user_meets_access_condition

 /**
  * Check whether the current user meets an access condition.
  *
  * @param string $access_condition 'anyone', 'loggedin', 'member',
  *                                 'mod', 'admin' or 'noone'.
  * @return bool
  */
 protected function user_meets_access_condition($access_condition)
 {
     $group = groups_get_group(array('group_id' => $this->group_id));
     switch ($access_condition) {
         case 'admin':
             $meets_condition = groups_is_user_admin(bp_loggedin_user_id(), $this->group_id);
             break;
         case 'mod':
             $meets_condition = groups_is_user_mod(bp_loggedin_user_id(), $this->group_id);
             break;
         case 'member':
             $meets_condition = groups_is_user_member(bp_loggedin_user_id(), $this->group_id);
             break;
         case 'loggedin':
             $meets_condition = is_user_logged_in();
             break;
         case 'noone':
             $meets_condition = false;
             break;
         case 'anyone':
         default:
             $meets_condition = true;
             break;
     }
     return $meets_condition;
 }
开发者ID:AceMedia,项目名称:BuddyPress,代码行数:33,代码来源:class-bp-group-extension.php

示例9: has_cap_edit

 /**
  * In some places in CP, cp_check_permissions() is used as a wrapper for current_user_can(),
  * which maps against a built-in user role rather than a custom cp_ cap. This method
  * requires a different kind of workaround from map_meta_cap() (above).
  */
 function has_cap_edit($retval, $type)
 {
     if (bp_is_group()) {
         $edit_delete_role = isset($this->group_settings['edit_delete_role']) ? $this->group_settings['edit_delete_role'] : '';
         switch ($edit_delete_role) {
             case 'admins-mods-owners':
                 // The way that CP handles redirects is inconsistent,
                 // so we do some manual checks to make sure a delete GET
                 // argument is for real
                 if (isset($_GET['cp-delete-task-id'])) {
                     $maybe_item_id = $_GET['cp-delete-task-id'];
                 } else {
                     if (isset($_GET['cp-delete-task-list-id'])) {
                         $maybe_item_id = $_GET['cp-delete-task-list-id'];
                     }
                 }
                 if (!empty($maybe_item_id)) {
                     $maybe_item = get_post($maybe_item_id);
                     if (isset($maybe_item->post_status) && 'trash' != $maybe_item->post_status) {
                         $is_delete_attempt = true;
                     }
                 }
                 // Check to see whether this is the main project loop,
                 // in which case there's no item author
                 if (!bp_action_variables()) {
                     $is_project_list = true;
                 }
                 if (isset($_POST['cp-edit-task-id'])) {
                     $item_id = $_POST['cp-edit-task-id'];
                     $item = get_post($item_id);
                     $item_author = $item->post_author;
                 } else {
                     if (isset($_POST['cp-edit-task-list-id'])) {
                         $item_id = $_POST['cp-edit-task-list-id'];
                         $item = get_post($item_id);
                         $item_author = $item->post_author;
                     } else {
                         if (isset($_POST['cp-edit-project-id'])) {
                             $item_id = $_POST['cp-edit-project-id'];
                             $item = get_post($item_id);
                             $item_author = $item->post_author;
                         } else {
                             if (!empty($is_delete_attempt)) {
                                 $item_author = $maybe_item->post_author;
                             } else {
                                 if (!empty($is_project_list)) {
                                     $item_author = 0;
                                 } else {
                                     $item_author = get_the_author_meta('ID');
                                 }
                             }
                         }
                     }
                 }
                 if (groups_is_user_admin(bp_loggedin_user_id(), bp_get_current_group_id()) || groups_is_user_mod(bp_loggedin_user_id(), bp_get_current_group_id()) || $item_author == bp_loggedin_user_id()) {
                     $retval = 'exist';
                 } else {
                     $retval = 'do_not_allow';
                 }
                 break;
             case 'group-members':
                 if (groups_is_user_member(bp_loggedin_user_id(), bp_get_current_group_id())) {
                     $retval = 'exist';
                 } else {
                     $retval = 'do_not_allow';
                 }
                 break;
         }
     }
     return $retval;
 }
开发者ID:clarkewd,项目名称:CollabPress,代码行数:76,代码来源:cp-bp-groups.php

示例10: bp_groupblog_upgrade_user

/**
 * bp_groupblog_upgrade_user( $user_id, $group_id, $blog_id )
 *
 * Subscribes user in question to blog in question
 * This code was initially inspired by Burt Adsit re-interpreted by Boone
 */
function bp_groupblog_upgrade_user($user_id, $group_id, $blog_id = false)
{
    global $bp;
    if (!$blog_id) {
        $blog_id = groups_get_groupmeta($group_id, 'groupblog_blog_id');
    }
    // If the group has no blog linked, get the heck out of here!
    if (!$blog_id) {
        return;
    }
    // Set up some variables
    $groupblog_silent_add = groups_get_groupmeta($group_id, 'groupblog_silent_add');
    $groupblog_default_member_role = groups_get_groupmeta($group_id, 'groupblog_default_member_role');
    $groupblog_default_mod_role = groups_get_groupmeta($group_id, 'groupblog_default_mod_role');
    $groupblog_default_admin_role = groups_get_groupmeta($group_id, 'groupblog_default_admin_role');
    $groupblog_creator_role = 'admin';
    $user = new WP_User($user_id);
    $user_role = bp_groupblog_get_user_role($user_id, $user->data->user_login, $blog_id);
    // Get the current user's group status. For efficiency, we try first to look at the
    // current group object
    if (isset($bp->groups->current_group->id) && $group_id == $bp->groups->current_group->id) {
        // It's tricky to walk through the admin/mod lists over and over, so let's format
        if (empty($bp->groups->current_group->adminlist)) {
            $bp->groups->current_group->adminlist = array();
            if (isset($bp->groups->current_group->admins)) {
                foreach ((array) $bp->groups->current_group->admins as $admin) {
                    if (isset($admin->user_id)) {
                        $bp->groups->current_group->adminlist[] = $admin->user_id;
                    }
                }
            }
        }
        if (empty($bp->groups->current_group->modlist)) {
            $bp->groups->current_group->modlist = array();
            if (isset($bp->groups->current_group->mods)) {
                foreach ((array) $bp->groups->current_group->mods as $mod) {
                    if (isset($mod->user_id)) {
                        $bp->groups->current_group->modlist[] = $mod->user_id;
                    }
                }
            }
        }
        if (in_array($user_id, $bp->groups->current_group->adminlist)) {
            $user_group_status = 'admin';
        } elseif (in_array($user_id, $bp->groups->current_group->modlist)) {
            $user_group_status = 'mod';
        } else {
            // I'm assuming that if a user is passed to this function, they're a member
            // Doing an actual lookup is costly. Try to look for an efficient method
            $user_group_status = 'member';
        }
    } else {
        if (groups_is_user_admin($user_id, $group_id)) {
            $user_group_status = 'admin';
        } else {
            if (groups_is_user_mod($user_id, $group_id)) {
                $user_group_status = 'mod';
            } else {
                if (groups_is_user_member($user_id, $group_id)) {
                    $user_group_status = 'member';
                } else {
                    return false;
                }
            }
        }
    }
    switch ($user_group_status) {
        case 'admin':
            $default_role = $groupblog_default_admin_role;
            break;
        case 'mod':
            $default_role = $groupblog_default_mod_role;
            break;
        case 'member':
        default:
            $default_role = $groupblog_default_member_role;
            break;
    }
    if ($user_role == $default_role && $groupblog_silent_add == true) {
        return false;
    }
    if (!$groupblog_silent_add) {
        $default_role = 'subscriber';
    }
    add_user_to_blog($blog_id, $user_id, $default_role);
    do_action('bp_groupblog_upgrade_user', $user_id, $user_role, $default_role);
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:93,代码来源:bp-groupblog.php

示例11: group_map_meta_caps


//.........这里部分代码省略.........
 public function group_map_meta_caps($caps = array(), $cap = '', $user_id = 0, $args = array())
 {
     // Group meta caps territory is limited to groups
     if (!bp_is_group() && !self::is_group_admin() && !wp_idea_stream_buddypress_is_delete_account()) {
         return $caps;
     }
     // Not logged in user can't do anything in groups
     if (empty($user_id)) {
         return array('do_not_allow');
     }
     // Let's get the current group (we'll have the status available)
     $group = groups_get_current_group();
     if (empty($group->id) && !empty($this->group_delete)) {
         $group = new StdClass();
         $group->id = $this->group_delete;
     }
     switch ($cap) {
         case 'publish_ideas':
         case 'comment_group_ideas':
         case 'rate_ideas':
         case 'read_private_ideas':
         case 'read_idea':
             if (!empty($group->id) && groups_is_user_member($user_id, $group->id)) {
                 $caps = array('exist');
                 /**
                  * We need a else there to be sure an admin can remove ideas comment
                  * from the group Administration screen
                  */
             } else {
                 $caps = array('manage_options');
             }
             break;
         case 'edit_idea':
             if (!empty($group->id)) {
                 // Group admins can edit idea
                 if (groups_is_user_admin($user_id, $group->id)) {
                     $caps = array('exist');
                     // Is the author a group member ?
                 } else {
                     if (groups_is_user_member($user_id, $group->id)) {
                         $_post = get_post($args[0]);
                         if (!empty($_post)) {
                             $caps = array();
                             if (!is_admin() && (int) $user_id === (int) $_post->post_author) {
                                 $caps = array('exist');
                                 // Unknown, so map to manage_options
                             } else {
                                 $caps = array('manage_options');
                             }
                         }
                         // Defaults to manage_options
                     } else {
                         $caps = array('manage_options');
                     }
                 }
                 /**
                  * We need a else there to be sure an admin can edit group ideas
                  * from the group Administration screen
                  */
             } else {
                 $caps = array('manage_options');
             }
             break;
         case 'remove_group_ideas':
         case 'edit_others_ideas':
         case 'edit_private_ideas':
         case 'edit_published_ideas':
         case 'edit_ideas':
             if (!empty($group->id) && groups_is_user_admin($user_id, $group->id)) {
                 $caps = array('exist');
                 /**
                  * We need a else there to be sure an admin can remove group ideas
                  * from the group Administration screen
                  */
             } else {
                 $caps = array('manage_options');
             }
             break;
         case 'edit_comment':
         case 'trash_group_idea_comments':
         case 'spam_group_idea_comments':
             if (!empty($group->id) && (groups_is_user_admin($user_id, $group->id) || groups_is_user_mod($user_id, $group->id))) {
                 $caps = array('exist');
                 /**
                  * We need a else there to be sure an admin can trash/span ideas comment
                  * from the group Administration screen
                  */
             } else {
                 $caps = array('manage_options');
             }
             break;
     }
     /**
      * @param  array $caps Capabilities for meta capability
      * @param  string $cap Capability name
      * @param  int $user_id User id
      * @param  mixed $args Arguments
      */
     return apply_filters('wp_idea_stream_buddypress_group_map_meta_caps', $caps, $cap, $user_id, $args, $group);
 }
开发者ID:mrjarbenne,项目名称:wp-idea-stream,代码行数:101,代码来源:groups.php

示例12: groups_setup_nav

function groups_setup_nav()
{
    global $bp, $current_blog;
    global $group_obj;
    if ($group_id = BP_Groups_Group::group_exists($bp->current_action)) {
        /* This is a single group page. */
        $bp->is_single_item = true;
        $group_obj = new BP_Groups_Group($group_id);
        /* Using "item" not "group" for generic support in other components. */
        if (is_site_admin()) {
            $bp->is_item_admin = 1;
        } else {
            $bp->is_item_admin = groups_is_user_admin($bp->loggedin_user->id, $group_obj->id);
        }
        /* If the user is not an admin, check if they are a moderator */
        if (!$bp->is_item_admin) {
            $bp->is_item_mod = groups_is_user_mod($bp->loggedin_user->id, $group_obj->id);
        }
        /* Is the logged in user a member of the group? */
        $is_member = groups_is_user_member($bp->loggedin_user->id, $group_obj->id) ? true : false;
        /* Should this group be visible to the logged in user? */
        $is_visible = 'public' == $group_obj->status || $is_member ? true : false;
    }
    /* Add 'Groups' to the main navigation */
    bp_core_add_nav_item(__('Groups', 'buddypress'), $bp->groups->slug);
    if ($bp->displayed_user->id) {
        bp_core_add_nav_default($bp->groups->slug, 'groups_screen_my_groups', 'my-groups');
    }
    $groups_link = $bp->loggedin_user->domain . $bp->groups->slug . '/';
    /* Add the subnav items to the groups nav item */
    bp_core_add_subnav_item($bp->groups->slug, 'my-groups', __('My Groups', 'buddypress'), $groups_link, 'groups_screen_my_groups', 'my-groups-list');
    bp_core_add_subnav_item($bp->groups->slug, 'create', __('Create a Group', 'buddypress'), $groups_link, 'groups_screen_create_group', false, bp_is_home());
    bp_core_add_subnav_item($bp->groups->slug, 'invites', __('Invites', 'buddypress'), $groups_link, 'groups_screen_group_invites', false, bp_is_home());
    if ($bp->current_component == $bp->groups->slug) {
        if (bp_is_home() && !$bp->is_single_item) {
            $bp->bp_options_title = __('My Groups', 'buddypress');
        } else {
            if (!bp_is_home() && !$bp->is_single_item) {
                $bp->bp_options_avatar = bp_core_get_avatar($bp->displayed_user->id, 1);
                $bp->bp_options_title = $bp->displayed_user->fullname;
            } else {
                if ($bp->is_single_item) {
                    // We are viewing a single group, so set up the
                    // group navigation menu using the $group_obj global.
                    /* 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_variables[0];
                    array_shift($bp->action_variables);
                    $bp->bp_options_title = $group_obj->name;
                    $bp->bp_options_avatar = '<img src="' . $group_obj->avatar_thumb . '" alt="Group Avatar Thumbnail" />';
                    $group_link = $bp->root_domain . '/' . $bp->groups->slug . '/' . $group_obj->slug . '/';
                    // If this is a private or hidden group, does the user have access?
                    if ('private' == $group_obj->status || 'hidden' == $group_obj->status) {
                        if (groups_is_user_member($bp->loggedin_user->id, $group_obj->id) && is_user_logged_in()) {
                            $has_access = true;
                        } else {
                            $has_access = false;
                        }
                    } else {
                        $has_access = true;
                    }
                    // Reset the existing subnav items
                    bp_core_reset_subnav_items($bp->groups->slug);
                    bp_core_add_nav_default($bp->groups->slug, 'groups_screen_group_home', 'home');
                    bp_core_add_subnav_item($bp->groups->slug, 'home', __('Home', 'buddypress'), $group_link, 'groups_screen_group_home', 'group-home');
                    // If the user is a group mod or more, then show the group admin nav item */
                    if ($bp->is_item_mod || $bp->is_item_admin) {
                        bp_core_add_subnav_item($bp->groups->slug, 'admin', __('Admin', 'buddypress'), $group_link, 'groups_screen_group_admin', 'group-admin', $bp->is_item_admin + (int) $bp->is_item_mod);
                    }
                    // If this is a private group, and the user is not a member, show a "Request Membership" nav item.
                    if (!$has_access && !groups_check_for_membership_request($bp->loggedin_user->id, $group_obj->id) && $group_obj->status == 'private') {
                        bp_core_add_subnav_item($bp->groups->slug, 'request-membership', __('Request Membership', 'buddypress'), $group_link, 'groups_screen_group_request_membership', 'request-membership');
                    }
                    if ($has_access && $group_obj->enable_forum && function_exists('bp_forums_setup')) {
                        bp_core_add_subnav_item($bp->groups->slug, 'forum', __('Forum', 'buddypress'), $group_link, 'groups_screen_group_forum', 'group-forum', $is_visible);
                    }
                    if ($has_access && $group_obj->enable_wire && function_exists('bp_wire_install')) {
                        bp_core_add_subnav_item($bp->groups->slug, 'wire', __('Wire', 'buddypress'), $group_link, 'groups_screen_group_wire', 'group-wire', $is_visible);
                    }
                    if ($has_access && $group_obj->enable_photos && function_exists('bp_gallery_install')) {
                        bp_core_add_subnav_item($bp->groups->slug, 'photos', __('Photos', 'buddypress'), $group_link, 'groups_screen_group_photos', 'group-photos', $is_visible);
                    }
                    if ($has_access) {
                        bp_core_add_subnav_item($bp->groups->slug, 'members', __('Members', 'buddypress'), $group_link, 'groups_screen_group_members', 'group-members', $is_visible);
                    }
                    if (is_user_logged_in() && groups_is_user_member($bp->loggedin_user->id, $group_obj->id)) {
                        if (function_exists('friends_install')) {
                            bp_core_add_subnav_item($bp->groups->slug, 'send-invites', __('Send Invites', 'buddypress'), $group_link, 'groups_screen_group_invite', 'group-invite', $is_member);
                        }
                        bp_core_add_subnav_item($bp->groups->slug, 'leave-group', __('Leave Group', 'buddypress'), $group_link, 'groups_screen_group_leave', 'group-leave', $is_member);
                    }
                }
            }
        }
    }
}
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:97,代码来源:bp-groups.php

示例13: user_can_associate_doc_with_group

 /**
  * Can a given user associate a doc with a given group?
  */
 public static function user_can_associate_doc_with_group($user_id, $group_id)
 {
     _deprecated_function(__FUNCTION__, '1.8', "Use current_user_can( 'bp_docs_associate_with_group' ) instead");
     $group = groups_get_group(array('group_id' => intval($group_id)));
     // No one can associate anything with a non-existent group
     if (empty($group->name)) {
         return false;
     }
     // Site admins can do anything
     if (bp_current_user_can('bp_moderate')) {
         return true;
     }
     // Non-group-members can't associate a doc with a group
     if (!groups_is_user_member($user_id, $group_id)) {
         return false;
     }
     // Check against group settings. Default to 'member'
     // @todo Abstract default settings out better
     $group_settings = bp_docs_get_group_settings($group_id);
     $can_create = isset($group_settings['can-create']) ? $group_settings['can-create'] : 'member';
     if ('admin' == $can_create) {
         return (bool) groups_is_user_admin($user_id, $group_id);
     } else {
         if ('mod' == $can_create) {
             return groups_is_user_admin($user_id, $group_id) || groups_is_user_mod($user_id, $group_id);
         }
     }
     return true;
 }
开发者ID:projectestac,项目名称:wordpress-buddypress-docs,代码行数:32,代码来源:integration-groups.php

示例14: 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

示例15: bp_groupblog_options_nav

/**
 * bp_groupblog_options_nav()
 *
 * Manually create the navigation for the group since we can't fetch any other way.
 * You should manually add items if you have third party plugins that add a menu item.
 *
 * The BuddyPress function we duplicate is called bp_get_options_nav()
 */
function bp_groupblog_options_nav()
{
    global $bp;
    $checks = get_site_option('bp_groupblog_blog_defaults_options');
    ?>

	  <li id="home-personal-li"<?php 
    if ($checks['deep_group_integration']) {
        ?>
 class="current selected"<?php 
    }
    ?>
>
			<a id="home" href="<?php 
    bp_group_permalink();
    ?>
"><?php 
    _e('Home', 'groupblog');
    ?>
</a>
		</li>

    <?php 
    if (groups_is_user_admin($bp->loggedin_user->id, bp_get_group_id()) || groups_is_user_mod($bp->loggedin_user->id, bp_get_group_id())) {
        ?>
			<li id="admin-personal-li" >
				<a id="admin" href="<?php 
        bp_group_permalink();
        ?>
admin/"><?php 
        _e('Admin', 'groupblog');
        ?>
</a>
			</li>
		<?php 
    }
    ?>

		<?php 
    if (bp_group_is_visible()) {
        ?>

			<?php 
        if (bp_groupblog_is_blog_enabled(bp_get_group_id())) {
            ?>
				<?php 
            if (!$checks['deep_group_integration']) {
                ?>
					<li id="<?php 
                echo BP_GROUPBLOG_SLUG;
                ?>
-personal-li"<?php 
                //if ( is_page() ) :
                ?>
 class="current selected"<?php 
                //endif;
                ?>
>
						<a id="<?php 
                echo BP_GROUPBLOG_SLUG;
                ?>
" href="<?php 
                bp_group_permalink();
                ?>
blog/"><?php 
                _e('Blog', 'groupblog');
                ?>
</a>
					</li>
				<?php 
            }
            ?>
		  <?php 
        }
        ?>

			<?php 
        if (bp_is_active('forums') && (function_exists('bp_forums_is_installed_correctly') && bp_group_is_forum_enabled() && !(int) bp_get_option('bp-disable-forum-directory')) && bp_forums_is_installed_correctly()) {
            ?>
				<li id="<?php 
            echo BP_FORUMS_SLUG;
            ?>
-personal-li" >
					<a id="<?php 
            echo BP_FORUMS_SLUG;
            ?>
" href="<?php 
            bp_group_permalink();
            ?>
forum/"><?php 
            _e('Forum', 'groupblog');
            ?>
//.........这里部分代码省略.........
开发者ID:adisonc,项目名称:MaineLearning,代码行数:101,代码来源:functions.php


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