ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilCronDeleteInactiveUserReminderMail.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once 'Services/Mail/classes/class.ilMailNotification.php';
5
13{
14 const TABLE_NAME = "usr_cron_mail_reminder";
15
16 private static function mailSent($usr_id)
17 {
18 global $ilDB;
19 $ilDB->manipulateF(
20 "INSERT INTO " . self::TABLE_NAME . " (usr_id, ts) VALUES (%s, %s)",
21 array(
22 "integer",
23 "integer"
24 ),
25 array(
26 $usr_id,
27 time()
28 )
29 );
30 }
31
32 private static function sendReminder(ilObjUser $user, $reminderTime, $time_frame_for_deletion)
33 {
34 include_once 'Services/User/classes/class.ilCronDeleteInactiveUserReminderMailNotification.php';
36 $mail->setRecipients(array($user));
37 $mail->setAdditionalInformation(
38 array(
39 "www" => ilUtil::_getHttpPath(),
40 "days" => $reminderTime,
41 "date" => $time_frame_for_deletion
42 )
43 );
44 $mail->send();
45 self::mailSent($user->getId());
46 }
47
49 {
50 global $ilDB;
51 $query = "SELECT usr_id,ts FROM " . self::TABLE_NAME;
52 $res = $ilDB->queryF($query, array(
53 'integer',
54 'integer'
55 ), array(
56 'usr_id',
57 'ts'
58 ));
59 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
60 $lastLoginUnixtime = strtotime(ilObjUser::_lookupLastLogin($row->usr_id));
61 $lastReminderSent = (int) $row->ts;
62 if ($lastLoginUnixtime >= $lastReminderSent) {
64 }
65 }
66 }
67
68 public static function checkIfReminderMailShouldBeSend(ilObjUser $user, $reminderTime, $time_frame_for_deletion)
69 {
70 global $ilDB;
71 $query = "SELECT ts FROM " . self::TABLE_NAME . " WHERE usr_id = %s";
72 $res = $ilDB->queryF($query, array('integer'), array($user->getId()));
74 if ($row->ts == null) {
75 self::sendReminder($user, $reminderTime, $time_frame_for_deletion);
76 return true;
77 }
78 return false;
79 }
80
81 public static function flushDataTable()
82 {
83 global $ilDB;
84 $ilDB->manipulate("DELETE FROM " . self::TABLE_NAME);
85 }
86
87 public static function removeSingleUserFromTable($usr_id)
88 {
89 global $ilDB;
90 $query = "DELETE FROM " . self::TABLE_NAME . " WHERE usr_id = %s";
91 $ilDB->manipulateF($query, array('integer'), array($usr_id));
92 }
93}
PHPExcel root directory.
Definition: PHPExcel.php:30
An exception for terminatinating execution or to throw for unit testing.
static checkIfReminderMailShouldBeSend(ilObjUser $user, $reminderTime, $time_frame_for_deletion)
static sendReminder(ilObjUser $user, $reminderTime, $time_frame_for_deletion)
static _lookupLastLogin($a_user_id)
lookup last login
getId()
get object id @access public
static _getHttpPath()
$query
foreach($_POST as $key=> $value) $res
global $ilDB