Example #1
0
 public function edit_answer($postid, $userid, $question_id)
 {
     ap_add_history($userid, $postid, $postid, 'edit_answer');
 }
Example #2
0
 /**
  * Handle change post status request.
  * @since 2.1
  */
 public function change_post_status()
 {
     $post_id = (int) $_POST['post_id'];
     $status = sanitize_text_field(wp_unslash($_POST['status']));
     if (!is_user_logged_in() || !ap_verify_nonce('change_post_status_' . $post_id) || !ap_user_can_change_status($post_id)) {
         $this->send('no_permission');
     } else {
         $post = get_post($post_id);
         if (($post->post_type == 'question' || $post->post_type == 'answer') && $post->post_status != $status) {
             $update_data = array();
             if ('publish' == $status) {
                 $update_data['post_status'] = 'publish';
             } elseif ('moderate' == $status) {
                 $update_data['post_status'] = 'moderate';
             } elseif ('private_post' == $status) {
                 $update_data['post_status'] = 'private_post';
             } elseif ('closed' == $status) {
                 $update_data['post_status'] = 'closed';
             }
             // Unregister history action for edit.
             remove_action('ap_after_new_answer', array('AP_History', 'new_answer'));
             remove_action('ap_after_new_question', array('AP_History', 'new_question'));
             $update_data['ID'] = $post->ID;
             wp_update_post($update_data);
             ap_add_history(get_current_user_id(), $post_id, '', 'status_updated');
             add_action('ap_post_status_updated', $post->ID);
             ob_start();
             ap_post_status_description($post->ID);
             $html = ob_get_clean();
             $this->send(array('action' => 'status_updated', 'message' => 'status_updated', 'do' => array('remove_if_exists' => '#ap_post_status_desc_' . $post->ID, 'toggle_active_class' => array('#ap_post_status_toggle_' . $post->ID, '.' . $status), 'append_before' => '#ap_post_actions_' . $post->ID), 'html' => $html));
         }
     }
     $this->something_wrong();
 }
Example #3
0
 /**
  * Handle change post status request
  * @return void
  * @since 2.1
  */
 public function change_post_status()
 {
     $post_id = (int) $_POST['post_id'];
     $status = $_POST['status'];
     if (!is_user_logged_in() || !wp_verify_nonce($_POST['__nonce'], 'change_post_status_' . $post_id) || !ap_user_can_change_status($post_id)) {
         ap_send_json(ap_ajax_responce('no_permission'));
         die;
     } else {
         $post = get_post($post_id);
         if (($post->post_type == 'question' || $post->post_type == 'answer') && $post->post_status != $status) {
             $update_data = array();
             if ($status == 'publish') {
                 $update_data['post_status'] = 'publish';
             } elseif ($status == 'moderate') {
                 $update_data['post_status'] = 'moderate';
             } elseif ($status == 'private_post') {
                 $update_data['post_status'] = 'private_post';
             } elseif ($status == 'closed') {
                 $update_data['post_status'] = 'closed';
             }
             // unregister history action for edit
             remove_action('ap_after_new_answer', array('AP_History', 'new_answer'));
             remove_action('ap_after_new_question', array('AP_History', 'new_question'));
             $update_data['ID'] = $post->ID;
             wp_update_post($update_data);
             ap_add_history(get_current_user_id(), $post_id, '', 'status_updated');
             add_action('ap_post_status_updated', $post->ID);
             ob_start();
             ap_post_status_description($post->ID);
             $html = ob_get_clean();
             ap_send_json(ap_ajax_responce(array('action' => 'status_updated', 'message' => 'status_updated', 'do' => array('remove_if_exists', 'toggle_active_class', 'append_before'), 'append_before_container' => '#ap_post_actions_' . $post->ID, 'toggle_active_class_container' => '#ap_post_status_toggle_' . $post->ID, 'remove_if_exists_container' => '#ap_post_status_desc_' . $post->ID, 'active' => '.' . $status, 'html' => $html)));
             die;
         }
     }
     ap_send_json(ap_ajax_responce('something_wrong'));
     die;
 }
Example #4
0
 public function unselect_answer($user_id, $question_id, $answer_id)
 {
     ap_add_history($user_id, $question_id, $answer_id, 'answer_unselected');
 }
Example #5
0
 public function after_label_removed($object_id, $tt_ids)
 {
     if (!is_user_logged_in()) {
         return false;
     }
     ap_add_history(get_current_user_id(), $object_id, implode(',', $tt_ids), 'removed_label');
 }