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/class-wppm-functions.php +66 -2 6.0.46.0.6 View file →
@@ -54,9 +54,10 @@
54 54 'priority'=>(isset($args['wppm_create_task_priority']))?$args['wppm_create_task_priority']:"",
55 55 'users'=>(!empty($args['user_names']))?implode(",",$args['user_names']):"",
56 56 'date_created'=>isset($args['date_created'])? $args['date_created']:wp_date("Y-m-d h:i:sa"),
57 57 'task_auth_code'=> self::getRandomString(10),
58 - 'active'=>1
58 + 'active'=>1,
59 + 'parent_task_id'=>(isset($args['parent_task_id']))?absint($args['parent_task_id']):0
59 60 );
60 61 $wpdb->insert($wpdb->prefix .'wppm_task', $values);
61 62 $task_id = $wpdb->insert_id;
62 63 return $task_id;
@@ -247,8 +248,71 @@
247 248 }
248 249 return $checklist_items_data;
249 250 }
250 251
252 + public function get_subtasks($task_id){
253 + global $wpdb;
254 + $task_id = absint($task_id);
255 + $subtasks_data = array();
256 + $subtasks = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}wppm_task WHERE parent_task_id = %d ORDER BY id ASC", $task_id));
257 + if( $subtasks ){
258 + $subtasks_data = json_decode(wp_json_encode($subtasks), true);
259 + }
260 + return $subtasks_data;
261 + }
262 +
263 + public function get_subtask_progress($task_id){
264 + global $wpdb;
265 + $task_id = absint($task_id);
266 + $completed_status_id = 4;
267 + $total = (int) $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->prefix}wppm_task WHERE parent_task_id = %d", $task_id));
268 + $completed = (int) $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->prefix}wppm_task WHERE parent_task_id = %d AND status = %d", $task_id, $completed_status_id));
269 + return array('total'=>$total,'completed'=>$completed);
270 + }
271 +
272 + // Deletes a task along with its subtasks (and each one's checklists/comments/attachments).
273 + public static function delete_task_and_children($task_id){
274 + global $wpdb;
275 + $task_id = absint($task_id);
276 + $child_ids = $wpdb->get_col($wpdb->prepare("SELECT id FROM {$wpdb->prefix}wppm_task WHERE parent_task_id = %d", $task_id));
277 + foreach($child_ids as $child_id){
278 + self::delete_task_and_children($child_id);
279 + }
280 + $thread_attachment_ids = $wpdb->get_results($wpdb->prepare("SELECT attachment_ids FROM {$wpdb->prefix}wppm_task_comment WHERE task_id = %d", $task_id));
281 + if(!empty($thread_attachment_ids)){
282 + foreach ($thread_attachment_ids as $thread_attachment_id){
283 + $attachment_ids_temp = array();
284 + if($thread_attachment_id->attachment_ids){
285 + $attachment_ids_temp = explode(',', $thread_attachment_id->attachment_ids);
286 + }
287 + foreach ($attachment_ids_temp as $attachment_id){
288 + $attachment_id = absint($attachment_id);
289 + $result = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}wppm_attachments WHERE id = %d", $attachment_id));
290 + if(!empty($result)){
291 + $attach_result = $wpdb->get_results($wpdb->prepare("SELECT file_path FROM {$wpdb->prefix}wppm_attachments WHERE file_path = %s", $result->file_path));
292 + if(file_exists($result->file_path) && count($attach_result) < 2){
293 + wp_delete_file($result->file_path);
294 + }
295 + $wpdb->delete($wpdb->prefix.'wppm_attachments', array('id' => $attachment_id));
296 + }
297 + }
298 + }
299 + }
300 + $checklists = $wpdb->get_results($wpdb->prepare("SELECT id FROM {$wpdb->prefix}wppm_checklist WHERE task_id = %d", $task_id));
301 + if(!empty($checklists)){
302 + foreach($checklists as $checklist){
303 + $checklist_id = absint($checklist->id);
304 + $wpdb->delete($wpdb->prefix.'wppm_checklist_items', array('checklist_id'=>$checklist_id));
305 + $wpdb->delete($wpdb->prefix.'wppm_checklist', array('id'=>$checklist_id));
306 + }
307 + }
308 + $wpdb->delete($wpdb->prefix.'wppm_task', array('id'=>$task_id));
309 + $wpdb->delete($wpdb->prefix.'wppm_task_meta', array('task_id'=>$task_id));
310 + $wpdb->delete($wpdb->prefix.'wppm_task_comment', array('task_id'=>$task_id));
311 + $wpdb->delete($wpdb->prefix.'wppm_task_comment_meta', array('task_id'=>$task_id));
312 + do_action('wppm_after_delete_task', $task_id);
313 + }
314 +
251 315 public function get_project($project_id){
252 316 global $wpdb;
253 317 $project_data = array();
254 318 $project_id = absint($project_id);
@@ -1040,9 +1104,9 @@
1040 1104 $task_comment = $wpdb->get_var($wpdb->prepare("SELECT body FROM {$wpdb->prefix}wppm_task_comment WHERE (id=(select MAX(id) from {$wpdb->prefix}wppm_task_comment) AND task_id = %d)",$task_id));
1041 1105 return $task_comment;
1042 1106 }
1043 1107
1044 - public function create_duplicate_task($ptask_id, $project_id,$ajax_nonce){
1108 + public function create_duplicate_task($ptask_id, $project_id,$internal_code_flag=false){
1045 1109 include WPPM_ABSPATH . 'includes/admin/tasks/open_task/wppm_set_clone_task.php';
1046 1110 }
1047 1111
1048 1112 public function get_last_comment_proj_user_name($project_id){