4 require_once
'./Services/Logging/classes/public/class.ilLoggerFactory.php';
37 $this->db = $DIC->database();
43 private function deleteAttachments()
45 $attachment_paths = array();
47 $res = $this->db->query(
' 48 SELECT path, COUNT(mail_id) cnt_mail_ids 50 WHERE ' . $this->db->in(
'mail_id', $this->collector->getMailIdsToDelete(),
false,
'integer') .
' 53 while (
$row = $this->db->fetchAssoc(
$res)) {
54 $usage_res = $this->db->queryF(
55 'SELECT mail_id, path FROM mail_attachment WHERE path = %s',
60 $num_rows = $this->db->numRows($usage_res);
61 if (
$row[
'cnt_mail_ids'] >= $num_rows) {
63 $attachment_paths[
$row[
'mail_id']] = $row[
'path'];
67 foreach ($attachment_paths as $mail_id =>
$path) {
72 RecursiveIteratorIterator::CHILD_FIRST
75 foreach ($iter as $file) {
80 $path_name = $file->getPathname();
84 'Attachment directory (%s) deleted for mail_id: %s',
89 if (file_exists($path_name) && unlink($path_name)) {
91 'Attachment file (%s) deleted for mail_id: %s',
97 'Attachment file (%s) for mail_id could not be deleted due to missing file system permissions: %s',
107 'Attachment directory (%s) deleted for mail_id: %s',
115 $this->db->manipulate(
'DELETE FROM mail_attachment WHERE ' . $this->db->in(
'mail_id', $this->collector->getMailIdsToDelete(),
false,
'integer'));
123 $this->db->manipulate(
'DELETE FROM mail WHERE ' . $this->db->in(
'mail_id', $this->collector->getMailIdsToDelete(),
false,
'integer'));
131 if ((
int) $this->
settings->get(
'mail_notify_orphaned') >= 1) {
132 $this->db->manipulate(
'DELETE FROM mail_cron_orphaned WHERE ' . $this->db->in(
'mail_id', $this->collector->getMailIdsToDelete(),
false,
'integer'));
134 $this->db->manipulate(
'DELETE FROM mail_cron_orphaned');
143 if (count($this->collector->getMailIdsToDelete()) > 0) {
145 $this->deleteAttachments();
148 require_once
'./Services/Logging/classes/public/class.ilLoggerFactory.php';
150 'Deleted mail_ids: %s',
151 implode(
', ', $this->collector->getMailIdsToDelete())
156 'Deleted mail_cron_orphaned mail_ids: %s',
157 implode(
', ', $this->collector->getMailIdsToDelete())
__construct(ilMailCronOrphanedMailsDeletionCollector $collector)
foreach($_POST as $key=> $value) $res
ilMailCronOrphanedMailsDeletionProcessor
ilMailCronOrphanedMailsDeletionCollector
static getLogger($a_component_id)
Get component logger.
deleteMarkedAsNotified()
Delete entries about notification.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively