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


PHP BP_Activity_Activity::delete_activity_item_comments方法代码示例

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


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

示例1: test_delete_activity_item_comments

 /**
  * @group delete_activity_item_comments
  */
 public function test_delete_activity_item_comments()
 {
     $parent_activity = $this->factory->activity->create(array('type' => 'activity_update'));
     $comments = $this->factory->activity->create_many(3, array('item_id' => $parent_activity, 'type' => 'activity_comment'));
     BP_Activity_Activity::delete_activity_item_comments($parent_activity);
     $result = BP_Activity_Activity::get(array('in' => wp_list_pluck($comments, 'id')));
     $this->assertEmpty($result['activities']);
 }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:11,代码来源:class.BP_Activity_Activity.php

示例2: delete

 function delete($args)
 {
     global $nxtdb, $bp;
     $defaults = array('id' => false, 'action' => false, 'content' => false, 'component' => false, 'type' => false, 'primary_link' => false, 'user_id' => false, 'item_id' => false, 'secondary_item_id' => false, 'date_recorded' => false, 'hide_sitewide' => false);
     $params = nxt_parse_args($args, $defaults);
     extract($params);
     $where_args = false;
     if (!empty($id)) {
         $where_args[] = $nxtdb->prepare("id = %d", $id);
     }
     if (!empty($user_id)) {
         $where_args[] = $nxtdb->prepare("user_id = %d", $user_id);
     }
     if (!empty($action)) {
         $where_args[] = $nxtdb->prepare("action = %s", $action);
     }
     if (!empty($content)) {
         $where_args[] = $nxtdb->prepare("content = %s", $content);
     }
     if (!empty($component)) {
         $where_args[] = $nxtdb->prepare("component = %s", $component);
     }
     if (!empty($type)) {
         $where_args[] = $nxtdb->prepare("type = %s", $type);
     }
     if (!empty($primary_link)) {
         $where_args[] = $nxtdb->prepare("primary_link = %s", $primary_link);
     }
     if (!empty($item_id)) {
         $where_args[] = $nxtdb->prepare("item_id = %s", $item_id);
     }
     if (!empty($secondary_item_id)) {
         $where_args[] = $nxtdb->prepare("secondary_item_id = %s", $secondary_item_id);
     }
     if (!empty($date_recorded)) {
         $where_args[] = $nxtdb->prepare("date_recorded = %s", $date_recorded);
     }
     if (!empty($hide_sitewide)) {
         $where_args[] = $nxtdb->prepare("hide_sitewide = %d", $hide_sitewide);
     }
     if (!empty($where_args)) {
         $where_sql = 'WHERE ' . join(' AND ', $where_args);
     } else {
         return false;
     }
     // Fetch the activity IDs so we can delete any comments for this activity item
     $activity_ids = $nxtdb->get_col($nxtdb->prepare("SELECT id FROM {$bp->activity->table_name} {$where_sql}"));
     if (!$nxtdb->query($nxtdb->prepare("DELETE FROM {$bp->activity->table_name} {$where_sql}"))) {
         return false;
     }
     if ($activity_ids) {
         BP_Activity_Activity::delete_activity_item_comments($activity_ids);
         BP_Activity_Activity::delete_activity_meta_entries($activity_ids);
         return $activity_ids;
     }
     return $activity_ids;
 }
开发者ID:nxtclass,项目名称:NXTClass-Plugin,代码行数:57,代码来源:bp-activity-classes.php

示例3: buddy_boss_pics_cleanup_db

/**
 * CLEANUP DATABASE AND RECONCILE WITH WP MEDIA LIBRARY
 */
function buddy_boss_pics_cleanup_db()
{
    global $wpdb;
    $activity_table = $wpdb->prefix . "bp_activity";
    $activity_meta_table = $wpdb->prefix . "bp_activity_meta";
    $posts_table = $wpdb->prefix . "posts";
    // Prepare a SQL query to retrieve the activity posts
    // that have pictures associated with them
    $all_aids_sql = "SELECT am.meta_value, am.activity_id FROM {$activity_table} a \r\n\t\t\t\t\t\t\t\t\t\t INNER JOIN {$activity_meta_table} am ON a.id = am.activity_id \r\n\t\t\t\t\t\t\t\t\t\t WHERE am.meta_key = 'bboss_pics_aid'";
    // Now perpare a SQL query to retrieve all attachments
    // that are BuddyBoss wall pictures AND are published in the media library
    $existing_sql = "SELECT am.meta_value FROM {$activity_table} a \r\n\t\t\t\t\t\t\t\t\t\t INNER JOIN {$activity_meta_table} am ON a.id = am.activity_id \r\n\t\t\t\t\t\t\t\t\t\t INNER JOIN {$posts_table} p ON am.meta_value = p.ID \r\n\t\t\t\t\t\t\t\t\t\t WHERE am.meta_key = 'bboss_pics_aid'\r\n\t\t\t\t\t\t\t\t\t\t AND p.post_status = 'inherit'\r\n\t\t\t\t\t\t\t\t\t\t AND p.post_parent = 0";
    // Query the database for all attachment IDS
    $all_aids = (array) $wpdb->get_results($all_aids_sql, ARRAY_A);
    // Query the database for all pics in the media library that are BuddyBoss pics
    $existing_aids = (array) $wpdb->get_col($existing_sql);
    // If we have a result set
    if (!empty($all_aids)) {
        // Prepare array
        $attachment_ids = $activity_ids = $aids2activity = array();
        foreach ($all_aids as $aid) {
            $attachment_ids[] = $aid['meta_value'];
            $aids2activity[$aid['meta_value']] = $activity_ids[] = $aid['activity_id'];
        }
        // Lets get the difference of our published vs. orphaned IDs
        $orphans = array_diff($attachment_ids, $existing_aids);
        // Delete related activity stream posts
        if (!empty($orphans)) {
            $orphan_acitivity_ids = array();
            foreach ($orphans as $orphan) {
                if (isset($aids2activity[$orphan])) {
                    $orphan_acitivity_ids[] = $aids2activity[$orphan];
                }
            }
            $orphan_acitivity_ids_string = implode(',', $orphan_acitivity_ids);
            $sql = $wpdb->prepare("DELETE FROM {$activity_table} WHERE id IN ({$orphan_acitivity_ids_string})");
            $deleted = $wpdb->query($sql);
            BP_Activity_Activity::delete_activity_item_comments($orphan_acitivity_ids);
            BP_Activity_Activity::delete_activity_meta_entries($orphan_acitivity_ids);
        }
    }
}
开发者ID:par-orillonsoft,项目名称:Wishmagnet,代码行数:45,代码来源:buddy_boss_pics.php


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