/**
 * 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;
}
Example #2
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 
/**
 * 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;
}
Example #4
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">
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;
}
Example #6
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;
 }
Example #7
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';
}
Example #8
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')) {
    ?>
    /**
     * 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 
        }
    }
Example #10
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);
 }