Skip to content

Commit

Permalink
Reviewed the script bug_reminder_mail2.php
Browse files Browse the repository at this point in the history
Reviewed the script bug_reminder_mail2.php
  • Loading branch information
CasN committed Jun 24, 2024
1 parent 74e1372 commit 018937a
Showing 1 changed file with 20 additions and 44 deletions.
64 changes: 20 additions & 44 deletions scripts/bug_reminder_mail2.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
# This page tests sending an E-mail if a due date is getting near
# Real email is sent but notes are not created for the various issues
# This page sends an E-mail if a due date is getting near
# includes all due_dates not met
require_once( '../../../core.php' );
$t_login = config_get( 'plugin_Reminder_reminder_login' );
$ok=auth_attempt_script_login( $t_login );
Expand All @@ -24,7 +24,6 @@
$t_rem_subject = config_get( 'plugin_Reminder_reminder_group_subject' );
$t_rem_body1 = config_get( 'plugin_Reminder_reminder_group_body1' );
$t_rem_body2 = config_get( 'plugin_Reminder_reminder_group_body2' );

$t_rem_hours = config_get('plugin_Reminder_reminder_hours');
if (ON != $t_rem_hours){
$multiply=24;
Expand All @@ -38,14 +37,8 @@
//
$baseline = time()+ ($t_rem_days*$multiply*60*60);
$basenow = time();

echo "Path setting retrieved : ".config_get('path');
echo "<br>";

if ( ON == $t_rem_handler ) {
$query = "select id,handler_id,project_id from {bug} bugs where status in (".implode(",", $t_rem_status).") and due_date<=$baseline and handler_id>0 ";
$query = "select bugs.id, bugs.handler_id, bugs.project_id, bugs.priority, bugs.category_id, bugs.status, bugs.severity, bugs.summary from {bug} bugs JOIN {bug_text} text ON (bugs.bug_text_id = text.id) where status in (".implode(",", $t_rem_status).") and due_date<=$baseline and handler_id<>0 ";

if ( ON == $t_rem_ign_past ) {
$query .=" and due_date>=$basenow" ;
} else{
Expand All @@ -57,15 +50,15 @@
$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;
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;
}
}
}

if ( ON == $t_rem_group1 ) {
$query .=" order by handler_id" ;
Expand All @@ -82,10 +75,8 @@
$id = $row1['id'];
$handler = $row1['handler_id'];
$list = string_get_bug_view_url_with_fqdn( $id, $handler2 );
$body = $t_rem_body1;
$body .= "<br>";
$body .= $list;
$body .= "<br>";
$body = $t_rem_body1. " \n\n";
$body .= $list. " \n\n";
$body .= $t_rem_body2;
$result = email_group_reminder( $handler, $body );
# Add reminder as bugnote if store reminders option is ON.
Expand All @@ -110,25 +101,19 @@
}
if ($handler==$handler2){
$list .= formatBugEntry($row1);
// $list .="<br>";
// $list .= string_get_bug_view_url_with_fqdn( $id, $handler2 );
# Add reminder as bugnote if store reminders option is ON.
if ( ON == $t_rem_store ) {
$t_attr = '|'.$handler2.'|';
bugnote_add( $id, $t_rem_body, 0, config_get( 'default_reminder_view_status' ) == VS_PRIVATE, REMINDER, $t_attr, NULL, FALSE );
}
} else {
// now send the grouped email
$body = $t_rem_body1;
$body .= "<br>";
$body .= $list;
$body .= "<br>";
$body = $t_rem_body1. " \n\n";
$body .= $list. " \n\n";
$body .= $t_rem_body2;
$result = email_group_reminder( $handler2, $body);
$handler2 = $handler ;
$list .= formatBugEntry($row1);
// $list ="<br>";
// $list= string_get_bug_view_url_with_fqdn( $id, $handler2 );
# Add reminder as bugnote if store reminders option is ON.
if ( ON == $t_rem_store ) {
$t_attr = '|'.$handler2.'|';
Expand All @@ -139,10 +124,8 @@
// handle last one
if ($resnum>0){
// now send the grouped email
$body = $t_rem_body1;
$body .= "<br>";
$body .= $list;
$body .= "<br>";
$body = $t_rem_body1. " \n\n";;
$body .= $list. " \n\n";;
$body .= $t_rem_body2;
$result = email_group_reminder( $handler2, $body);

Expand All @@ -161,11 +144,10 @@
$query .=" and due_date>1" ;
}
}

$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 .= ")";
$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 ($t_rem_projects <>"0") {
$query .= " and bugs.project_id IN ". $t_rem_projects;
Expand Down Expand Up @@ -223,12 +205,6 @@ function email_group_reminder( $p_user_id, $issues ) {
$t_subject = config_get( 'plugin_Reminder_reminder_group_subject' );
$t_message = $issues ;
if( !is_blank( $t_email ) ) {
echo $t_email;
echo '**';
echo $t_subject;
echo '<br>';
echo $t_message;
echo '<br>';
email_store( $t_email, $t_subject, $t_message );
if( OFF == config_get( 'email_send_using_cronjob' ) ) {
email_send_all();
Expand Down

0 comments on commit 018937a

Please sign in to comment.