ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilMailCronOrphanedMailsNotifier.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2015 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
9 {
13  protected $collector;
14 
18  protected $db;
19 
23  protected $threshold = 0;
24 
28  protected $mail_notify_orphaned = 0;
29 
37  {
38  global $DIC;
39 
40  $this->db = $DIC->database();
41 
42  $this->collector = $collector;
43  $this->threshold = $threshold;
44  $this->mail_notify_orphaned = $mail_notify_orphaned;
45  }
46 
51  {
52  if ($this->threshold > $this->mail_notify_orphaned) {
53  $notify_days_before = $this->threshold - $this->mail_notify_orphaned;
54  } else {
55  $notify_days_before = 1;
56  }
57 
58  $ts_delete = strtotime("+ " . $notify_days_before . " days");
59  $ts_for_deletion = mktime(0, 0, 0, date('m', $ts_delete), date('d', $ts_delete), date('Y', $ts_delete));
60 
61  foreach ($collection_obj->getFolderObjects() as $folder_obj) {
62  $folder_id = $folder_obj->getFolderId();
63 
64  foreach ($folder_obj->getOrphanedMailObjects() as $mail_obj) {
65  $mail_id = $mail_obj->getMailId();
66 
67  $this->db->insert(
68  'mail_cron_orphaned',
69  array(
70  'mail_id' => array('integer', $mail_id),
71  'folder_id' => array('integer', $folder_id),
72  'ts_do_delete' => array('integer', $ts_for_deletion))
73  );
74  }
75  }
76  }
77 
82  {
83  include_once './Services/Mail/classes/class.ilMailCronOrphanedMailsNotification.php';
85 
86  $mail->setRecipients(array($collection_obj->getUserId()));
87  $mail->setAdditionalInformation(array('mail_folders' => $collection_obj->getFolderObjects()));
88  $mail->send();
89  }
90 
94  public function processNotification()
95  {
96  foreach ($this->collector->getCollection() as $collection_obj) {
97  $this->sendMail($collection_obj);
98  $this->markAsNotified($collection_obj);
99  }
100  }
101 }
global $DIC
Definition: saml.php:7
__construct(ilMailCronOrphanedMailsNotificationCollector $collector, $threshold, $mail_notify_orphaned)
ilMailCronOrphanedMailsNotifier constructor.
markAsNotified(ilMailCronOrphanedMailsNotificationCollectionObj $collection_obj)
sendMail(ilMailCronOrphanedMailsNotificationCollectionObj $collection_obj)