| 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_task', '_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 |
|
| 12 |
$task_data = $wppmfunction->get_task($task_id); |
| 13 |
$project_data = $wppmfunction->get_project($task_data['project']); |
| 14 |
$wppm_current_user_capability = get_user_meta( $current_user->ID, 'wppm_capability', true ); |
| 15 |
if(!(($current_user->ID && $current_user->has_cap('manage_options')) || ($wppmfunction->has_permission('delete_task',$task_id)) || $wppm_current_user_capability == 'wppm_admin'|| $project_data['created_by']==$current_user->ID )){ |
| 16 |
exit; |
| 17 |
} |
| 18 |
// Deletes the task's own attachments/checklists/comments, and cascades to any subtasks. |
| 19 |
WPPM_Functions::delete_task_and_children($task_id); |