ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 = NULL;
14
19 {
20 $this->collector = $collector;
21 }
22
26 private function markAsNotified(ilMailCronOrphanedMailsNotificationCollectionObj$collection_obj)
27 {
28 global $ilDB;
29
30 if($this->threshold > $this->mail_notify_orphaned )
31 {
32 $notify_days_before = $this->threshold - $this->mail_notify_orphaned;
33 }
34 else
35 {
36 $notify_days_before = 1;
37 }
38
39 $ts_delete = strtotime("+ ".$notify_days_before." days");
40 $this->ts_for_deletion = mktime(0, 0, 0, date('m', $ts_delete), date('d', $ts_delete), date('Y', $ts_delete));
41
42 foreach($collection_obj->getFolderObjects() as $folder_obj)
43 {
44 $folder_id = $folder_obj->getFolderId();
45
46 foreach($folder_obj->getOrphanedMailObjects() as $mail_obj)
47 {
48 $mail_id = $mail_obj->getMailId();
49
50 $ilDB->insert('mail_cron_orphaned', array(
51 'mail_id' => array('integer', $mail_id),
52 'folder_id' => array('integer', $folder_id),
53 'ts_do_delete' => array('integer', $this->ts_for_deletion))
54 );
55 }
56 }
57 }
58
63 {
64 include_once './Services/Mail/classes/class.ilMailCronOrphanedMailsNotification.php';
66
67 $mail->setRecipients(array($collection_obj->getUserId()));
68 $mail->setAdditionalInformation(array('mail_folders' => $collection_obj->getFolderObjects()));
69 $mail->send();
70 }
71
75 public function processNotification()
76 {
77 foreach($this->collector->getCollection() as $collection_obj)
78 {
79 $this->sendMail($collection_obj);
80 $this->markAsNotified($collection_obj);
81 }
82 }
83}
__construct(ilMailCronOrphanedMailsNotificationCollector $collector)
sendMail(ilMailCronOrphanedMailsNotificationCollectionObj $collection_obj)
markAsNotified(ilMailCronOrphanedMailsNotificationCollectionObj$collection_obj)
global $ilDB