コード例 #1
0
 protected static function processUnmarkSpam()
 {
     if (!empty($_GET['nonce']) and wp_verify_nonce($_GET['nonce'], self::ADMIN_UNMARK_SPAM)) {
         // Answer
         if (!empty($_GET['answer_id'])) {
             if ($answer = CMA_Answer::getById($_GET['answer_id'])) {
                 if ($answer->canUnmarkSpam()) {
                     $answer->markAsSpam(0);
                 } else {
                     die('Cannot unmark spam.');
                 }
             } else {
                 die('Unknown answer.');
             }
         }
         // Comment
         if (!empty($_GET['comment_id'])) {
             if ($comment = CMA_Comment::getById($_GET['comment_id'])) {
                 if ($comment->canUnmarkSpam()) {
                     $comment->markAsSpam(0);
                 } else {
                     die('Cannot unmark spam.');
                 }
             } else {
                 die('Unknown comment.');
             }
         }
         if (!empty($_GET['backlink'])) {
             wp_safe_redirect(base64_decode(urldecode($_GET['backlink'])));
             exit;
         }
     } else {
         die('Invalid nonce.');
     }
 }
コード例 #2
0
 protected static function _processCommentDelete()
 {
     header('content-type: application/json');
     $response = array('success' => 0, 'msg' => CMA::__('An error occured.'));
     $commentId = self::_getParam('cma-comment-id');
     if (empty($_POST['nonce']) or !wp_verify_nonce($_POST['nonce'], 'cma_comment_delete')) {
         $response['msg'] = CMA::__('Invalid nonce.');
     } else {
         if ($commentId and $comment = CMA_Comment::getById($commentId)) {
             $comment->trash();
             $response = array('success' => 1, 'msg' => CMA::__('Comment moved to trash.'));
         }
     }
     echo json_encode(apply_filters('cma_comment_delete_ajax_response', $response));
     exit;
 }
コード例 #3
0
 public static function processAnwserStatusChange($answerId, $status)
 {
     /*
      * Get the comment, author, thread
      */
     $answer = get_comment($answerId);
     /*
      * Comment not found
      */
     if (!$answer) {
         return;
     }
     // Comment is not a CMA answer nor comment
     if ($answer->comment_type != CMA_Answer::COMMENT_TYPE and $answer->comment_type != CMA_Comment::COMMENT_TYPE) {
         return;
     }
     $thread = CMA_Thread::getInstance($answer->comment_post_ID);
     /*
      * Fix in case $thread isn't found
      */
     if (is_object($thread)) {
         $thread->updateThreadMetadata(array('answerId' => $answerId));
         if ($status == 'approve') {
             // Send notifications
             $thread->setUpdated();
             if ($answer->comment_type == CMA_Answer::COMMENT_TYPE) {
                 $thread->notifyAboutNewAnswer($answerId);
             } else {
                 if ($comment = CMA_Comment::getById($answerId)) {
                     $comment->sendNotifications();
                 }
             }
         } else {
             $thread->clearCache();
         }
     }
 }