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_clone_task.php +46 -24 5.0.26.0.6 View file →
@@ -1,30 +1,50 @@
1 1 <?php
2 2 if ( ! defined( 'ABSPATH' ) ) {
3 3 exit; // Exit if accessed directly
4 4 }
5 -global $wpdb,$current_user,$wppmfunction;
6 -$redirect_flag = false;
7 -if ( !isset($ajax_nonce) && (check_ajax_referer( 'wppm_set_clone_task', '_ajax_nonce', false ) != 1) ) {
8 - $redirect_flag = true;
9 -}elseif((isset($ajax_nonce) && !wp_verify_nonce($ajax_nonce,'wppm_set_clone_task'))){
10 - $redirect_flag = true;
5 +global $wpdb, $current_user, $wppmfunction;
6 +$is_internal_clone = ! empty( $internal_code_flag );
7 +if ( ! $is_internal_clone ) {
8 + if (
9 + empty( $_POST['_ajax_nonce'] ) ||
10 + ! wp_verify_nonce(
11 + sanitize_text_field(
12 + wp_unslash( $_POST['_ajax_nonce'] )
13 + ),
14 + 'wppm_set_clone_task'
15 + )
16 + ) {
17 + wp_send_json_error(
18 + array(
19 + 'message' => esc_html__(
20 + 'Security check failed.',
21 + 'taskbuilder'
22 + )
23 + )
24 + );
25 + }
11 26 }
12 -if($redirect_flag == true){
13 - wp_send_json_error( 'Unauthorised request!', 401 );
27 +$prev_task_id = isset($_POST['task_id']) ? absint(sanitize_text_field(wp_unslash($_POST['task_id']))) : $ptask_id ;
28 +$task = $wppmfunction->get_task($prev_task_id);
29 +if ( empty($task) ) {
30 + wp_send_json_error('Invalid task', 404);
14 31 }
15 -$prev_task_id = isset($_POST['task_id']) ? intval(sanitize_text_field($_POST['task_id'])) : $ptask_id ;
16 -$task = $wppmfunction->get_task($prev_task_id);
17 -if (!(($current_user->ID && $current_user->has_cap('manage_options')) || $wppmfunction->has_permission('clone_task',$task['id']))) {
18 - exit;
32 +if (!(($current_user->has_cap('manage_options')) || $wppmfunction->has_permission('clone_task',$task['id']))) {
33 + wp_send_json_error('Unauthorized', 403);
19 34 }
20 35 $wppm_default_duplicate_project_email_notification = get_option('wppm_default_duplicate_project_email_notification');
21 36 $checklists = $wppmfunction->get_checklist($prev_task_id);
22 37 $task_project = isset($project_id) ? $project_id : $task['project'];
23 38 $prev_task_id = esc_sql($prev_task_id);
24 -$task_comments = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}wppm_task_comment WHERE task_id='$prev_task_id' ");
25 -$task_name = isset($_POST['task_name']) ? stripslashes(sanitize_text_field($_POST['task_name'])) : $task['task_name'] ;
26 -$now = date("Y-m-d H:i:s");
39 +$task_comments = $wpdb->get_results(
40 + $wpdb->prepare(
41 + "SELECT * FROM {$wpdb->prefix}wppm_task_comment WHERE task_id = %d",
42 + $prev_task_id
43 + )
44 +);
45 +$task_name = isset($_POST['task_name']) ? stripslashes(sanitize_text_field(wp_unslash($_POST['task_name']))) : $task['task_name'] ;
46 +$now = wp_date("Y-m-d H:i:s");
27 47 $values = array(
28 48 'created_by'=>$task['created_by'],
29 49 'name'=>$task_name,
30 50 'wppm_task_description'=>$task['description'],
@@ -35,9 +55,10 @@
35 55 'wppm_create_task_priority'=>$task['priority'],
36 56 'user_names'=>explode(",",$task['users']),
37 57 'date_created'=>$task['date_created'],
38 58 'task_auth_code'=> $wppmfunction->getRandomString(10),
39 - 'active'=>1
59 + 'active'=>1,
60 + 'parent_task_id'=>isset($task['parent_task_id']) ? $task['parent_task_id'] : 0
40 61 );
41 62 $task_id = $wppmfunction->create_task($values);
42 63 if(!isset($project_id) || $wppm_default_duplicate_project_email_notification==1){
43 64 do_action('wppm_after_task_created', $task_id);
@@ -72,9 +93,9 @@
72 93 }
73 94 if(!empty($task_comments)){
74 95 $args = array();
75 96 foreach($task_comments as $task_comment){
76 - $task_comment_data = json_decode(json_encode($task_comment), true);
97 + $task_comment_data = json_decode(wp_json_encode($task_comment), true);
77 98 $attachment_ids = $task_comment_data['attachment_ids'];
78 99 $attachment_ids_array = explode(",",$attachment_ids);
79 100 if(!empty($attachment_ids_array)){
80 101 $attachment_id = array();
@@ -82,15 +103,15 @@
82 103 foreach($attachment_ids_array as $attach_id){
83 104 if(!empty($attach_id)){
84 105 $attachment_data = $wppmfunction->get_attachment($attach_id);
85 106 $values=array(
86 - 'name'=>$attachment_data['name'],
87 - 'file_name'=> $attachment_data['file_name'],
88 - 'file_path'=>$attachment_data['file_path'],
89 - 'is_image'=>$attachment_data['is_image'],
107 + 'name'=>!empty($attachment_data['name']) ? $attachment_data['name'] : '',
108 + 'file_name'=> !empty($attachment_data['file_name']) ? $attachment_data['file_name'] : '',
109 + 'file_path'=>!empty($attachment_data['file_path']) ? $attachment_data['file_path'] : '',
110 + 'is_image'=>!empty($attachment_data['is_image']) ? $attachment_data['is_image'] : 0,
90 111 'is_active'=>1,
91 112 'is_uploaded'=>0,
92 - 'date_created'=>$attachment_data['date_created']
113 + 'date_created'=>!empty($attachment_data['date_created']) ? $attachment_data['date_created'] : ''
93 114 );
94 115 if(!empty($values)){
95 116 $wpdb->insert($wpdb->prefix.'wppm_attachments',$values);
96 117 $attachment_id[] = $wpdb->insert_id;
@@ -107,9 +128,9 @@
107 128 );
108 129 if(!empty($args)){
109 130 $comment_id = $wppmfunction->wppm_submit_task_comment($args);
110 131 $task_comm_id = esc_sql($task_comment->id);
111 - $task_comment_type = $wpdb->get_var( "SELECT comment_type FROM {$wpdb->prefix}wppm_task_comment_meta where task_id='$prev_task_id' AND comment_id='$task_comm_id'");
132 + $task_comment_type = $wpdb->get_var( $wpdb->prepare("SELECT comment_type FROM {$wpdb->prefix}wppm_task_comment_meta WHERE task_id = %d AND comment_id = %d",$prev_task_id,$task_comm_id));
112 133 if(!empty($task_comment_type)){
113 134 $meta_values = array(
114 135 'task_id'=>$task_id,
115 136 'comment_id'=>$comment_id,
@@ -119,5 +140,6 @@
119 140 }
120 141 }
121 142 }
122 143 }
123 -do_action("wppm_after_task_clone",$prev_task_id,$task_id);
144 +do_action("wppm_after_task_clone",$prev_task_id,$task_id);
145 +return $task_id;