ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $db;
14
18 protected $settings;
19
23 protected $mail_ids = array();
24
28 public function __construct()
29 {
30 global $DIC;
31
32 $this->settings = $DIC->settings();
33 $this->db = $DIC->database();
34
35 $this->collect();
36 }
37
41 public function collect()
42 {
43 $mail_only_inbox_trash = (int) $this->settings->get('mail_only_inbox_trash');
44 $last_cron_start_ts = (int) $this->settings->get('last_cronjob_start_ts', time());
45 $mail_notify_orphaned = (int) $this->settings->get('mail_notify_orphaned');
46
47 $now = time();
48
49 if ($mail_notify_orphaned > 0) {
50 if ($last_cron_start_ts != null) {
51 if ($mail_only_inbox_trash) {
52 // überprüfen ob die mail in einen anderen Ordner verschoben wurde
53 // selektiere die, die tatsächlich gelöscht werden sollen
54 $res = $this->db->queryF(
55 "
56 SELECT * FROM mail_cron_orphaned
57 INNER JOIN mail_obj_data mdata ON obj_id = folder_id
58 WHERE ts_do_delete <= %s
59 AND (mdata.m_type = %s OR mdata.m_type = %s)",
60 array('integer', 'text', 'text'),
61 array($now, 'inbox', 'trash')
62 );
63 } else {
64 // selektiere alle zu löschenden mails unabhängig vom ordner..
65 $res = $this->db->queryF(
66 "
67 SELECT * FROM mail_cron_orphaned
68 WHERE ts_do_delete <= %s",
69 array('integer'),
70 array($now)
71 );
72 }
73
74 while ($row = $this->db->fetchAssoc($res)) {
75 $this->addMailIdToDelete($row['mail_id']);
76 }
77 }
78 } else {
79 // mails sollen direkt ohne vorheriger notification gelöscht werden.
80 $mail_threshold = (int) $this->settings->get('mail_threshold');
81 $ts_notify = strtotime("- " . $mail_threshold . " days");
82 $ts_for_deletion = date('Y-m-d', $ts_notify) . ' 23:59:59';
83
84 $types = array('timestamp');
85 $data = array($ts_for_deletion);
86
87 $mails_query = "
88 SELECT mail_id, m.user_id, folder_id, send_time, m_subject, mdata.title
89 FROM mail m
90 INNER JOIN mail_obj_data mdata ON obj_id = folder_id
91 WHERE send_time <= %s";
92
93 if ((int) $this->settings->get('mail_only_inbox_trash') > 0) {
94 $mails_query .= " AND (mdata.m_type = %s OR mdata.m_type = %s)";
95 $types = array('timestamp', 'text', 'text');
96 $data = array($ts_for_deletion, 'inbox', 'trash');
97 }
98
99 $res = $this->db->queryF($mails_query, $types, $data);
100 while ($row = $this->db->fetchAssoc($res)) {
101 $this->addMailIdToDelete($row['mail_id']);
102 }
103 }
104 }
105
109 public function addMailIdToDelete($mail_id)
110 {
111 $this->mail_ids[] = (int) $mail_id;
112 }
113
117 public function getMailIdsToDelete()
118 {
119 return $this->mail_ids;
120 }
121}
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
An exception for terminatinating execution or to throw for unit testing.
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
settings()
Definition: settings.php:2