ILIAS  release_7 Revision v7.30-3-g800a261c036
ilMailCronOrphanedMailsDeletionCollector Class Reference

ilMailCronOrphanedMailsDeletionCollector More...

+ Collaboration diagram for ilMailCronOrphanedMailsDeletionCollector:

Public Member Functions

 __construct (ilMailCronOrphanedMails $job)
 
 collect ()
 
 addMailIdToDelete ($mail_id)
 
 getMailIdsToDelete ()
 

Protected Attributes

 $db
 
 $settings
 
 $mail_ids = array()
 

Private Attributes

const PING_THRESHOLD = 500
 
 $job
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilMailCronOrphanedMailsDeletionCollector::__construct ( ilMailCronOrphanedMails  $job)

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

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

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

Member Function Documentation

◆ addMailIdToDelete()

ilMailCronOrphanedMailsDeletionCollector::addMailIdToDelete (   $mail_id)
Parameters
int$mail_id

Definition at line 118 of file class.ilMailCronOrphanedMailsDeletionCollector.php.

Referenced by collect().

119  {
120  $this->mail_ids[] = (int) $mail_id;
121  }
+ Here is the caller graph for this function:

◆ collect()

ilMailCronOrphanedMailsDeletionCollector::collect ( )

Definition at line 43 of file class.ilMailCronOrphanedMailsDeletionCollector.php.

References $data, $i, $res, addMailIdToDelete(), and settings().

Referenced by __construct().

44  {
45  $mail_only_inbox_trash = (int) $this->settings->get('mail_only_inbox_trash');
46  $last_cron_start_ts = (int) $this->settings->get('last_cronjob_start_ts', time());
47  $mail_notify_orphaned = (int) $this->settings->get('mail_notify_orphaned');
48 
49  $now = time();
50 
51  if ($mail_notify_orphaned > 0) {
52  if ($last_cron_start_ts != null) {
53  if ($mail_only_inbox_trash) {
54  // überprüfen ob die mail in einen anderen Ordner verschoben wurde
55  // selektiere die, die tatsächlich gelöscht werden sollen
56  $res = $this->db->queryF(
57  "
58  SELECT mail_id FROM mail_cron_orphaned
59  LEFT JOIN mail_obj_data mdata ON mdata.obj_id = folder_id
60  WHERE ts_do_delete <= %s
61  AND ((mdata.m_type = %s OR mdata.m_type = %s) OR mdata.obj_id IS NULL)",
62  array('integer', 'text', 'text'),
63  array($now, 'inbox', 'trash')
64  );
65  } else {
66  // selektiere alle zu löschenden mails unabhängig vom ordner..
67  $res = $this->db->queryF(
68  "
69  SELECT mail_id FROM mail_cron_orphaned
70  WHERE ts_do_delete <= %s",
71  array('integer'),
72  array($now)
73  );
74  }
75 
76  while ($row = $this->db->fetchAssoc($res)) {
77  $this->addMailIdToDelete($row['mail_id']);
78  }
79  }
80  } else {
81  // mails sollen direkt ohne vorheriger notification gelöscht werden.
82  $mail_threshold = (int) $this->settings->get('mail_threshold');
83  $ts_notify = strtotime("- " . $mail_threshold . " days");
84  $ts_for_deletion = date('Y-m-d', $ts_notify) . ' 23:59:59';
85 
86  $types = array('timestamp');
87  $data = array($ts_for_deletion);
88 
89  $mails_query = "
90  SELECT mail_id
91  FROM mail m
92  INNER JOIN mail_obj_data mdata ON obj_id = folder_id
93  WHERE send_time <= %s";
94 
95  if ((int) $this->settings->get('mail_only_inbox_trash') > 0) {
96  $mails_query .= " AND (mdata.m_type = %s OR mdata.m_type = %s)";
97  $types = array('timestamp', 'text', 'text');
98  $data = array($ts_for_deletion, 'inbox', 'trash');
99  }
100 
101  $i = 0;
102  $res = $this->db->queryF($mails_query, $types, $data);
103  while ($row = $this->db->fetchAssoc($res)) {
104  if ($i > 0 && $i % self::PING_THRESHOLD) {
105  $this->job->ping();
106  }
107 
108  $this->addMailIdToDelete($row['mail_id']);
109 
110  ++$i;
111  }
112  }
113  }
settings()
Definition: settings.php:2
$data
Definition: storeScorm.php:23
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:

◆ getMailIdsToDelete()

ilMailCronOrphanedMailsDeletionCollector::getMailIdsToDelete ( )

Field Documentation

◆ $db

ilMailCronOrphanedMailsDeletionCollector::$db
protected

◆ $job

ilMailCronOrphanedMailsDeletionCollector::$job
private

Definition at line 12 of file class.ilMailCronOrphanedMailsDeletionCollector.php.

Referenced by __construct().

◆ $mail_ids

ilMailCronOrphanedMailsDeletionCollector::$mail_ids = array()
protected

◆ $settings

ilMailCronOrphanedMailsDeletionCollector::$settings
protected

◆ PING_THRESHOLD

const ilMailCronOrphanedMailsDeletionCollector::PING_THRESHOLD = 500
private

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