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


PHP bbp_is_forum_private函数代码示例

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


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

示例1: bbp_forum_enforce_private

/**
 * Check if it's a private forum or a topic or reply of a private forum and if
 * the user can't view it, then sets a 404
 *
 * @since bbPress (r2996)
 *
 * @uses current_user_can() To check if the current user can read private forums
 * @uses is_singular() To check if it's a singular page
 * @uses bbp_is_user_keymaster() To check if user is a keymaster
 * @uses bbp_get_forum_post_type() To get the forum post type
 * @uses bbp_get_topic_post_type() To get the topic post type
 * @uses bbp_get_reply_post_type() TO get the reply post type
 * @uses bbp_get_topic_forum_id() To get the topic forum id
 * @uses bbp_get_reply_forum_id() To get the reply forum id
 * @uses bbp_is_forum_private() To check if the forum is private or not
 * @uses bbp_set_404() To set a 404 status
 */
function bbp_forum_enforce_private()
{
    // Bail if not viewing a single item or if user has caps
    if (!is_singular() || bbp_is_user_keymaster() || current_user_can('read_private_forums')) {
        return;
    }
    global $wp_query;
    // Define local variable
    $forum_id = 0;
    // Check post type
    switch ($wp_query->get('post_type')) {
        // Forum
        case bbp_get_forum_post_type():
            $forum_id = bbp_get_forum_id($wp_query->post->ID);
            break;
            // Topic
        // Topic
        case bbp_get_topic_post_type():
            $forum_id = bbp_get_topic_forum_id($wp_query->post->ID);
            break;
            // Reply
        // Reply
        case bbp_get_reply_post_type():
            $forum_id = bbp_get_reply_forum_id($wp_query->post->ID);
            break;
    }
    // If forum is explicitly hidden and user not capable, set 404
    if (!empty($forum_id) && bbp_is_forum_private($forum_id) && !current_user_can('read_private_forums')) {
        bbp_set_404();
    }
}
开发者ID:jenia-buianov,项目名称:all_my_sites,代码行数:48,代码来源:functions.php

示例2: bbp_edit_topic_handler


//.........这里部分代码省略.........
    // Nonce check
    if (!bbp_verify_nonce_request('bbp-edit-topic_' . $topic_id)) {
        bbp_add_error('bbp_edit_topic_nonce', __('<strong>ERROR</strong>: Are you sure you wanted to do that?', 'bbpress'));
        return;
    }
    // Remove kses filters from title and content for capable users and if the nonce is verified
    if (current_user_can('unfiltered_html') && !empty($_POST['_bbp_unfiltered_html_topic']) && wp_create_nonce('bbp-unfiltered-html-topic_' . $topic_id) === $_POST['_bbp_unfiltered_html_topic']) {
        remove_filter('bbp_edit_topic_pre_title', 'wp_filter_kses');
        remove_filter('bbp_edit_topic_pre_content', 'bbp_encode_bad', 10);
        remove_filter('bbp_edit_topic_pre_content', 'bbp_filter_kses', 30);
    }
    /** Topic Forum ***********************************************************/
    // Forum id was not passed
    if (empty($_POST['bbp_forum_id'])) {
        bbp_add_error('bbp_topic_forum_id', __('<strong>ERROR</strong>: Forum ID is missing.', 'bbpress'));
        // Forum id was passed
    } elseif (is_numeric($_POST['bbp_forum_id'])) {
        $forum_id = (int) $_POST['bbp_forum_id'];
    }
    // Current forum this topic is in
    $current_forum_id = bbp_get_topic_forum_id($topic_id);
    // Forum exists
    if (!empty($forum_id) && $forum_id !== $current_forum_id) {
        // Forum is a category
        if (bbp_is_forum_category($forum_id)) {
            bbp_add_error('bbp_edit_topic_forum_category', __('<strong>ERROR</strong>: This forum is a category. No topics can be created in it.', 'bbpress'));
            // Forum is not a category
        } else {
            // Forum is closed and user cannot access
            if (bbp_is_forum_closed($forum_id) && !current_user_can('edit_forum', $forum_id)) {
                bbp_add_error('bbp_edit_topic_forum_closed', __('<strong>ERROR</strong>: This forum has been closed to new topics.', 'bbpress'));
            }
            // Forum is private and user cannot access
            if (bbp_is_forum_private($forum_id)) {
                if (!current_user_can('read_private_forums')) {
                    bbp_add_error('bbp_edit_topic_forum_private', __('<strong>ERROR</strong>: This forum is private and you do not have the capability to read or create new topics in it.', 'bbpress'));
                }
                // Forum is hidden and user cannot access
            } elseif (bbp_is_forum_hidden($forum_id)) {
                if (!current_user_can('read_hidden_forums')) {
                    bbp_add_error('bbp_edit_topic_forum_hidden', __('<strong>ERROR</strong>: This forum is hidden and you do not have the capability to read or create new topics in it.', 'bbpress'));
                }
            }
        }
    }
    /** Topic Title ***********************************************************/
    if (!empty($_POST['bbp_topic_title'])) {
        $topic_title = esc_attr(strip_tags($_POST['bbp_topic_title']));
    }
    // Filter and sanitize
    $topic_title = apply_filters('bbp_edit_topic_pre_title', $topic_title, $topic_id);
    // No topic title
    if (empty($topic_title)) {
        bbp_add_error('bbp_edit_topic_title', __('<strong>ERROR</strong>: Your topic needs a title.', 'bbpress'));
    }
    /** Topic Content *********************************************************/
    if (!empty($_POST['bbp_topic_content'])) {
        $topic_content = $_POST['bbp_topic_content'];
    }
    // Filter and sanitize
    $topic_content = apply_filters('bbp_edit_topic_pre_content', $topic_content, $topic_id);
    // No topic content
    if (empty($topic_content)) {
        bbp_add_error('bbp_edit_topic_content', __('<strong>ERROR</strong>: Your topic cannot be empty.', 'bbpress'));
    }
    /** Topic Blacklist *******************************************************/
开发者ID:jenia-buianov,项目名称:all_my_sites,代码行数:67,代码来源:functions.php

示例3: bbp_suppress_private_author_link

/**
 * Replace forum author details for users that cannot view them.
 *
 * @since bbPress (r3162)
 *
 * @param string $retval
 * @param int $forum_id
 *
 * @uses bbp_is_forum_private()
 * @uses get_post_field()
 * @uses bbp_get_topic_post_type()
 * @uses bbp_is_forum_private()
 * @uses bbp_get_topic_forum_id()
 * @uses bbp_get_reply_post_type()
 * @uses bbp_get_reply_forum_id()
 *
 * @return string
 */
function bbp_suppress_private_author_link($author_link, $args)
{
    // Assume the author link is the return value
    $retval = $author_link;
    // Show the normal author link
    if (!empty($args['post_id']) && !current_user_can('read_private_forums')) {
        // What post type are we looking at?
        $post_type = get_post_field('post_type', $args['post_id']);
        switch ($post_type) {
            // Topic
            case bbp_get_topic_post_type():
                if (bbp_is_forum_private(bbp_get_topic_forum_id($args['post_id']))) {
                    $retval = '';
                }
                break;
                // Reply
            // Reply
            case bbp_get_reply_post_type():
                if (bbp_is_forum_private(bbp_get_reply_forum_id($args['post_id']))) {
                    $retval = '';
                }
                break;
                // Post
            // Post
            default:
                if (bbp_is_forum_private($args['post_id'])) {
                    $retval = '';
                }
                break;
        }
    }
    return apply_filters('bbp_suppress_private_author_link', $retval);
}
开发者ID:hscale,项目名称:webento,代码行数:51,代码来源:bbp-forum-template.php

示例4: bbp_edit_reply_handler


//.........这里部分代码省略.........
                bbp_add_error('bbp_edit_reply_permissions', __('<strong>ERROR</strong>: You do not have permission to edit that reply.', 'bbpress'));
                return;
            }
            // Set reply author
            $reply_author = bbp_get_reply_author_id($reply_id);
            // It is an anonymous post
        } else {
            // Filter anonymous data
            $anonymous_data = bbp_filter_anonymous_post_data();
        }
    }
    // Remove kses filters from title and content for capable users and if the nonce is verified
    if (current_user_can('unfiltered_html') && !empty($_POST['_bbp_unfiltered_html_reply']) && wp_create_nonce('bbp-unfiltered-html-reply_' . $reply_id) === $_POST['_bbp_unfiltered_html_reply']) {
        remove_filter('bbp_edit_reply_pre_title', 'wp_filter_kses');
        remove_filter('bbp_edit_reply_pre_content', 'bbp_encode_bad', 10);
        remove_filter('bbp_edit_reply_pre_content', 'bbp_filter_kses', 30);
    }
    /** Reply Topic ***********************************************************/
    $topic_id = bbp_get_reply_topic_id($reply_id);
    /** Topic Forum ***********************************************************/
    $forum_id = bbp_get_topic_forum_id($topic_id);
    // Forum exists
    if (!empty($forum_id) && $forum_id !== bbp_get_reply_forum_id($reply_id)) {
        // Forum is a category
        if (bbp_is_forum_category($forum_id)) {
            bbp_add_error('bbp_edit_reply_forum_category', __('<strong>ERROR</strong>: This forum is a category. No replies can be created in this forum.', 'bbpress'));
            // Forum is not a category
        } else {
            // Forum is closed and user cannot access
            if (bbp_is_forum_closed($forum_id) && !current_user_can('edit_forum', $forum_id)) {
                bbp_add_error('bbp_edit_reply_forum_closed', __('<strong>ERROR</strong>: This forum has been closed to new replies.', 'bbpress'));
            }
            // Forum is private and user cannot access
            if (bbp_is_forum_private($forum_id)) {
                if (!current_user_can('read_private_forums')) {
                    bbp_add_error('bbp_edit_reply_forum_private', __('<strong>ERROR</strong>: This forum is private and you do not have the capability to read or create new replies in it.', 'bbpress'));
                }
                // Forum is hidden and user cannot access
            } elseif (bbp_is_forum_hidden($forum_id)) {
                if (!current_user_can('read_hidden_forums')) {
                    bbp_add_error('bbp_edit_reply_forum_hidden', __('<strong>ERROR</strong>: This forum is hidden and you do not have the capability to read or create new replies in it.', 'bbpress'));
                }
            }
        }
    }
    /** Reply Title ***********************************************************/
    if (!empty($_POST['bbp_reply_title'])) {
        $reply_title = esc_attr(strip_tags($_POST['bbp_reply_title']));
    }
    // Filter and sanitize
    $reply_title = apply_filters('bbp_edit_reply_pre_title', $reply_title, $reply_id);
    /** Reply Content *********************************************************/
    if (!empty($_POST['bbp_reply_content'])) {
        $reply_content = $_POST['bbp_reply_content'];
    }
    // Filter and sanitize
    $reply_content = apply_filters('bbp_edit_reply_pre_content', $reply_content, $reply_id);
    // No reply content
    if (empty($reply_content)) {
        bbp_add_error('bbp_edit_reply_content', __('<strong>ERROR</strong>: Your reply cannot be empty.', 'bbpress'));
    }
    /** Reply Blacklist *******************************************************/
    if (!bbp_check_for_blacklist($anonymous_data, $reply_author, $reply_title, $reply_content)) {
        bbp_add_error('bbp_reply_blacklist', __('<strong>ERROR</strong>: Your reply cannot be edited at this time.', 'bbpress'));
    }
    /** Reply Status **********************************************************/
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:67,代码来源:functions.php

示例5: bbp_get_template_part

								<?php 
        bbp_get_template_part('bbpress/content', 'single-topic');
        ?>

							</div>
						</div><!-- #bbp-topic-wrapper-<?php 
        bbp_topic_id();
        ?>
 -->

					<?php 
    }
    ?>

				<?php 
} elseif (bbp_is_forum_private(bbp_get_topic_forum_id(), false)) {
    ?>

					<?php 
    bbp_get_template_part('bbpress/feedback', 'no-access');
    ?>

				<?php 
}
?>

			</div><!-- #content -->
		</div><!-- #container -->

<?php 
get_footer();
开发者ID:shads196770,项目名称:cbox-theme,代码行数:31,代码来源:single-topic.php

示例6: bbp_user_can_view_forum

/**
 * Check if the user can access a specific forum
 *
 * @since 2.0.0 bbPress (r3127)
 *
 * @uses bbp_get_current_user_id()
 * @uses bbp_get_forum_id()
 * @uses bbp_allow_anonymous()
 * @uses bbp_parse_args()
 * @uses bbp_get_user_id()
 * @uses current_user_can()
 * @uses bbp_is_user_keymaster()
 * @uses bbp_is_forum_public()
 * @uses bbp_is_forum_private()
 * @uses bbp_is_forum_hidden()
 * @uses current_user_can()
 * @uses apply_filters()
 *
 * @return bool
 */
function bbp_user_can_view_forum($args = array())
{
    // Parse arguments against default values
    $r = bbp_parse_args($args, array('user_id' => bbp_get_current_user_id(), 'forum_id' => bbp_get_forum_id(), 'check_ancestors' => false), 'user_can_view_forum');
    // Validate parsed values
    $user_id = bbp_get_user_id($r['user_id'], false, false);
    $forum_id = bbp_get_forum_id($r['forum_id']);
    $retval = false;
    // User is a keymaster
    if (!empty($user_id) && bbp_is_user_keymaster($user_id)) {
        $retval = true;
        // Forum is public, and user can read forums or is not logged in
    } elseif (bbp_is_forum_public($forum_id, $r['check_ancestors'])) {
        $retval = true;
        // Forum is private, and user can see it
    } elseif (bbp_is_forum_private($forum_id, $r['check_ancestors']) && user_can($user_id, 'read_private_forums')) {
        $retval = true;
        // Forum is hidden, and user can see it
    } elseif (bbp_is_forum_hidden($forum_id, $r['check_ancestors']) && user_can($user_id, 'read_hidden_forums')) {
        $retval = true;
    }
    return apply_filters('bbp_user_can_view_forum', $retval, $forum_id, $user_id);
}
开发者ID:CompositeUK,项目名称:clone.bbPress,代码行数:43,代码来源:template.php

示例7: display_reply

 /**
  * Display the contents of a specific reply ID in an output buffer
  * and return to ensure that post/page contents are displayed first.
  *
  * @since bbPress (r3031)
  *
  * @param array $attr
  * @param string $content
  * @uses get_template_part()
  * @return string
  */
 public function display_reply($attr, $content = '')
 {
     // Sanity check required info
     if (!empty($content) || (empty($attr['id']) || !is_numeric($attr['id']))) {
         return $content;
     }
     // Unset globals
     $this->unset_globals();
     // Set passed attribute to $reply_id for clarity
     $reply_id = bbpress()->current_reply_id = $attr['id'];
     $forum_id = bbp_get_reply_forum_id($reply_id);
     // Bail if ID passed is not a reply
     if (!bbp_is_reply($reply_id)) {
         return $content;
     }
     // Reset the queries if not in theme compat
     if (!bbp_is_theme_compat_active()) {
         $bbp = bbpress();
         // Reset necessary forum_query attributes for replys loop to function
         $bbp->forum_query->query_vars['post_type'] = bbp_get_forum_post_type();
         $bbp->forum_query->in_the_loop = true;
         $bbp->forum_query->post = get_post($forum_id);
         // Reset necessary reply_query attributes for replys loop to function
         $bbp->reply_query->query_vars['post_type'] = bbp_get_reply_post_type();
         $bbp->reply_query->in_the_loop = true;
         $bbp->reply_query->post = get_post($reply_id);
     }
     // Start output buffer
     $this->start('bbp_single_reply');
     // Check forum caps
     if (bbp_user_can_view_forum(array('forum_id' => $forum_id))) {
         bbp_get_template_part('content', 'single-reply');
         // Forum is private and user does not have caps
     } elseif (bbp_is_forum_private($forum_id, false)) {
         bbp_get_template_part('feedback', 'no-access');
     }
     // Return contents of output buffer
     return $this->end();
 }
开发者ID:hscale,项目名称:webento,代码行数:50,代码来源:shortcodes.php

示例8: bbp_user_can_view_forum

/**
 * Check if the user can access a specific forum
 *
 * @since bbPress (r3127)
 *
 * @uses bbp_get_current_user_id()
 * @uses bbp_get_forum_id()
 * @uses bbp_allow_anonymous()
 * @uses bbp_parse_args()
 * @uses bbp_get_user_id()
 * @uses current_user_can()
 * @uses is_super_admin()
 * @uses bbp_is_forum_public()
 * @uses bbp_is_forum_private()
 * @uses bbp_is_forum_hidden()
 * @uses current_user_can()
 * @uses apply_filters()
 *
 * @return bool
 */
function bbp_user_can_view_forum($args = '')
{
    // Default arguments
    $defaults = array('user_id' => bbp_get_current_user_id(), 'forum_id' => bbp_get_forum_id(), 'check_ancestors' => false);
    $r = bbp_parse_args($args, $defaults, 'user_can_view_forum');
    extract($r);
    // Validate parsed values
    $user_id = bbp_get_user_id($user_id, false, false);
    $forum_id = bbp_get_forum_id($forum_id);
    $retval = false;
    // User is a super admin
    if (is_super_admin()) {
        $retval = true;
    } elseif (bbp_is_forum_public($forum_id, $check_ancestors)) {
        $retval = true;
    } elseif (bbp_is_forum_private($forum_id, $check_ancestors) && current_user_can('read_private_forums')) {
        $retval = true;
    } elseif (bbp_is_forum_hidden($forum_id, $check_ancestors) && current_user_can('read_hidden_forums')) {
        $retval = true;
    }
    return apply_filters('bbp_user_can_view_forum', $retval, $forum_id, $user_id);
}
开发者ID:rmccue,项目名称:bbPress,代码行数:42,代码来源:bbp-user-template.php

示例9: test_bbp_insert_forum

 /**
  * @group canonical
  * @covers ::bbp_insert_forum
  */
 public function test_bbp_insert_forum()
 {
     $c = $this->factory->forum->create(array('post_title' => 'Category 1', 'post_content' => 'Content of Category 1', 'forum_meta' => array('forum_type' => 'category', 'status' => 'open')));
     $f = $this->factory->forum->create(array('post_title' => 'Forum 1', 'post_content' => 'Content of Forum 1', 'post_parent' => $c, 'forum_meta' => array('forum_id' => $c, 'forum_type' => 'forum', 'status' => 'open')));
     $now = time();
     $post_date = date('Y-m-d H:i:s', $now - 60 * 60 * 100);
     $t = $this->factory->topic->create(array('post_parent' => $f, 'post_date' => $post_date, 'topic_meta' => array('forum_id' => $f)));
     $r = $this->factory->reply->create(array('post_parent' => $t, 'post_date' => $post_date, 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t)));
     // Get the category.
     $category = bbp_get_forum($c);
     // Get the forum.
     $forum = bbp_get_forum($f);
     // Category post.
     $this->assertSame('Category 1', bbp_get_forum_title($c));
     $this->assertSame('Content of Category 1', bbp_get_forum_content($c));
     $this->assertSame('open', bbp_get_forum_status($c));
     $this->assertSame('category', bbp_get_forum_type($c));
     $this->assertTrue(bbp_is_forum($c));
     $this->assertTrue(bbp_is_forum_category($c));
     $this->assertTrue(bbp_is_forum_open($c));
     $this->assertTrue(bbp_is_forum_public($c));
     $this->assertFalse(bbp_is_forum_closed($c));
     $this->assertFalse(bbp_is_forum_hidden($c));
     $this->assertFalse(bbp_is_forum_private($c));
     $this->assertSame(0, bbp_get_forum_parent_id($c));
     $this->assertEquals('http://' . WP_TESTS_DOMAIN . '/?forum=' . $category->post_name, $category->guid);
     // Forum post.
     $this->assertSame('Forum 1', bbp_get_forum_title($f));
     $this->assertSame('Content of Forum 1', bbp_get_forum_content($f));
     $this->assertSame('open', bbp_get_forum_status($f));
     $this->assertSame('forum', bbp_get_forum_type($f));
     $this->assertTrue(bbp_is_forum($f));
     $this->assertTrue(bbp_is_forum_open($f));
     $this->assertTrue(bbp_is_forum_public($f));
     $this->assertFalse(bbp_is_forum_closed($f));
     $this->assertFalse(bbp_is_forum_hidden($f));
     $this->assertFalse(bbp_is_forum_private($f));
     $this->assertSame($c, bbp_get_forum_parent_id($f));
     $this->assertEquals('http://' . WP_TESTS_DOMAIN . '/?forum=' . $category->post_name . '/' . $forum->post_name, $forum->guid);
     // Category meta.
     $this->assertSame(1, bbp_get_forum_subforum_count($c, true));
     $this->assertSame(0, bbp_get_forum_topic_count($c, false, true));
     $this->assertSame(1, bbp_get_forum_topic_count($c, true, true));
     $this->assertSame(0, bbp_get_forum_topic_count_hidden($c, true));
     $this->assertSame(0, bbp_get_forum_reply_count($c, false, true));
     $this->assertSame(1, bbp_get_forum_reply_count($c, true, true));
     $this->assertSame(0, bbp_get_forum_post_count($c, false, true));
     $this->assertSame(2, bbp_get_forum_post_count($c, true, true));
     $this->assertSame($t, bbp_get_forum_last_topic_id($c));
     $this->assertSame($r, bbp_get_forum_last_reply_id($c));
     $this->assertSame($r, bbp_get_forum_last_active_id($c));
     $this->assertSame('4 days, 4 hours ago', bbp_get_forum_last_active_time($c));
     // Forum meta.
     $this->assertSame(0, bbp_get_forum_subforum_count($f, true));
     $this->assertSame(1, bbp_get_forum_topic_count($f, false, true));
     $this->assertSame(1, bbp_get_forum_topic_count($f, true, true));
     $this->assertSame(0, bbp_get_forum_topic_count_hidden($f, true));
     $this->assertSame(1, bbp_get_forum_reply_count($f, false, true));
     $this->assertSame(1, bbp_get_forum_reply_count($f, true, true));
     $this->assertSame(2, bbp_get_forum_post_count($f, false, true));
     $this->assertSame(2, bbp_get_forum_post_count($f, true, true));
     $this->assertSame($t, bbp_get_forum_last_topic_id($f));
     $this->assertSame($r, bbp_get_forum_last_reply_id($f));
     $this->assertSame($r, bbp_get_forum_last_active_id($f));
     $this->assertSame('4 days, 4 hours ago', bbp_get_forum_last_active_time($f));
 }
开发者ID:CompositeUK,项目名称:clone.bbPress,代码行数:70,代码来源:forum.php

示例10: test_bbp_is_forum_private

 /**
  * @covers ::bbp_is_forum_private
  */
 public function test_bbp_is_forum_private()
 {
     $f = $this->factory->forum->create(array('post_status' => 'private'));
     $forum = bbp_get_forum_visibility($f);
     $this->assertSame('private', $forum);
     $forum_status_id = bbp_get_private_status_id($f);
     $this->assertSame('private', $forum_status_id);
     $this->assertTrue(bbp_is_forum_private($f));
 }
开发者ID:joeyblake,项目名称:bbpress,代码行数:12,代码来源:status.php

示例11: post_new_topic

 /**
  * Post new topic by email handler.
  *
  * For bbPress, the logic in this method is the same as {@link bbp_new_topic_handler()}.
  * It's duplicated because bbPress doesn't utilize hooks for verifying topics.
  *
  * @todo No fancy support for topic tags, subscriptions yet. Will probably need shortcodes.
  *
  * @param array $data {
  *     An array of arguments.
  *
  *     @type array $headers Email headers.
  *     @type string $content The email body content.
  *     @type string $subject The email subject line.
  *     @type int $user_id The user ID who sent the email.
  *     @type bool $is_html Whether the email content is HTML or not.
  *     @type int $i The email message number.
  * }
  * @param array $params Parsed paramaters from the email address querystring.
  *   See {@link BP_Reply_By_Email_Parser::get_parameters()}.
  * @return array|object Array of the parsed item on success. WP_Error object
  *  on failure.
  */
 private function post_new_topic($data, $params)
 {
     //private function post_new_topic( $connection, $i, $headers, $params, $body, $topic_author ) {
     /** SETUP DATA ***************************************************/
     $i = $data['i'];
     $topic_author = $data['user_id'];
     $forum_id = $params[$this->forum_id_param];
     /* current email is a bbPress new topic, let's proceed! */
     // let RBE know that we're in the process of rendering a bbP new topic
     // BuddyPress group new topic
     if (!empty($params[$this->item_id_param])) {
         bp_rbe_log('Message #' . $i . ': this is a bbPress group forum new topic');
         // bbPress
     } else {
         bp_rbe_log('Message #' . $i . ': this is a bbPress new topic');
     }
     // other variables
     $anonymous_data = 0;
     /** GROUP PERMISSIONS ********************************************/
     // posting from a BP group
     if (!empty($params[$this->item_id_param])) {
         global $bp;
         // set group ID and cache it in global for later use
         // $bp->rbe->temp->group_id gets passed to the set_group_id() method later on
         $group_id = $bp->rbe->temp->group_id = $params[$this->item_id_param];
         // get all group member data for the user in one swoop!
         $group_member_data = bp_rbe_get_group_member_info($topic_author, $group_id);
         // user is not a member of the group anymore
         if (empty($group_member_data)) {
             //do_action( 'bp_rbe_imap_no_match', $connection, $i, $headers, 'user_not_group_member' );
             return new WP_Error('user_not_group_member', '', $data);
         }
         // user is banned from group
         if ((int) $group_member_data->is_banned == 1) {
             //do_action( 'bp_rbe_imap_no_match', $connection, $i, $headers, 'user_banned_from_group' );
             return new WP_Error('user_banned_from_group', '', $data);
         }
         // override groups_get_current_group() with our cached group ID
         add_filter('groups_get_current_group', array($this, 'set_group_id'));
         // temporarily add some GES filters here
         add_filter('bp_ass_activity_notification_subject', 'wp_specialchars_decode');
         add_filter('bp_ass_activity_notification_content', 'wp_specialchars_decode');
     }
     /** TOPIC / FORUM PERMISSIONS ************************************/
     // Allow member to pass default cap checks.
     // The reason why we keep the user_can() checks below is b/c bbPress
     // plugins may disable cap access for a specific user if they have hooked into
     // the 'bbp_map_meta_caps' filter.
     add_filter('bbp_map_meta_caps', array($this, 'map_forum_meta_caps'), 5, 4);
     // User cannot create topics
     if (!user_can($topic_author, 'publish_topics')) {
         //do_action( 'bp_rbe_imap_no_match', $connection, $i, $headers, 'bbp_topic_permissions' );
         return new WP_Error('bbp_topic_permissions', '', $data);
     }
     // Forum is a category
     if (bbp_is_forum_category($forum_id)) {
         //do_action( 'bp_rbe_imap_no_match', $connection, $i, $headers, 'bbp_edit_topic_forum_category' );
         //bbp_add_error( 'bbp_edit_topic_forum_category', __( '<strong>ERROR</strong>: This forum is a category. No topics can be created in this forum.', 'bbpress' ) );
         return new WP_Error('bbp_edit_topic_forum_category', '', $data);
         // Forum is not a category
     } else {
         // Forum is closed and user cannot access
         if (bbp_is_forum_closed($forum_id) && !user_can($topic_author, 'edit_forum')) {
             //do_action( 'bp_rbe_imap_no_match', $connection, $i, $headers, 'bbp_edit_topic_forum_closed' );
             //bbp_add_error( 'bbp_edit_topic_forum_closed', __( '<strong>ERROR</strong>: This forum has been closed to new topics.', 'bbpress' ) );
             return new WP_Error('bbp_edit_topic_forum_closed', '', $data);
         }
         // Forum is private and user cannot access
         if (bbp_is_forum_private($forum_id)) {
             if (!user_can($topic_author, 'read_private_forums')) {
                 //do_action( 'bp_rbe_imap_no_match', $connection, $i, $headers, 'bbp_edit_topic_forum_private' );
                 //bbp_add_error( 'bbp_edit_topic_forum_private', __( '<strong>ERROR</strong>: This forum is private and you do not have the capability to read or create new topics in it.', 'bbpress' ) );
                 return new WP_Error('bbp_edit_topic_forum_private', '', $data);
             }
         }
         // Forum is hidden and user cannot access
         if (bbp_is_forum_hidden($forum_id)) {
//.........这里部分代码省略.........
开发者ID:r-a-y,项目名称:bp-reply-by-email,代码行数:101,代码来源:bp-rbe-extend-bbpress.php

示例12: bbp_get_template_part

					<?php 
        bbp_get_template_part('content', 'single-reply');
        ?>

				</div><!-- .entry-content -->
		</div>
	</div>
	</section>
	</div><!-- #topic-front -->

		<?php 
    }
    ?>

	<?php 
} elseif (bbp_is_forum_private(bbp_get_reply_forum_id(), false)) {
    ?>

		<?php 
    bbp_get_template_part('feedback', 'no-access');
    ?>

	<?php 
}
?>

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

	</section>
开发者ID:gigikir,项目名称:adebe,代码行数:31,代码来源:single-reply.php

示例13: custom_freshness_link

function custom_freshness_link($forum_id = 0)
{
    global $rpg_settingsf;
    $forum_id = bbp_get_forum_id($forum_id);
    $active_id = bbp_get_forum_last_active_id($forum_id);
    $link_url = $title = '';
    $forum_title = bbp_get_forum_title($forum_id);
    if (empty($active_id)) {
        $active_id = bbp_get_forum_last_reply_id($forum_id);
    }
    if (empty($active_id)) {
        $active_id = bbp_get_forum_last_topic_id($forum_id);
    }
    if (bbp_is_topic($active_id)) {
        $link_url = bbp_get_forum_last_topic_permalink($forum_id);
        //$link_id added to get post_id and type to allow for later check
        $link_id = bbp_get_forum_last_topic_id($forum_id);
        $check = "topic";
        $title = bbp_get_forum_last_topic_title($forum_id);
        $forum_id_last_active = bbp_get_topic_forum_id($active_id);
    } elseif (bbp_is_reply($active_id)) {
        $link_url = bbp_get_forum_last_reply_url($forum_id);
        //$link-id added to get post-id and type to allow for later check
        $link_id = bbp_get_forum_last_reply_id($forum_id);
        $check = "reply";
        $title = bbp_get_forum_last_reply_title($forum_id);
        $forum_id_last_active = bbp_get_reply_forum_id($active_id);
    }
    $time_since = bbp_get_forum_last_active_time($forum_id);
    if (!empty($time_since) && !empty($link_url)) {
        //ADDITIONAL CODE to original bbp_get_forum_freshness_link function
        //test if user can see this post, and post link if they can
        $user_id = wp_get_current_user()->ID;
        //get the forum id for the post - that's the forum ID against which we check to see if it is in a group - no idea what forum group the stuff above produces, suspect post id of when last changed.
        $forum_id_check = private_groups_get_forum_id_from_post_id($link_id, $check);
        //now we can check if the user can view this, and if it's not private
        if (private_groups_can_user_view_post($user_id, $forum_id_check) && !bbp_is_forum_private($forum_id_last_active)) {
            $anchor = '<a href="' . esc_url($link_url) . '" title="' . esc_attr($title) . '">' . esc_html($time_since) . '</a>';
        } elseif (private_groups_can_user_view_post($user_id, $forum_id_check) && bbp_is_forum_private($forum_id_last_active) && current_user_can('read_private_forums')) {
            $anchor = '<a href="' . esc_url($link_url) . '" title="' . esc_attr($title) . '">' . esc_html($time_since) . '</a>';
        } else {
            //set up which link to send them to
            if (!is_user_logged_in()) {
                if ($rpg_settingsf['redirect_page2']) {
                    $link = $rpg_settingsf['redirect_page2'];
                } else {
                    $link = "/wp-login";
                }
            } else {
                if ($rpg_settingsf['redirect_page1']) {
                    $link = $rpg_settingsf['redirect_page1'];
                } else {
                    $link = '/404';
                }
            }
            //now see if there is a freshness message
            if ($rpg_settingsf['set_freshness_message']) {
                $title = $rpg_settingsf['freshness_message'];
                //and set up anchor
                $anchor = '<a href="' . esc_url($link) . '">' . $title . '</a>';
            } else {
                $anchor = '<a href="' . esc_url($link) . '">' . esc_html($time_since) . '</a>';
            }
        }
    } else {
        $anchor = esc_html__('No Topics', 'bbpress');
    }
    return $anchor;
}
开发者ID:USSLomaPrieta,项目名称:usslomaprieta.org,代码行数:69,代码来源:functions.php

示例14: custom_list_forums

function custom_list_forums($args = '')
{
    // Define used variables
    global $rpg_settingsg;
    global $rpg_settingsf;
    $output = $sub_forums = $topic_count = $reply_count = $counts = '';
    $i = 0;
    $count = array();
    // Parse arguments against default values
    $r = bbp_parse_args($args, array('before' => '<ul class="bbp-forums-list">', 'after' => '</ul>', 'link_before' => '<li class="bbp-forum">', 'link_after' => '</li>', 'count_before' => ' (', 'count_after' => ')', 'count_sep' => ', ', 'separator' => '<br> ', 'forum_id' => '', 'show_topic_count' => true, 'show_reply_count' => true), 'listb_forums');
    // Loop through forums and create a list
    $sub_forums = bbp_forum_get_subforums($r['forum_id']);
    if (!empty($sub_forums)) {
        // Total count (for separator)
        $total_subs = count($sub_forums);
        foreach ($sub_forums as $sub_forum) {
            $i++;
            // Separator count
            // Get forum details
            $count = array();
            $show_sep = $total_subs > $i ? $r['separator'] : '';
            $permalink = bbp_get_forum_permalink($sub_forum->ID);
            $title = bbp_get_forum_title($sub_forum->ID);
            $content = bbp_get_forum_content($sub_forum->ID);
            if ($rpg_settingsg['activate_descriptions'] == true) {
                $content = bbp_get_forum_content($sub_forum->ID);
            } else {
                $content = '';
            }
            // Show topic count
            if (!empty($r['show_topic_count']) && !bbp_is_forum_category($sub_forum->ID)) {
                $count['topic'] = bbp_get_forum_topic_count($sub_forum->ID);
            }
            // Show reply count
            if (!empty($r['show_reply_count']) && !bbp_is_forum_category($sub_forum->ID)) {
                $count['reply'] = bbp_get_forum_reply_count($sub_forum->ID);
            }
            // Counts to show
            if (!empty($count)) {
                $counts = $r['count_before'] . implode($r['count_sep'], $count) . $r['count_after'];
            }
            if ($rpg_settingsg['hide_counts'] == true) {
                $counts = '';
            }
            //Build this sub forums link
            if (bbp_is_forum_private($sub_forum->ID)) {
                if (!current_user_can('read_private_forums')) {
                    if (!$rpg_settingsf['redirect_page']) {
                        $link = '/home';
                    } else {
                        $link = $rpg_settingsf['redirect_page'];
                    }
                    $output .= $r['before'] . $r['link_before'] . '<a href="' . $link . '" class="bbp-forum-link">' . $title . $counts . '</a>' . $show_sep . $r['link_after'] . '<div class="bbp-forum-content">' . $content . '</div>' . $r['after'];
                } else {
                    $output .= $r['before'] . $r['link_before'] . '<a href="' . esc_url($permalink) . '" class="bbp-forum-link">' . $title . $counts . '</a>' . $show_sep . $r['link_after'] . '<div class="bbp-forum-content">' . $content . '</div>' . $r['after'];
                }
            } else {
                $output .= $r['before'] . $r['link_before'] . '<a href="' . esc_url($permalink) . '" class="bbp-forum-link">' . $title . $counts . '</a>' . $show_sep . $r['link_after'] . '<div class="bbp-forum-content">' . $content . '</div>' . $r['after'];
            }
        }
        //Output the list
        return $output;
    }
}
开发者ID:USSLomaPrieta,项目名称:usslomaprieta.org,代码行数:64,代码来源:forum-filters.php

示例15: template_no_access

 public static function template_no_access($template)
 {
     global $wp_query, $post;
     $check_perm = false;
     if (bbp_is_single_user_edit() || bbp_is_single_user()) {
     } elseif (bbp_is_forum_archive()) {
     } elseif (bbp_is_forum_edit()) {
         $forum_id = bbp_get_forum_id();
         if (bbp_is_forum($forum_id) && !bbp_user_can_view_forum(array('forum_id' => $forum_id)) && !bbp_is_forum_private($forum_id, false)) {
             $check_perm = true;
         }
     } elseif (bbp_is_single_forum()) {
         $forum_id = bbp_get_forum_id();
         if (bbp_is_forum($forum_id) && !bbp_user_can_view_forum(array('forum_id' => $forum_id)) && !bbp_is_forum_private($forum_id, false)) {
             $check_perm = true;
         }
     } elseif (bbp_is_topic_archive()) {
     } elseif (bbp_is_topic_edit() || bbp_is_single_topic()) {
         $check_perm = true;
     } elseif (is_post_type_archive(bbp_get_reply_post_type())) {
     } elseif (bbp_is_reply_edit() || bbp_is_single_reply()) {
         $check_perm = true;
     } elseif (bbp_is_single_view()) {
     } elseif (bbp_is_search()) {
     } elseif (bbp_is_topic_tag_edit() || bbp_is_topic_tag()) {
     }
     if ($check_perm && empty($post->post_content)) {
         $user_id = get_current_user_id();
         $forum_id = bbp_get_forum_id();
         if (!self::view_forum(false, $forum_id, $user_id)) {
             ob_start();
             bbp_get_template_part('feedback', 'no-access');
             $content = ob_get_clean();
             $post->post_content = "\n{$content}\n";
             $wp_query->post = $post;
             $wp_query->posts = array($post);
         }
     }
     return $template;
 }
开发者ID:082net,项目名称:bbpresskr,代码行数:40,代码来源:permissions.php


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