PluginProbe
Taskbuilder – Project Management & Task Management Tool With Kanban Board / 3.0.5
Taskbuilder – Project Management & Task Management Tool With Kanban Board v3.0.5
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 / replace_task_macro.php

replace_task_macro.php in Taskbuilder – Project Management & Task Management Tool With Kanban Board 3.0.5, at includes/replace_task_macro.php

146 lines 6.1 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 $current_user_data = get_userdata($current_user->ID);
8 $task_id = intval(sanitize_text_field($task_id));
9 $wppm_task_data = $wppmfunction->get_task($task_id);
10 $orderby_sql = sanitize_sql_orderby( "id DESC" );
11 $wppm_task_comment = $wpdb->get_row("SELECT * FROM {$wpdb->prefix}wppm_task_comment where task_id='".$task_id."' ORDER BY $orderby_sql LIMIT 1;");
12 $wppm_project_data = $wppmfunction->get_project($wppm_task_data['project']);
13 $auth_id = sanitize_text_field($wppm_task_data['task_auth_code']);
14 $attachments = array();
15 if(!empty($wppm_task_comment)){
16 $attachments = explode(',',$wppm_task_comment->attachment_ids);
17 }
18 preg_match_all("/{[^}]*}/" ,$str,$matches);
19 $matches = array_unique($matches[0]);
20 $flag =false;
21 foreach($matches as $match){
22 switch($match){
23 // Task ID
24 case '{task_id}':
25 $str = preg_replace('/{task_id}/', $task_id, $str);
26 break;
27 //Current User Name
28 case '{user_name}':
29 $str = preg_replace('/{user_name}/', sanitize_text_field($current_user_data->display_name), $str);
30 break;
31 // Task Name
32 case '{task_name}':
33 $str = preg_replace('/{task_name}/', sanitize_text_field($wppm_task_data['task_name']), $str);
34 break;
35 //Old Task Status
36 case '{old_task_status}':
37 $str = preg_replace('/{old_task_status}/', $this->get_old_task_status_name($task_id), $str);
38 break;
39 //New Task Status
40 case '{new_task_status}':
41 $str = preg_replace('/{new_task_status}/', $this->get_new_task_status_name(sanitize_text_field($wppm_task_data['status'])), $str);
42 break;
43 //New Task Status
44 case '{task_status}':
45 $str = preg_replace('/{task_status}/', $this->get_new_task_status_name(sanitize_text_field($wppm_task_data['status'])), $str);
46 break;
47 //Task Assigned Users
48 case '{task_assigned_users}':
49 $assigned_users = $this->get_task_assigned_users_names($task_id);
50 $str = preg_replace('/{task_assigned_users}/', sanitize_text_field($assigned_users), $str);
51 break;
52 //Previously Assign Task Users
53 case '{previously_assigned_task_users}':
54 $previously_assigned_task_users = $this->get_task_previously_assigned_users_names($task_id);
55 $str = preg_replace('/{previously_assigned_task_users}/', sanitize_text_field($previously_assigned_task_users), $str);
56 break;
57 // Task Start Date
58 case '{task_start_date}':
59 $str = preg_replace('/{task_start_date}/', sanitize_text_field($wppm_task_data['start_date']), $str);
60 break;
61 // Task End Date
62 case '{task_end_date}':
63 $str = preg_replace('/{task_end_date}/', sanitize_text_field($wppm_task_data['end_date']), $str);
64 break;
65 // Task Priority
66 case '{task_priority}':
67 $str = preg_replace('/{task_priority}/', $this->get_task_priority_name(sanitize_text_field($wppm_task_data['priority'])), $str);
68 break;
69 // Task Description
70 case '{task_description}':
71 $str = preg_replace('/{task_description}/', sanitize_text_field($wppm_task_data['description']), $str);
72 break;
73 // Date created
74 case '{task_date_created}':
75 $str = preg_replace('/{task_date_created}/', get_date_from_gmt(sanitize_text_field($wppm_task_data['date_created']) ), $str);
76 break;
77 // Project Name
78 case '{project_name}':
79 $str = preg_replace('/{project_name}/', sanitize_text_field($wppm_project_data['project_name']), $str);
80 break;
81 //Last comment user name
82 case '{last_comment_user_name}':
83 $str = preg_replace('/{last_comment_user_name}/', $this->get_last_comment_user_name($task_id), $str);
84 break;
85 //Project status
86 case '{project_status}';
87 $str = preg_replace('/{project_status}/', $this->get_new_project_status_name((sanitize_text_field($wppm_project_data['status'])), $str));
88 break;
89 // Project Category
90 case '{project_category}';
91 $str = preg_replace('/{project_category}/', $this->get_project_category_name((sanitize_text_field($wppm_project_data['cat_id'])), $str));
92 break;
93 // Project Name
94 case '{project_name}':
95 $str = preg_replace('/{project_name}/', (sanitize_text_field($wppm_project_data['project_name'])), $str);
96 break;
97 // Project Start Date
98 case 'project_start_date':
99 $str = preg_replace('/{project_start_date}/', (sanitize_text_field($wppm_project_data['start_date'])), $str);
100 break;
101 // Project End Date
102 case '{project_end_date}':
103 $str = preg_replace('/{project_end_date}/', (sanitize_text_field($wppm_project_data['end_date'])), $str);
104 break;
105 // Project Description
106 case '{project_description}':
107 $str = preg_replace('/{project_description}/', (sanitize_text_field($wppm_project_data['description'])), $str);
108 break;
109 // Project Assigned Users
110 case '{project_assigned_users}':
111 $assigned_users = $this->get_project_assigned_users_names($wppm_project_data['id']);
112 $str = preg_replace('/{project_assigned_users}/', (sanitize_text_field($assigned_users)), $str);
113 break;
114 //Last comment body
115 case '{comment_body}':
116 $flag= true;
117 $str = preg_replace('/{comment_body}/', $this->get_last_comment_body($task_id), $str);
118 break;
119
120 }
121 }
122 if($flag == true){
123 if(!empty($attachments)){
124 foreach($attachments as $attach_id){
125 $upload_dir = wp_upload_dir();
126 $attach_id = esc_sql($attach_id);
127 $attachment = $wpdb->get_row("select * from {$wpdb->prefix}wppm_attachments where id='".$attach_id."'");
128 if(!empty($attachment)){
129 $updated_time = sanitize_text_field($attachment->date_created);
130 $time = strtotime(sanitize_text_field($updated_time));
131 $month = date("m",$time);
132 $year = date("Y",$time);
133 $findStr = ".txt";
134 $attachment_name = preg_replace('/' . $findStr . '/', "", sanitize_file_name($attachment->name), 1);
135 $file_url = $upload_dir['basedir'] . '/wppm/'.'/'.$year.'/'.$month.'/'. $attachment_name;
136 $download_url = home_url('/').'?wppm_attachment='.sanitize_text_field($attachment->id).'&tid='.sanitize_text_field($task_id).'&tac='.sanitize_text_field($auth_id);
137 $attach_url[] = '<a style="text-decoration:none;" href="'.$download_url.'" target="_blank">'.sanitize_file_name($attachment->file_name).'</a>';
138 }else{
139 $attach_url= array();
140 }
141 }
142 $str = $str.implode("<br>",$attach_url);
143 }
144
145 }
146 $str = apply_filters('wppm_replace_task_macro',$str,$task_id);