PluginProbe
Taskbuilder – Project Management & Task Management Tool With Kanban Board / 1.0.3
Taskbuilder – Project Management & Task Management Tool With Kanban Board v1.0.3
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
taskbuilder / includes / admin / tasks / open_task / wppm_thread_attachment_remove.php

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

33 lines 1.5 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 $attachment = isset($_POST['attachment']) ? intval(sanitize_text_field($_POST['attachment'])) : '0' ;
8 $comment_id = isset($_POST['comment_id']) ? intval(sanitize_text_field($_POST['comment_id'])) : '0' ;
9 $task_id = isset($_POST['task_id']) ? intval(sanitize_text_field($_POST['task_id'])) : '0' ;
10 $task_comment = $wpdb->get_row( "SELECT * FROM {$wpdb->prefix}wppm_task_comment where id = $comment_id AND task_id=$task_id");
11 if(!(((!empty($task_comment)) && ($task_comment->created_by == $current_user->ID)) || ($current_user->has_cap('manage_options')) || ($wppmfunction->has_comment_permission('edit_task_comment',$task_id,$comment_id)))){
12 exit;
13 }
14 $success = $wpdb->delete(
15 $wpdb->prefix . 'wppm_attachments',
16 array( 'id' => $attachment )
17 );
18 if( !$success ) return false;
19 $task_attachment = $wpdb->get_var("SELECT attachment_ids FROM {$wpdb->prefix}wppm_task_comment WHERE id=$comment_id ");
20 $task_attachment = explode(",",$task_attachment);
21 if(!empty($task_attachment)){
22 foreach($task_attachment as $key=>$val){
23 if($val == $attachment){
24 unset($task_attachment[$key]);
25 }
26 }
27 }
28 $tattachment = implode(',',$task_attachment);
29 $values=array(
30 'attachment_ids'=>$tattachment
31 );
32 $wpdb->update($wpdb->prefix.'wppm_task_comment', $values, array('id'=>$comment_id));
33 $attachment = apply_filters('wppm_after_delete_comment_attachment',$attachment,$comment_id,$task_id);