Skip to content

Commit

Permalink
Migrate notify_admin_by_mail function
Browse files Browse the repository at this point in the history
  • Loading branch information
coudot committed Jul 12, 2024
1 parent a25da54 commit 4a13a43
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
3 changes: 2 additions & 1 deletion htdocs/resetpassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@

# Notify administrator if needed
$data = array( "dn" => $dn );
notify_admin_by_mail($mail_from, $mail_from_name, $messages["changesubjectforadmin"], $messages["changemessageforadmin"], $mail_signature, $data);
$admin_mail_list = get_admin_mail_list($notify_admin_by_mail, $notify_admin_by_mail_list);
$mailer->send_mail($admin_mail_list, $mail_from, $mail_from_name, $messages["changesubjectforadmin"], $messages["changemessageforadmin"], $mail_signature, $data);
}

}
Expand Down
14 changes: 3 additions & 11 deletions lib/mail.inc.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<?php

# Notify administrators
function notify_admin_by_mail($mail_from, $mail_from_name, $changesubject, $changemessage, $mail_signature, $data)
# Get administrators mail list but remove duplicates
function get_admin_mail_list($notify_admin_by_mail, $notify_admin_by_mail_list)
{
global $notify_admin_by_mail;
global $notify_admin_by_mail_list;

$admin_mail_list=array();

Expand All @@ -22,13 +20,7 @@ function notify_admin_by_mail($mail_from, $mail_from_name, $changesubject, $chan
}
}

if (! empty($admin_mail_list))
{
if ( !$mailer->send_mail($admin_mail_list, $mail_from, $mail_from_name, $changesubject, $changemessage.$mail_signature, $data) ) {
error_log("Error while sending email to administrators $admin_mail_list");
}
}

return $admin_mail_list;
}

?>

0 comments on commit 4a13a43

Please sign in to comment.