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


PHP BP_Activity_Activity::get_child_comments方法代码示例

本文整理汇总了PHP中BP_Activity_Activity::get_child_comments方法的典型用法代码示例。如果您正苦于以下问题:PHP BP_Activity_Activity::get_child_comments方法的具体用法?PHP BP_Activity_Activity::get_child_comments怎么用?PHP BP_Activity_Activity::get_child_comments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BP_Activity_Activity的用法示例。


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

示例1: rebuild_activity_comment_tree

 function rebuild_activity_comment_tree($parent_id, $left = 1)
 {
     global $nxtdb, $bp;
     // The right value of this node is the left value + 1
     $right = $left + 1;
     // Get all descendants of this node
     $descendants = BP_Activity_Activity::get_child_comments($parent_id);
     // Loop the descendants and recalculate the left and right values
     foreach ((array) $descendants as $descendant) {
         $right = BP_Activity_Activity::rebuild_activity_comment_tree($descendant->id, $right);
     }
     // We've got the left value, and now that we've processed the children
     // of this node we also know the right value
     if (1 == $left) {
         $nxtdb->query($nxtdb->prepare("UPDATE {$bp->activity->table_name} SET mptt_left = %d, mptt_right = %d WHERE id = %d", $left, $right, $parent_id));
     } else {
         $nxtdb->query($nxtdb->prepare("UPDATE {$bp->activity->table_name} SET mptt_left = %d, mptt_right = %d WHERE type = 'activity_comment' AND id = %d", $left, $right, $parent_id));
     }
     // Return the right value of this node + 1
     return $right + 1;
 }
开发者ID:nxtclass,项目名称:NXTClass-Plugin,代码行数:21,代码来源:bp-activity-classes.php

示例2: rebuild_activity_comment_tree

 /**
  * Rebuild nested comment tree under an activity or activity comment.
  *
  * @since 1.2.0
  *
  * @global wpdb $wpdb WordPress database object.
  *
  * @param  int $parent_id ID of an activity or activity comment.
  * @param  int $left      Node boundary start for activity or activity comment.
  * @return int Right      Node boundary of activity or activity comment.
  */
 public static function rebuild_activity_comment_tree($parent_id, $left = 1)
 {
     global $wpdb;
     $bp = buddypress();
     // The right value of this node is the left value + 1.
     $right = intval($left + 1);
     // Get all descendants of this node.
     $comments = BP_Activity_Activity::get_child_comments($parent_id);
     $descendants = wp_list_pluck($comments, 'id');
     // Loop the descendants and recalculate the left and right values.
     foreach ((array) $descendants as $descendant_id) {
         $right = BP_Activity_Activity::rebuild_activity_comment_tree($descendant_id, $right);
     }
     // We've got the left value, and now that we've processed the children
     // of this node we also know the right value.
     if (1 === $left) {
         $wpdb->query($wpdb->prepare("UPDATE {$bp->activity->table_name} SET mptt_left = %d, mptt_right = %d WHERE id = %d", $left, $right, $parent_id));
     } else {
         $wpdb->query($wpdb->prepare("UPDATE {$bp->activity->table_name} SET mptt_left = %d, mptt_right = %d WHERE type = 'activity_comment' AND id = %d", $left, $right, $parent_id));
     }
     // Return the right value of this node + 1.
     return intval($right + 1);
 }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:34,代码来源:class-bp-activity-activity.php

示例3: bp_activity_delete_children

/**
 * Delete an activity comment's children.
 *
 * @since BuddyPress (1.2.0)
 *
 * @uses BP_Activity_Activity::get_child_comments() {@link BP_Activity_Activity}
 * @uses bp_activity_delete_children()
 * @uses bp_activity_delete()
 *
 * @param int $activity_id The ID of the "root" activity, ie the
 *        comment's oldest ancestor.
 * @param int $comment_id The ID of the comment to be deleted.
 */
function bp_activity_delete_children($activity_id, $comment_id)
{
    // Get activity children to delete
    $children = BP_Activity_Activity::get_child_comments($comment_id);
    // Recursively delete all children of this comment.
    if (!empty($children)) {
        foreach ((array) $children as $child) {
            bp_activity_delete_children($activity_id, $child->id);
        }
    }
    // Delete the comment itself
    bp_activity_delete(array('secondary_item_id' => $comment_id, 'type' => 'activity_comment', 'item_id' => $activity_id));
}
开发者ID:eresyyl,项目名称:mk,代码行数:26,代码来源:bp-activity-functions.php

示例4: bp_activity_delete_children

	function bp_activity_delete_children( $activity_id, $comment_id) {
		/* Recursively delete all children of this comment. */
		if ( $children = BP_Activity_Activity::get_child_comments( $comment_id ) ) {
			foreach( (array)$children as $child )
				bp_activity_delete_children( $activity_id, $child->id );
		}
		bp_activity_delete( array( 'secondary_item_id' => $comment_id, 'type' => 'activity_comment', 'item_id' => $activity_id ) );
	}
开发者ID:n-sane,项目名称:zaroka,代码行数:8,代码来源:bp-activity.php


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