ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilMailCronOrphanedMailsNotificationCollector Class Reference

ilMailCronOrphanedMailsNotificationCollector More...

+ Collaboration diagram for ilMailCronOrphanedMailsNotificationCollector:

Public Member Functions

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

Protected Attributes

 $collection = array()
 
 $db
 
 $setting
 

Private Member Functions

 existsCollectionObjForUserId ($user_id)
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilMailCronOrphanedMailsNotificationCollector::__construct ( )

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

References $DIC, and collect().

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

Member Function Documentation

◆ addCollectionObject()

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

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

References ilMailCronOrphanedMailsNotificationCollectionObj\getUserId().

Referenced by collect().

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

◆ collect()

ilMailCronOrphanedMailsNotificationCollector::collect ( )

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

References $data, $res, $row, addCollectionObject(), array, date, and existsCollectionObjForUserId().

Referenced by __construct().

45  {
46  $mail_notify_orphaned = (int) $this->setting->get('mail_notify_orphaned');
47  $mail_threshold = (int) $this->setting->get('mail_threshold');
48 
49  if ($mail_threshold > $mail_notify_orphaned) {
50  $notify_days_before = $mail_threshold - $mail_notify_orphaned;
51  } else {
52  $notify_days_before = 1;
53  }
54 
55  $ts_notify = strtotime("- " . $notify_days_before . " days");
56  $ts_for_notification = date('Y-m-d', $ts_notify) . ' 23:59:59';
57 
58  $res = $this->db->query('SELECT mail_id FROM mail_cron_orphaned');
59  $already_notified = array();
60  while ($row = $this->db->fetchAssoc($res)) {
61  $already_notified[$row['mail_id']] = $row['mail_id'];
62  }
63 
64  $types = array('timestamp');
65  $data = array($ts_for_notification);
66 
67  $notification_query = "
68  SELECT mail_id, m.user_id, folder_id, send_time, m_subject, mdata.title
69  FROM mail m
70  INNER JOIN mail_obj_data mdata ON obj_id = folder_id
71  WHERE send_time <= %s";
72 
73  if ((int) $this->setting->get('mail_only_inbox_trash') > 0) {
74  $notification_query .= " AND (mdata.m_type = %s OR mdata.m_type = %s)";
75  $types = array('timestamp', 'text', 'text');
76  $data = array($ts_for_notification, 'inbox', 'trash');
77  }
78 
79  $notification_query .= " AND " . $this->db->in('mail_id', array_values($already_notified), true, 'integer')
80  . " ORDER BY m.user_id, folder_id, mail_id";
81 
82  $collection_obj = null;
83  $folder_obj = null;
84 
85  $res = $this->db->queryF($notification_query, $types, $data);
86  while ($row = $this->db->fetchAssoc($res)) {
87  if (!$this->existsCollectionObjForUserId($row['user_id'])) {
88  if (is_object($collection_obj)) {
89  $this->addCollectionObject($collection_obj);
90  }
91  }
92 
93  if (!is_object($collection_obj)) {
94  $collection_obj = new ilMailCronOrphanedMailsNotificationCollectionObj($row['user_id']);
95  }
96 
97  if (is_object($collection_obj)) {
98  if (!$folder_obj = $collection_obj->getFolderObjectById($row['folder_id'])) {
99  $folder_obj = new ilMailCronOrphanedMailsFolderObject($row['folder_id']);
100  $folder_obj->setFolderTitle($row['title']);
101  $collection_obj->addFolderObject($folder_obj);
102  }
103 
104  if (is_object($folder_obj)) {
105  $orphaned_mail_obj = new ilMailCronOrphanedMailsFolderMailObject($row['mail_id'], $row['m_subject']);
106  $folder_obj->addMailObject($orphaned_mail_obj);
107  }
108  }
109  }
110 
111  if (is_object($collection_obj)) {
112  $this->addCollectionObject($collection_obj);
113  unset($collection_obj);
114  }
115  }
addCollectionObject(ilMailCronOrphanedMailsNotificationCollectionObj $collection_obj)
foreach($_POST as $key=> $value) $res
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Create styles array
The data for the language used.
+ 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 129 of file class.ilMailCronOrphanedMailsNotificationCollector.php.

Referenced by collect().

130  {
131  if (isset($this->collection[$user_id])) {
132  return true;
133  }
134 
135  return false;
136  }
+ Here is the caller graph for this function:

◆ getCollection()

ilMailCronOrphanedMailsNotificationCollector::getCollection ( )

Field Documentation

◆ $collection

ilMailCronOrphanedMailsNotificationCollector::$collection = array()
protected

◆ $db

ilMailCronOrphanedMailsNotificationCollector::$db
protected

◆ $setting

ilMailCronOrphanedMailsNotificationCollector::$setting
protected

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