ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilCronDeleteInactiveUserReminderMail Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilCronDeleteInactiveUserReminderMail:

Public Member Functions

 __construct (private ilDBInterface $db)
 
 removeEntriesFromTableIfLastLoginIsNewer ()
 
 sendReminderMailIfNeeded (ilObjUser $user, int $reminderTime, int $time_frame_for_deletion)
 
 flushDataTable ()
 
 removeSingleUserFromTable (int $usr_id)
 

Data Fields

const TABLE_NAME = "usr_cron_mail_reminder"
 

Private Member Functions

 persistMailSent (int $usr_id)
 
 sendReminder (ilObjUser $user, int $reminderTime, int $time_frame_for_deletion)
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning This checks if a mail has to be send after a certain INACTIVITY period

Author
Guido Vollbach gvoll.nosp@m.bach.nosp@m.@data.nosp@m.bay..nosp@m.de

Definition at line 23 of file class.ilCronDeleteInactiveUserReminderMail.php.

Constructor & Destructor Documentation

◆ __construct()

ilCronDeleteInactiveUserReminderMail::__construct ( private ilDBInterface  $db)

Definition at line 27 of file class.ilCronDeleteInactiveUserReminderMail.php.

29 {
30 }

Member Function Documentation

◆ flushDataTable()

ilCronDeleteInactiveUserReminderMail::flushDataTable ( )

Definition at line 66 of file class.ilCronDeleteInactiveUserReminderMail.php.

66 : void
67 {
68
69 $this->db->manipulate("DELETE FROM " . self::TABLE_NAME);
70 }

◆ persistMailSent()

ilCronDeleteInactiveUserReminderMail::persistMailSent ( int  $usr_id)
private

Definition at line 78 of file class.ilCronDeleteInactiveUserReminderMail.php.

78 : void
79 {
80 $this->db->manipulateF(
81 "INSERT INTO " . self::TABLE_NAME . " (usr_id, ts) VALUES (%s, %s)",
82 [
83 "integer",
84 "integer"
85 ],
86 [
87 $usr_id,
88 time()
89 ]
90 );
91 }

◆ removeEntriesFromTableIfLastLoginIsNewer()

ilCronDeleteInactiveUserReminderMail::removeEntriesFromTableIfLastLoginIsNewer ( )

Definition at line 32 of file class.ilCronDeleteInactiveUserReminderMail.php.

32 : void
33 {
34 $query = "SELECT usr_id,ts FROM " . self::TABLE_NAME;
35 $res = $this->db->queryF($query, [
36 'integer',
37 'integer'
38 ], [
39 'usr_id',
40 'ts'
41 ]);
42 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
43 $lastLoginUnixtime = strtotime(ilObjUser::_lookupLastLogin($row->usr_id));
44 $lastReminderSent = (int) $row->ts;
45 if ($lastLoginUnixtime >= $lastReminderSent) {
46 $this->removeSingleUserFromTable($row->usr_id);
47 }
48 }
49 }
static _lookupLastLogin(int $a_user_id)
$res
Definition: ltiservices.php:69
if(!file_exists('../ilias.ini.php'))

References $res, ilObjUser\_lookupLastLogin(), ilDBConstants\FETCHMODE_OBJECT, if, ILIAS\Repository\int(), removeSingleUserFromTable(), and TABLE_NAME.

+ Here is the call graph for this function:

◆ removeSingleUserFromTable()

ilCronDeleteInactiveUserReminderMail::removeSingleUserFromTable ( int  $usr_id)

Definition at line 72 of file class.ilCronDeleteInactiveUserReminderMail.php.

72 : void
73 {
74 $query = "DELETE FROM " . self::TABLE_NAME . " WHERE usr_id = %s";
75 $this->db->manipulateF($query, ['integer'], [$usr_id]);
76 }

Referenced by removeEntriesFromTableIfLastLoginIsNewer().

+ Here is the caller graph for this function:

◆ sendReminder()

ilCronDeleteInactiveUserReminderMail::sendReminder ( ilObjUser  $user,
int  $reminderTime,
int  $time_frame_for_deletion 
)
private

Definition at line 93 of file class.ilCronDeleteInactiveUserReminderMail.php.

97 : void {
99 $mail->setRecipients([$user]);
100 $mail->setAdditionalInformation(
101 [
102 "www" => ilUtil::_getHttpPath(),
103 "days" => $reminderTime,
104 "date" => $time_frame_for_deletion
105 ]
106 );
107 $mail->send();
108 $this->persistMailSent($user->getId());
109 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getHttpPath()

Referenced by sendReminderMailIfNeeded().

+ Here is the caller graph for this function:

◆ sendReminderMailIfNeeded()

ilCronDeleteInactiveUserReminderMail::sendReminderMailIfNeeded ( ilObjUser  $user,
int  $reminderTime,
int  $time_frame_for_deletion 
)

Definition at line 51 of file class.ilCronDeleteInactiveUserReminderMail.php.

55 : bool {
56 $query = "SELECT ts FROM " . self::TABLE_NAME . " WHERE usr_id = %s";
57 $res = $this->db->queryF($query, ['integer'], [$user->getId()]);
58 $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
59 if ($row === false || $row->ts === null) {
60 $this->sendReminder($user, $reminderTime, $time_frame_for_deletion);
61 return true;
62 }
63 return false;
64 }
sendReminder(ilObjUser $user, int $reminderTime, int $time_frame_for_deletion)

References sendReminder().

+ Here is the call graph for this function:

Field Documentation

◆ TABLE_NAME

const ilCronDeleteInactiveUserReminderMail::TABLE_NAME = "usr_cron_mail_reminder"

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