PluginProbe
Taskbuilder – Project Management & Task Management Tool With Kanban Board / 3.0.3
Taskbuilder – Project Management & Task Management Tool With Kanban Board v3.0.3
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_macro.php

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

115 lines 4.7 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 $project_id = intval(sanitize_text_field($project_id));
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 }
16 preg_match_all("/{[^}]*}/" ,$str,$matches);
17 $matches = array_unique($matches[0]);
18 $flag =false;
19 foreach($matches as $match){
20 switch($match){
21 //Current User Name
22 case '{user_name}':
23 $str = preg_replace('/{user_name}/', $current_user_data->display_name, $str);
24 break;
25 // Project ID
26 case '{project_id}':
27 $str = preg_replace('/{project_id}/', $project_id, $str);
28 break;
29 // Old project Status
30 case '{old_project_status}':
31 $str = preg_replace('/{old_project_status}/', $this->get_old_project_status_name($project_id), $str);
32 break;
33 // Project Status
34 case '{new_project_status}':
35 $str = preg_replace('/{new_project_status}/', $this->get_new_project_status_name(sanitize_text_field($wppm_project_data['status'])), $str);
36 break;
37 // Project Status
38 case '{project_status}':
39 $str = preg_replace('/{project_status}/', $this->get_new_project_status_name(sanitize_text_field($wppm_project_data['status'])), $str);
40 break;
41 // Project Category
42 case '{project_category}':
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
49 break;
50 // Project Name
51 case '{project_name}':
52 $str = preg_replace('/{project_name}/', sanitize_text_field($wppm_project_data['project_name']), $str);
53 break;
54 // Project Start Date
55 case '{project_start_date}':
56 $str = preg_replace('/{project_start_date}/', sanitize_text_field($wppm_project_data['start_date']), $str);
57 break;
58 // Project End Date
59 case '{project_end_date}':
60 $str = preg_replace('/{project_end_date}/', sanitize_text_field($wppm_project_data['end_date']), $str);
61 break;
62 // Assigned Users
63 case '{project_assigned_users}':
64 $assigned_users = $this->get_project_assigned_users_names($project_id);
65 $str = preg_replace('/{project_assigned_users}/', sanitize_text_field($assigned_users), $str);
66 break;
67 // Previously Assigned users
68 case '{previously_assigned_project_users}':
69 $previously_assigned_users = $this->get_project_previously_assigned_users_names($project_id);
70 $str = preg_replace('/{previously_assigned_project_users}/', sanitize_text_field($previously_assigned_users), $str);
71 break;
72 // Date created
73 case '{date_created}':
74 $str = preg_replace('/{date_created}/', get_date_from_gmt(sanitize_text_field($wppm_project_data['date_created'] )), $str);
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
86 // Project Description
87 case '{project_description}':
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);
111 }
112 }
113 $str = apply_filters('wppm_replace_macro',$str,$project_id);
114
115