/**
 * Adds the Group Admin top-level menu to group pages
 *
 * @package BuddyPress
 * @since 1.5
 *
 * @todo Add dynamic menu items for group extensions
 */
function bp_groups_group_admin_menu()
{
    global $nxt_admin_bar, $bp;
    // Only show if viewing a group
    if (!bp_is_group()) {
        return false;
    }
    // Only show this menu to group admins and super admins
    if (!is_super_admin() && !bp_group_is_admin()) {
        return false;
    }
    if ('3.2' == bp_get_major_nxt_version()) {
        // Group avatar
        $avatar = bp_core_fetch_avatar(array('object' => 'group', 'type' => 'thumb', 'avatar_dir' => 'group-avatars', 'item_id' => $bp->groups->current_group->id, 'width' => 16, 'height' => 16));
        // Unique ID for the 'My Account' menu
        $bp->group_admin_menu_id = !empty($avatar) ? 'group-admin-with-avatar' : 'group-admin';
        // Add the top-level Group Admin button
        $nxt_admin_bar->add_menu(array('id' => $bp->group_admin_menu_id, 'title' => $avatar . bp_get_current_group_name(), 'href' => bp_get_group_permalink($bp->groups->current_group)));
    } elseif ('3.3' == bp_get_major_nxt_version()) {
        // Unique ID for the 'My Account' menu
        $bp->group_admin_menu_id = 'group-admin';
        // Add the top-level Group Admin button
        $nxt_admin_bar->add_menu(array('id' => $bp->group_admin_menu_id, 'title' => __('Edit Group', 'buddypress'), 'href' => bp_get_group_permalink($bp->groups->current_group)));
    }
    // Group Admin > Edit details
    $nxt_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'edit-details', 'title' => __('Edit Details', 'buddypress'), 'href' => bp_get_groups_action_link('admin/edit-details')));
    // Group Admin > Group settings
    $nxt_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'group-settings', 'title' => __('Edit Settings', 'buddypress'), 'href' => bp_get_groups_action_link('admin/group-settings')));
    // Group Admin > Group avatar
    if (!(int) bp_get_option('bp-disable-avatar-uploads')) {
        $nxt_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'group-avatar', 'title' => __('Edit Avatar', 'buddypress'), 'href' => bp_get_groups_action_link('admin/group-avatar')));
    }
    // Group Admin > Manage invitations
    if (bp_is_active('friends')) {
        $nxt_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'manage-invitations', 'title' => __('Manage Invitations', 'buddypress'), 'href' => bp_get_groups_action_link('send-invites')));
    }
    // Group Admin > Manage members
    $nxt_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'manage-members', 'title' => __('Manage Members', 'buddypress'), 'href' => bp_get_groups_action_link('admin/manage-members')));
    // Group Admin > Membership Requests
    if (bp_get_group_status($bp->groups->current_group) == 'private') {
        $nxt_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'membership-requests', 'title' => __('Membership Requests', 'buddypress'), 'href' => bp_get_groups_action_link('admin/membership-requests')));
    }
    // Delete Group
    $nxt_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'delete-group', 'title' => __('Delete Group', 'buddypress'), 'href' => bp_get_groups_action_link('admin/delete-group')));
}
/**
 * Add the Group Admin top-level menu when viewing group pages.
 *
 * @since 1.5.0
 *
 * @todo Add dynamic menu items for group extensions.
 *
 * @return false|null False if not on a group page, or if user does not have
 *                    access to group admin options.
 */
function bp_groups_group_admin_menu()
{
    global $wp_admin_bar;
    $bp = buddypress();
    // Only show if viewing a group.
    if (!bp_is_group() || bp_is_group_create()) {
        return false;
    }
    // Only show this menu to group admins and super admins.
    if (!bp_current_user_can('bp_moderate') && !bp_group_is_admin()) {
        return false;
    }
    // Unique ID for the 'Edit Group' menu.
    $bp->group_admin_menu_id = 'group-admin';
    // Add the top-level Group Admin button.
    $wp_admin_bar->add_menu(array('id' => $bp->group_admin_menu_id, 'title' => __('Edit Group', 'buddypress'), 'href' => bp_get_group_permalink($bp->groups->current_group)));
    // Index of the Manage tabs parent slug.
    $nav_index = $bp->groups->current_group->slug . '_manage';
    // Check if current group has Manage tabs.
    if (empty($bp->bp_options_nav[$nav_index])) {
        return;
    }
    // Build the Group Admin menus.
    foreach ($bp->bp_options_nav[$nav_index] as $menu) {
        /**
         * Should we add the current manage link in the Group's "Edit" Admin Bar menu ?
         *
         * All core items will be added, plugins can use a new parameter in the BP Group Extension API
         * to also add the link to the "edit screen" of their group component. To do so, set the
         * the 'show_in_admin_bar' argument of your edit screen to true
         */
        if ($menu['show_in_admin_bar']) {
            $title = sprintf(_x('Edit Group %s', 'Group WP Admin Bar manage links', 'buddypress'), $menu['name']);
            // Title is specific for delete.
            if ('delete-group' == $menu['slug']) {
                $title = sprintf(_x('%s Group', 'Group WP Admin Bar delete link', 'buddypress'), $menu['name']);
            }
            $wp_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => $menu['slug'], 'title' => $title, 'href' => bp_get_groups_action_link('admin/' . $menu['slug'])));
        }
    }
}
/**
 * Add the Group Admin top-level menu when viewing group pages.
 *
 * @since BuddyPress (1.5.0)
 *
 * @todo Add dynamic menu items for group extensions.
 */
function bp_groups_group_admin_menu()
{
    global $wp_admin_bar, $bp;
    // Only show if viewing a group
    if (!bp_is_group()) {
        return false;
    }
    // Only show this menu to group admins and super admins
    if (!bp_current_user_can('bp_moderate') && !bp_group_is_admin()) {
        return false;
    }
    // Unique ID for the 'Edit Group' menu
    $bp->group_admin_menu_id = 'group-admin';
    // Add the top-level Group Admin button
    $wp_admin_bar->add_menu(array('id' => $bp->group_admin_menu_id, 'title' => __('Edit Group', 'buddypress'), 'href' => bp_get_group_permalink($bp->groups->current_group)));
    // Group Admin > Edit details
    $wp_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'edit-details', 'title' => __('Edit Details', 'buddypress'), 'href' => bp_get_groups_action_link('admin/edit-details')));
    // Group Admin > Group settings
    $wp_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'group-settings', 'title' => __('Edit Settings', 'buddypress'), 'href' => bp_get_groups_action_link('admin/group-settings')));
    // Group Admin > Group avatar
    if (!(int) bp_get_option('bp-disable-avatar-uploads')) {
        $wp_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'group-avatar', 'title' => __('Edit Avatar', 'buddypress'), 'href' => bp_get_groups_action_link('admin/group-avatar')));
    }
    // Group Admin > Manage invitations
    if (bp_is_active('friends')) {
        $wp_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'manage-invitations', 'title' => __('Manage Invitations', 'buddypress'), 'href' => bp_get_groups_action_link('send-invites')));
    }
    // Group Admin > Manage members
    $wp_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'manage-members', 'title' => __('Manage Members', 'buddypress'), 'href' => bp_get_groups_action_link('admin/manage-members')));
    // Group Admin > Membership Requests
    if (bp_get_group_status($bp->groups->current_group) == 'private') {
        $wp_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'membership-requests', 'title' => __('Membership Requests', 'buddypress'), 'href' => bp_get_groups_action_link('admin/membership-requests')));
    }
    // Delete Group
    $wp_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'delete-group', 'title' => __('Delete Group', 'buddypress'), 'href' => bp_get_groups_action_link('admin/delete-group')));
}
 /**
  * has_response_caps( $user_id )
  *
  * Checks if $user_id has response management capabilities
  *
  * @param Int $user_id ID of the user capabilities to be checked
  * @return True if $user_id is eligible and False if not.
  */
 function has_response_caps($user_id = null)
 {
     $is_ok = true;
     if (!$user_id) {
         global $bp;
         $user_id = $bp->loggedin_user->id;
     }
     // Treat super admins
     if (is_super_admin($user_id)) {
         $this->add_response_caps($user_id);
     }
     $user = new WP_User($user_id);
     foreach ($this->caps as $c) {
         if (!$user->has_cap($c)) {
             $is_ok = false;
         }
     }
     if (!get_option('bpsp_allow_only_admins')) {
         if (!bp_group_is_admin()) {
             $is_ok = false;
         }
     }
     return $is_ok;
 }
Пример #5
0
			<?php while ( bp_forum_topic_posts() ) : bp_the_forum_topic_post(); ?>

				<li id="post-<?php bp_the_topic_post_id() ?>" class="<?php bp_the_topic_post_css_class() ?>">
					<div class="poster-meta">
						<a href="<?php bp_the_topic_post_poster_link() ?>">
							<?php bp_the_topic_post_poster_avatar( 'width=40&height=40' ) ?>
						</a>
						<?php echo sprintf( __( '%s said %s ago:', 'buddypress' ), bp_get_the_topic_post_poster_name(), bp_get_the_topic_post_time_since() ) ?>
					</div>

					<div class="post-content">
						<?php bp_the_topic_post_content() ?>
					</div>

					<div class="admin-links">
						<?php if ( bp_group_is_admin() || bp_group_is_mod() || bp_get_the_topic_post_is_mine() ) : ?>
							<?php bp_the_topic_post_admin_links() ?>
						<?php endif; ?>

						<?php do_action( 'bp_group_forum_post_meta' ); ?>

						<a href="#post-<?php bp_the_topic_post_id() ?>" title="<?php _e( 'Permanent link to this post', 'buddypress' ) ?>">#</a>
					</div>
				</li>

			<?php endwhile; ?>
		</ul><!-- #topic-post-list -->

		<?php do_action( 'bp_after_group_forum_topic_posts' ) ?>

		<div class="pagination no-ajax">
    /**
     * Creates the markup for the group-specific doc settings
     *
     * In the future I'll try to get the markup out of here. Sorry, themers.
     *
     * @package BuddyPress Docs
     * @since 1.0-beta
     *
     * @param array $doc_settings Passed along to reduce lookups
     */
    function doc_settings_markup($doc_settings)
    {
        global $bp;
        // Only add these settings if we're in the group component
        // BP 1.2/1.3 compatibility
        $is_group_component = function_exists('bp_is_current_component') ? bp_is_current_component('groups') : $bp->current_component == $bp->groups->slug;
        if ($is_group_component) {
            // Get the current values
            $edit = !empty($doc_settings['edit']) ? $doc_settings['edit'] : 'group-members';
            $post_comments = !empty($doc_settings['post_comments']) ? $doc_settings['post_comments'] : 'group-members';
            // Read settings have a different default value for public groups
            if (!empty($doc_settings['read_comments'])) {
                $read_comments = $doc_settings['read_comments'];
            } else {
                $read_comments = bp_group_is_visible() ? 'anyone' : 'group-members';
            }
            $view_history = !empty($doc_settings['view_history']) ? $doc_settings['view_history'] : 'anyone';
            $manage = !empty($doc_settings['manage']) ? $doc_settings['manage'] : 'creator';
            // Set the text of the 'creator only' label
            if (!empty($bp->bp_docs->current_post->post_author) && $bp->bp_docs->current_post->post_author != bp_loggedin_user_id()) {
                $creator_text = sprintf(__('Doc creator only (%s)', 'bp-docs'), bp_core_get_user_displayname($bp->bp_docs->current_post->post_author));
            } else {
                $creator_text = __('Doc creator only (that\'s you!)', 'bp-docs');
            }
            ?>
			
			<?php 
            /* EDITING */
            ?>
			<tr>
				<td class="desc-column">
					<label for="settings[edit]"><?php 
            _e('Who can edit this doc?', 'bp-docs');
            ?>
</label>
				</td>
				
				<td class="content-column">
					<input name="settings[edit]" type="radio" value="group-members" <?php 
            checked($edit, 'group-members');
            ?>
/> <?php 
            _e('All members of the group', 'bp-docs');
            ?>
<br />
			
					<input name="settings[edit]" type="radio" value="creator" <?php 
            checked($edit, 'creator');
            ?>
/> <?php 
            echo esc_html($creator_text);
            ?>
<br />
			
					<?php 
            if (bp_group_is_admin() || bp_group_is_mod()) {
                ?>
						<input name="settings[edit]" type="radio" value="admins-mods" <?php 
                checked($edit, 'admins-mods');
                ?>
/> <?php 
                _e('Only admins and mods of this group', 'bp-docs');
                ?>
<br />
					<?php 
            }
            ?>
				</td>
			</tr>
			
			<?php 
            /* POSTING COMMENTS */
            ?>
			<tr>
				<td class="desc-column">
					<label for="settings[post_comments]"><?php 
            _e('Who can <em>post</em> comments on this doc?', 'bp-docs');
            ?>
</label>
				</td>
				
				<td class="content-column">
					<input name="settings[post_comments]" type="radio" value="group-members" <?php 
            checked($post_comments, 'group-members');
            ?>
/> <?php 
            _e('All members of the group', 'bp-docs');
            ?>
<br />
					
					<?php 
            if (bp_group_is_admin() || bp_group_is_mod()) {
                ?>
						<input name="settings[post_comments]" type="radio" value="admins-mods" <?php 
                checked($post_comments, 'admins-mods');
                ?>
/> <?php 
                _e('Only admins and mods of this group', 'bp-docs');
                ?>
<br />
					<?php 
            }
            ?>
					
					<input name="settings[post_comments]" type="radio" value="no-one" <?php 
            checked($post_comments, 'no-one');
            ?>
/> <?php 
            _e('No one', 'bp-docs');
            ?>
<br />
				</td>
			</tr>
			
			<?php 
            /* READING COMMENTS */
            ?>
			<tr>
				<td class="desc-column">
					<label for="settings[read_comments]"><?php 
            _e('Who can <em>read</em> comments on this doc?', 'bp-docs');
            ?>
</label>
				</td>
				
				<td class="content-column">
					<?php 
            if (bp_docs_current_group_is_public()) {
                ?>
				
						<input name="settings[read_comments]" type="radio" value="anyone" <?php 
                checked($read_comments, 'anyone');
                ?>
/> <?php 
                _e('Anyone', 'bp-docs');
                ?>
<br />
					<?php 
            }
            ?>
					
					<input name="settings[read_comments]" type="radio" value="group-members" <?php 
            checked($read_comments, 'group-members');
            ?>
/> <?php 
            _e('All members of the group', 'bp-docs');
            ?>
<br />
					
					<?php 
            if (bp_group_is_admin() || bp_group_is_mod()) {
                ?>
						<input name="settings[read_comments]" type="radio" value="admins-mods" <?php 
                checked($read_comments, 'admins-mods');
                ?>
/> <?php 
                _e('Only admins and mods of this group', 'bp-docs');
                ?>
<br />
					<?php 
            }
            ?>
					
					<input name="settings[read_comments]" type="radio" value="no-one" <?php 
            checked($read_comments, 'no-one');
            ?>
/> <?php 
            _e('No one', 'bp-docs');
            ?>
<br />
				</td>
			</tr>
			
			<?php 
            /* VIEWING HISTORY */
            ?>
			<tr>
				<td class="desc-column">
					<label for="settings[view_history]"><?php 
            _e('Who can view this doc\'s history?', 'bp-docs');
            ?>
</label>
				</td>
				
				<td class="content-column">
				
					<input name="settings[view_history]" type="radio" value="anyone" <?php 
            checked($view_history, 'anyone');
            ?>
/> <?php 
            _e('Anyone', 'bp-docs');
            ?>
<br />
					
					<input name="settings[view_history]" type="radio" value="group-members" <?php 
            checked($view_history, 'group-members');
            ?>
/> <?php 
            _e('All members of the group', 'bp-docs');
            ?>
<br />
					
					<?php 
            if (bp_group_is_admin() || bp_group_is_mod()) {
                ?>
						<input name="settings[view_history]" type="radio" value="admins-mods" <?php 
                checked($view_history, 'admins-mods');
                ?>
/> <?php 
                _e('Only admins and mods of this group', 'bp-docs');
                ?>
<br />
					<?php 
            }
            ?>
					
					<input name="settings[view_history]" type="radio" value="no-one" <?php 
            checked($view_history, 'no-one');
            ?>
/> <?php 
            _e('No one', 'bp-docs');
            ?>
<br />
				</td>
			</tr>
			
			<?php 
        }
    }
/**
 * Return the row class of a group
 *
 * @global BP_Groups_Template $groups_template
 * @return string Row class of the group
 * @since BuddyPress (1.7)
 */
function bp_get_group_class()
{
    global $groups_template;
    $classes = array();
    $pos_in_loop = (int) $groups_template->current_group;
    // If we've only one group in the loop, don't both with odd and even.
    if ($groups_template->group_count > 1) {
        $classes[] = $pos_in_loop % 2 ? 'even' : 'odd';
    } else {
        $classes[] = 'bp-single-group';
    }
    // Group type - public, private, hidden.
    $classes[] = esc_attr($groups_template->group->status);
    // User's group status
    if (bp_is_user_active()) {
        if (bp_group_is_admin()) {
            $classes[] = 'is-admin';
        }
        if (bp_group_is_member()) {
            $classes[] = 'is-member';
        }
        if (bp_group_is_mod()) {
            $classes[] = 'is-mod';
        }
    }
    $classes = apply_filters('bp_get_group_class', $classes);
    $classes = array_merge($classes, array());
    $retval = 'class="' . join(' ', $classes) . '"';
    return $retval;
}
Пример #8
0
		</div>

		<div id="topic-meta">
			<h3><?php 
    _e('Edit:', 'buddypress');
    ?>
 <?php 
    bp_the_topic_title();
    ?>
 (<?php 
    bp_the_topic_total_post_count();
    ?>
)</h3>

			<?php 
    if (bp_group_is_admin() || bp_group_is_mod() || bp_get_the_topic_is_mine()) {
        ?>

				<div class="last admin-links">

					<?php 
        bp_the_topic_admin_links();
        ?>

				</div>

			<?php 
    }
    ?>

			<?php 
function rtmedia_delete_allowed()
{
    global $rtmedia_media;
    $flag = $rtmedia_media->media_author == get_current_user_id();
    if (!$flag && isset($rtmedia_media->context) && $rtmedia_media->context == 'group' && function_exists('bp_group_is_admin')) {
        $flag = bp_group_is_admin() || bp_group_is_mod();
    }
    if (!$flag) {
        $flag = is_super_admin();
    }
    $flag = apply_filters('rtmedia_media_delete_priv', $flag);
    return $flag;
}
 /**
  * can_teach( $user_id = null )
  *
  * This will check if current user is allowed to manage courseware for current group
  * @param Int $user_id, the id of the user to check
  * @return Bool, true or false
  */
 function can_teach($user_id = null)
 {
     global $bp;
     if (!$user_id) {
         $user_id = $bp->loggedin_user->id;
     }
     $is_admin = false;
     if (!BPSP_Groups::courseware_status()) {
         return false;
     }
     if (is_super_admin($user_id)) {
         return true;
     }
     if (self::is_teacher($user_id)) {
         $is_admin = true;
     }
     if (!get_option('bpsp_allow_only_admins') && !bp_group_is_admin()) {
         $is_admin = false;
     }
     return $is_admin;
 }
Пример #11
0
		<div class="toggleable doc-is-locked">
			<span class="toggle-switch" id="toggle-doc-is-locked"><?php 
    _e('Locked', 'bp-docs');
    ?>
 <span class="hide-if-no-js description"><?php 
    _e('(click for more info)', 'bp-docs');
    ?>
</span></span>
			<div class="toggle-content">
				<p><?php 
    printf(__('This doc is currently being edited by %1$s. In order to prevent edit conflicts, only one user can edit a doc at a time.', 'bp-docs'), bp_docs_get_current_doc_locker_name());
    ?>
</p>

				<?php 
    if (is_super_admin() || bp_group_is_admin()) {
        ?>
					<p><?php 
        printf(__('Please try again in a few minutes. Or, as an admin, you can <a href="%s">force cancel</a> the edit lock.', 'bp-docs'), bp_docs_get_force_cancel_edit_lock_link());
        ?>
</p>
				<?php 
    } else {
        ?>
					<p><?php 
        _e('Please try again in a few minutes.', 'bp-docs');
        ?>
</p>
				<?php 
    }
    ?>
                <li id="assignment-enable-forum">
                    <form method="post" action="<?php 
    echo $assignment_e_forum_permalink;
    ?>
" class="standard-form" >
                        <input type="submit" value="<?php 
    _e('Enable Assignment Forum', 'bpsp');
    ?>
" />
                        <?php 
    echo $assignment_e_forum_nonce;
    ?>
                    </form>
                </li>
            <?php 
} elseif (bp_group_is_admin()) {
    ?>
                <li id="assignment-forum-inactive">
                    <a href="#" class="action alert"><?php 
    _e('You need forums enabled', 'bpsp');
    ?>
</a>
                </li>
            <?php 
}
?>
            <?php 
if (count($responses) > 0) {
    ?>
                <li id="responses">
                    <a href="#courseware-responses-list" class="action">
Пример #13
0
function invite_anyone_group_invite_access_test()
{
    global $current_user, $bp;
    if (!is_user_logged_in() || empty($bp->groups->current_group)) {
        return 'noone';
    }
    if (!($iaoptions = get_option('invite_anyone'))) {
        $iaoptions = array();
    }
    if (bp_is_group_create()) {
        if (empty($iaoptions['group_invites_can_group_admin']) || $iaoptions['group_invites_can_group_admin'] == 'anyone' || !$iaoptions['group_invites_can_group_admin']) {
            return 'anyone';
        }
        if ($iaoptions['group_invites_can_group_admin'] == 'friends') {
            return 'friends';
        }
        if ($iaoptions['group_invites_can_group_admin'] == 'noone') {
            return 'noone';
        }
    }
    if (!groups_is_user_member($bp->loggedin_user->id, $bp->groups->current_group->id)) {
        return 'noone';
    }
    if (is_super_admin()) {
        if (empty($iaoptions['group_invites_can_admin']) || $iaoptions['group_invites_can_admin'] == 'anyone' || !$iaoptions['group_invites_can_admin']) {
            return 'anyone';
        }
        if ($iaoptions['group_invites_can_admin'] == 'friends') {
            return 'friends';
        }
        if ($iaoptions['group_invites_can_admin'] == 'noone') {
            return 'noone';
        }
    } else {
        if (bp_group_is_admin() || bp_is_group_create()) {
            if (empty($iaoptions['group_invites_can_group_admin']) || $iaoptions['group_invites_can_group_admin'] == 'anyone' || !$iaoptions['group_invites_can_group_admin']) {
                return 'anyone';
            }
            if ($iaoptions['group_invites_can_group_admin'] == 'friends') {
                return 'friends';
            }
            if ($iaoptions['group_invites_can_group_admin'] == 'noone') {
                return 'noone';
            }
        } else {
            if (bp_group_is_mod()) {
                if (empty($iaoptions['group_invites_can_group_mod']) || $iaoptions['group_invites_can_group_mod'] == 'anyone' || !$iaoptions['group_invites_can_group_mod']) {
                    return 'anyone';
                }
                if ($iaoptions['group_invites_can_group_mod'] == 'friends') {
                    return 'friends';
                }
                if ($iaoptions['group_invites_can_group_mod'] == 'noone') {
                    return 'noone';
                }
            } else {
                if (empty($iaoptions['group_invites_can_group_member']) || $iaoptions['group_invites_can_group_member'] == 'anyone' || !$iaoptions['group_invites_can_group_member']) {
                    return 'anyone';
                }
                if ($iaoptions['group_invites_can_group_member'] == 'friends') {
                    return 'friends';
                }
                if ($iaoptions['group_invites_can_group_member'] == 'noone') {
                    return 'noone';
                }
            }
        }
    }
    return 'noone';
}
Пример #14
0
 * Apocrypha Theme Group Members Component
 * Andrew Clayton
 * Version 2.0
 * 10-18-2014
 */
?>

<nav class="reply-header" id="subnav">
	<ul id="profile-tabs" class="tabs" role="navigation">
		<li class="current"><a href="<?php 
bp_group_permalink();
?>
members/" title="Group Members">Guild Members</a></li>
		
		<?php 
if (bp_group_is_admin() || bp_group_is_mod()) {
    ?>
		<li><a href="<?php 
    bp_group_permalink();
    ?>
admin/manage-members/" title="Manage group members">Roster Management</a></li>
		<?php 
}
?>
	</ul>
</nav><!-- #subnav -->

<div id="members-dir-list" class="members dir-list">
<?php 
if (bp_is_current_action('requests')) {
    ?>
Пример #15
0
    function edit_screen()
    {
        global $bp;
        if (!bp_is_group_admin_screen($this->slug)) {
            return false;
        }
        if (is_super_admin()) {
            $exclude_groups = BP_Groups_Hierarchy::get_by_parent($bp->groups->current_group->id);
            if (count($exclude_groups['groups']) > 0) {
                foreach ($exclude_groups['groups'] as $key => $exclude_group) {
                    $exclude_groups['groups'][$key] = $exclude_group->id;
                }
                $exclude_groups = $exclude_groups['groups'];
            } else {
                $exclude_groups = array();
            }
            $exclude_groups[] = $bp->groups->current_group->id;
            $groups = BP_Groups_Hierarchy::get('alphabetical', null, null, 0, false, false, true, $exclude_groups);
            $site_root = new stdClass();
            $site_root->id = 0;
            $site_root->name = __('Site Root', 'bp-group-hierarchy');
            $display_groups = array($site_root);
            foreach ($groups['groups'] as $group) {
                $display_groups[] = $group;
            }
            /* deprecated */
            $display_groups = apply_filters('bp_group_hierarchy_display_groups', $display_groups);
            $display_groups = apply_filters('bp_group_hierarchy_available_parent_groups', $display_groups);
            ?>
			<label for="parent_id"><?php 
            _e('Parent Group', 'bp-group-hierarchy');
            ?>
</label>
			<select name="parent_id" id="parent_id">
				<?php 
            foreach ($display_groups as $group) {
                ?>
					<option value="<?php 
                echo $group->id;
                ?>
"<?php 
                if ($group->id == $bp->groups->current_group->parent_id) {
                    echo ' selected';
                }
                ?>
><?php 
                echo stripslashes($group->name);
                ?>
</option>
				<?php 
            }
            ?>
			</select>
			<?php 
        } else {
            ?>
			<div id="message">
				<p><?php 
            _e('Only a site administrator can edit the group hierarchy.', 'bp-group-hierarchy');
            ?>
</p>
			</div>
			<?php 
        }
        if (is_super_admin() || bp_group_is_admin()) {
            $subgroup_permission_options = apply_filters('bp_group_hierarchy_subgroup_permission_options', $this->subgroup_permission_options);
            $current_subgroup_permission = groups_get_groupmeta($bp->groups->current_group->id, 'bp_group_hierarchy_subgroup_creators');
            if ($current_subgroup_permission == '') {
                $current_subgroup_permission = $this->get_default_permission_option();
            }
            $permission_select = '<select name="allow_children_by" id="allow_children_by">';
            foreach ($subgroup_permission_options as $option => $text) {
                $permission_select .= '<option value="' . $option . '"' . ($option == $current_subgroup_permission ? ' selected' : '') . '>' . $text . '</option>' . "\n";
            }
            $permission_select .= '</select>';
            ?>
			<p>
				<label for="allow_children_by"><?php 
            _e('Member Groups', 'bp-group-hierarchy');
            ?>
</label>
				<?php 
            printf(__('Allow %1$s to create %2$s', 'bp-group-hierarchy'), $permission_select, __('Member Groups', 'bp-group-hierarchy'));
            ?>
			</p>
			<p>
				<input type="submit" class="button primary" id="save" name="save" value="<?php 
            _e('Save Changes', 'bp-group-hierarchy');
            ?>
" />
			</p>
			<?php 
            wp_nonce_field('groups_edit_save_' . $this->slug);
        }
    }
 /**
  * can_teach( $user_id )
  *
  * This will check if current user is allowed to manage courseware for current group
  * @param Int $user_id, the id of the user to check
  * @return Bool, true or false
  */
 function can_teach($user_id)
 {
     $is_admin = false;
     if (!BPSP_Groups::courseware_status()) {
         return false;
     }
     if (is_super_admin($user_id)) {
         return true;
     }
     if (self::is_teacher($user_id)) {
         $is_admin = true;
     }
     if (!get_option('bpsp_allow_only_admins') && !bp_group_is_admin()) {
         $is_admin = false;
     }
     return $is_admin;
 }
    /**
     *
     */
    function add_sticky_icon()
    {
        if (bp_is_group()) {
            if (bp_group_is_admin()) {
                $nonce = wp_create_nonce('pin-activity-nonce');
                $sticky = bp_activity_get_meta(bp_get_activity_id(), 'rw_sticky_activity');
                $title = __('Pin activity', RW_Sticky_Activity::$textdomain);
                $class = "sa-button-pin notpinned";
                if ($sticky == 1) {
                    $title = __('Unpin activity', RW_Sticky_Activity::$textdomain);
                    $class = "sa-button-unpin  pinned";
                }
                ?>
                <a href="" class="fa fa-map-marker <?php 
                echo $class;
                ?>
" title="<?php 
                echo $title;
                ?>
" data-post-nonces="<?php 
                echo $nonce;
                ?>
" data-post-id="<?php 
                echo bp_get_activity_id();
                ?>
"></a>
                <?php 
            }
        }
    }
Пример #18
0
 /**
  * student_screen( $vars )
  *
  * Hooks into courseware_assignment
  * If a student is visiting assignment screen, his grade will be shown
  *
  * @param Array $vars a set of variables received for this screen template
  * @return Array $vars a set of variable passed to this screen template
  */
 function student_screen($vars)
 {
     global $bp;
     $user_id = null;
     if (bp_group_is_member($bp->groups->current_group) && !bp_group_is_admin()) {
         $user_id = $bp->loggedin_user->id;
     }
     if ($user_id) {
         $vars['user_grade'] = $this->load_grade_by_user_id($this->current_assignment, $user_id);
     }
     $vars['has_gradebook_caps'] = $this->has_gradebook_caps($bp->loggedin_user->id);
     return $vars;
 }
Пример #19
0
 /**
  * Catches page loads, determines what to do, and sends users on their merry way
  *
  * @package BuddyPress Docs
  * @since 1.0-beta
  * @todo This needs a ton of cleanup
  */
 function catch_page_load()
 {
     global $bp;
     if (!empty($_POST['doc-edit-submit'])) {
         check_admin_referer('bp_docs_save');
         $this_doc = new BP_Docs_Query();
         $result = $this_doc->save();
         bp_core_add_message($result['message'], $result['message_type']);
         bp_core_redirect(trailingslashit($result['redirect_url']));
     }
     if (!empty($_POST['docs-filter-submit'])) {
         $this->handle_filters();
     }
     // If this is the edit screen, ensure that the user can edit the
     // doc before querying, and redirect if necessary
     if (bp_docs_is_doc_edit()) {
         if (current_user_can('bp_docs_edit')) {
             $doc = bp_docs_get_current_doc();
             // The user can edit, so we check for edit locks
             // Because we're not using WP autosave at the moment, ensure that
             // the lock interval always returns as in process
             add_filter('wp_check_post_lock_window', create_function(false, 'return time();'));
             $lock = bp_docs_check_post_lock($doc->ID);
             if ($lock) {
                 bp_core_add_message(sprintf(__('This doc is currently being edited by %s. To prevent overwrites, you cannot edit until that user has finished. Please try again in a few minutes.', 'bp-docs'), bp_core_get_user_displayname($lock)), 'error');
                 // Redirect back to the non-edit view of this document
                 bp_core_redirect(bp_docs_get_doc_link($doc->ID));
                 die;
             }
         } else {
             if (function_exists('bp_core_no_access') && !is_user_logged_in()) {
                 bp_core_no_access();
             }
             // The user does not have edit permission. Redirect.
             bp_core_add_message(__('You do not have permission to edit the doc.', 'bp-docs'), 'error');
             // Redirect back to the non-edit view of this document
             bp_core_redirect(bp_docs_get_doc_link($doc->ID));
             die;
         }
     }
     if (bp_docs_is_doc_create()) {
         if (!current_user_can('bp_docs_create')) {
             // The user does not have edit permission. Redirect.
             if (function_exists('bp_core_no_access') && !is_user_logged_in()) {
                 bp_core_no_access();
             }
             bp_core_add_message(__('You do not have permission to create a Doc in this group.', 'bp-docs'), 'error');
             $group_permalink = bp_get_group_permalink($bp->groups->current_group);
             // Redirect back to the Doc list view
             bp_core_redirect($group_permalink . $bp->bp_docs->slug . '/');
             die;
         }
     }
     if (!empty($bp->bp_docs->current_view) && 'history' == $bp->bp_docs->current_view) {
         if (!current_user_can('bp_docs_view_history')) {
             // The user does not have edit permission. Redirect.
             if (function_exists('bp_core_no_access') && !is_user_logged_in()) {
                 bp_core_no_access();
             }
             bp_core_add_message(__('You do not have permission to view this Doc\'s history.', 'bp-docs'), 'error');
             $doc = bp_docs_get_current_doc();
             $redirect = bp_docs_get_doc_link($doc->ID);
             // Redirect back to the Doc list view
             bp_core_redirect($redirect);
             die;
         }
     }
     // Cancel edit lock
     if (!empty($_GET['bpd_action']) && $_GET['bpd_action'] == 'cancel_edit_lock') {
         // Check the nonce
         check_admin_referer('bp_docs_cancel_edit_lock');
         // Todo: make this part of the perms system
         if (is_super_admin() || bp_group_is_admin()) {
             $doc = bp_docs_get_current_doc();
             // Todo: get this into a proper method as well, blech
             delete_post_meta($doc->ID, '_bp_docs_last_pinged');
             bp_core_add_message(__('Lock successfully removed', 'bp-docs'));
             bp_core_redirect(bp_docs_get_doc_link($doc->ID));
             die;
         }
     }
     // Cancel edit
     // Have to have a catcher for this so the edit lock can be removed
     if (!empty($_GET['bpd_action']) && $_GET['bpd_action'] == 'cancel_edit') {
         $doc = bp_docs_get_current_doc();
         // Todo: get this into a proper method as well, blech
         delete_post_meta($doc->ID, '_bp_docs_last_pinged');
         bp_core_redirect(bp_docs_get_doc_link($doc->ID));
         die;
     }
     // Todo: get this into a proper method
     if (bp_docs_is_doc_read() && !empty($_GET['delete'])) {
         check_admin_referer('bp_docs_delete');
         if (current_user_can('bp_docs_manage')) {
             $delete_doc_id = get_queried_object_id();
             if (bp_docs_trash_doc($delete_doc_id)) {
                 bp_core_add_message(__('Doc successfully deleted!', 'bp-docs'));
             } else {
                 bp_core_add_message(__('Could not delete doc.', 'bp-docs'));
             }
         } else {
             bp_core_add_message(__('You do not have permission to delete that doc.', 'bp-docs'), 'error');
         }
         bp_core_redirect(home_url(bp_docs_get_docs_slug()));
         die;
     }
     if (bp_docs_is_doc_read() && !empty($_GET['untrash']) && !empty($_GET['doc_id'])) {
         check_admin_referer('bp_docs_untrash');
         $untrash_doc_id = absint($_GET['doc_id']);
         if (current_user_can('bp_docs_manage', $untrash_doc_id)) {
             if (bp_docs_untrash_doc($untrash_doc_id)) {
                 bp_core_add_message(__('Doc successfully removed from Trash!', 'bp-docs'));
             } else {
                 bp_core_add_message(__('Could not remove Doc from Trash.', 'bp-docs'));
             }
         } else {
             bp_core_add_message(__('You do not have permission to remove that Doc from the Trash.', 'bp-docs'), 'error');
         }
         bp_core_redirect(bp_docs_get_doc_link($untrash_doc_id));
         die;
     }
 }
Пример #20
0
 public function current_user_can($action)
 {
     global $bp;
     if (bp_group_is_admin()) {
         return true;
     }
     $user_is_owner = $this->user_id == get_current_user_id();
     switch ($action) {
         case 'add':
             switch (get_option('bp_group_documents_upload_permission')) {
                 case 'mods_decide':
                     switch (groups_get_groupmeta($bp->groups->current_group->id, 'group_documents_upload_permission')) {
                         case 'mods_only':
                             if (bp_group_is_mod($bp->groups->current_group)) {
                                 return true;
                             }
                             break;
                         case 'members':
                         default:
                             if (bp_group_is_member($bp->groups->current_group)) {
                                 return true;
                             }
                             break;
                     }
                     break;
                 case 'mods_only':
                     if (bp_group_is_mod($bp->groups->current_group)) {
                         return true;
                     }
                     break;
                 case 'members':
                 default:
                     if (bp_group_is_member($bp->groups->current_group)) {
                         return true;
                     }
                     break;
             }
             break;
         case 'edit':
             if (bp_group_is_mod($bp->groups->current_group) || bp_group_is_member($bp->groups->current_group) && $user_is_owner) {
                 return true;
             }
             break;
         case 'delete':
             if (bp_group_is_mod($bp->groups->current_group) || bp_group_is_member($bp->groups->current_group) && $user_is_owner) {
                 return true;
             }
             break;
     }
     return false;
 }
Пример #21
0
/**
 * Catches and processes a groupblog uncoupling
 *
 * @since 1.7
 */
function bp_groupblog_process_uncouple()
{
    if (bp_is_group() && bp_is_current_action('admin') && bp_is_action_variable('group-blog', 0) && bp_is_action_variable('uncouple', 1)) {
        check_admin_referer('groupblog-uncouple');
        if (!bp_group_is_admin()) {
            bp_core_add_message(__('You must be a group admin to perform this action.', 'groupblog'), 'error');
            bp_core_redirect(bp_get_group_permalink(groups_get_current_group()));
        }
        $blog_id = get_groupblog_blog_id();
        // If groupblog is enabled, disable it
        groups_update_groupmeta(bp_get_current_group_id(), 'groupblog_enable_blog', 0);
        // Unset the groupblog ID
        groups_update_groupmeta(bp_get_current_group_id(), 'groupblog_blog_id', '');
        bp_core_add_message(__('Blog uncoupled.', 'groupblog'));
        // Redirect to the groupblog admin
        bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'admin/group-blog');
    }
}
/**
 * Get the row class of the current group in the loop.
 *
 * @since 1.7.0
 *
 * @param array $classes Array of custom classes.
 * @return string Row class of the group.
 */
function bp_get_group_class($classes = array())
{
    global $groups_template;
    // Add even/odd classes, but only if there's more than 1 group.
    if ($groups_template->group_count > 1) {
        $pos_in_loop = (int) $groups_template->current_group;
        $classes[] = $pos_in_loop % 2 ? 'even' : 'odd';
        // If we've only one group in the loop, don't bother with odd and even.
    } else {
        $classes[] = 'bp-single-group';
    }
    // Group type - public, private, hidden.
    $classes[] = sanitize_key($groups_template->group->status);
    // User's group role.
    if (bp_is_user_active()) {
        // Admin.
        if (bp_group_is_admin()) {
            $classes[] = 'is-admin';
        }
        // Moderator.
        if (bp_group_is_mod()) {
            $classes[] = 'is-mod';
        }
        // Member.
        if (bp_group_is_member()) {
            $classes[] = 'is-member';
        }
    }
    // Whether a group avatar will appear.
    if (bp_disable_group_avatar_uploads() || !buddypress()->avatar->show_avatars) {
        $classes[] = 'group-no-avatar';
    } else {
        $classes[] = 'group-has-avatar';
    }
    /**
     * Filters classes that will be applied to row class of the current group in the loop.
     *
     * @since 1.7.0
     *
     * @param array $classes Array of determined classes for the row.
     */
    $classes = apply_filters('bp_get_group_class', $classes);
    $classes = array_merge($classes, array());
    $retval = 'class="' . join(' ', $classes) . '"';
    return $retval;
}
Пример #23
0
 /**
  * Catches page loads, determines what to do, and sends users on their merry way
  *
  * @package BuddyPress Docs
  * @since 1.0-beta
  */
 function catch_page_load()
 {
     global $bp;
     if (!empty($_POST['doc-edit-submit'])) {
         $this_doc = new BP_Docs_Query();
         $this_doc->save();
     }
     if (!empty($_POST['docs-filter-submit'])) {
         $this->handle_filters();
     }
     // If this is the edit screen, ensure that the user can edit the
     // doc before querying, and redirect if necessary
     if (!empty($bp->bp_docs->current_view) && 'edit' == $bp->bp_docs->current_view) {
         if (bp_docs_current_user_can('edit')) {
             $doc = bp_docs_get_current_doc();
             // The user can edit, so we check for edit locks
             // Because we're not using WP autosave at the moment, ensure that
             // the lock interval always returns as in process
             add_filter('wp_check_post_lock_window', create_function(false, 'return time();'));
             $lock = wp_check_post_lock($doc->ID);
             if ($lock) {
                 bp_core_add_message(sprintf(__('This doc is currently being edited by %s. To prevent overwrites, you cannot edit until that user has finished. Please try again in a few minutes.', 'bp-docs'), bp_core_get_user_displayname($lock)), 'error');
                 $group_permalink = bp_get_group_permalink($bp->groups->current_group);
                 $doc_slug = $bp->bp_docs->doc_slug;
                 // Redirect back to the non-edit view of this document
                 bp_core_redirect($group_permalink . $bp->bp_docs->slug . '/' . $doc_slug);
             }
         } else {
             // The user does not have edit permission. Redirect.
             bp_core_add_message(__('You do not have permission to edit the doc.', 'bp-docs'), 'error');
             $group_permalink = bp_get_group_permalink($bp->groups->current_group);
             $doc_slug = $bp->bp_docs->doc_slug;
             // Redirect back to the non-edit view of this document
             bp_core_redirect($group_permalink . $bp->bp_docs->slug . '/' . $doc_slug);
         }
     }
     if (!empty($bp->bp_docs->current_view) && 'create' == $bp->bp_docs->current_view) {
         if (!bp_docs_current_user_can('create')) {
             // The user does not have edit permission. Redirect.
             bp_core_add_message(__('You do not have permission to create a Doc in this group.', 'bp-docs'), 'error');
             $group_permalink = bp_get_group_permalink($bp->groups->current_group);
             // Redirect back to the Doc list view
             bp_core_redirect($group_permalink . $bp->bp_docs->slug . '/');
         }
     }
     if (!empty($bp->bp_docs->current_view) && 'history' == $bp->bp_docs->current_view) {
         if (!bp_docs_current_user_can('view_history')) {
             // The user does not have edit permission. Redirect.
             bp_core_add_message(__('You do not have permission to view this Doc\'s history.', 'bp-docs'), 'error');
             $doc = bp_docs_get_current_doc();
             $redirect = bp_docs_get_doc_link($doc->ID);
             // Redirect back to the Doc list view
             bp_core_redirect($redirect);
         }
     }
     // Cancel edit lock
     if (!empty($_GET['bpd_action']) && $_GET['bpd_action'] == 'cancel_edit_lock') {
         // Check the nonce
         check_admin_referer('bp_docs_cancel_edit_lock');
         // Todo: make this part of the perms system
         if (is_super_admin() || bp_group_is_admin()) {
             $doc = bp_docs_get_current_doc();
             // Todo: get this into a proper method as well, blech
             delete_post_meta($doc->ID, '_edit_lock');
             bp_core_add_message(__('Lock successfully removed', 'bp-docs'));
             bp_core_redirect(bp_docs_get_doc_link($doc->ID));
         }
     }
     // Cancel edit
     // Have to have a catcher for this so the edit lock can be removed
     if (!empty($_GET['bpd_action']) && $_GET['bpd_action'] == 'cancel_edit') {
         $doc = bp_docs_get_current_doc();
         // Todo: get this into a proper method as well, blech
         delete_post_meta($doc->ID, '_edit_lock');
         bp_core_redirect(bp_docs_get_doc_link($doc->ID));
     }
     // Todo: get this into a proper method
     if ($bp->bp_docs->current_view == 'delete') {
         check_admin_referer('bp_docs_delete');
         if (bp_docs_current_user_can('manage')) {
             $the_doc_args = array('name' => $bp->action_variables[0], 'post_type' => $bp->bp_docs->post_type_name);
             $the_docs = get_posts($the_doc_args);
             $doc_id = $the_docs[0]->ID;
             do_action('bp_docs_before_doc_delete', $doc_id);
             $delete_args = array('ID' => $doc_id, 'post_status' => 'trash');
             wp_update_post($delete_args);
             do_action('bp_docs_doc_deleted', $delete_args);
             bp_core_add_message(__('Doc successfully deleted!', 'bp-docs'));
         } else {
             bp_core_add_message(__('You do not have permission to delete that doc.', 'bp-docs'), 'error');
         }
         // todo: abstract this out so I don't have to call group permalink here
         $redirect_url = bp_get_group_permalink($bp->groups->current_group) . $bp->bp_docs->slug . '/';
         bp_core_redirect($redirect_url);
     }
 }
 /**
  * has_assignment_caps( $user_id )
  *
  * Checks if $user_id has assignment management capabilities
  *
  * @param Int $user_id ID of the user capabilities to be checked
  * @return True if $user_id is eligible and False if not.
  */
 function has_assignment_caps($user_id)
 {
     $is_ok = true;
     //Treat super admins
     if (is_super_admin($user_id)) {
         $this->add_assignment_caps($user_id);
     }
     $user = new WP_User($user_id);
     foreach ($this->caps as $c) {
         if (!$user->has_cap($c)) {
             $is_ok = false;
         }
     }
     if (!get_option('bpsp_allow_only_admins')) {
         if (!bp_group_is_admin()) {
             $is_ok = false;
         }
     }
     return $is_ok;
 }
Пример #25
0
 /**
  * Allow group members to have advanced priviledges in group forum topics.
  *
  * @since bbPress (r4434)
  *
  * @param array $caps
  * @param string $cap
  * @param int $user_id
  * @param array $args
  * @return array
  */
 public function map_topic_meta_caps($caps = array(), $cap = '', $user_id = 0, $args = array())
 {
     // Bail if not viewing a single topic
     if (!bp_is_single_item() || !bp_is_groups_component() || !bp_is_current_action('forum') || !bp_is_action_variable(0, 'topic')) {
         return $caps;
     }
     switch ($cap) {
         // If user is a group mmember, allow them to create content.
         case 'read_forum':
         case 'publish_replies':
         case 'publish_topics':
         case 'read_hidden_forums':
         case 'read_private_forums':
             if (bp_group_is_member() || bp_group_is_mod() || bp_group_is_admin()) {
                 $caps = array('participate');
             }
             break;
             // If user is a group mod ar admin, map to participate cap.
         // If user is a group mod ar admin, map to participate cap.
         case 'moderate':
         case 'edit_topic':
         case 'edit_reply':
         case 'view_trash':
         case 'edit_others_replies':
         case 'edit_others_topics':
             if (bp_group_is_mod() || bp_group_is_admin()) {
                 $caps = array('participate');
             }
             break;
             // If user is a group admin, allow them to delete topics and replies.
         // If user is a group admin, allow them to delete topics and replies.
         case 'delete_topic':
         case 'delete_reply':
             if (bp_group_is_admin()) {
                 $caps = array('participate');
             }
             break;
     }
     return apply_filters('bbp_map_group_forum_topic_meta_caps', $caps, $cap, $user_id, $args);
 }