ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilMailCronOrphanedMailsNotificationCollector Class Reference

ilMailCronOrphanedMailsNotificationCollector More...

+ Collaboration diagram for ilMailCronOrphanedMailsNotificationCollector:

Public Member Functions

 __construct (ilMailCronOrphanedMails $job)
 
 collect ()
 
 addCollectionObject (ilMailCronOrphanedMailsNotificationCollectionObj $collection_obj)
 
 getCollection ()
 

Protected Attributes

 $collection = array()
 
 $db
 
 $setting
 

Private Member Functions

 existsCollectionObjForUserId ($user_id)
 

Private Attributes

const PING_THRESHOLD = 500
 
 $job
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilMailCronOrphanedMailsNotificationCollector::__construct ( ilMailCronOrphanedMails  $job)

Definition at line 30 of file class.ilMailCronOrphanedMailsNotificationCollector.php.

References $DIC, $job, and collect().

31  {
32  global $DIC;
33 
34  $this->db = $DIC->database();
35  $this->setting = $DIC->settings();
36 
37  $this->job = $job;
38 
39  $this->collect();
40  }
global $DIC
Definition: goto.php:24
+ Here is the call graph for this function:

Member Function Documentation

◆ addCollectionObject()

ilMailCronOrphanedMailsNotificationCollector::addCollectionObject ( ilMailCronOrphanedMailsNotificationCollectionObj  $collection_obj)
Parameters
ilMailCronOrphanedMailsNotificationCollectionObj$collection_obj

Definition at line 114 of file class.ilMailCronOrphanedMailsNotificationCollector.php.

References ilMailCronOrphanedMailsNotificationCollectionObj\getUserId().

Referenced by collect().

115  {
116  $this->collection[$collection_obj->getUserId()] = $collection_obj;
117  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ collect()

ilMailCronOrphanedMailsNotificationCollector::collect ( )

Definition at line 45 of file class.ilMailCronOrphanedMailsNotificationCollector.php.

References $data, $i, $res, addCollectionObject(), and existsCollectionObjForUserId().

Referenced by __construct().

46  {
47  $mail_notify_orphaned = (int) $this->setting->get('mail_notify_orphaned');
48  $mail_threshold = (int) $this->setting->get('mail_threshold');
49 
50  if ($mail_threshold > $mail_notify_orphaned) {
51  $notify_days_before = $mail_threshold - $mail_notify_orphaned;
52  } else {
53  $notify_days_before = 1;
54  }
55 
56  $ts_notify = strtotime("- " . $notify_days_before . " days");
57  $ts_for_notification = date('Y-m-d', $ts_notify) . ' 23:59:59';
58 
59  $types = array('timestamp');
60  $data = array($ts_for_notification);
61 
62  $notification_query = "
63  SELECT m.mail_id, m.user_id, m.folder_id, m.send_time, m.m_subject, mdata.title
64  FROM mail m
65  LEFT JOIN mail_obj_data mdata ON mdata.obj_id = m.folder_id
66  LEFT JOIN mail_cron_orphaned mco ON mco.mail_id = m.mail_id
67  WHERE mco.mail_id IS NULL AND m.send_time <= %s
68  ";
69 
70  if ((int) $this->setting->get('mail_only_inbox_trash') > 0) {
71  $notification_query .= " AND ((mdata.m_type = %s OR mdata.m_type = %s) OR mdata.obj_id IS NULL)";
72  $types = array('timestamp', 'text', 'text');
73  $data = array($ts_for_notification, 'inbox', 'trash');
74  }
75 
76  $notification_query .= " ORDER BY m.user_id, m.folder_id, m.mail_id";
77 
78  $collection_obj = null;
79 
80  $res = $this->db->queryF($notification_query, $types, $data);
81  $i = 0;
82  while ($row = $this->db->fetchAssoc($res)) {
83  if ($i > 0 && $i % self::PING_THRESHOLD === 0) {
84  $this->job->ping();
85  }
86 
87  if ($collection_obj !== null && !$this->existsCollectionObjForUserId($row['user_id'])) {
88  // The user changed, so we'll have to set the collection to NULL after adding it to the queue
89  $collection_obj = null;
90  }
91 
92  if ($collection_obj === null) {
93  // For the first user or if the user changed, we'll create a new collection object
94  $collection_obj = new ilMailCronOrphanedMailsNotificationCollectionObj($row['user_id']);
95  $this->addCollectionObject($collection_obj);
96  }
97 
98  $folder_obj = $collection_obj->getFolderObjectById($row['folder_id']);
99  if (!$folder_obj) {
100  $folder_obj = new ilMailCronOrphanedMailsFolderObject($row['folder_id']);
101  $folder_obj->setFolderTitle($row['title']);
102  $collection_obj->addFolderObject($folder_obj);
103  }
104 
105  $orphaned_mail_obj = new ilMailCronOrphanedMailsFolderMailObject($row['mail_id'], $row['m_subject']);
106  $folder_obj->addMailObject($orphaned_mail_obj);
107  ++$i;
108  }
109  }
$data
Definition: storeScorm.php:23
addCollectionObject(ilMailCronOrphanedMailsNotificationCollectionObj $collection_obj)
foreach($_POST as $key=> $value) $res
$i
Definition: metadata.php:24
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ existsCollectionObjForUserId()

ilMailCronOrphanedMailsNotificationCollector::existsCollectionObjForUserId (   $user_id)
private
Parameters
$user_id
Returns
bool

Definition at line 123 of file class.ilMailCronOrphanedMailsNotificationCollector.php.

Referenced by collect().

124  {
125  if (isset($this->collection[$user_id])) {
126  return true;
127  }
128 
129  return false;
130  }
+ Here is the caller graph for this function:

◆ getCollection()

ilMailCronOrphanedMailsNotificationCollector::getCollection ( )

Field Documentation

◆ $collection

ilMailCronOrphanedMailsNotificationCollector::$collection = array()
protected

◆ $db

ilMailCronOrphanedMailsNotificationCollector::$db
protected

◆ $job

ilMailCronOrphanedMailsNotificationCollector::$job
private

Definition at line 28 of file class.ilMailCronOrphanedMailsNotificationCollector.php.

Referenced by __construct().

◆ $setting

ilMailCronOrphanedMailsNotificationCollector::$setting
protected

◆ PING_THRESHOLD

const ilMailCronOrphanedMailsNotificationCollector::PING_THRESHOLD = 500
private

The documentation for this class was generated from the following file: