ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilUserCronCheckAccounts Class Reference

This cron send notifications about expiring user accounts. More...

+ Inheritance diagram for ilUserCronCheckAccounts:
+ Collaboration diagram for ilUserCronCheckAccounts:

Public Member Functions

 getId ()
 
 getTitle ()
 
 getDescription ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 hasAutoActivation ()
 
 hasFlexibleSchedule ()
 
 run ()
 
- Public Member Functions inherited from ILIAS\Cron\CronJob
 setDateTimeProvider (?\Closure $date_time_provider)
 
 isDue (?\DateTimeImmutable $last_run, ?JobScheduleType $schedule_type, ?int $schedule_value, bool $is_manually_executed=false)
 
 getScheduleType ()
 Get current schedule type (if flexible) More...
 
 getScheduleValue ()
 Get current schedule value (if flexible) More...
 
 setSchedule (?JobScheduleType $a_type, ?int $a_value)
 Update current schedule (if flexible) More...
 
 getAllScheduleTypes ()
 Get all available schedule types. More...
 
 getScheduleTypesWithValues ()
 
 getValidScheduleTypes ()
 Returns a collection of all valid schedule types for a specific job. More...
 
 isManuallyExecutable ()
 
 hasCustomSettings ()
 
 usesLegacyForms ()
 
 getCustomConfigurationInput (\ILIAS\UI\Factory $ui_factory, \ILIAS\Refinery\Factory $factory, \ilLanguage $lng)
 
 addCustomSettingsToForm (\ilPropertyFormGUI $a_form)
 
 saveCustomConfiguration (mixed $form_data)
 
 saveCustomSettings (\ilPropertyFormGUI $a_form)
 
 addToExternalSettingsForm (int $a_form_id, array &$a_fields, bool $a_is_active)
 
 activationWasToggled (\ilDBInterface $db, \ilSetting $setting, bool $a_currently_active)
 Important: This method is (also) called from the setup process, where the constructor of an ilCronJob ist NOT executed. More...
 
 getId ()
 
 getTitle ()
 
 getDescription ()
 
 hasAutoActivation ()
 Is to be activated on "installation", does only work for ILIAS core cron jobs. More...
 
 hasFlexibleSchedule ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 run ()
 

Protected Member Functions

 checkNotConfirmedUserAccounts ()
 

Protected Attributes

int $counter = 0
 
- Protected Attributes inherited from ILIAS\Cron\CronJob
JobScheduleType $schedule_type = null
 
int $schedule_value = null
 
Closure $date_time_provider = null
 

Private Attributes

ilDBInterface $db
 
ilLanguage $lng
 
ilComponentLogger $log
 

Detailed Description

This cron send notifications about expiring user accounts.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 29 of file class.ilUserCronCheckAccounts.php.

Member Function Documentation

◆ checkNotConfirmedUserAccounts()

ilUserCronCheckAccounts::checkNotConfirmedUserAccounts ( )
protected

Definition at line 159 of file class.ilUserCronCheckAccounts.php.

References $res, and ilObjectFactory\getInstanceByObjId().

Referenced by run().

159  : void
160  {
161  $registration_settings = new ilRegistrationSettings();
162 
163  $query = 'SELECT usr_id FROM usr_data '
164  . 'WHERE (reg_hash IS NOT NULL AND reg_hash != %s)'
165  . 'AND active = %s '
166  . 'AND create_date < %s';
167  $res = $this->db->queryF(
168  $query,
169  ['text', 'integer', 'timestamp'],
170  ['', 0, date('Y-m-d H:i:s', time() - $registration_settings->getRegistrationHashLifetime())]
171  );
172  while ($row = $this->db->fetchAssoc($res)) {
173  $user = ilObjectFactory::getInstanceByObjId((int) $row['usr_id']);
174  $user->delete();
175  $this->log->write('Cron: Deleted ' . $user->getLogin() . ' [' . $user->getId() . '] ' . __METHOD__);
176 
177  $this->counter++;
178  }
179  }
$res
Definition: ltiservices.php:66
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
Class ilObjAuthSettingsGUI.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefaultScheduleType()

ilUserCronCheckAccounts::getDefaultScheduleType ( )

Definition at line 70 of file class.ilUserCronCheckAccounts.php.

71  {
72  return JobScheduleType::DAILY;
73  }

◆ getDefaultScheduleValue()

ilUserCronCheckAccounts::getDefaultScheduleValue ( )

Definition at line 75 of file class.ilUserCronCheckAccounts.php.

References null.

75  : ?int
76  {
77  return null;
78  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ getDescription()

ilUserCronCheckAccounts::getDescription ( )

Definition at line 65 of file class.ilUserCronCheckAccounts.php.

References ILIAS\Repository\lng().

65  : string
66  {
67  return $this->lng->txt('check_user_accounts_desc');
68  }
+ Here is the call graph for this function:

◆ getId()

ilUserCronCheckAccounts::getId ( )

Definition at line 55 of file class.ilUserCronCheckAccounts.php.

55  : string
56  {
57  return 'user_check_accounts';
58  }

◆ getTitle()

ilUserCronCheckAccounts::getTitle ( )

Definition at line 60 of file class.ilUserCronCheckAccounts.php.

References ILIAS\Repository\lng().

60  : string
61  {
62  return $this->lng->txt('check_user_accounts');
63  }
+ Here is the call graph for this function:

◆ hasAutoActivation()

ilUserCronCheckAccounts::hasAutoActivation ( )

Definition at line 80 of file class.ilUserCronCheckAccounts.php.

80  : bool
81  {
82  return false;
83  }

◆ hasFlexibleSchedule()

ilUserCronCheckAccounts::hasFlexibleSchedule ( )

Definition at line 85 of file class.ilUserCronCheckAccounts.php.

85  : bool
86  {
87  return false;
88  }

◆ run()

ilUserCronCheckAccounts::run ( )

Definition at line 90 of file class.ilUserCronCheckAccounts.php.

References $res, ilMail\_getAutoGeneratedMessageString(), ilLanguageFactory\_getLanguageOfUser(), ilObjUser\_lookupEmail(), ANONYMOUS_USER_ID, checkNotConfirmedUserAccounts(), ilMail\getSalutation(), ilLanguage\loadLanguageModule(), and ilLanguage\txt().

90  : JobResult
91  {
92  $status = JobResult::STATUS_NO_ACTION;
93 
94  $now = time();
95  $two_weeks_in_seconds = $now + (60 * 60 * 24 * 14); // #14630
96 
97  // all users who are currently active and expire in the next 2 weeks
98  $query = 'SELECT usr_id, login, time_limit_until ' .
99  'FROM usr_data ' .
100  'WHERE time_limit_message = "0" ' .
101  'AND time_limit_unlimited = "0" ' .
102  'AND time_limit_from < ' . $this->db->quote($now, 'integer') . ' ' .
103  'AND time_limit_until > ' . $this->db->quote($now, 'integer') . ' ' .
104  'AND time_limit_until < ' . $this->db->quote($two_weeks_in_seconds, 'integer');
105 
106  $res = $this->db->query($query);
107 
108  while ($row = $this->db->fetchObject($res)) {
109  $expires = $row->time_limit_until;
110  $login = $row->login;
111  $usr_id = $row->usr_id;
112 
114  $lng->loadLanguageModule('mail');
115 
116  $salutation = ilMail::getSalutation($usr_id, $lng);
117 
118  $body = $salutation . "\n\n";
119  $body .= sprintf(
120  $lng->txt('account_expires_body'),
121  $login,
122  ILIAS_HTTP_PATH,
123  date('Y-m-d H:i', $expires)
124  );
125 
126  $body .= "\n\n" . ilMail::_getAutoGeneratedMessageString($lng);
127 
128  // force email
129  $mail = new ilMail(ANONYMOUS_USER_ID);
130  $mail->enqueue(
131  ilObjUser::_lookupEmail($usr_id),
132  '',
133  '',
134  $lng->txt('account_expires_subject'),
135  $body,
136  []
137  );
138 
139  // set status 'mail sent'
140  $query = 'UPDATE usr_data SET time_limit_message = "1" WHERE usr_id = "' . $usr_id . '"';
141  $this->db->query($query);
142 
143  // Send log message
144  $this->log->write('Cron: (checkUserAccounts()) sent message to ' . $login . '.');
145 
146  $this->counter++;
147  }
148 
150 
151  if ($this->counter) {
152  $status = JobResult::STATUS_OK;
153  }
154  $result = new JobResult();
155  $result->setStatus($status);
156  return $result;
157  }
$res
Definition: ltiservices.php:66
const ANONYMOUS_USER_ID
Definition: constants.php:27
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
loadLanguageModule(string $a_module)
Load language module.
static _getAutoGeneratedMessageString(?ilLanguage $lang=null)
static _getLanguageOfUser(int $a_usr_id)
Get language object of user.
static getSalutation(int $a_usr_id, ?ilLanguage $a_language=null)
static _lookupEmail(int $a_user_id)
+ Here is the call graph for this function:

Field Documentation

◆ $counter

int ilUserCronCheckAccounts::$counter = 0
protected

Definition at line 31 of file class.ilUserCronCheckAccounts.php.

◆ $db

ilDBInterface ilUserCronCheckAccounts::$db
private

Definition at line 33 of file class.ilUserCronCheckAccounts.php.

◆ $lng

ilLanguage ilUserCronCheckAccounts::$lng
private

Definition at line 34 of file class.ilUserCronCheckAccounts.php.

◆ $log

ilComponentLogger ilUserCronCheckAccounts::$log
private

Definition at line 35 of file class.ilUserCronCheckAccounts.php.


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