PluginProbe
Taskbuilder – Project Management & Task Management Tool With Kanban Board / 2.0.2
Taskbuilder – Project Management & Task Management Tool With Kanban Board v2.0.2
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 1.0.6 All 57 releases
taskbuilder / includes / admin / tasks / open_task / wppm_set_delete_thread.php

wppm_set_delete_thread.php in Taskbuilder – Project Management & Task Management Tool With Kanban Board 2.0.2, at includes/admin/tasks/open_task/wppm_set_delete_thread.php

40 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 if(!empty($attachment_ids_temp)){
21 foreach ($attachment_ids_temp as $attachment_id){
22 $sql="SELECT * FROM {$wpdb->prefix}wppm_attachments WHERE id =".$attachment_id;
23 $result=$wpdb->get_row($sql);
24 if(!empty($result)){
25 $sql_query="SELECT file_path FROM {$wpdb->prefix}wppm_attachments WHERE file_path ='".$result->file_path."'";
26 $attach_result=$wpdb->get_results($sql_query);
27 $result_count = count($attach_result);
28 if(file_exists($result->file_path) && $result_count < 2)
29 {
30 unlink($result->file_path);
31 }
32 $wpdb->delete($wpdb->prefix.'wppm_attachments', array( 'id' => $attachment_id));
33 }
34 }
35 }
36 }
37 }
38 $wpdb->delete($wpdb->prefix.'wppm_task_comment',array('id'=>$thread_id));
39
40 ?>