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


PHP bp_forums_get_topic_details函数代码示例

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


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

示例1: __construct

 /**
  * Constructor method.
  *
  * @param int $topic_id ID of the topic whose posts are being requested.
  * @param int $per_page Number of items to return per page.
  * @param int $max Max records to return.
  * @param string $order Direction to order results.
  */
 function __construct($topic_id, $per_page, $max, $order)
 {
     global $bp, $current_user, $forum_template;
     if (!isset($forum_template)) {
         $forum_template = new stdClass();
     }
     $this->pag_page = isset($_REQUEST['topic_page']) ? intval($_REQUEST['topic_page']) : 1;
     $this->pag_num = isset($_REQUEST['num']) ? intval($_REQUEST['num']) : $per_page;
     $this->order = $order;
     $this->topic_id = $topic_id;
     $forum_template->topic = (object) bp_forums_get_topic_details($this->topic_id);
     $this->forum_id = $forum_template->topic->forum_id;
     $this->posts = bp_forums_get_topic_posts(array('topic_id' => $this->topic_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'order' => $this->order));
     if (!$this->posts) {
         $this->post_count = 0;
         $this->total_post_count = 0;
     } else {
         if (!$max || $max >= (int) $forum_template->topic->topic_posts) {
             $this->total_post_count = (int) $forum_template->topic->topic_posts;
         } else {
             $this->total_post_count = (int) $max;
         }
         if ($max) {
             if ($max >= count($this->posts)) {
                 $this->post_count = count($this->posts);
             } else {
                 $this->post_count = (int) $max;
             }
         } else {
             $this->post_count = count($this->posts);
         }
     }
     // Load topic tags
     $this->topic_tags = bb_get_topic_tags($this->topic_id);
     $this->pag = new stdClass();
     if ((int) $this->total_post_count && (int) $this->pag_num) {
         $this->pag_links = paginate_links(array('base' => add_query_arg(array('topic_page' => '%#%', 'num' => (int) $this->pag_num)), 'format' => '', 'total' => ceil((int) $this->total_post_count / (int) $this->pag_num), 'current' => $this->pag_page, 'prev_text' => _x('←', 'Forum thread pagination previous text', 'buddypress'), 'next_text' => _x('→', 'Forum thread pagination next text', 'buddypress'), 'mid_size' => 1));
         $this->pag->total_pages = ceil((int) $this->total_post_count / (int) $this->pag_num);
     } else {
         $this->pag->total_pages = 1;
     }
 }
开发者ID:danielcoats,项目名称:schoolpress,代码行数:50,代码来源:bp-forums-template.php

示例2: bp_forums_update_topic

/**
 * Update a topic's details.
 *
 * @param array $args {
 *     Array of arguments.
 *     @type int $topic_id ID of the topic being updated.
 *     @type string $topic_title Updated title of the topic.
 *     @type string $topic_title Updated text of the topic.
 *     @type array|string|bool $topic_tags Array or comma-separated list of
 *           topic tags. False to leave empty. Default: false.
 * }
 * @return object Details about the new topic, as returned by
 *         {@link bp_forums_get_topic_details()}.
 */
function bp_forums_update_topic($args = '')
{
    /** This action is documented in bp-forums/bp-forums-screens */
    do_action('bbpress_init');
    $r = wp_parse_args($args, array('topic_id' => false, 'topic_title' => '', 'topic_text' => '', 'topic_tags' => false));
    extract($r, EXTR_SKIP);
    // Check if the user is a spammer
    if (bp_is_user_inactive(bp_loggedin_user_id())) {
        return false;
    }
    // bb_insert_topic() will append tags, but not remove them. So we remove all existing tags.
    bb_remove_topic_tags($topic_id);
    if (!($topic_id = bb_insert_topic(array('topic_id' => $topic_id, 'topic_title' => stripslashes($topic_title), 'tags' => $topic_tags)))) {
        return false;
    }
    if (!($post = bb_get_first_post($topic_id))) {
        return false;
    }
    // Update the first post
    if (!($post = bp_forums_insert_post(array('post_id' => $post->post_id, 'topic_id' => $topic_id, 'post_text' => $topic_text, 'post_time' => $post->post_time, 'poster_id' => $post->poster_id, 'poster_ip' => $post->poster_ip, 'post_status' => $post->post_status, 'post_position' => $post->post_position)))) {
        return false;
    }
    return bp_forums_get_topic_details($topic_id);
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:38,代码来源:bp-forums-functions.php

示例3: groups_screen_group_forum


//.........这里部分代码省略.........
            if (!bp_forums_openclose_topic(array('topic_id' => $topic_id))) {
                bp_core_add_message(__('There was an error when closing that topic', 'buddypress'), 'error');
            } else {
                bp_core_add_message(__('The topic was closed successfully', 'buddypress'));
            }
            /**
             * Fires after a group forum topic has been closed.
             *
             * @since 1.1.0
             *
             * @param int $topic_id ID of the topic being closed.
             */
            do_action('groups_close_forum_topic', $topic_id);
            bp_core_redirect(wp_get_referer());
        } elseif (bp_is_action_variable('open', 2) && (bp_is_item_admin() || bp_is_item_mod())) {
            // Check the nonce.
            check_admin_referer('bp_forums_open_topic');
            if (!bp_forums_openclose_topic(array('topic_id' => $topic_id, 'mode' => 'open'))) {
                bp_core_add_message(__('There was an error when opening that topic', 'buddypress'), 'error');
            } else {
                bp_core_add_message(__('The topic was opened successfully', 'buddypress'));
            }
            /**
             * Fires after a group forum topic has been opened.
             *
             * @since 1.1.0
             *
             * @param int $topic_id ID of the topic being opened.
             */
            do_action('groups_open_forum_topic', $topic_id);
            bp_core_redirect(wp_get_referer());
        } elseif (empty($user_is_banned) && bp_is_action_variable('delete', 2) && !bp_action_variable(3)) {
            // Fetch the topic.
            $topic = bp_forums_get_topic_details($topic_id);
            /* Check the logged in user can delete this topic */
            if (!bp_is_item_admin() && !bp_is_item_mod() && (int) bp_loggedin_user_id() != (int) $topic->topic_poster) {
                bp_core_redirect(wp_get_referer());
            }
            // Check the nonce.
            check_admin_referer('bp_forums_delete_topic');
            /**
             * Fires before a group forum topic is deleted.
             *
             * @since 1.5.0
             *
             * @param int $topic_id ID of the topic being deleted.
             */
            do_action('groups_before_delete_forum_topic', $topic_id);
            if (!groups_delete_group_forum_topic($topic_id)) {
                bp_core_add_message(__('There was an error deleting the topic', 'buddypress'), 'error');
            } else {
                bp_core_add_message(__('The topic was deleted successfully', 'buddypress'));
            }
            /**
             * Fires after a group forum topic has been deleted.
             *
             * @since 1.5.0
             *
             * @param int $topic_id ID of the topic being deleted.
             */
            do_action('groups_delete_forum_topic', $topic_id);
            bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'forum/');
        } elseif (empty($user_is_banned) && bp_is_action_variable('edit', 2) && !bp_action_variable(3)) {
            // Fetch the topic.
            $topic = bp_forums_get_topic_details($topic_id);
            // Check the logged in user can edit this topic.
开发者ID:swissspidy,项目名称:BuddyPress,代码行数:67,代码来源:bp-groups-screens.php

示例4: BP_Forums_Template_Topic

	function BP_Forums_Template_Topic( $topic_id, $per_page, $max, $order ) {
		global $bp, $current_user, $forum_template;

		$this->pag_page        = isset( $_REQUEST['topic_page'] ) ? intval( $_REQUEST['topic_page'] ) : 1;
		$this->pag_num         = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;

		$this->order           = $order;
		$this->topic_id        = $topic_id;
		$forum_template->topic = (object) bp_forums_get_topic_details( $this->topic_id );
		$this->forum_id        = $forum_template->topic->forum_id;

		$this->posts           = bp_forums_get_topic_posts( array( 'topic_id' => $this->topic_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'order' => $this->order ) );

		if ( !$this->posts ) {
			$this->post_count       = 0;
			$this->total_post_count = 0;
		} else {
			if ( !$max || $max >= (int)$forum_template->topic->topic_posts ) {
				$this->total_post_count = (int)$forum_template->topic->topic_posts;
			} else {
				$this->total_post_count = (int)$max;
			}

			if ( $max ) {
				if ( $max >= count( $this->posts ) ) {
					$this->post_count = count( $this->posts );
				} else {
					$this->post_count = (int)$max;
				}
			} else {
				$this->post_count = count( $this->posts );
			}
		}

		if ( (int)$this->total_post_count && (int)$this->pag_num ) {
			$this->pag_links = paginate_links( array(
				'base'      => add_query_arg( array( 'topic_page' => '%#%', 'num' => (int)$this->pag_num ) ),
				'format'    => '',
				'total'     => ceil( (int)$this->total_post_count / (int)$this->pag_num ),
				'current'   => $this->pag_page,
				'prev_text' => '←',
				'next_text' => '→',
				'mid_size'  => 1
			) );

			$this->pag->total_pages = ceil( (int)$this->total_post_count / (int)$this->pag_num );
		} else {
			$this->pag->total_pages = 1;
		}
	}
开发者ID:n-sane,项目名称:zaroka,代码行数:50,代码来源:bp-forums-templatetags.php

示例5: groups_update_group_forum_post

/**
 * Update an existing group forum post.
 *
 * Uses the bundled version of bbPress packaged with BuddyPress.
 *
 * @since BuddyPress (1.1.0)
 *
 * @param int    $post_id   The post ID of the existing forum post.
 * @param string $post_text The text for the forum post.
 * @param int    $topic_id  The topic ID of the existing forum topic.
 * @param mixed  $page      The page number where the new forum post should reside. Optional.
 *
 * @return mixed The forum post ID on success. Boolean false on failure.
 */
function groups_update_group_forum_post($post_id, $post_text, $topic_id, $page = false)
{
    $bp = buddypress();
    /** This filter is documented in bp-groups/bp-groups-forums.php */
    $post_text = apply_filters('group_forum_post_text_before_save', $post_text);
    /** This filter is documented in bp-groups/bp-groups-forums.php */
    $topic_id = apply_filters('group_forum_post_topic_id_before_save', $topic_id);
    $post = bp_forums_get_post($post_id);
    $post_id = bp_forums_insert_post(array('post_id' => $post_id, 'post_text' => $post_text, 'post_time' => $post->post_time, 'topic_id' => $topic_id, 'poster_id' => $post->poster_id));
    if (empty($post_id)) {
        return false;
    }
    $topic = bp_forums_get_topic_details($topic_id);
    $activity_action = sprintf(__('%1$s replied to the forum topic %2$s in the group %3$s', 'buddypress'), bp_core_get_userlink($post->poster_id), '<a href="' . bp_get_group_permalink(groups_get_current_group()) . 'forum/topic/' . $topic->topic_slug . '">' . esc_attr($topic->topic_title) . '</a>', '<a href="' . bp_get_group_permalink(groups_get_current_group()) . '">' . esc_attr(bp_get_current_group_name()) . '</a>');
    $activity_content = bp_create_excerpt($post_text);
    $primary_link = bp_get_group_permalink(groups_get_current_group()) . 'forum/topic/' . $topic->topic_slug . '/';
    if (!empty($page)) {
        $primary_link .= "?topic_page=" . $page;
    }
    // Get the corresponding activity item
    if (bp_is_active('activity')) {
        $id = bp_activity_get_activity_id(array('user_id' => $post->poster_id, 'component' => $bp->groups->id, 'type' => 'new_forum_post', 'item_id' => bp_get_current_group_id(), 'secondary_item_id' => $post_id));
    }
    /** This filter is documented in bp-groups/bp-groups-forums.php */
    $action = apply_filters_ref_array('groups_activity_new_forum_post_action', array($activity_action, $post_text, &$topic, &$topic));
    /** This filter is documented in bp-groups/bp-groups-forums.php */
    $content = apply_filters_ref_array('groups_activity_new_forum_post_content', array($activity_content, $post_text, &$topic, &$topic));
    /** This filter is documented in bp-groups/bp-groups-forums.php */
    $filtered_primary_link = apply_filters('groups_activity_new_forum_post_primary_link', $primary_link . "#post-" . $post_id);
    groups_record_activity(array('id' => $id, 'action' => $action, 'content' => $content, 'primary_link' => $filtered_primary_link, 'type' => 'new_forum_post', 'item_id' => (int) bp_get_current_group_id(), 'user_id' => (int) $post->poster_id, 'secondary_item_id' => $post_id, 'recorded_time' => $post->post_time));
    /**
     * Fires after the update of a group forum post.
     *
     * @since BuddyPress (1.1.0)
     *
     * @param object $post  Object holding current post being updated.
     * @param object $topic Object holding current topic details. Passed by reference.
     */
    do_action_ref_array('groups_update_group_forum_post', array($post, &$topic));
    return $post_id;
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:55,代码来源:bp-groups-forums.php

示例6: groups_screen_group_forum

/**
 * This screen function handles actions related to group forums
 *
 * @package BuddyPress
 */
function groups_screen_group_forum()
{
    global $bp;
    if (!bp_is_active('forums') || !bp_forums_is_installed_correctly()) {
        return false;
    }
    if (bp_action_variable(0) && !bp_is_action_variable('topic', 0)) {
        bp_do_404();
        return;
    }
    if (!$bp->groups->current_group->user_has_access) {
        bp_core_no_access();
        return;
    }
    if (bp_is_single_item()) {
        // Fetch the details we need
        $topic_slug = (string) bp_action_variable(1);
        $topic_id = bp_forums_get_topic_id_from_slug($topic_slug);
        $forum_id = groups_get_groupmeta($bp->groups->current_group->id, 'forum_id');
        $user_is_banned = false;
        if (!bp_current_user_can('bp_moderate') && groups_is_user_banned(bp_loggedin_user_id(), $bp->groups->current_group->id)) {
            $user_is_banned = true;
        }
        if (!empty($topic_slug) && !empty($topic_id)) {
            // Posting a reply
            if (!$user_is_banned && !bp_action_variable(2) && isset($_POST['submit_reply'])) {
                // Check the nonce
                check_admin_referer('bp_forums_new_reply');
                // Auto join this user if they are not yet a member of this group
                if (bp_groups_auto_join() && !bp_current_user_can('bp_moderate') && 'public' == $bp->groups->current_group->status && !groups_is_user_member(bp_loggedin_user_id(), $bp->groups->current_group->id)) {
                    groups_join_group($bp->groups->current_group->id, bp_loggedin_user_id());
                }
                $topic_page = isset($_GET['topic_page']) ? $_GET['topic_page'] : false;
                if (!($post_id = groups_new_group_forum_post($_POST['reply_text'], $topic_id, $topic_page))) {
                    bp_core_add_message(__('There was an error when replying to that topic', 'buddypress'), 'error');
                } else {
                    bp_core_add_message(__('Your reply was posted successfully', 'buddypress'));
                }
                if (isset($_SERVER['QUERY_STRING'])) {
                    $query_vars = '?' . $_SERVER['QUERY_STRING'];
                }
                bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'forum/topic/' . $topic_slug . '/' . $query_vars . '#post-' . $post_id);
            } else {
                if (bp_is_action_variable('stick', 2) && (isset($bp->is_item_admin) || isset($bp->is_item_mod))) {
                    // Check the nonce
                    check_admin_referer('bp_forums_stick_topic');
                    if (!bp_forums_sticky_topic(array('topic_id' => $topic_id))) {
                        bp_core_add_message(__('There was an error when making that topic a sticky', 'buddypress'), 'error');
                    } else {
                        bp_core_add_message(__('The topic was made sticky successfully', 'buddypress'));
                    }
                    do_action('groups_stick_forum_topic', $topic_id);
                    bp_core_redirect(wp_get_referer());
                } else {
                    if (bp_is_action_variable('unstick', 2) && (isset($bp->is_item_admin) || isset($bp->is_item_mod))) {
                        // Check the nonce
                        check_admin_referer('bp_forums_unstick_topic');
                        if (!bp_forums_sticky_topic(array('topic_id' => $topic_id, 'mode' => 'unstick'))) {
                            bp_core_add_message(__('There was an error when unsticking that topic', 'buddypress'), 'error');
                        } else {
                            bp_core_add_message(__('The topic was unstuck successfully', 'buddypress'));
                        }
                        do_action('groups_unstick_forum_topic', $topic_id);
                        bp_core_redirect(wp_get_referer());
                    } else {
                        if (bp_is_action_variable('close', 2) && (isset($bp->is_item_admin) || isset($bp->is_item_mod))) {
                            // Check the nonce
                            check_admin_referer('bp_forums_close_topic');
                            if (!bp_forums_openclose_topic(array('topic_id' => $topic_id))) {
                                bp_core_add_message(__('There was an error when closing that topic', 'buddypress'), 'error');
                            } else {
                                bp_core_add_message(__('The topic was closed successfully', 'buddypress'));
                            }
                            do_action('groups_close_forum_topic', $topic_id);
                            bp_core_redirect(wp_get_referer());
                        } else {
                            if (bp_is_action_variable('open', 2) && (isset($bp->is_item_admin) || isset($bp->is_item_mod))) {
                                // Check the nonce
                                check_admin_referer('bp_forums_open_topic');
                                if (!bp_forums_openclose_topic(array('topic_id' => $topic_id, 'mode' => 'open'))) {
                                    bp_core_add_message(__('There was an error when opening that topic', 'buddypress'), 'error');
                                } else {
                                    bp_core_add_message(__('The topic was opened successfully', 'buddypress'));
                                }
                                do_action('groups_open_forum_topic', $topic_id);
                                bp_core_redirect(wp_get_referer());
                            } else {
                                if (empty($user_is_banned) && bp_is_action_variable('delete', 2) && !bp_action_variable(3)) {
                                    // Fetch the topic
                                    $topic = bp_forums_get_topic_details($topic_id);
                                    /* Check the logged in user can delete this topic */
                                    if (!$bp->is_item_admin && !$bp->is_item_mod && (int) bp_loggedin_user_id() != (int) $topic->topic_poster) {
                                        bp_core_redirect(wp_get_referer());
                                    }
                                    // Check the nonce
//.........这里部分代码省略.........
开发者ID:newington,项目名称:buddypress,代码行数:101,代码来源:bp-groups-screens.php

示例7: bp_forums_update_topic

function bp_forums_update_topic($args = '')
{
    global $bp;
    do_action('bbpress_init');
    $defaults = array('topic_id' => false, 'topic_title' => '', 'topic_text' => '', 'topic_tags' => false);
    $r = nxt_parse_args($args, $defaults);
    extract($r, EXTR_SKIP);
    // Check if the user is a spammer
    if (bp_core_is_user_spammer($bp->loggedin_user->id) || bp_core_is_user_deleted($bp->loggedin_user->id)) {
        return false;
    }
    // bb_insert_topic() will append tags, but not remove them. So we remove all existing tags.
    bb_remove_topic_tags($topic_id);
    if (!($topic_id = bb_insert_topic(array('topic_id' => $topic_id, 'topic_title' => stripslashes($topic_title), 'tags' => $topic_tags)))) {
        return false;
    }
    if (!($post = bb_get_first_post($topic_id))) {
        return false;
    }
    // Update the first post
    if (!($post = bp_forums_insert_post(array('post_id' => $post->post_id, 'topic_id' => $topic_id, 'post_text' => $topic_text, 'post_time' => $post->post_time, 'poster_id' => $post->poster_id, 'poster_ip' => $post->poster_ip, 'post_status' => $post->post_status, 'post_position' => $post->post_position)))) {
        return false;
    }
    return bp_forums_get_topic_details($topic_id);
}
开发者ID:nxtclass,项目名称:NXTClass,代码行数:25,代码来源:bp-forums-functions.php

示例8: forum_post_edit

 function forum_post_edit($id, $id2)
 {
     if (!($post = bp_forums_get_post($id2))) {
         return false;
     }
     $topic = bp_forums_get_topic_details($post->topic_id);
     $url = bp_core_get_root_domain() . '/' . BP_GROUPS_SLUG . '/' . $topic->object_slug . '/forum/topic/' . $topic->topic_slug . '/edit/post/' . $post->post_id . '/';
     return wp_nonce_url($url, 'bp_forums_edit_post');
 }
开发者ID:pausaura,项目名称:agora_nodes,代码行数:9,代码来源:bpModDefaultContentTypes.php

示例9: groups_update_group_forum_post

/**
 * Update an existing group forum post.
 *
 * Uses the bundled version of bbPress packaged with BuddyPress.
 *
 * @since BuddyPress (1.1.0)
 *
 * @param int $post_id The post ID of the existing forum post.
 * @param string $post_text The text for the forum post.
 * @param int $topic_id The topic ID of the existing forum topic.
 * @param mixed $page The page number where the new forum post should reside.
 *	  Optional.
 * @return mixed The forum post ID on success. Boolean false on failure.
 */
function groups_update_group_forum_post($post_id, $post_text, $topic_id, $page = false)
{
    $bp = buddypress();
    $post_text = apply_filters('group_forum_post_text_before_save', $post_text);
    $topic_id = apply_filters('group_forum_post_topic_id_before_save', $topic_id);
    $post = bp_forums_get_post($post_id);
    $post_id = bp_forums_insert_post(array('post_id' => $post_id, 'post_text' => $post_text, 'post_time' => $post->post_time, 'topic_id' => $topic_id, 'poster_id' => $post->poster_id));
    if (empty($post_id)) {
        return false;
    }
    $topic = bp_forums_get_topic_details($topic_id);
    $activity_action = sprintf(__('%1$s replied to the forum topic %2$s in the group %3$s', 'buddypress'), bp_core_get_userlink($post->poster_id), '<a href="' . bp_get_group_permalink(groups_get_current_group()) . 'forum/topic/' . $topic->topic_slug . '">' . esc_attr($topic->topic_title) . '</a>', '<a href="' . bp_get_group_permalink(groups_get_current_group()) . '">' . esc_attr(bp_get_current_group_name()) . '</a>');
    $activity_content = bp_create_excerpt($post_text);
    $primary_link = bp_get_group_permalink(groups_get_current_group()) . 'forum/topic/' . $topic->topic_slug . '/';
    if (!empty($page)) {
        $primary_link .= "?topic_page=" . $page;
    }
    // Get the corresponding activity item
    if (bp_is_active('activity')) {
        $id = bp_activity_get_activity_id(array('user_id' => $post->poster_id, 'component' => $bp->groups->id, 'type' => 'new_forum_post', 'item_id' => bp_get_current_group_id(), 'secondary_item_id' => $post_id));
    }
    // Update the entry in activity streams
    groups_record_activity(array('id' => $id, 'action' => apply_filters_ref_array('groups_activity_new_forum_post_action', array($activity_action, $post_text, &$topic, &$topic)), 'content' => apply_filters_ref_array('groups_activity_new_forum_post_content', array($activity_content, $post_text, &$topic, &$topic)), 'primary_link' => apply_filters('groups_activity_new_forum_post_primary_link', $primary_link . "#post-" . $post_id), 'type' => 'new_forum_post', 'item_id' => (int) bp_get_current_group_id(), 'user_id' => (int) $post->poster_id, 'secondary_item_id' => $post_id, 'recorded_time' => $post->post_time));
    do_action_ref_array('groups_update_group_forum_post', array($post, &$topic));
    return $post_id;
}
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:40,代码来源:bp-groups-forums.php

示例10: groups_update_group_forum_post

function groups_update_group_forum_post( $post_id, $post_text, $topic_id, $page = false ) {
	global $bp;

	$post_text = apply_filters( 'group_forum_post_text_before_save', $post_text );
	$topic_id = apply_filters( 'group_forum_post_topic_id_before_save', $topic_id );

	$post = bp_forums_get_post( $post_id );

	if ( $post_id = bp_forums_insert_post( array( 'post_id' => $post_id, 'post_text' => $post_text, 'post_time' => $post->post_time, 'topic_id' => $topic_id, 'poster_id' => $post->poster_id ) ) ) {
		$topic = bp_forums_get_topic_details( $topic_id );

		$activity_action = sprintf( __( '%s posted on the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink( $post->poster_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug .'">' . esc_attr( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . esc_attr( $bp->groups->current_group->name ) . '</a>' );
		$activity_content = bp_create_excerpt( $post_text );
		$primary_link = bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/';

		if ( $page )
			$primary_link .= "?topic_page=" . $page;

		/* Fetch an existing entry and update if one exists. */
		if ( function_exists( 'bp_activity_get_activity_id' ) )
			$id = bp_activity_get_activity_id( array( 'user_id' => $post->poster_id, 'component' => $bp->groups->id, 'type' => 'new_forum_post', 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $post_id ) );

		/* Update the entry in activity streams */
		groups_record_activity( array(
			'id' => $id,
			'action' => apply_filters( 'groups_activity_new_forum_post_action', $activity_action, $post_text, &$topic, &$forum_post ),
			'content' => apply_filters( 'groups_activity_new_forum_post_content', $activity_content, $post_text, &$topic, &$forum_post ),
			'primary_link' => apply_filters( 'groups_activity_new_forum_post_primary_link', $primary_link . "#post-" . $post_id ),
			'type' => 'new_forum_post',
			'item_id' => (int)$bp->groups->current_group->id,
			'user_id' => (int)$post->poster_id,
			'secondary_item_id' => $post_id,
			'recorded_time' => $post->post_time
		) );

		do_action( 'groups_update_group_forum_post', &$post, &$topic );

		return $post_id;
	}

	return false;
}
开发者ID:n-sane,项目名称:zaroka,代码行数:42,代码来源:bp-groups.php

示例11: groups_format_activity

function groups_format_activity($item_id, $user_id, $action, $secondary_item_id = false, $for_secondary_user = false)
{
    global $bp;
    switch ($action) {
        case 'joined_group':
            $group = new BP_Groups_Group($item_id, false, false);
            if (!$group) {
                return false;
            }
            $user_link = bp_core_get_userlink($user_id);
            $group_link = bp_get_group_permalink($group);
            return array('primary_link' => $group_link, 'content' => apply_filters('bp_groups_joined_group_activity', sprintf(__('%s joined the group %s', 'buddypress'), $user_link, '<a href="' . $group_link . '">' . $group->name . '</a>') . ' <span class="time-since">%s</span>', $user_link, $group_link, $group->name));
            break;
        case 'created_group':
            $group = new BP_Groups_Group($item_id, false, false);
            if (!$group) {
                return false;
            }
            $user_link = bp_core_get_userlink($user_id);
            $group_link = bp_get_group_permalink($group);
            return array('primary_link' => $group_link, 'content' => apply_filters('bp_groups_created_group_activity', sprintf(__('%s created the group %s', 'buddypress'), $user_link, '<a href="' . $group_link . '">' . $group->name . '</a>') . ' <span class="time-since">%s</span>', $user_link, $group_link, $group->name));
            break;
        case 'new_wire_post':
            $wire_post = new BP_Wire_Post($bp->groups->table_name_wire, $item_id);
            $group = new BP_Groups_Group($wire_post->item_id, false, false);
            if (!$group || !$wire_post || !$wire_post->content) {
                return false;
            }
            $user_link = bp_core_get_userlink($user_id);
            $group_link = bp_get_group_permalink($group);
            $post_excerpt = bp_create_excerpt($wire_post->content);
            $content = sprintf(__('%s wrote on the wire of the group %s', 'buddypress'), $user_link, '<a href="' . $group_link . '">' . $group->name . '</a>') . ' <span class="time-since">%s</span>';
            $content .= '<blockquote>' . $post_excerpt . '</blockquote>';
            $content = apply_filters('bp_groups_new_wire_post_activity', $content, $user_link, $group_link, $group->name, $post_excerpt);
            return array('primary_link' => $group_link, 'content' => $content);
            break;
        case 'new_forum_post':
            if (function_exists('bp_forums_setup')) {
                $group = new BP_Groups_Group($item_id, false, false);
                $forum_post = bp_forums_get_post($secondary_item_id);
                $forum_topic = bp_forums_get_topic_details($forum_post['topic_id']);
                if (!$group || !$forum_post || !$forum_topic) {
                    return false;
                }
                $user_link = bp_core_get_userlink($user_id);
                $group_link = bp_get_group_permalink($group);
                $post_content = apply_filters('bp_the_topic_post_content', bp_create_excerpt(stripslashes($forum_post['post_text']), 55, false));
                $content = sprintf(__('%s posted on the forum topic %s in the group %s:', 'buddypress'), $user_link, '<a href="' . $group_link . '/forum/topic/' . $forum_topic['topic_id'] . '">' . $forum_topic['topic_title'] . '</a>', '<a href="' . $group_link . '">' . $group->name . '</a>') . ' <span class="time-since">%s</span>';
                $content .= '<blockquote>' . $post_content . '</blockquote>';
                $content = apply_filters('bp_groups_new_forum_post_activity', $content, $user_link, $group_link, $forum_topic['topic_id'], $forum_topic['topic_title'], $group_link, $group->name, $post_content);
                return array('primary_link' => $group_link, 'content' => $content);
            }
            break;
        case 'new_forum_topic':
            if (function_exists('bp_forums_setup')) {
                $group = new BP_Groups_Group($item_id, false, false);
                $forum_topic = bp_forums_get_topic_details($secondary_item_id);
                $forum_post = bp_forums_get_post($forum_topic['topic_last_post_id']);
                if (!$group || !$forum_post || !$forum_topic) {
                    return false;
                }
                $user_link = bp_core_get_userlink($user_id);
                $group_link = bp_get_group_permalink($group);
                $post_content = apply_filters('bp_the_topic_post_content', bp_create_excerpt(stripslashes($forum_post['post_text']), 55, false));
                $content = sprintf(__('%s created the forum topic %s in the group %s:', 'buddypress'), $user_link, '<a href="' . $group_link . '/forum/topic/' . $forum_topic['topic_id'] . '">' . $forum_topic['topic_title'] . '</a>', '<a href="' . $group_link . '">' . $group->name . '</a>') . ' <span class="time-since">%s</span>';
                $content .= '<blockquote>' . $post_content . '</blockquote>';
                $content = apply_filters('bp_groups_new_forum_topic_activity', $content, $user_link, $group_link, $forum_topic['topic_id'], $forum_topic['topic_title'], $group_link, $group->name, $post_content);
                return array('primary_link' => $group_link, 'content' => $content);
            }
            break;
    }
    do_action('groups_format_activity', $action, $item_id, $user_id, $action, $secondary_item_id, $for_secondary_user);
    return false;
}
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:74,代码来源:bp-groups.php

示例12: bplf_catcher


//.........这里部分代码省略.........
                // Individual member new forum topic feed
                // /members/username/activity/forumtopics/feed
            // Individual member new forum topic feed
            // /members/username/activity/forumtopics/feed
            case 'forumtopics':
                if (!defined('BPLF_DISABLE_MEMBER_TOPICS_FEED')) {
                    $this_bp_feed = 'member_topics';
                }
                break;
                // Individual member forum reply feed
                // /members/username/activity/forumreplies/feed
            // Individual member forum reply feed
            // /members/username/activity/forumreplies/feed
            case 'forumreplies':
                if (!defined('BPLF_DISABLE_MEMBER_REPLIES_FEED')) {
                    $this_bp_feed = 'member_replies';
                }
                break;
                // Individual member forum activity feed
                // /members/username/activity/forums/feed
            // Individual member forum activity feed
            // /members/username/activity/forums/feed
            case 'forums':
                if (!defined('BPLF_DISABLE_MEMBER_FORUMS_FEED')) {
                    $this_bp_feed = 'member_forums';
                }
                break;
        }
    }
    // Group activity feeds
    if (bp_is_groups_component() && isset($bp->groups->current_group->id) && bp_action_variable(0) == 'feed') {
        switch (bp_current_action()) {
            // Group activity updates
            // /groups/groupname/updates/feed
            case 'updates':
                if (!defined('BPLF_DISABLE_GROUP_UPDATES_FEED')) {
                    $this_bp_feed = 'group_updates';
                }
                break;
                // New group forum topics
                // /groups/groupname/forumtopics/feed
            // New group forum topics
            // /groups/groupname/forumtopics/feed
            case 'forumtopics':
                if (!defined('BPLF_DISABLE_GROUP_TOPICS_FEED')) {
                    $this_bp_feed = 'group_topics';
                }
                break;
                // New group forum replies
                // /groups/groupname/forumreplies/feed
            // New group forum replies
            // /groups/groupname/forumreplies/feed
            case 'forumreplies':
                if (!defined('BPLF_DISABLE_GROUP_REPLIES_FEED')) {
                    $this_bp_feed = 'group_replies';
                }
                break;
                // Group forum activity
                // /groups/groupname/forums/feed
            // Group forum activity
            // /groups/groupname/forums/feed
            case 'forums':
                if (!defined('BPLF_DISABLE_GROUP_FORUMS_FEED')) {
                    $this_bp_feed = 'group_forums';
                }
                break;
                // Group membership activity
                // /groups/groupname/membership/feed
            // Group membership activity
            // /groups/groupname/membership/feed
            case 'membership':
                if (!defined('BPLF_DISABLE_GROUP_MEMBERSHIP_FEED')) {
                    $this_bp_feed = 'group_membership';
                }
                break;
        }
    }
    // Individual forum topic feeds
    // /groups/groupname/forum/topic/topicslug/feed
    if (bp_is_groups_component() && bp_current_action() == 'forum' && bp_action_variable(0) == 'topic' && bp_action_variable(1) && bp_action_variable(2) == 'feed') {
        global $bplf_topic, $bplf_topic_posts;
        if (!defined('BPLF_DISABLE_INDIVIDUAL_TOPIC_FEED')) {
            $topic_id = bp_forums_get_topic_id_from_slug(bp_action_variable(1));
            $bplf_topic = bp_forums_get_topic_details($topic_id);
            $topic_args = array('per_page' => 50, 'max' => 50, 'order' => 'ASC');
            $topic_args = apply_filters('bp_lotsa_feeds_topic_feed_args', $topic_args);
            extract($topic_args);
            $bplf_topic_posts = new BP_Forums_Template_Topic($topic_id, $per_page, $max, $order);
            $this_bp_feed = 'forum_topic';
        }
    }
    $this_bp_feed = apply_filters('bplf_which_feed', $this_bp_feed);
    if (!$this_bp_feed) {
        return false;
    }
    $wp_query->is_404 = false;
    status_header(200);
    include_once apply_filters('bplf_feed_template', dirname(__FILE__) . '/feed-template.php');
    die;
}
开发者ID:r-a-y,项目名称:bp-lotsa-feeds,代码行数:101,代码来源:bp-lotsa-feeds.php

示例13: bp_forums_update_topic

function bp_forums_update_topic( $args = '' ) {
	global $bp;

	do_action( 'bbpress_init' );

	$defaults = array(
		'topic_id' => false,
		'topic_title' => '',
		'topic_text' => ''
	);

	$r = wp_parse_args( $args, $defaults );
	extract( $r, EXTR_SKIP );

	if ( !$topic_id = bb_insert_topic( array( 'topic_id' => $topic_id, 'topic_title' => stripslashes( $topic_title ) ) ) )
		return false;

	if ( !$post = bb_get_first_post( $topic_id ) )
		return false;

	/* Update the first post */
	if ( !$post = bp_forums_insert_post( array( 'post_id' => $post->post_id, 'topic_id' => $topic_id, 'post_text' => $topic_text, 'post_time' => $post->post_time, 'poster_id' => $post->poster_id, 'poster_ip' => $post->poster_ip, 'post_status' => $post->post_status, 'post_position' => $post->post_position ) ) )
		return false;

	return bp_forums_get_topic_details( $topic_id );
}
开发者ID:n-sane,项目名称:zaroka,代码行数:26,代码来源:bp-forums.php

示例14: bp_ning_import_get_discussions

function bp_ning_import_get_discussions()
{
    global $wpdb;
    $ning_id_array = get_option('bp_ning_user_array');
    // Get list of Ning groups for cross reference
    $groups = bp_ning_import_prepare_json('groups');
    $ning_group_id_array = get_option('bp_ning_group_array', array());
    $discussions = bp_ning_import_prepare_json('discussions');
    //delete_option('bp_ning_discussions_imported');
    $imported = get_option('bp_ning_discussions_imported', array());
    $counter = 0;
    foreach ((array) $discussions as $discussion_key => $discussion) {
        unset($topic_id);
        if (isset($imported[$discussion->id])) {
            continue;
        }
        if ($counter >= 10) {
            update_option('bp_ning_discussions_imported', $imported);
            printf(__('%d out of %d discussions done.'), count($imported), count($discussions));
            return false;
        }
        $slug = sanitize_title(esc_attr($discussion->category));
        $ning_group_creator_id = $discussion->contributorName;
        $creator_id = $ning_id_array[$ning_group_creator_id];
        if (!$creator_id) {
            $what++;
            continue;
        }
        $ndate = strtotime($discussion->createdDate);
        $date_created = date("Y-m-d H:i:s", $ndate);
        if (isset($discussion->category)) {
            $ning_group_id = $discussion->category;
            $group_id = $ning_group_id_array[$ning_group_id];
        } else {
            if (isset($discussion->groupId)) {
                $ngroup_id = $discussion->groupId;
                $group_id = $ning_group_id_array[$ngroup_id];
            } else {
                continue;
                // todo fix me!
            }
        }
        $group = new BP_Groups_Group($group_id);
        $args = array('topic_title' => $discussion->title, 'topic_slug' => groups_check_slug(sanitize_title(esc_attr($discussion->title))), 'topic_text' => $discussion->description, 'topic_poster' => $creator_id, 'topic_poster_name' => bp_core_get_user_displayname($creator_id), 'topic_last_poster' => $creator_id, 'topic_last_poster_name' => bp_core_get_user_displayname($creator_id), 'topic_start_time' => $date_created, 'topic_time' => $date_created, 'forum_id' => groups_get_groupmeta($group_id, 'forum_id'));
        $query = "SELECT `topic_id` FROM wp_bb_topics WHERE topic_title = '%s' AND topic_start_time = '%s' LIMIT 1";
        $q = $wpdb->prepare($query, $args['topic_title'], $args['topic_start_time']);
        $topic_exists = $wpdb->get_results($q);
        if (isset($topic_exists[0])) {
            echo "<em>- Topic {$discussion->title} already exists</em><br />";
            $imported[$discussion->id] = true;
            continue;
        }
        if (!$args['forum_id']) {
            echo "No forum id - skipping";
            continue;
        }
        if (!($topic_id = bp_forums_new_topic($args))) {
            // TODO: WTF?
            return false;
            echo "<h2>Refresh to import more discussions</h2>";
            die;
        } else {
            bp_ning_import_process_inline_images_new('discussions', $topic_id, 'topic');
            echo "<strong>- Created topic: {$discussion->title}</strong><br />";
        }
        $activity_content = bp_create_excerpt($discussion->description);
        $skip_activity = get_option('bp_ning_skip_forum_activity');
        if (!$skip_activity) {
            $topic = bp_forums_get_topic_details($topic_id);
            // Activity item
            $activity_action = sprintf(__('%s started the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink($creator_id), '<a href="' . bp_get_group_permalink($group) . 'forum/topic/' . $topic->topic_slug . '/">' . esc_html($topic->topic_title) . '</a>', '<a href="' . bp_get_group_permalink($group) . '">' . esc_html($group->name) . '</a>');
            groups_record_activity(array('user_id' => $creator_id, 'action' => apply_filters('groups_activity_new_forum_topic_action', $activity_action, $discussion->description, $topic), 'content' => apply_filters('groups_activity_new_forum_topic_content', $activity_content, $discussion->description, $topic), 'primary_link' => apply_filters('groups_activity_new_forum_topic_primary_link', bp_get_group_permalink($group) . 'forum/topic/' . $topic->topic_slug . '/'), 'type' => 'new_forum_topic', 'item_id' => $group_id, 'secondary_item_id' => $topic->topic_id, 'recorded_time' => $date_created, 'hide_sitewide' => 0));
            do_action('groups_new_forum_topic', $group_id, $topic);
        }
        // Now check for comments
        if (isset($discussion->comments)) {
            foreach ($discussion->comments as $reply) {
                $ning_group_creator_id = $reply->contributorName;
                $creator_id = $ning_id_array[$ning_group_creator_id];
                $ndate = strtotime($reply->createdDate);
                $date_created = date("Y-m-d H:i:s", $ndate);
                $args = array('topic_id' => $topic_id, 'post_text' => $reply->description, 'post_time' => $date_created, 'poster_id' => $creator_id, 'poster_ip' => '192.168.1.1');
                $query = "SELECT * FROM wp_bb_posts WHERE topic_id = '%s' AND post_text = '%s'";
                $q = $wpdb->prepare($query, $args['topic_id'], $args['post_text']);
                $post_exists = $wpdb->get_results($q);
                if ($post_exists) {
                    continue;
                }
                $post_id = bp_forums_insert_post($args);
                if ($post_id) {
                    bp_ning_import_process_inline_images_new('discussions', $post_id, 'topic_reply');
                    $import_summary = esc_html(bp_create_excerpt($reply->description, 100, array('html' => false)));
                    echo "<em>- Imported forum post: {$import_summary}</em><br />";
                }
                if (!groups_is_user_member($creator_id, $group_id)) {
                    if (!$bp->groups->current_group) {
                        $bp->groups->current_group = new BP_Groups_Group($group_id);
                    }
                    $new_member = new BP_Groups_Member();
                    $new_member->group_id = $group_id;
//.........这里部分代码省略.........
开发者ID:boonebgorges,项目名称:Import-from-Ning,代码行数:101,代码来源:bp-functions.php


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