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


PHP Comments::delete_by_status方法代码示例

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


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

示例1: ajax_update_comment

	/**
	 * Handles AJAX requests to update comments, comment moderation
	 */
	public function ajax_update_comment( $handler_vars )
	{

		Utils::check_request_method( array( 'POST' ) );

		// check WSSE authentication
		$wsse = Utils::WSSE( $handler_vars['nonce'], $handler_vars['timestamp'] );
		if ( $handler_vars['digest'] != $wsse['digest'] ) {
			Session::error( _t( 'WSSE authentication failed.' ) );
			echo Session::messages_get( true, array( 'Format', 'json_messages' ) );
			return;
		}

		$ids = array();

		foreach ( $_POST as $id => $update ) {
			// skip POST elements which are not comment ids
			if ( preg_match( '/^p\d+$/', $id ) && $update ) {
				$ids[] = (int) substr( $id, 1 );
			}
		}

		if ( ( ! isset( $ids ) || empty( $ids ) ) && $handler_vars['action'] == 'delete' ) {
			Session::notice( _t( 'No comments selected.' ) );
			echo Session::messages_get( true, array( 'Format', 'json_messages' ) );
			return;
		}

		$comments = Comments::get( array( 'id' => $ids, 'nolimit' => true ) );
		Plugins::act( 'admin_moderate_comments', $handler_vars['action'], $comments, $this );
		$status_msg = _t( 'Unknown action "%s"', array( $handler_vars['action'] ) );

		switch ( $handler_vars['action'] ) {
			case 'delete_spam':
				Comments::delete_by_status( Comment::STATUS_SPAM );
				$status_msg = _t( 'Deleted all spam comments' );
				break;
			case 'delete_unapproved':
				Comments::delete_by_status( Comment::STATUS_UNAPPROVED );
				$status_msg = _t( 'Deleted all unapproved comments' );
				break;
			case 'delete':
				// Comments marked for deletion
				Comments::delete_these( $comments );
				$status_msg = sprintf( _n( 'Deleted %d comment', 'Deleted %d comments', count( $ids ) ), count( $ids ) );
				break;
			case 'spam':
				// Comments marked as spam
				Comments::moderate_these( $comments, Comment::STATUS_SPAM );
				$status_msg = sprintf( _n( 'Marked %d comment as spam', 'Marked %d comments as spam', count( $ids ) ), count( $ids ) );
				break;
			case 'approve':
			case 'approved':
				// Comments marked for approval
				Comments::moderate_these( $comments, Comment::STATUS_APPROVED );
				$status_msg = sprintf( _n( 'Approved %d comment', 'Approved %d comments', count( $ids ) ), count( $ids ) );
				break;
			case 'unapprove':
			case 'unapproved':
				// Comments marked for unapproval
				Comments::moderate_these( $comments, Comment::STATUS_UNAPPROVED );
				$status_msg = sprintf( _n( 'Unapproved %d comment', 'Unapproved %d comments', count( $ids ) ), count( $ids ) );
				break;
			default:
				// Specific plugin-supplied action
				$status_msg = Plugins::filter( 'admin_comments_action', $status_msg, $handler_vars['action'], $comments );
				break;
		}

		Session::notice( $status_msg );
		echo Session::messages_get( true, array( 'Format', 'json_messages' ) );
	}
开发者ID:rynodivino,项目名称:system,代码行数:75,代码来源:admincommentshandler.php

示例2: fetch_comments

 public function fetch_comments($params = array())
 {
     // Make certain handler_vars local with defaults, and add them to the theme output
     $locals = array('do_delete' => false, 'do_spam' => false, 'do_approve' => false, 'do_unapprove' => false, 'comment_ids' => null, 'nonce' => '', 'timestamp' => '', 'PasswordDigest' => '', 'mass_spam_delete' => null, 'mass_delete' => null, 'type' => 'All', 'limit' => 20, 'offset' => 0, 'search' => '', 'status' => 'All', 'orderby' => 'date DESC');
     foreach ($locals as $varname => $default) {
         ${$varname} = isset($this->handler_vars[$varname]) ? $this->handler_vars[$varname] : (isset($params[$varname]) ? $params[$varname] : $default);
         $this->theme->{$varname} = ${$varname};
     }
     // Setting these mass_delete options prevents any other processing.  Desired?
     if (isset($mass_spam_delete) && $status == Comment::STATUS_SPAM) {
         // Delete all comments that have the spam status.
         Comments::delete_by_status(Comment::STATUS_SPAM);
         // let's optimize the table
         $result = DB::query('OPTIMIZE TABLE {comments}');
         Session::notice(_t('Deleted all spam comments'));
         Utils::redirect();
     } elseif (isset($mass_delete) && $status == Comment::STATUS_UNAPPROVED) {
         // Delete all comments that are unapproved.
         Comments::delete_by_status(Comment::STATUS_UNAPPROVED);
         Session::notice(_t('Deleted all unapproved comments'));
         Utils::redirect();
     } elseif (($do_delete || $do_spam || $do_approve || $do_unapprove) && isset($comment_ids)) {
         $okay = true;
         if (empty($nonce) || empty($timestamp) || empty($PasswordDigest)) {
             $okay = false;
         }
         $wsse = Utils::WSSE($nonce, $timestamp);
         if ($PasswordDigest != $wsse['digest']) {
             $okay = false;
         }
         if ($okay) {
             if ($do_delete) {
                 $action = 'delete';
             } elseif ($do_spam) {
                 $action = 'spam';
             } elseif ($do_approve) {
                 $action = 'approve';
             } elseif ($do_unapprove) {
                 $action = 'unapprove';
             }
             $ids = array();
             foreach ($comment_ids as $id => $id_value) {
                 if (!isset(${'$comment_ids[' . $id . ']'})) {
                     // Skip unmoderated submitted comment_ids
                     $ids[] = $id;
                 }
             }
             $to_update = Comments::get(array('id' => $ids));
             $modstatus = array('Deleted %d comments' => 0, 'Marked %d comments as spam' => 0, 'Approved %d comments' => 0, 'Unapproved %d comments' => 0, 'Edited %d comments' => 0);
             Plugins::act('admin_moderate_comments', $action, $to_update, $this);
             switch ($action) {
                 case 'delete':
                     // This comment was marked for deletion
                     $to_update = $this->comment_access_filter($to_update, 'delete');
                     Comments::delete_these($to_update);
                     $modstatus['Deleted %d comments'] = count($to_update);
                     break;
                 case 'spam':
                     // This comment was marked as spam
                     $to_update = $this->comment_access_filter($to_update, 'edit');
                     Comments::moderate_these($to_update, Comment::STATUS_SPAM);
                     $modstatus['Marked %d comments as spam'] = count($to_update);
                     break;
                 case 'approve':
                 case 'approved':
                     // Comments marked for approval
                     $to_update = $this->comment_access_filter($to_update, 'edit');
                     Comments::moderate_these($to_update, Comment::STATUS_APPROVED);
                     $modstatus['Approved %d comments'] = count($to_update);
                     foreach ($to_update as $comment) {
                         $modstatus['Approved comments on these posts: %s'] = (isset($modstatus['Approved comments on these posts: %s']) ? $modstatus['Approved comments on these posts: %s'] . ' &middot; ' : '') . '<a href="' . $comment->post->permalink . '">' . $comment->post->title . '</a> ';
                     }
                     break;
                 case 'unapprove':
                 case 'unapproved':
                     // This comment was marked for unapproval
                     $to_update = $this->comment_access_filter($to_update, 'edit');
                     Comments::moderate_these($to_update, Comment::STATUS_UNAPPROVED);
                     $modstatus['Unapproved %d comments'] = count($to_update);
                     break;
                 case 'edit':
                     $to_update = $this->comment_access_filter($to_update, 'edit');
                     foreach ($to_update as $comment) {
                         // This comment was edited
                         if ($_POST['name_' . $comment->id] != NULL) {
                             $comment->name = $_POST['name_' . $comment->id];
                         }
                         if ($_POST['email_' . $comment->id] != NULL) {
                             $comment->email = $_POST['email_' . $comment->id];
                         }
                         if ($_POST['url_' . $comment->id] != NULL) {
                             $comment->url = $_POST['url_' . $comment->id];
                         }
                         if ($_POST['content_' . $comment->id] != NULL) {
                             $comment->content = $_POST['content_' . $comment->id];
                         }
                         $comment->update();
                     }
                     $modstatus['Edited %d comments'] = count($to_update);
                     break;
//.........这里部分代码省略.........
开发者ID:anupom,项目名称:my-blog,代码行数:101,代码来源:adminhandler.php

示例3: action_auth_ajax_deleteall

 /**
  * Handles spam deletion
  *
  * @return void
  **/
 public function action_auth_ajax_deleteall($handler)
 {
     $result = array();
     switch ($handler->handler_vars['target']) {
         case 'spam':
             if (!User::identify()->can('manage_all_comments')) {
                 Session::error(_t('You do not have permission to do that action.'));
                 break;
             }
             $total = Comments::count_total(Comment::STATUS_SPAM, FALSE);
             Comments::delete_by_status(Comment::status('spam'));
             Session::notice(sprintf(_t('Deleted all %s spam comments.'), $total));
             break;
         case 'logs':
             if (!User::identify()->can('manage_logs')) {
                 Session::error(_t('You do not have permission to do that action.'));
                 break;
             }
             $to_delete = EventLog::get(array('date' => 'any', 'nolimit' => 1));
             $count = 0;
             foreach ($to_delete as $log) {
                 $log->delete();
                 $count++;
             }
             Session::notice(sprintf(_t('Deleted all %s log entries.'), $count));
             break;
     }
     $result['messages'] = Session::messages_get(true, 'array');
     echo json_encode($result);
 }
开发者ID:habari-extras,项目名称:spamview,代码行数:35,代码来源:spamview.plugin.php

示例4: ajax_update_comment

 /**
  * Handles AJAX requests to update comments, comment moderation
  */
 public function ajax_update_comment($handler_vars)
 {
     Utils::check_request_method(array('POST'));
     $ar = new AjaxResponse();
     // check WSSE authentication
     $wsse = Utils::WSSE($_POST['nonce'], $_POST['timestamp']);
     if ($_POST['digest'] != $wsse['digest']) {
         $ar->message = _t('WSSE authentication failed.');
         $ar->out();
         return;
     }
     $ids = $_POST['selected'];
     if ((!isset($ids) || empty($ids)) && $_POST['action'] == 'delete') {
         $ar->message = _t('No comments selected.');
         $ar->out();
         return;
     }
     $comments = Comments::get(array('id' => $ids, 'nolimit' => true));
     Plugins::act('admin_moderate_comments', $_POST['action'], $comments, $this);
     $status_msg = _t('Unknown action "%s"', array($handler_vars['action']));
     switch ($_POST['action']) {
         case 'delete_spam':
             Comments::delete_by_status('spam');
             $status_msg = _t('Deleted all spam comments');
             break;
         case 'delete_unapproved':
             Comments::delete_by_status('unapproved');
             $status_msg = _t('Deleted all unapproved comments');
             break;
         case 'delete':
             // Comments marked for deletion
             Comments::delete_these($comments);
             $status_msg = sprintf(_n('Deleted %d comment', 'Deleted %d comments', count($ids)), count($ids));
             break;
         case 'spam':
             // Comments marked as spam
             Comments::moderate_these($comments, 'spam');
             $status_msg = sprintf(_n('Marked %d comment as spam', 'Marked %d comments as spam', count($ids)), count($ids));
             break;
         case 'approve':
         case 'approved':
             // Comments marked for approval
             Comments::moderate_these($comments, 'approved');
             $status_msg = sprintf(_n('Approved %d comment', 'Approved %d comments', count($ids)), count($ids));
             break;
         case 'unapprove':
         case 'unapproved':
             // Comments marked for unapproval
             Comments::moderate_these($comments, 'unapproved');
             $status_msg = sprintf(_n('Unapproved %d comment', 'Unapproved %d comments', count($ids)), count($ids));
             break;
         default:
             // Specific plugin-supplied action
             $status_msg = Plugins::filter('admin_comments_action', $status_msg, $_POST['action'], $comments);
             break;
     }
     $ar->message = $status_msg;
     $ar->out();
 }
开发者ID:habari,项目名称:system,代码行数:62,代码来源:admincommentshandler.php


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