ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
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.

Referenced by sendReminder().

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  }
+ Here is the caller graph for this function:

◆ removeEntriesFromTableIfLastLoginIsNewer()

ilCronDeleteInactiveUserReminderMail::removeEntriesFromTableIfLastLoginIsNewer ( )

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

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

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  }
$res
Definition: ltiservices.php:66
if(!file_exists('../ilias.ini.php'))
static _lookupLastLogin(int $a_user_id)
+ Here is the call graph for this function:

◆ removeSingleUserFromTable()

ilCronDeleteInactiveUserReminderMail::removeSingleUserFromTable ( int  $usr_id)

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

Referenced by removeEntriesFromTableIfLastLoginIsNewer().

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

References ilUtil\_getHttpPath(), ilObject\getId(), and persistMailSent().

Referenced by sendReminderMailIfNeeded().

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  }
static _getHttpPath()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ 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.

References $res, ilDBConstants\FETCHMODE_OBJECT, ilObject\getId(), null, and sendReminder().

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  }
$res
Definition: ltiservices.php:66
sendReminder(ilObjUser $user, int $reminderTime, int $time_frame_for_deletion)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ 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: