ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilTimingsCronReminder Class Reference
+ Inheritance diagram for ilTimingsCronReminder:
+ Collaboration diagram for ilTimingsCronReminder:

Public Member Functions

 __construct ()
 Constructor. More...
 
 getId ()
 
 getTitle ()
 
 getDescription ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 hasAutoActivation ()
 
 hasFlexibleSchedule ()
 
 hasCustomSettings ()
 
 run ()
 
- Public Member Functions inherited from ilCronJob
 isActive ($a_ts_last_run, $a_schedule_type, $a_schedule_value, $a_manual=false)
 Is job currently active? More...
 
 getScheduleType ()
 Get current schedule type (if flexible) More...
 
 getScheduleValue ()
 Get current schedule value (if flexible) More...
 
 setSchedule ($a_type, $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...
 
 getTitle ()
 Get title. More...
 
 getDescription ()
 Get description. More...
 
 isManuallyExecutable ()
 Defines whether or not a cron job can be started manually. More...
 
 hasCustomSettings ()
 Has cron job any custom setting which can be edited? More...
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 Add custom settings to form. More...
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 Save custom settings. More...
 
 addToExternalSettingsForm ($a_form_id, array &$a_fields, $a_is_active)
 Add external settings to form. More...
 
 activationWasToggled ($a_currently_active)
 Cron job status was changed. More...
 
 getId ()
 Get id. More...
 
 hasAutoActivation ()
 Is to be activated on "installation". More...
 
 hasFlexibleSchedule ()
 Can the schedule be configured? More...
 
 getDefaultScheduleType ()
 Get schedule type. More...
 
 getDefaultScheduleValue ()
 Get schedule value. More...
 
 run ()
 Run job. More...
 

Protected Member Functions

 gatherUsers ()
 Read all active users. More...
 
 gatherUsersWithExceededTimings ()
 Users with exceeded timings. More...
 
 getNewExceededObjectForUser ()
 get new exceeded objects for users More...
 
 getFreshlyStartedObjectsForUser ()
 Get freshly started objects. More...
 
 buildExceededMails ($users_with_exceeded_objects)
 
 buildFreshlyStartedMails ($users_with_freshly_started_objects)
 
 buildTopMailBody ($user_id, $language_variable)
 
 fillObjectListForMailBody ($objects, $tpl)
 
 getUserLanguage ($user_id)
 
 buildMailSalutation ($user_id, $tpl)
 
 sendExceededMail ($user_id, $ref_ids, $mail_body)
 
 sendFreshlyStartedMail ($user_id, $ref_ids, $mail_body)
 
 markExceededInDatabase ($user_id, $ref_ids)
 
 markFreshlyStartedInDatabase ($user_id, $ref_ids)
 
 getAlreadySentNotifications ($user_id, $for_exceeded=true)
 
 getInformationForRefId ($ref_id)
 
 getExceededObjectsForUser ($user_id)
 
 getObjectsWithTimingsForUser ($user_id)
 
 hasUserActivatedNotification ($user_id)
 
- Protected Member Functions inherited from ilCronJob
 checkSchedule ($a_ts_last_run, $a_schedule_type, $a_schedule_value)
 

Protected Attributes

 $log
 
 $lng
 
 $user_lang
 
 $db
 
 $obj_data_cache
 
 $users_with_exceeded_timings
 
 $users
 
 $now
 

Static Protected Attributes

static $objects_information
 
static $coaches_emails
 

Additional Inherited Members

- Data Fields inherited from ilCronJob
const SCHEDULE_TYPE_DAILY = 1
 
const SCHEDULE_TYPE_IN_MINUTES = 2
 
const SCHEDULE_TYPE_IN_HOURS = 3
 
const SCHEDULE_TYPE_IN_DAYS = 4
 
const SCHEDULE_TYPE_WEEKLY = 5
 
const SCHEDULE_TYPE_MONTHLY = 6
 
const SCHEDULE_TYPE_QUARTERLY = 7
 
const SCHEDULE_TYPE_YEARLY = 8
 

Detailed Description

Definition at line 4 of file class.ilTimingsCronReminder.php.

Constructor & Destructor Documentation

◆ __construct()

ilTimingsCronReminder::__construct ( )

Constructor.

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

References $DIC, $ilDB, and $lng.

61  {
62  global $DIC;
63  global $ilObjDataCache, $lng, $ilDB;
64 
65  $this->log = $DIC->logger()->crs();
66  $this->lng = $DIC->language();
67  $this->lng->loadLanguageModule('crs');
68  $this->db = $DIC->database();
69  $this->obj_data_cache = $DIC['ilObjDataCache'];
70 
71  self::$objects_information = array();
72  self::$coaches_emails = array();
73  $this->users_with_exceeded_timings = array();
74  $this->users = array();
75  $this->now = time();
76  }
global $DIC
Definition: saml.php:7
global $ilDB

Member Function Documentation

◆ buildExceededMails()

ilTimingsCronReminder::buildExceededMails (   $users_with_exceeded_objects)
protected
Parameters
array$users_with_exceeded_objects

Definition at line 257 of file class.ilTimingsCronReminder.php.

References $tpl, buildTopMailBody(), fillObjectListForMailBody(), and sendExceededMail().

Referenced by getNewExceededObjectForUser().

258  {
259  $this->log->debug('Start.');
260  if (is_array($users_with_exceeded_objects)) {
261  $this->log->debug('...found ' . count($users_with_exceeded_objects));
262  foreach ($users_with_exceeded_objects as $user_id => $exceeded_objects) {
263  $tpl = $this->buildTopMailBody($user_id, 'timings_cron_reminder_exceeded_start');
264  $has_exceeded = $this->fillObjectListForMailBody($exceeded_objects, $tpl);
265 
266  if ($has_exceeded) {
267  $this->sendExceededMail($user_id, $exceeded_objects, $tpl->get());
268  $this->log->debug('start sending exceeded mail to user: ' . $user_id);
269  }
270  }
271  } else {
272  $this->log->warning('no array given.');
273  }
274 
275  $this->log->debug('end.');
276  }
$tpl
Definition: ilias.php:10
sendExceededMail($user_id, $ref_ids, $mail_body)
buildTopMailBody($user_id, $language_variable)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildFreshlyStartedMails()

ilTimingsCronReminder::buildFreshlyStartedMails (   $users_with_freshly_started_objects)
protected
Parameters
array$users_with_freshly_started_objects

Definition at line 281 of file class.ilTimingsCronReminder.php.

References $tpl, buildTopMailBody(), fillObjectListForMailBody(), and sendFreshlyStartedMail().

Referenced by getFreshlyStartedObjectsForUser().

282  {
283  $this->log->debug('start.');
284  if (is_array($users_with_freshly_started_objects)) {
285  $this->log->debug('...found ' . sizeof($users_with_freshly_started_objects));
286  foreach ($users_with_freshly_started_objects as $user_id => $freshly_started_objects) {
287  $tpl = $this->buildTopMailBody($user_id, 'timings_cron_reminder_freshly_start');
288  $has_freshly_started = $this->fillObjectListForMailBody($freshly_started_objects, $tpl);
289 
290  if ($has_freshly_started) {
291  $this->sendFreshlyStartedMail($user_id, $freshly_started_objects, $tpl->get());
292  }
293  }
294  } else {
295  $this->log->debug('no array given.');
296  }
297 
298  $this->log->debug('end.');
299  }
$tpl
Definition: ilias.php:10
sendFreshlyStartedMail($user_id, $ref_ids, $mail_body)
buildTopMailBody($user_id, $language_variable)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildMailSalutation()

ilTimingsCronReminder::buildMailSalutation (   $user_id,
  $tpl 
)
protected
Parameters
$user_id
ilTemplate$tpl

Definition at line 358 of file class.ilTimingsCronReminder.php.

References $name, $tpl, and ilObjUser\_lookupName().

Referenced by buildTopMailBody().

359  {
360  $name = ilObjUser::_lookupName($user_id);
361  if (is_array($name)) {
362  $salutation = $this->user_lang->txt('mail_salutation_n') . ' ';
363  if ($name['gender'] != '') {
364  $salutation .= $this->user_lang->txt('salutation_' . $name['gender']) . ' ';
365  }
366  if ($name['title'] != '') {
367  $salutation .= $name['title'] . ' ';
368  }
369  $tpl->setVariable('SALUTATION', $salutation);
370  $tpl->setVariable('FIRSTNAME', $name['firstname']);
371  $tpl->setVariable('LASTNAME', $name['lastname']);
372  $this->log->debug('Salutation: ' . $salutation . ' Firstname: ' . $name['firstname'] . ' Lastname: ' . $name['lastname']);
373  } else {
374  $this->log->debug('did not get an array from _lookupName.');
375  }
376  }
static _lookupName($a_user_id)
lookup user name
$tpl
Definition: ilias.php:10
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildTopMailBody()

ilTimingsCronReminder::buildTopMailBody (   $user_id,
  $language_variable 
)
protected
Parameters
$user_id
$language_variable
Returns
ilTemplate

Definition at line 306 of file class.ilTimingsCronReminder.php.

References $tpl, buildMailSalutation(), and getUserLanguage().

Referenced by buildExceededMails(), and buildFreshlyStartedMails().

307  {
308  $this->log->debug('start...');
309  $tpl = new ilTemplate('tpl.crs_timings_cron_reminder_mail.html', true, true, 'Modules/Course');
310 
311  $this->getUserLanguage($user_id);
312  $this->buildMailSalutation($user_id, $tpl);
313  $tpl->setVariable('START_BODY', $this->user_lang->txt($language_variable));
314  $this->log->debug('for user: ' . $user_id . ' end.');
315  return $tpl;
316  }
$tpl
Definition: ilias.php:10
special template class to simplify handling of ITX/PEAR
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fillObjectListForMailBody()

ilTimingsCronReminder::fillObjectListForMailBody (   $objects,
  $tpl 
)
protected
Parameters
$objects
$tpl
Returns
bool

Definition at line 323 of file class.ilTimingsCronReminder.php.

References $tpl, and ilMail\_getInstallationSignature().

Referenced by buildExceededMails(), and buildFreshlyStartedMails().

324  {
325  $has_elements = false;
326  foreach ($objects as $object_id => $object_details) {
327  if ($object_details['type'] == 'fold') {
328  $tpl->setCurrentBlock('items');
329  $tpl->setVariable('HREF', $object_details['url']);
330  $tpl->setVariable('ITEM_TITLE', $object_details['title']);
331  $tpl->parseCurrentBlock();
332  $has_elements = true;
333  }
334  }
335 
336  $tpl->setVariable('INSTALLATION_SIGNATURE', \ilMail::_getInstallationSignature());
337 
338  $this->log->debug('found elements: ' . $has_elements);
339  return $has_elements;
340  }
$tpl
Definition: ilias.php:10
static _getInstallationSignature()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gatherUsers()

ilTimingsCronReminder::gatherUsers ( )
protected

Read all active users.

Definition at line 163 of file class.ilTimingsCronReminder.php.

References $now, $query, and $row.

Referenced by run().

164  {
165  $now = time();
166  $query = $this->db->queryF(
167  'SELECT usr_id FROM usr_data WHERE
168  (active = 1 AND time_limit_unlimited = 1) OR
169  (active = 1 AND time_limit_unlimited = 0 AND time_limit_from < %s AND time_limit_until > %s)',
170  array('integer', 'integer'),
171  array($now, $now)
172  );
173  while ($row = $this->db->fetchAssoc($query)) {
174  $usr_id = (int) $row['usr_id'];
175  $this->users[$usr_id] = $usr_id;
176  }
177  $this->log->debug('Found ' . count($this->users) . ' users.');
178  }
$query
$row
+ Here is the caller graph for this function:

◆ gatherUsersWithExceededTimings()

ilTimingsCronReminder::gatherUsersWithExceededTimings ( )
protected

Users with exceeded timings.

Definition at line 183 of file class.ilTimingsCronReminder.php.

References ilTimingsUser\lookupTimingsExceededByUser().

Referenced by run().

184  {
185  $this->users_with_exceeded_timings = ilTimingsUser::lookupTimingsExceededByUser($this->users);
186  $this->log->debug('Found ' . count($this->users_with_exceeded_timings) . ' users with exceeded timings.');
187  }
static lookupTimingsExceededByUser(array $a_user_ids)
Check if users currently exceeded ANY object.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAlreadySentNotifications()

ilTimingsCronReminder::getAlreadySentNotifications (   $user_id,
  $for_exceeded = true 
)
protected
Parameters
int$user_id
bool | true$for_exceeded
Returns
array

Definition at line 479 of file class.ilTimingsCronReminder.php.

References $result, $table, ilCourseConstants\CRON_TIMINGS_EXCEEDED_TABLE, and ilCourseConstants\CRON_TIMINGS_STARTED_TABLE.

Referenced by getFreshlyStartedObjectsForUser(), and getNewExceededObjectForUser().

480  {
481  $ref_ids = array();
483 
484  if (!$for_exceeded) {
486  }
487 
488  $result = $this->db->queryF(
489  'SELECT * FROM ' . $table . ' WHERE ' .
490  'user_id = %s',
491  array('integer'),
492  array($user_id)
493  );
494 
495  while ($record = $this->db->fetchAssoc($result)) {
496  $ref_ids[$record['ref_id']] = $record['ref_id'];
497  }
498 
499  return $ref_ids;
500  }
$result
if(empty($password)) $table
Definition: pwgen.php:24
+ Here is the caller graph for this function:

◆ getDefaultScheduleType()

ilTimingsCronReminder::getDefaultScheduleType ( )
Returns
int

Definition at line 105 of file class.ilTimingsCronReminder.php.

106  {
107  return self::SCHEDULE_TYPE_DAILY;
108  }

◆ getDefaultScheduleValue()

ilTimingsCronReminder::getDefaultScheduleValue ( )

Definition at line 110 of file class.ilTimingsCronReminder.php.

111  {
112  return;
113  }

◆ getDescription()

ilTimingsCronReminder::getDescription ( )
Returns
string

Definition at line 97 of file class.ilTimingsCronReminder.php.

98  {
99  return $this->lng->txt('timings_reminder_notifications_info');
100  }

◆ getExceededObjectsForUser()

ilTimingsCronReminder::getExceededObjectsForUser (   $user_id)
protected
Parameters
$user_id
Returns
array

Definition at line 528 of file class.ilTimingsCronReminder.php.

References ilTimingsUser\lookupTimings().

Referenced by getNewExceededObjectForUser().

529  {
530  $exceeded_obj_list = ilTimingsUser::lookupTimings(array($user_id), $arr = array(), true, true);
531  return $exceeded_obj_list;
532  }
static lookupTimings(array $a_user_ids, array &$a_meta=null, $a_only_exceeded=true)
Lookup references, users with exceeded timings.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFreshlyStartedObjectsForUser()

ilTimingsCronReminder::getFreshlyStartedObjectsForUser ( )
protected

Get freshly started objects.

Definition at line 221 of file class.ilTimingsCronReminder.php.

References $key, buildFreshlyStartedMails(), getAlreadySentNotifications(), getInformationForRefId(), and getObjectsWithTimingsForUser().

Referenced by run().

222  {
223  $users_with_new_started_object = array();
224 
225  if (is_array($this->users) && count($this->users) > 0) {
226  foreach ($this->users as $key => $user_id) {
227  $objects = $this->getObjectsWithTimingsForUser($user_id);
228  if (is_array($objects) && count($objects) > 0) {
229  $obj_data = array();
230  $already_notified = $this->getAlreadySentNotifications($user_id, false);
231  $this->log->debug('User_id ' . $user_id . ' was already notified for ' . sizeof($already_notified) . ' elements ');
232  $objects = array_diff_key($objects, $already_notified);
233  foreach ($objects as $ref_id => $v) {
234  $obj_data[$ref_id] = $this->getInformationForRefId($ref_id);
235 
236  if (is_array($objects[$ref_id])) {
237  if ((isset($objects[$ref_id]['end']) && isset($objects[$ref_id]['start'])) && $objects[$ref_id]['end'] > $this->now) {
238  if ($objects[$ref_id]['start'] < $this->now) {
239  $users_with_new_started_object[$user_id][$ref_id] = $obj_data[$ref_id];
240  }
241  } else {
242  $this->log->debug('End is already older than today no notification send for user_id ' . $user_id . ' on ref_id ' . $ref_id);
243  }
244  }
245  }
246  }
247  }
248  $this->log->debug('Found ' . count($users_with_new_started_object) . ' users with freshly started timings.');
249 
250  $this->buildFreshlyStartedMails($users_with_new_started_object);
251  }
252  }
getAlreadySentNotifications($user_id, $for_exceeded=true)
buildFreshlyStartedMails($users_with_freshly_started_objects)
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getId()

ilTimingsCronReminder::getId ( )
Returns
string

Definition at line 81 of file class.ilTimingsCronReminder.php.

82  {
83  return 'crs_timings_reminder';
84  }

◆ getInformationForRefId()

ilTimingsCronReminder::getInformationForRefId (   $ref_id)
protected
Parameters
$ref_id
Returns
mixed

Definition at line 506 of file class.ilTimingsCronReminder.php.

References $type, and ilLink\_getLink().

Referenced by getFreshlyStartedObjectsForUser(), and getNewExceededObjectForUser().

507  {
508  if (!array_key_exists($ref_id, self::$objects_information)) {
509  $obj_id = $this->obj_data_cache->lookupObjId($ref_id);
510  $type = $this->obj_data_cache->lookupType($obj_id);
511  $value = array( 'title' => $this->obj_data_cache->lookupTitle($obj_id),
512  'type' => $type,
513  'url' => ilLink::_getLink($ref_id, $type),
514  'obj_id' => $obj_id
515  );
516  self::$objects_information[$ref_id] = $value;
517 
518  $this->log->debug('ilTimingsCronReminder->getInformationForRefId: ...cached object information for => ' . $value['type'] . ' => ' . $value['title']);
519  }
520  return self::$objects_information[$ref_id];
521  }
$type
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNewExceededObjectForUser()

ilTimingsCronReminder::getNewExceededObjectForUser ( )
protected

get new exceeded objects for users

Definition at line 192 of file class.ilTimingsCronReminder.php.

References $key, buildExceededMails(), getAlreadySentNotifications(), getExceededObjectsForUser(), and getInformationForRefId().

Referenced by run().

193  {
194  $users_with_exceeded_objects = array();
195 
196  if (is_array($this->users_with_exceeded_timings) && count($this->users_with_exceeded_timings) > 0) {
197  foreach ($this->users_with_exceeded_timings as $key => $user_id) {
198  $objects = $this->getExceededObjectsForUser($user_id);
199  if (is_array($objects) && count($objects) > 0) {
200  $obj_data = array();
201  $already_notified = $this->getAlreadySentNotifications($user_id);
202  $objects = array_diff_key($objects, $already_notified);
203  foreach ($objects as $ref_id => $v) {
204  $detail_data = $this->getInformationForRefId($ref_id);
205  $obj_data[$ref_id] = $detail_data;
206  }
207  if (count($obj_data) > 0) {
208  $users_with_exceeded_objects[$user_id] = $obj_data;
209  }
210  }
211  }
212  $this->log->debug('Found ' . sizeof($users_with_exceeded_objects) . ' users with new exceeded timings.');
213 
214  $this->buildExceededMails($users_with_exceeded_objects);
215  }
216  }
buildExceededMails($users_with_exceeded_objects)
getAlreadySentNotifications($user_id, $for_exceeded=true)
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getObjectsWithTimingsForUser()

ilTimingsCronReminder::getObjectsWithTimingsForUser (   $user_id)
protected
Parameters
$user_id
Returns
array

Definition at line 538 of file class.ilTimingsCronReminder.php.

References ilTimingsUser\lookupTimings().

Referenced by getFreshlyStartedObjectsForUser().

539  {
540  $meta = array();
541  $timings_obj_list = ilTimingsUser::lookupTimings(array($user_id), $meta, false, true);
542  $meta = $meta[$user_id];
543  return $meta;
544  }
static lookupTimings(array $a_user_ids, array &$a_meta=null, $a_only_exceeded=true)
Lookup references, users with exceeded timings.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTitle()

ilTimingsCronReminder::getTitle ( )
Returns
string

Definition at line 89 of file class.ilTimingsCronReminder.php.

90  {
91  return $this->lng->txt('timings_reminder_notifications');
92  }

◆ getUserLanguage()

ilTimingsCronReminder::getUserLanguage (   $user_id)
protected
Parameters
$user_id

Definition at line 345 of file class.ilTimingsCronReminder.php.

References ilLanguageFactory\_getLanguageOfUser().

Referenced by buildTopMailBody().

346  {
347  $this->log->debug('start...');
348  $this->user_lang = ilLanguageFactory::_getLanguageOfUser($user_id);
349  $this->user_lang->loadLanguageModule('crs');
350  $this->user_lang->loadLanguageModule('mail');
351  $this->log->debug('user language for user ' . $user_id . ' is ' . $this->user_lang->getLangKey() . ' end.');
352  }
static _getLanguageOfUser($a_usr_id)
Get language object of user.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasAutoActivation()

ilTimingsCronReminder::hasAutoActivation ( )
Returns
bool

Definition at line 118 of file class.ilTimingsCronReminder.php.

119  {
120  return false;
121  }

◆ hasCustomSettings()

ilTimingsCronReminder::hasCustomSettings ( )
Returns
bool

Definition at line 134 of file class.ilTimingsCronReminder.php.

135  {
136  return false;
137  }

◆ hasFlexibleSchedule()

ilTimingsCronReminder::hasFlexibleSchedule ( )
Returns
bool

Definition at line 126 of file class.ilTimingsCronReminder.php.

127  {
128  return false;
129  }

◆ hasUserActivatedNotification()

ilTimingsCronReminder::hasUserActivatedNotification (   $user_id)
protected

Definition at line 546 of file class.ilTimingsCronReminder.php.

Referenced by sendExceededMail(), and sendFreshlyStartedMail().

547  {
548  return true;
549  }
+ Here is the caller graph for this function:

◆ markExceededInDatabase()

ilTimingsCronReminder::markExceededInDatabase (   $user_id,
  $ref_ids 
)
protected
Parameters
int$user_id
array$ref_ids

Definition at line 442 of file class.ilTimingsCronReminder.php.

References $data, and ilCourseConstants\CRON_TIMINGS_EXCEEDED_TABLE.

Referenced by sendExceededMail().

443  {
444  foreach ($ref_ids as $ref_id => $data) {
445  $this->db->manipulateF(
446  'INSERT INTO ' . ilCourseConstants::CRON_TIMINGS_EXCEEDED_TABLE . ' (user_id, ref_id, sent) VALUES ' .
447  ' (%s,%s,%s)',
448  array('integer', 'integer', 'integer'),
449  array($user_id, $ref_id, $this->now)
450  );
451 
452  $this->log->debug('ilTimingsCronReminder->markExceededInDatabase: Marked exceeded in Database. User ' . $user_id . ' ref_id ' . $ref_id);
453  }
454  }
$data
Definition: bench.php:6
+ Here is the caller graph for this function:

◆ markFreshlyStartedInDatabase()

ilTimingsCronReminder::markFreshlyStartedInDatabase (   $user_id,
  $ref_ids 
)
protected
Parameters
int$user_id
array$ref_ids

Definition at line 460 of file class.ilTimingsCronReminder.php.

References $data, and ilCourseConstants\CRON_TIMINGS_STARTED_TABLE.

Referenced by sendFreshlyStartedMail().

461  {
462  foreach ($ref_ids as $ref_id => $data) {
463  $this->db->manipulateF(
464  'INSERT INTO ' . ilCourseConstants::CRON_TIMINGS_STARTED_TABLE . ' (user_id, ref_id, sent) VALUES ' .
465  ' (%s,%s,%s)',
466  array('integer', 'integer', 'integer'),
467  array($user_id, $ref_id, $this->now)
468  );
469 
470  $this->log->debug('ilTimingsCronReminder->markFreshlyStartedInDatabase: Marked freshly started in Database. User ' . $user_id . ' ref_id ' . $ref_id);
471  }
472  }
$data
Definition: bench.php:6
+ Here is the caller graph for this function:

◆ run()

ilTimingsCronReminder::run ( )
Returns
ilCronJobResult

Definition at line 142 of file class.ilTimingsCronReminder.php.

References $result, gatherUsers(), gatherUsersWithExceededTimings(), getFreshlyStartedObjectsForUser(), getNewExceededObjectForUser(), and ilCronJobResult\STATUS_OK.

143  {
144  $this->log->debug('Start.');
145 
146  $result = new ilCronJobResult();
147 
148  $this->gatherUsers();
152 
154 
155  $this->log->debug('End');
156 
157  return $result;
158  }
getFreshlyStartedObjectsForUser()
Get freshly started objects.
$result
gatherUsers()
Read all active users.
gatherUsersWithExceededTimings()
Users with exceeded timings.
getNewExceededObjectForUser()
get new exceeded objects for users
Cron job result data container.
+ Here is the call graph for this function:

◆ sendExceededMail()

ilTimingsCronReminder::sendExceededMail (   $user_id,
  $ref_ids,
  $mail_body 
)
protected
Parameters
$user_id
$ref_ids
$mail_body

Definition at line 383 of file class.ilTimingsCronReminder.php.

References $login, ilObjUser\_lookupLogin(), hasUserActivatedNotification(), and markExceededInDatabase().

Referenced by buildExceededMails().

384  {
385  $login = \ilObjUser::_lookupLogin($user_id);
386  if ($login != '') {
387  $mail = new ilMail(ANONYMOUS_USER_ID);
388  if ($this->hasUserActivatedNotification($user_id)) {
389  $mail->sendMail(
390  $login,
391  '',
392  '',
393  $this->user_lang->txt('timings_cron_reminder_exceeded_subject'),
394  $mail_body,
395  [],
396  ['normal'],
397  true
398  );
399  $this->log->debug('...mail send for user ' . $user_id . ' to mail ' . $login . ' has exceeded timings for ' . $mail_body);
400  $this->markExceededInDatabase($user_id, $ref_ids);
401  } else {
402  $this->log->debug('... no mail was sent because user ' . $user_id . ' has deactivated their notifications and has no coaches assigned.');
403  }
404  } else {
405  $this->log->debug('Not send. User ' . $user_id . ' has no email.');
406  }
407  }
static _lookupLogin($a_user_id)
lookup login
markExceededInDatabase($user_id, $ref_ids)
$login
Definition: cron.php:13
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendFreshlyStartedMail()

ilTimingsCronReminder::sendFreshlyStartedMail (   $user_id,
  $ref_ids,
  $mail_body 
)
protected
Parameters
$user_id
$ref_ids
$mail_body

Definition at line 415 of file class.ilTimingsCronReminder.php.

References $login, ilObjUser\_lookupLogin(), hasUserActivatedNotification(), and markFreshlyStartedInDatabase().

Referenced by buildFreshlyStartedMails().

416  {
417  $login = \ilObjUser::_lookupLogin($user_id);
418 
419  if ($login != '' && $this->hasUserActivatedNotification($user_id)) {
420  $mail = new ilMail(ANONYMOUS_USER_ID);
421  $mail->sendMail(
422  $login,
423  '',
424  '',
425  $this->user_lang->txt('timings_cron_reminder_started_subject'),
426  $mail_body,
427  [],
428  ['normal'],
429  true
430  );
431  $this->log->debug('...mail send for user ' . $user_id . ' to mail ' . $login . ' has freshly started timings for ' . $mail_body);
432  $this->markFreshlyStartedInDatabase($user_id, $ref_ids);
433  } else {
434  $this->log->debug('Not send. User ' . $user_id . ' has no email.');
435  }
436  }
static _lookupLogin($a_user_id)
lookup login
markFreshlyStartedInDatabase($user_id, $ref_ids)
$login
Definition: cron.php:13
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $coaches_emails

ilTimingsCronReminder::$coaches_emails
staticprotected

Definition at line 50 of file class.ilTimingsCronReminder.php.

◆ $db

ilTimingsCronReminder::$db
protected

Definition at line 25 of file class.ilTimingsCronReminder.php.

◆ $lng

ilTimingsCronReminder::$lng
protected

Definition at line 15 of file class.ilTimingsCronReminder.php.

Referenced by __construct().

◆ $log

ilTimingsCronReminder::$log
protected

Definition at line 10 of file class.ilTimingsCronReminder.php.

◆ $now

ilTimingsCronReminder::$now
protected

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

Referenced by gatherUsers().

◆ $obj_data_cache

ilTimingsCronReminder::$obj_data_cache
protected

Definition at line 30 of file class.ilTimingsCronReminder.php.

◆ $objects_information

ilTimingsCronReminder::$objects_information
staticprotected

Definition at line 45 of file class.ilTimingsCronReminder.php.

◆ $user_lang

ilTimingsCronReminder::$user_lang
protected

Definition at line 20 of file class.ilTimingsCronReminder.php.

◆ $users

ilTimingsCronReminder::$users
protected

Definition at line 40 of file class.ilTimingsCronReminder.php.

◆ $users_with_exceeded_timings

ilTimingsCronReminder::$users_with_exceeded_timings
protected

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


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