| @@ -6,9 +6,13 @@ | ||
| 6 | 6 | global $current_user, $wppmfunction,$wpdb; |
| 7 | 7 | $current_user_data = get_userdata($current_user->ID); |
| 8 | 8 | $task_id = intval(sanitize_text_field($task_id)); |
| 9 | 9 | $wppm_task_data = $wppmfunction->get_task($task_id); |
| 10 | -$wppm_task_comment = $wpdb->get_row("SELECT * FROM {$wpdb->prefix}wppm_task_comment where task_id='".$task_id."' ORDER BY id DESC LIMIT 1;"); | |
| 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;"); | |
| 11 | 15 | $wppm_project_data = $wppmfunction->get_project($wppm_task_data['project']); |
| 12 | 16 | $auth_id = sanitize_text_field($wppm_task_data['task_auth_code']); |
| 13 | 17 | $attachments = array(); |
| 14 | 18 | if(!empty($wppm_task_comment)){ |
| @@ -16,8 +20,10 @@ | ||
| 16 | 20 | } |
| 17 | 21 | preg_match_all("/{[^}]*}/" ,$str,$matches); |
| 18 | 22 | $matches = array_unique($matches[0]); |
| 19 | 23 | $flag =false; |
| 24 | +$page_setting = get_option( 'wppm-page-settings' ); | |
| 25 | +$view = $page_setting['task-url-page']; | |
| 20 | 26 | foreach($matches as $match){ |
| 21 | 27 | switch($match){ |
| 22 | 28 | // Task ID |
| 23 | 29 | case '{task_id}': |
| @@ -22,8 +28,12 @@ | ||
| 22 | 28 | // Task ID |
| 23 | 29 | case '{task_id}': |
| 24 | 30 | $str = preg_replace('/{task_id}/', $task_id, $str); |
| 25 | 31 | break; |
| 32 | + // Task Creator Name | |
| 33 | + case '{task_creator_name}': | |
| 34 | + $str = preg_replace('/{task_creator_name}/', $task_creator_name, $str); | |
| 35 | + break; | |
| 26 | 36 | //Current User Name |
| 27 | 37 | case '{user_name}': |
| 28 | 38 | $str = preg_replace('/{user_name}/', sanitize_text_field($current_user_data->display_name), $str); |
| 29 | 39 | break; |
| @@ -86,9 +96,13 @@ | ||
| 86 | 96 | $str = preg_replace('/{project_status}/', $this->get_new_project_status_name((sanitize_text_field($wppm_project_data['status'])), $str)); |
| 87 | 97 | break; |
| 88 | 98 | // Project Category |
| 89 | 99 | case '{project_category}'; |
| 90 | - $str = preg_replace('/{project_category}/', $this->get_project_category_name((sanitize_text_field($wppm_project_data['cat_id'])), $str)); | |
| 100 | + if(!empty($wppm_project_data['cat_id'])){ | |
| 101 | + $str = preg_replace('/{project_category}/', $this->get_project_category_name(sanitize_text_field($wppm_project_data['cat_id'])), $str); | |
| 102 | + }else{ | |
| 103 | + $str = ""; | |
| 104 | + } | |
| 91 | 105 | break; |
| 92 | 106 | // Project Name |
| 93 | 107 | case '{project_name}': |
| 94 | 108 | $str = preg_replace('/{project_name}/', (sanitize_text_field($wppm_project_data['project_name'])), $str); |
| @@ -114,8 +128,12 @@ | ||
| 114 | 128 | case '{comment_body}': |
| 115 | 129 | $flag= true; |
| 116 | 130 | $str = preg_replace('/{comment_body}/', $this->get_last_comment_body($task_id), $str); |
| 117 | 131 | break; |
| 132 | + case '{task_url}': | |
| 133 | + $task_url = '<a class="wppm_link" href="' . $this->get_task_url($task_id,$view) . '" target="_blank">' . $this->get_task_url($task_id,$view) . '</a>'; | |
| 134 | + $str = preg_replace('/{task_url}/', $task_url, $str); | |
| 135 | + break; | |
| 118 | 136 | |
| 119 | 137 | } |
| 120 | 138 | } |
| 121 | 139 | if($flag == true){ |
| @@ -121,8 +139,9 @@ | ||
| 121 | 139 | if($flag == true){ |
| 122 | 140 | if(!empty($attachments)){ |
| 123 | 141 | foreach($attachments as $attach_id){ |
| 124 | 142 | $upload_dir = wp_upload_dir(); |
| 143 | + $attach_id = esc_sql($attach_id); | |
| 125 | 144 | $attachment = $wpdb->get_row("select * from {$wpdb->prefix}wppm_attachments where id='".$attach_id."'"); |
| 126 | 145 | if(!empty($attachment)){ |
| 127 | 146 | $updated_time = sanitize_text_field($attachment->date_created); |
| 128 | 147 | $time = strtotime(sanitize_text_field($updated_time)); |