From aeb27867085772a6f1ff3aa5250dbc68bd519bfe Mon Sep 17 00:00:00 2001 From: Richard Klees Date: Thu, 22 Oct 2015 15:03:22 +0200 Subject: [PATCH] implemented #1735 (check online status of course on moment of event, not on moment where mail is send) --- .../Mailing/classes/class.gevCrsAutoMail.php | 19 ++++++++++--------- .../Mailing/classes/class.gevCrsAutoMails.php | 4 +++- .../classes/class.gevDeferredMails.php | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Services/GEV/Mailing/classes/class.gevCrsAutoMail.php b/Services/GEV/Mailing/classes/class.gevCrsAutoMail.php index 7964aac2c014..8860db232801 100644 --- a/Services/GEV/Mailing/classes/class.gevCrsAutoMail.php +++ b/Services/GEV/Mailing/classes/class.gevCrsAutoMail.php @@ -24,7 +24,7 @@ abstract class gevCrsAutoMail extends ilAutoMail { private static $template_type = "CrsMail"; - public function __construct($a_crs_id, $a_id) { + public function __construct($a_crs_id, $a_id, $a_check_offline_status = true) { global $ilDB, $lng, $ilCtrl, $ilias, $ilSetting, $ilUser; $this->db = &$ilDB; @@ -48,6 +48,8 @@ public function __construct($a_crs_id, $a_id) { $this->gev_crs_mail_template_type = self::$template_type; $this->global_bcc = null; + $this->check_offline_status = $a_check_offline_status; + parent::__construct($a_id); } @@ -430,18 +432,14 @@ protected function getMessageFromTemplate($a_templ_id, $a_user_id, $a_email, $a_ public function send($a_recipients = null, $a_occasion = null) { - //TODO: this maybe needs to be adjusted - // Do not send mails for online-trainings. -/* if ($this->getCourse()->getVfSettings()->isTypeOnline()) { - return; - }*/ - // Do not send mails for courses that are offline. // except for trainer mail when training is cancelled. // This is a hack and really no good design. global $ilLog; - if ($this->getCourse()->getOfflineStatus() && $this->getId() != "trainer_training_cancelled") { + if ($this->check_offline_status + && $this->getCourse()->getOfflineStatus() + && $this->getId() != "trainer_training_cancelled") { $ilLog->write("gevCrsAutoMail::send: course is offline, won't send mail. crs_id=".$this->getCourse()->getId().", mail_id=".$this->getId()); return; } @@ -460,7 +458,10 @@ public function send($a_recipients = null, $a_occasion = null) { public function sendDeferred($a_recipients = null, $a_occasion = null) { global $ilLog; $ilLog->write("gevCrsAutoMail::sendDeferred"); - if ($this->getCourse()->getOfflineStatus() && $this->getId() != "bill_mail") { + + if ($this->check_offline_status + && $this->getCourse()->getOfflineStatus() + && $this->getId() != "bill_mail") { $ilLog->write("....courseOffline and not a bill"); return; } diff --git a/Services/GEV/Mailing/classes/class.gevCrsAutoMails.php b/Services/GEV/Mailing/classes/class.gevCrsAutoMails.php index ca84135f3bb2..6b8d4db2e537 100644 --- a/Services/GEV/Mailing/classes/class.gevCrsAutoMails.php +++ b/Services/GEV/Mailing/classes/class.gevCrsAutoMails.php @@ -11,7 +11,7 @@ */ class gevCrsAutoMails extends ilAutoMails { - public function __construct($a_obj_id) { + public function __construct($a_obj_id, $a_check_offline_status = true) { $this->mail_data = array( "self_booking_to_booked" => "gevSelfBookingToBooked" , "self_booking_to_waiting" => "gevSelfBookingToWaiting" @@ -44,6 +44,8 @@ public function __construct($a_obj_id) { parent::__construct($a_obj_id); + $this->check_offline_status = $a_check_offline_status; + global $lng; $this->lng = &$lng; diff --git a/Services/GEV/Mailing/classes/class.gevDeferredMails.php b/Services/GEV/Mailing/classes/class.gevDeferredMails.php index 6a8ed963b0e2..7fbb30afe2ec 100644 --- a/Services/GEV/Mailing/classes/class.gevDeferredMails.php +++ b/Services/GEV/Mailing/classes/class.gevDeferredMails.php @@ -121,7 +121,7 @@ public function sendDeferredMails($a_crs_ids = null, $a_mail_ids = null, $a_reci foreach ($mails as $mail) { if ($cur_crs_id != $mail["crs_id"]) { $cur_crs_id = $mail["crs_id"]; - $automails = new gevCrsAutoMails($cur_crs_id); + $automails = new gevCrsAutoMails($cur_crs_id, false); } try {