PluginProbe
Taskbuilder – Project Management & Task Management Tool With Kanban Board / 3.0.7
Taskbuilder – Project Management & Task Management Tool With Kanban Board v3.0.7
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.7, at includes/replace_task_macro.php

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