-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbug_feedback_mail_test.php
115 lines (101 loc) · 3.58 KB
/
bug_feedback_mail_test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
# Make sure this script doesn't run via the webserver
# This page sends an E-mail to the REPORTER if an issue is awaiting feedback
# No real email is sent not are notes created for the various issues
#
require_once( '../../../core.php' );
$t_login = config_get( 'plugin_Reminder_reminder_login' );
$ok=auth_attempt_script_login( $t_login );
$t_core_path = config_get( 'core_path' );
require_once( $t_core_path.'email_api.php' );
$t_project = config_get('plugin_Reminder_reminder_feedback_project');
$status = config_get('plugin_Reminder_reminder_feedback_status');
$t_rem_body1 = config_get( 'plugin_Reminder_reminder_group_body1' );
$t_rem_body2 = config_get( 'plugin_Reminder_reminder_group_body2' );
$query = "select id,reporter_id,handler_id,project_id from {bug} bugs where status in (".implode(",", $status).") ";
$t_rem_include = config_get('plugin_Reminder_reminder_include');
$t_rem_projects = "(";
$t_rem_projects .= config_get('plugin_Reminder_reminder_project_id');
$t_rem_projects .= ")";
if (ON==$t_rem_include){
if (!empty( config_get( 'plugin_Reminder_reminder_project_id' ) )) {
$query .= " and bugs.project_id IN ". $t_rem_projects;
}
}else{
if (!empty( config_get( 'plugin_Reminder_reminder_project_id' ) )) {
$query .= " and bugs.project_id NOT IN ".$t_rem_projects;
}
}
$query .= " order by reporter_id";
$results = db_query( $query );
if ($results){
$start = true ;
$list= "";
// first group and store feedback reminder per issue
while ($row1 = db_fetch_array($results)) {
$id = $row1['id'];
$handler = $row1['handler_id'];
$project = $row1['project_id'];
$reporter = $row1['reporter_id'];
echo "id: ".$id." handler_id: ".$handler." reporter_id:".$reporter." project_id: ".$project."\n<br>";
if ($start){
//$handler2 = $handler ;
$reporter2 = $reporter ;
$start = false ;
}
//if ($handler== $handler2){
if ($reporter== $reporter2){
$list .=" \n\n";
//$list .= string_get_bug_view_url_with_fqdn( $id, $handler2 );
$list .= string_get_bug_view_url_with_fqdn( $id, $reporter2 );
} else {
// now send the grouped email
$body = $t_rem_body1. " <br><br>\n\n";
$body .= $list. " <br>\n\n";
$body .= $t_rem_body2;
//$result = email_group_reminder( $handler2, $body);
$result = email_group_reminder( $reporter2, $body);
//$handler2 = $handler ;
$reporter2 = $reporter;
//$list= string_get_bug_view_url_with_fqdn( $id, $handler2 );
$list= string_get_bug_view_url_with_fqdn( $id, $reporter2 );
}
$list .=" <br>\n";
}
// handle last grouped email
if ($results){
$body = $t_rem_body1. " \n\n";
$body .= $list. " \n\n";
$body .= $t_rem_body2;
//why the handler? Feedback reminder email should go to the Reporter!
//$result = email_group_reminder( $handler2, $body);
$result = email_group_reminder( $reporter2, $body);
} else {
echo 'Query-Manager had no results '.$query ;
echo '<br>';
}
}
if (php_sapi_name() !== 'cli'){
echo config_get( 'plugin_Reminder_reminder_finished' );
}
# Send Grouped reminder
function email_group_reminder( $p_user_id, $issues ) {
$t_username = user_get_field( $p_user_id, 'username' );
$t_email = user_get_email( $p_user_id );
$t_message = $issues ;
$t_subject = config_get( 'plugin_Reminder_reminder_subject' );
if( !is_blank( $t_email ) ) {
echo '------------------------------- <br>';
echo $t_email;
echo '**';
echo $t_subject;
echo '<br>';
echo $t_message;
echo '<br>';
echo '------------------------------- <br>';
// email_store( $t_email, $t_subject, $t_message );
if( OFF == config_get( 'email_send_using_cronjob' ) ) {
// email_send_all();
}
}
}