ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilMailCronOrphanedMailsDeletionCollector.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 $mail_ids = array();
14 
18  public function __construct()
19  {
20  $this->collect();
21  }
22 
26  public function collect()
27  {
28  global $ilDB, $ilSetting;
29 
30  $mail_only_inbox_trash = (int)$ilSetting->get('mail_only_inbox_trash');
31  $last_cron_start_ts = (int)$ilSetting->get('last_cronjob_start_ts');
32 
33  $mail_notify_orphaned = (int)$ilSetting->get('mail_notify_orphaned');
34 
35  $now = time();
36 
37  if($mail_notify_orphaned > 0)
38  {
39  if($last_cron_start_ts != NULL)
40  {
41  if($mail_only_inbox_trash)
42  {
43  // überprüfen ob die mail in einen anderen Ordner verschoben wurde
44  // selektiere die, die tatsächlich gelöscht werden sollen
45  $res = $ilDB->queryF("
46  SELECT * FROM mail_cron_orphaned
47  INNER JOIN mail_obj_data mdata ON obj_id = folder_id
48  WHERE ts_do_delete <= %s
49  AND (mdata.m_type = %s OR mdata.m_type = %s)",
50  array('integer', 'text', 'text'),
51  array($now, 'inbox', 'trash'));
52  }
53  else
54  {
55  // selektiere alle zu löschenden mails unabhängig vom ordner..
56  $res = $ilDB->queryF("
57  SELECT * FROM mail_cron_orphaned
58  WHERE ts_do_delete <= %s",
59  array('integer'),
60  array($now));
61  }
62 
63  while($row = $ilDB->fetchAssoc($res))
64  {
65  $this->addMailIdToDelete($row['mail_id']);
66  }
67  }
68  }
69  else
70  {
71  // mails sollen direkt ohne vorheriger notification gelöscht werden.
72  $mail_threshold = (int)$ilSetting->get('mail_threshold');
73 
74  $ts_notify = strtotime("- ".$mail_threshold." days");
75  $ts_for_deletion = date('Y-m-d', $ts_notify).' 23:59:59';
76 
77  $types = array('timestamp');
78  $data = array($ts_for_deletion);
79 
80  $mails_query = "
81  SELECT mail_id, m.user_id, folder_id, send_time, m_subject, mdata.title
82  FROM mail m
83  INNER JOIN mail_obj_data mdata ON obj_id = folder_id
84  WHERE send_time <= %s";
85 
86  if((int)$ilSetting->get('mail_only_inbox_trash') > 0)
87  {
88  $mails_query .= " AND (mdata.m_type = %s OR mdata.m_type = %s)";
89  $types = array('timestamp', 'text', 'text');
90  $data = array($ts_for_deletion, 'inbox', 'trash');
91  }
92 
93  $res = $ilDB->queryF($mails_query, $types, $data);
94 
95  while($row = $ilDB->fetchAssoc($res))
96  {
97  $this->addMailIdToDelete($row['mail_id']);
98  }
99  }
100  }
101 
105  public function addMailIdToDelete($mail_id)
106  {
107  $this->mail_ids[] = (int)$mail_id;
108  }
109 
113  public function getMailIdsToDelete()
114  {
115  return $this->mail_ids;
116  }
117 }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Create styles array
The data for the language used.
global $ilSetting
Definition: privfeed.php:17
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.