PluginProbe
Taskbuilder – Project Management & Task Management Tool With Kanban Board / 3.0.0
Taskbuilder – Project Management & Task Management Tool With Kanban Board v3.0.0
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
← All changes | includes/replace_macro.php +46 -4 1.0.03.0.0 View file →
@@ -6,10 +6,17 @@
6 6 global $current_user, $wppmfunction,$wpdb;
7 7 $current_user_data = get_userdata($current_user->ID);
8 8 $project_id = intval(sanitize_text_field($project_id));
9 9 $wppm_project_data = $wppmfunction->get_project($project_id);
10 +$wppm_proj_comment = $wpdb->get_row("SELECT * FROM {$wpdb->prefix}wppm_project_comment where proj_id='".$project_id."' ORDER BY id DESC LIMIT 1;");
11 +$attachments = array();
12 +$auth_id = $wppmfunction->get_project_meta($project_id,'project_auth_code',true);
13 +if(!empty($wppm_proj_comment)){
14 + $attachments = explode(',',$wppm_proj_comment->attachment_ids);
15 +}
10 16 preg_match_all("/{[^}]*}/" ,$str,$matches);
11 17 $matches = array_unique($matches[0]);
18 +$flag =false;
12 19 foreach($matches as $match){
13 20 switch($match){
14 21 //Current User Name
15 22 case '{user_name}':
@@ -32,9 +39,14 @@
32 39 $str = preg_replace('/{project_status}/', $this->get_new_project_status_name(sanitize_text_field($wppm_project_data['status'])), $str);
33 40 break;
34 41 // Project Category
35 42 case '{project_category}':
36 - $str = preg_replace('/{project_category}/', $this->get_project_category_name(sanitize_text_field($wppm_project_data['cat_id'])), $str);
43 + if(!empty($wppm_project_data['cat_id'])){
44 + $str = preg_replace('/{project_category}/', $this->get_project_category_name(sanitize_text_field($wppm_project_data['cat_id'])), $str);
45 + }else{
46 + $str = "";
47 + }
48 +
37 49 break;
38 50 // Project Name
39 51 case '{project_name}':
40 52 $str = preg_replace('/{project_name}/', sanitize_text_field($wppm_project_data['project_name']), $str);
@@ -60,13 +72,43 @@
60 72 // Date created
61 73 case '{date_created}':
62 74 $str = preg_replace('/{date_created}/', get_date_from_gmt(sanitize_text_field($wppm_project_data['date_created'] )), $str);
63 75 break;
76 + //Last comment user name
77 + case '{last_proj_comment_user_name}':
78 + $str = preg_replace('/{last_proj_comment_user_name}/', $this->get_last_comment_proj_user_name($project_id), $str);
79 + break;
80 + //Last comment body
81 + case '{proj_comment_body}':
82 + $flag= true;
83 + $str = preg_replace('/{proj_comment_body}/', $this->get_proj_comment_body($project_id), $str);
84 + break;
85 +
64 86 // Project Description
65 87 case '{project_description}':
66 - $str = preg_replace('/{project_description}/', sanitize_text_field($wppm_project_data['description']), $str);
67 -
68 -
88 + $str = preg_replace('/{project_description}/', sanitize_text_field($wppm_project_data['description']), $str);
89 + }
90 +}
91 +if($flag == true){
92 + if(!empty($attachments)){
93 + foreach($attachments as $attach_id){
94 + $upload_dir = wp_upload_dir();
95 + $attachment = $wpdb->get_row("select * from {$wpdb->prefix}wppm_attachments where id='".$attach_id."'");
96 + if(!empty($attachment)){
97 + $updated_time = sanitize_text_field($attachment->date_created);
98 + $time = strtotime(sanitize_text_field($updated_time));
99 + $month = date("m",$time);
100 + $year = date("Y",$time);
101 + $findStr = ".txt";
102 + $attachment_name = preg_replace('/' . $findStr . '/', "", sanitize_file_name($attachment->name), 1);
103 + $file_url = $upload_dir['basedir'] . '/wppm/'.'/'.$year.'/'.$month.'/'. $attachment_name;
104 + $download_url = home_url('/').'?wppm_attachment='.sanitize_text_field($attachment->id).'&pid='.sanitize_text_field($project_id).'&pac='.sanitize_text_field($auth_id);
105 + $attach_url[] = '<a style="text-decoration:none;" href="'.$download_url.'" target="_blank">'.sanitize_file_name($attachment->file_name).'</a>';
106 + }else{
107 + $attach_url= array();
108 + }
109 + }
110 + $str = $str.implode("<br>",$attach_url);
69 111 }
70 112 }
71 113 $str = apply_filters('wppm_replace_macro',$str,$project_id);
72 114