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


PHP bp_activity_delete_comment函数代码示例

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


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

示例1: bp_activity_admin_load


//.........这里部分代码省略.........
         *
         * @param array $activity_ids Activity IDs to spam/un-spam/delete.
         */
        $activity_ids = apply_filters('bp_activity_admin_action_activity_ids', $activity_ids);
        // Is this a bulk request?
        if ('bulk_' == substr($doaction, 0, 5) && !empty($_REQUEST['aid'])) {
            // Check this is a valid form submission
            check_admin_referer('bulk-activities');
            // Trim 'bulk_' off the action name to avoid duplicating a ton of code
            $doaction = substr($doaction, 5);
            // This is a request to delete, spam, or un-spam, a single item.
        } elseif (!empty($_REQUEST['aid'])) {
            // Check this is a valid form submission
            check_admin_referer('spam-activity_' . $activity_ids[0]);
        }
        // Initialise counters for how many of each type of item we perform an action on
        $deleted = $spammed = $unspammed = 0;
        // Store any errors that occurs when updating the database items
        $errors = array();
        // "We'd like to shoot the monster, could you move, please?"
        foreach ($activity_ids as $activity_id) {
            // @todo: Check the permissions on each
            //if ( ! current_user_can( 'bp_edit_activity', $activity_id ) )
            //	continue;
            // Get the activity from the database
            $activity = new BP_Activity_Activity($activity_id);
            if (empty($activity->component)) {
                $errors[] = $activity_id;
                continue;
            }
            switch ($doaction) {
                case 'delete':
                    if ('activity_comment' == $activity->type) {
                        bp_activity_delete_comment($activity->item_id, $activity->id);
                    } else {
                        bp_activity_delete(array('id' => $activity->id));
                    }
                    $deleted++;
                    break;
                case 'ham':
                    /**
                     * Remove moderation and blacklist checks in case we want to ham an activity
                     * which contains one of these listed keys.
                     */
                    remove_action('bp_activity_before_save', 'bp_activity_check_moderation_keys', 2, 1);
                    remove_action('bp_activity_before_save', 'bp_activity_check_blacklist_keys', 2, 1);
                    bp_activity_mark_as_ham($activity);
                    $result = $activity->save();
                    // Check for any error during activity save
                    if (!$result) {
                        $errors[] = $activity->id;
                    } else {
                        $unspammed++;
                    }
                    break;
                case 'spam':
                    bp_activity_mark_as_spam($activity);
                    $result = $activity->save();
                    // Check for any error during activity save
                    if (!$result) {
                        $errors[] = $activity->id;
                    } else {
                        $spammed++;
                    }
                    break;
                default:
开发者ID:un1coin,项目名称:ovn-space,代码行数:67,代码来源:bp-activity-admin.php

示例2: bp_dtheme_delete_activity_comment

function bp_dtheme_delete_activity_comment()
{
    global $bp;
    /* Check the nonce */
    check_admin_referer('bp_activity_delete_link');
    if (!is_user_logged_in()) {
        echo '-1';
        return false;
    }
    $comment = new BP_Activity_Activity($_POST['id']);
    /* Check access */
    if (!is_super_admin() && $comment->user_id != $bp->loggedin_user->id) {
        return false;
    }
    if (empty($_POST['id']) || !is_numeric($_POST['id'])) {
        return false;
    }
    /* Call the action before the delete so plugins can still fetch information about it */
    do_action('bp_activity_before_action_delete_activity', $_POST['id'], $comment->user_id);
    if (!bp_activity_delete_comment($comment->item_id, $comment->id)) {
        echo '-1<div id="message" class="error"><p>' . __('There was a problem when deleting. Please try again.', 'buddypress') . '</p></div>';
        return false;
    }
    do_action('bp_activity_action_delete_activity', $_POST['id'], $comment->user_id);
    return true;
}
开发者ID:hscale,项目名称:webento,代码行数:26,代码来源:ajax.php

示例3: bp_legacy_theme_delete_activity_comment

/**
 * Deletes an Activity comment received via a POST request
 *
 * @return mixed String on error, void on success
 * @since BuddyPress (1.2)
 */
function bp_legacy_theme_delete_activity_comment()
{
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    // Check the nonce
    check_admin_referer('bp_activity_delete_link');
    if (!is_user_logged_in()) {
        exit('-1');
    }
    $comment = new BP_Activity_Activity($_POST['id']);
    // Check access
    if (!bp_current_user_can('bp_moderate') && $comment->user_id != bp_loggedin_user_id()) {
        exit('-1');
    }
    if (empty($_POST['id']) || !is_numeric($_POST['id'])) {
        exit('-1');
    }
    /** This action is documented in bp-activity/bp-activity-actions.php */
    do_action('bp_activity_before_action_delete_activity', $_POST['id'], $comment->user_id);
    if (!bp_activity_delete_comment($comment->item_id, $comment->id)) {
        exit('-1<div id="message" class="error bp-ajax-message"><p>' . __('There was a problem when deleting. Please try again.', 'buddypress') . '</p></div>');
    }
    /** This action is documented in bp-activity/bp-activity-actions.php */
    do_action('bp_activity_action_delete_activity', $_POST['id'], $comment->user_id);
    exit;
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:34,代码来源:buddypress-functions.php

示例4: check_delete_comments

 function check_delete_comments()
 {
     global $rtmedia_query;
     if ($rtmedia_query->action_query->action != 'delete-comment') {
         return;
     }
     if (count($_POST)) {
         /**
          * /media/id/delete-comment [POST]
          * Delete Comment by Comment ID
          */
         if (empty($_POST['comment_id'])) {
             return false;
         }
         $comment = new RTMediaComment();
         $id = $_POST['comment_id'];
         $activity_id = get_comment_meta($id, 'activity_id', true);
         if (!empty($activity_id)) {
             if (function_exists('bp_activity_delete_comment')) {
                 //if buddypress is active
                 $activity_deleted = bp_activity_delete_comment($activity_id, $id);
                 $delete = bp_activity_delete(array('id' => $activity_id, 'type' => 'activity_comment'));
             }
         }
         $comment_deleted = $comment->remove($id);
         echo $comment_deleted;
         exit;
     }
 }
开发者ID:fs-contributor,项目名称:rtMedia,代码行数:29,代码来源:RTMediaTemplate.php

示例5: check_delete_comments

 function check_delete_comments()
 {
     global $rtmedia_query;
     if ('delete-comment' !== $rtmedia_query->action_query->action) {
         return;
     }
     if (count($_POST)) {
         // @codingStandardsIgnoreLine
         /**
          * /media/id/delete-comment [POST]
          * Delete Comment by Comment ID
          */
         $_comment_id = filter_input(INPUT_POST, 'comment_id', FILTER_SANITIZE_NUMBER_INT);
         if (empty($_comment_id)) {
             return false;
         }
         $comment = new RTMediaComment();
         $id = $_comment_id;
         $activity_id = get_comment_meta($id, 'activity_id', true);
         if (!empty($activity_id)) {
             if (function_exists('bp_activity_delete_comment')) {
                 //if buddypress is active
                 $activity_deleted = bp_activity_delete_comment($activity_id, $id);
                 $delete = bp_activity_delete(array('id' => $activity_id, 'type' => 'activity_comment'));
             }
         }
         $comment_deleted = $comment->remove($id);
         echo $comment_deleted;
         // @codingStandardsIgnoreLine
         exit;
     }
 }
开发者ID:rtCamp,项目名称:rtMedia,代码行数:32,代码来源:RTMediaTemplate.php

示例6: bp_dtheme_delete_activity_comment

/**
 * Deletes an Activity comment received via a POST request
 *
 * @return mixed String on error, void on success
 * @since BuddyPress (1.2)
 */
function bp_dtheme_delete_activity_comment()
{
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    // Check the nonce
    check_admin_referer('bp_activity_delete_link');
    if (!is_user_logged_in()) {
        exit('-1');
    }
    $comment = new BP_Activity_Activity($_POST['id']);
    // Check access
    if (!bp_current_user_can('bp_moderate') && $comment->user_id != bp_loggedin_user_id()) {
        exit('-1');
    }
    if (empty($_POST['id']) || !is_numeric($_POST['id'])) {
        exit('-1');
    }
    // Call the action before the delete so plugins can still fetch information about it
    do_action('bp_activity_before_action_delete_activity', $_POST['id'], $comment->user_id);
    if (!bp_activity_delete_comment($comment->item_id, $comment->id)) {
        exit('-1<div id="message" class="error"><p>' . __('There was a problem when deleting. Please try again.', 'logicalboneshug') . '</p></div>');
    }
    do_action('bp_activity_action_delete_activity', $_POST['id'], $comment->user_id);
    exit;
}
开发者ID:raminjan,项目名称:logicalbones_hug,代码行数:33,代码来源:ajax.php

示例7: rtmedia_api_process_remove_comment_request

 /**
  * Delete comment by activity id or media id
  */
 function rtmedia_api_process_remove_comment_request()
 {
     global $wpdb;
     $this->rtmediajsonapifunction->rtmedia_api_verfiy_token();
     $this->rtmediajsonapifunction->rtmedia_api_media_activity_id_missing();
     //Errors Deleting comment
     $ec_comment_not_found = 800007;
     $msg_comment_not_found = __('invalid comment/media id', 'rtmedia');
     $ec_no_comment_id = 800008;
     $msg_no_comment_id = __('no comment id', 'rtmedia');
     $ec_comment_deleted = 800009;
     $msg_comment_deleted = __('comment deleted', 'rtmedia');
     extract($_POST);
     if (empty($comment_id)) {
         echo $this->rtmedia_api_response_object('FALSE', $ec_no_comment_id, $msg_no_comment_id);
         exit;
     }
     $id = rtmedia_media_id($media_id);
     $sql = "SELECT * FROM {$wpdb->comments} WHERE comment_ID = " . $comment_id . " AND comment_post_ID = " . $id . " AND user_id = " . $this->user_id;
     $comments = $wpdb->get_results($sql, ARRAY_A);
     //Delete Comment
     if (!empty($comments)) {
         $comment = new RTMediaComment();
         $activity_id = get_comment_meta($comment_id, 'activity_id', true);
         if (!empty($activity_id)) {
             $activity_deleted = bp_activity_delete_comment($activity_id, $comment_id);
             $delete = bp_activity_delete(array('id' => $activity_id, 'type' => 'activity_comment'));
         }
         $comment_deleted = $comment->rtmedia_comment_model->delete($comment_id);
         if ($comment_deleted) {
             echo $this->rtmedia_api_response_object('TRUE', $ec_comment_deleted, $msg_comment_deleted);
             exit;
         } else {
             echo $this->rtmedia_api_response_object('FALSE', $this->ec_server_error, $this->msg_server_error);
             exit;
         }
     } else {
         echo $this->rtmedia_api_response_object('FALSE', $ec_comment_not_found, $msg_comment_not_found);
         exit;
     }
 }
开发者ID:paulmedwal,项目名称:edxforumspublic,代码行数:44,代码来源:RTMediaJsonApi.php

示例8: test_bp_activity_delete_comment_clear_cache

 /**
  * @group bp_activity_delete_comment
  * @group cache
  */
 public function test_bp_activity_delete_comment_clear_cache()
 {
     $u = $this->factory->user->create();
     // add new activity update and comment to this update
     $a1 = $this->factory->activity->create(array('user_id' => $u));
     $a2 = bp_activity_new_comment(array('activity_id' => $a1, 'parent_id' => $a1, 'content' => 'foo', 'user_id' => $u));
     // prime cache
     bp_activity_get(array('in' => array($a1), 'display_comments' => 'threaded'));
     // delete activity comment
     bp_activity_delete_comment($a1, $a2);
     // assert comment cache as empty for $a1
     $this->assertEmpty(wp_cache_get($a1, 'bp_activity_comments'));
 }
开发者ID:swissspidy,项目名称:BuddyPress,代码行数:17,代码来源:functions.php

示例9: rtmedia_api_process_remove_comment_request

 /**
  * Delete comment by activity id or media id
  */
 function rtmedia_api_process_remove_comment_request()
 {
     global $wpdb;
     $this->rtmediajsonapifunction->rtmedia_api_verfiy_token();
     $this->rtmediajsonapifunction->rtmedia_api_media_activity_id_missing();
     //Errors Deleting comment
     $ec_comment_not_found = 800007;
     $msg_comment_not_found = esc_html__('invalid comment/media id', 'buddypress-media');
     $ec_no_comment_id = 800008;
     $msg_no_comment_id = esc_html__('no comment id', 'buddypress-media');
     $ec_comment_deleted = 800009;
     $msg_comment_deleted = esc_html__('comment deleted', 'buddypress-media');
     $media_id = filter_input(INPUT_POST, 'media_id', FILTER_SANITIZE_NUMBER_INT);
     $comment_id = filter_input(INPUT_POST, 'comment_id', FILTER_SANITIZE_NUMBER_INT);
     if (empty($comment_id)) {
         wp_send_json($this->rtmedia_api_response_object('FALSE', $ec_no_comment_id, $msg_no_comment_id));
     }
     $id = rtmedia_media_id($media_id);
     $sql = $wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_ID = %d AND comment_post_ID = %d AND user_id = %d limit 100", $comment_id, $id, $this->user_id);
     $comments = $wpdb->get_results($sql, ARRAY_A);
     // @codingStandardsIgnoreLine
     //Delete Comment
     if (!empty($comments)) {
         $comment = new RTMediaComment();
         $activity_id = get_comment_meta($comment_id, 'activity_id', true);
         if (!empty($activity_id)) {
             $activity_deleted = bp_activity_delete_comment($activity_id, $comment_id);
             $delete = bp_activity_delete(array('id' => $activity_id, 'type' => 'activity_comment'));
         }
         $comment_deleted = $comment->rtmedia_comment_model->delete($comment_id);
         if ($comment_deleted) {
             wp_send_json($this->rtmedia_api_response_object('TRUE', $ec_comment_deleted, $msg_comment_deleted));
         } else {
             wp_send_json($this->rtmedia_api_response_object('FALSE', $this->ec_server_error, $this->msg_server_error));
         }
     } else {
         wp_send_json($this->rtmedia_api_response_object('FALSE', $ec_comment_not_found, $msg_comment_not_found));
     }
 }
开发者ID:rtCamp,项目名称:rtMedia,代码行数:42,代码来源:RTMediaJsonApi.php

示例10: bp_activity_admin_load

/**
 * Set up the admin page before any output is sent. Register contextual help and screen options for this admin page.
 *
 * @global BP_Activity_List_Table $bp_activity_list_table Activity screen list table
 * @since 1.6
 */
function bp_activity_admin_load()
{
    global $bp_activity_list_table;
    // per_page screen option
    add_screen_option('per_page', array('label' => _x('Activities', 'Activity items per page (screen options)', 'buddypress')));
    // Help panel - text
    add_contextual_help(get_current_screen(), '<p>' . __('You can manage activities made on your site similar to the way you manage comments and other content. This screen is customizable in the same ways as other management screens, and you can act on activities using the on-hover action links or the Bulk Actions.', 'buddypress') . '</p>' . '<p>' . __('There are many different types of activities. Some are generated by BuddyPress automatically, and others are entered directly by a user in the form of status update. To help manage the different activity types, use the filter dropdown box to switch between them.', 'buddypress') . '</p>' . '<p>' . __('In the Activity column, above each activity it says &#8220;Submitted on,&#8221; followed by the date and time the activity item was generated on your site. Clicking on the date/time link will take you to that activity on your live site. Hovering over any activity gives you options to reply, edit, spam mark, or delete that activity.', 'buddypress') . '</p>' . '<p>' . __('In the In Response To column, the text is the name of the user who generated the activity, and a link to the activity on your live site. The small bubble with the number in it shows how many other activities are related to this one; these are usually comments. Clicking the bubble will filter the activity screen to show only related activity items.', 'buddypress') . '</p>');
    // Help panel - sidebar links
    get_current_screen()->set_help_sidebar('<p><strong>' . __('For more information:', 'buddypress') . '</strong></p>' . '<p>' . __('<a href="http://buddypress.org/support/">Support Forums</a>', 'buddypress') . '</p>');
    // Create the Activity screen list table
    $bp_activity_list_table = new BP_Activity_List_Table();
    // Handle spam/un-spam/delete of activities
    $doaction = $bp_activity_list_table->current_action();
    if ($doaction && 'edit' != $doaction) {
        // Build redirection URL
        $redirect_to = remove_query_arg(array('aid', 'deleted', 'spammed', 'unspammed'), wp_get_referer());
        $redirect_to = add_query_arg('paged', $bp_activity_list_table->get_pagenum(), $redirect_to);
        // Get activity IDs
        $activity_ids = array_map('absint', (array) $_REQUEST['aid']);
        // Is this a bulk request?
        if ('bulk_' == substr($doaction, 0, 5) && !empty($_REQUEST['aid'])) {
            // Check this is a valid form submission
            check_admin_referer('bulk-activities');
            // Trim 'bulk_' off the action name to avoid duplicating a ton of code
            $doaction = substr($doaction, 5);
            // This is a request to delete, spam, or un-spam, a single item.
        } elseif (!empty($_REQUEST['aid'])) {
            // Check this is a valid form submission
            check_admin_referer('spam-activity_' . $activity_ids[0]);
        }
        // Initialise counters for how many of each type of item we perform an action on
        $deleted = $spammed = $unspammed = 0;
        // "We'd like to shoot the monster, could you move, please?"
        foreach ($activity_ids as $activity_id) {
            // @todo: Check the permissions on each
            //if ( ! current_user_can( 'bp_edit_activity', $activity_id ) )
            //	continue;
            // Get the activity from the database
            $activity = new BP_Activity_Activity($activity_id);
            if (empty($activity->component)) {
                continue;
            }
            switch ($doaction) {
                case 'delete':
                    if ('activity_comment' == $activity->type) {
                        bp_activity_delete_comment($activity->item_id, $activity->id);
                    } else {
                        bp_activity_delete(array('id' => $activity->id));
                    }
                    $deleted++;
                    break;
                case 'ham':
                    bp_activity_mark_as_ham($activity);
                    $activity->save();
                    break;
                case 'spam':
                    bp_activity_mark_as_spam($activity);
                    $activity->save();
                    $spammed++;
                    break;
                default:
                    break;
            }
            // Release memory
            unset($activity);
        }
        // Add arguments to the redirect URL so that on page reload, we can easily display what we've just done.
        if ($spammed) {
            $redirect_to = add_query_arg('spammed', $spammed, $redirect_to);
        }
        if ($unspammed) {
            $redirect_to = add_query_arg('unspammed', $unspammed, $redirect_to);
        }
        if ($deleted) {
            $redirect_to = add_query_arg('deleted', $deleted, $redirect_to);
        }
        // Redirect
        wp_redirect($redirect_to);
        exit;
        // If a referrer and a nonce is supplied, but no action, redirect back.
    } elseif (!empty($_GET['_wp_http_referer'])) {
        wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
        exit;
    }
}
开发者ID:newington,项目名称:buddypress,代码行数:91,代码来源:bp-activity-admin.php

示例11: test_bp_blogs_sync_delete_from_activity_comment

 /**
  * @group bp_blogs_sync_delete_from_activity_comment
  * @group post_type_comment_activities
  */
 public function test_bp_blogs_sync_delete_from_activity_comment()
 {
     $old_user = get_current_user_id();
     $u = $this->factory->user->create();
     $this->set_current_user($u);
     $userdata = get_userdata($u);
     // let's use activity comments instead of single "new_blog_comment" activity items
     add_filter('bp_disable_blogforum_comments', '__return_false');
     // create the blog post
     $post_id = $this->factory->post->create(array('post_status' => 'publish', 'post_type' => 'post', 'post_title' => 'Test activity comment to post comment'));
     // grab the activity ID for the activity comment
     $a1 = bp_activity_get_activity_id(array('type' => 'new_blog_post', 'component' => buddypress()->blogs->id, 'filter' => array('item_id' => get_current_blog_id(), 'secondary_item_id' => $post_id)));
     $a2 = bp_activity_new_comment(array('content' => 'the generated comment should be deleted once the activity comment is removed', 'user_id' => $u, 'activity_id' => $a1));
     bp_activity_delete_comment($a1, $a2);
     $post_comments = get_comments(array('post_id' => $post_id));
     $this->assertEmpty($post_comments, 'A post comment should be deleted when the corresponding activity is');
     // reset
     remove_filter('bp_disable_blogforum_comments', '__return_false');
     $this->set_current_user($old_user);
 }
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:24,代码来源:activity.php


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