PluginProbe
Taskbuilder – Project Management & Task Management Tool With Kanban Board / 1.0.1
Taskbuilder – Project Management & Task Management Tool With Kanban Board v1.0.1
6.0.6 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 All 58 releases
taskbuilder / includes / admin / email_notifications / wppm_en_submit_task_comment.php

wppm_en_submit_task_comment.php in Taskbuilder – Project Management & Task Management Tool With Kanban Board 1.0.1, at includes/admin/email_notifications/wppm_en_submit_task_comment.php

81 lines 3.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 $wppmfunction, $current_user,$wpdb;
7 $from_name = get_option('wppm_en_from_name');
8 $from_email = get_option('wppm_en_from_email');
9 $ignore_emails = get_option('wppm_en_ignore_emails');
10 $task_id = intval(sanitize_text_field($task_id));
11 $task_data = $wppmfunction->get_task($task_id);
12 $project_id = $task_data['project'];
13 $task_users = $task_data['users'];
14 $task_users = explode(',',$task_users);
15 $flag= false;
16 if ( !$from_name || !$from_email ) {
17 return;
18 }
19 $wppm_email_notificatins = get_option('wppm_email_notification');
20 foreach ($wppm_email_notificatins as $key=>$val) :
21 if($val['type']=='new_discussion'){
22 $subject = $wppmfunction->replace_task_macro(stripslashes($val['subject']), $task_id);
23 $body = $wppmfunction->replace_task_macro(stripslashes($val['body']),$task_id);
24 $recipients = $val['recipients'];
25 $email_addresses = array();
26 if(!empty($recipients)){
27 foreach ($recipients as $recipient) {
28 if(is_numeric($recipient)){
29 if($recipient == 1 && !empty($task_users)) {
30 foreach($task_users as $user){
31 if(!empty($user)){
32 $project_user_data = $wpdb->get_row("SELECT * FROM {$wpdb->prefix}wppm_project_users WHERE proj_id = $project_id AND user_id = $user");
33 $userdata = get_userdata($user);
34 if((!empty($project_user_data)) && $project_user_data->role_id == 1){
35 $email_addresses[] = $userdata->user_email;
36 }
37 }
38 }
39 }
40 elseif($recipient == 2 && !empty($task_users)){
41 foreach($task_users as $user){
42 if(!empty($user)){
43 $project_user_data = $wpdb->get_row("SELECT * FROM {$wpdb->prefix}wppm_project_users WHERE proj_id = $project_id AND user_id = $user");
44 $userdata = get_userdata($user);
45 if((!empty($project_user_data)) && $project_user_data->role_id == 2){
46 $email_addresses[] = $userdata->user_email;
47 }
48 }
49 }
50 }
51 } else {
52 switch ($recipient) {
53 case 'previously_assigned_user':
54 $email_addresses = array_merge($email_addresses,$wppmfunction->get_previously_assigned_task_users($task_id));
55 break;
56 }
57 }
58 }
59 }
60 $email_addresses = array_unique($email_addresses);
61 $email_addresses = array_diff($email_addresses,$ignore_emails);
62 $email_addresses = array_diff($email_addresses,array($current_user->user_email));
63 $email_addresses = apply_filters('wppm_en_task_assign_users_email_addresses',$email_addresses,$val,$task_id);
64 $email_addresses = array_values($email_addresses);
65 $to = isset($email_addresses[0])? $email_addresses[0] : '';
66 if($to){
67 unset($email_addresses[0]);
68 } else {
69 continue; // no email address found to send. So go to next foreach iteration.
70 }
71 $bcc = implode(',',$email_addresses);
72 $headers = "From: {$from_name} <{$from_email}>\r\n";
73 $email_addresses = explode(',',$bcc);
74 foreach ($email_addresses as $email_address) {
75 $headers .= "BCC: {$email_address}\r\n";
76 }
77 $headers .= "Content-Type: text/html; charset=UTF-8 \r\n";
78 wp_mail($to, $subject, $body, $headers);
79 do_action('wppm_after_submit_task_comment_mail',$task_id,$val);
80 }
81 endforeach;