PluginProbe
Taskbuilder – Project Management & Task Management Tool With Kanban Board / 6.0.6
Taskbuilder – Project Management & Task Management Tool With Kanban Board v6.0.6
6.0.6 6.0.5 6.0.2 6.0.3 6.0.4 6.0.1 6.0.0 5.0.8 5.0.9 4.0.9 5.0.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 All 58 releases
← All changes | includes/admin/tasks/open_task/wppm_set_delete_thread.php +56 -32 1.0.46.0.6 View file →
@@ -1,33 +1,57 @@
1 -<?php
2 -if ( ! defined( 'ABSPATH' ) ) {
3 - exit; // Exit if accessed directly
4 -}
5 -
6 -global $current_user, $wppmfunction ,$wpdb;
7 -$task_id = isset($_POST['task_id']) ? sanitize_text_field($_POST['task_id']) : 0 ;
8 -$thread_id = isset($_POST['comment_id']) ? sanitize_text_field($_POST['comment_id']) : 0 ;
9 -$task_comment = $wppmfunction->get_task_comment($thread_id);
10 -if (!(($current_user->ID && $current_user->has_cap('manage_options')) || $wppmfunction->has_comment_permission('delete_task_thread',$task_id,$thread_id))) {exit;}
11 -$sql="SELECT attachment_ids FROM {$wpdb->prefix}wppm_task_comment WHERE id =".$thread_id;
12 -$thread_attachment_ids = $wpdb->get_results( $sql );
13 -if(!empty($thread_attachment_ids) ){
14 - foreach ($thread_attachment_ids as $thread_attachment_id){
15 - $attachment_ids_temp=array();
16 - if($thread_attachment_id->attachment_ids){
17 - $attachment_ids_temp= explode(',', $thread_attachment_id->attachment_ids);
18 - }
19 - $attachment_ids=$attachment_ids_temp;
20 - foreach ($attachment_ids_temp as $attachment_id){
21 - $sql="SELECT * FROM {$wpdb->prefix}wppm_attachments WHERE id =".$attachment_id;
22 - $result=$wpdb->get_row($sql);
23 - if(file_exists($result->file_path))
24 - {
25 - unlink($result->file_path);
26 - }
27 - $wpdb->delete($wpdb->prefix.'wppm_attachments', array( 'id' => $attachment_id));
28 - }
29 - }
30 -}
31 -$wpdb->delete($wpdb->prefix.'wppm_task_comment',array('id'=>$thread_id));
32 -
1 +<?php
2 +if ( ! defined( 'ABSPATH' ) ) {
3 + exit; // Exit if accessed directly
4 +}
5 +
6 +global $current_user, $wppmfunction ,$wpdb;
7 +if ( check_ajax_referer( 'wppm_set_delete_thread', '_ajax_nonce', false ) != 1 ) {
8 + wp_send_json_error( 'Unauthorised request!', 401 );
9 +}
10 +$task_id = isset($_POST['task_id']) ? intval(sanitize_text_field(wp_unslash($_POST['task_id']))) : 0 ;
11 +$thread_id = isset($_POST['comment_id']) ? intval(sanitize_text_field(wp_unslash($_POST['comment_id']))) : 0 ;
12 +$task_comment = $wppmfunction->get_task_comment($thread_id);
13 +if (!(($current_user->ID && $current_user->has_cap('manage_options')) || $wppmfunction->has_comment_permission('delete_task_thread',$task_id,$thread_id))) {exit;}
14 +$thread_id = absint($thread_id);
15 +$task_id = absint($task_id);
16 +$sql=$wpdb->prepare("SELECT attachment_ids FROM {$wpdb->prefix}wppm_task_comment WHERE id = %d",$thread_id);
17 +$thread_attachment_ids = $wpdb->get_results( $sql );
18 +if(!empty($thread_attachment_ids) ){
19 + foreach ($thread_attachment_ids as $thread_attachment_id){
20 + $attachment_ids_temp=array();
21 + if($thread_attachment_id->attachment_ids){
22 + $attachment_ids_temp = explode(',', $thread_attachment_id->attachment_ids);
23 + }
24 + $attachment_ids=$attachment_ids_temp;
25 + if(!empty($attachment_ids_temp)){
26 + foreach ($attachment_ids_temp as $attachment_id){
27 + $attachment_id = absint($attachment_id);
28 + $sql=$wpdb->prepare("SELECT * FROM {$wpdb->prefix}wppm_attachments WHERE id = %d",$attachment_id);
29 + $result=$wpdb->get_row($sql);
30 + if(!empty($result)){
31 + $sql_query=$wpdb->prepare("SELECT file_path FROM {$wpdb->prefix}wppm_attachments WHERE file_path = %s",$result->file_path);
32 + $attach_result=$wpdb->get_results($sql_query);
33 + $result_count = count($attach_result);
34 + if(file_exists($result->file_path) && $result_count < 2)
35 + {
36 + wp_delete_file($result->file_path);
37 + }
38 + $wpdb->delete($wpdb->prefix.'wppm_attachments', array( 'id' => $attachment_id));
39 + }
40 + }
41 + }
42 + }
43 +}
44 +$cur_user = get_userdata($current_user->ID);
45 +$cur_user_display_name = $cur_user->display_name;
46 +$log_values = array('task_id'=>"$task_id",'body'=>'This comment was deleted by '.$cur_user_display_name,'attachment_ids'=>"" );
47 +$wpdb->update($wpdb->prefix.'wppm_task_comment', $log_values, array('id'=>"$thread_id"));
48 +$task_log_values = array('task_id'=>"$task_id",'comment_id'=>"$thread_id",'comment_type'=>'delete_task_comment');
49 +$comment_meta = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}wppm_task_comment_meta WHERE comment_id = %d",$thread_id));
50 +if(!empty($comment_meta)){
51 + $comment_meta_id = absint($comment_meta->id);
52 + $wpdb->update($wpdb->prefix . 'wppm_task_comment_meta',$task_log_values,array('id'=>"$comment_meta_id"));
53 +}else{
54 + $wpdb->insert($wpdb->prefix . 'wppm_task_comment_meta',$task_log_values);
55 +
56 +}
33 57 ?>