|
| 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) |
|
| checkSchedule ($a_ts_last_run, $a_schedule_type, $a_schedule_value) |
|
◆ __construct()
ilTimingsCronReminder::__construct |
( |
| ) |
|
Constructor.
Definition at line 60 of file class.ilTimingsCronReminder.php.
References $DIC, $ilDB, and $lng.
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'];
71 self::$objects_information = array();
72 self::$coaches_emails = array();
73 $this->users_with_exceeded_timings = array();
74 $this->users = array();
◆ 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().
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) {
268 $this->log->debug(
'start sending exceeded mail to user: ' . $user_id);
272 $this->log->warning(
'no array given.');
275 $this->log->debug(
'end.');
sendExceededMail($user_id, $ref_ids, $mail_body)
fillObjectListForMailBody($objects, $tpl)
buildTopMailBody($user_id, $language_variable)
◆ 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().
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) {
290 if ($has_freshly_started) {
295 $this->log->debug(
'no array given.');
298 $this->log->debug(
'end.');
sendFreshlyStartedMail($user_id, $ref_ids, $mail_body)
fillObjectListForMailBody($objects, $tpl)
buildTopMailBody($user_id, $language_variable)
◆ buildMailSalutation()
ilTimingsCronReminder::buildMailSalutation |
( |
|
$user_id, |
|
|
|
$tpl |
|
) |
| |
|
protected |
- Parameters
-
Definition at line 358 of file class.ilTimingsCronReminder.php.
References $name, $tpl, and ilObjUser\_lookupName().
Referenced by buildTopMailBody().
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']) .
' ';
366 if (
$name[
'title'] !=
'') {
367 $salutation .=
$name[
'title'] .
' ';
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']);
374 $this->log->debug(
'did not get an array from _lookupName.');
static _lookupName($a_user_id)
lookup user name
◆ buildTopMailBody()
ilTimingsCronReminder::buildTopMailBody |
( |
|
$user_id, |
|
|
|
$language_variable |
|
) |
| |
|
protected |
◆ fillObjectListForMailBody()
ilTimingsCronReminder::fillObjectListForMailBody |
( |
|
$objects, |
|
|
|
$tpl |
|
) |
| |
|
protected |
- Parameters
-
- Returns
- bool
Definition at line 323 of file class.ilTimingsCronReminder.php.
References $tpl, and ilMail\_getInstallationSignature().
Referenced by buildExceededMails(), and buildFreshlyStartedMails().
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;
338 $this->log->debug(
'found elements: ' . $has_elements);
339 return $has_elements;
static _getInstallationSignature()
◆ 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().
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'),
173 while (
$row = $this->db->fetchAssoc(
$query)) {
174 $usr_id = (int)
$row[
'usr_id'];
175 $this->users[$usr_id] = $usr_id;
177 $this->log->debug(
'Found ' . count($this->users) .
' users.');
◆ gatherUsersWithExceededTimings()
ilTimingsCronReminder::gatherUsersWithExceededTimings |
( |
| ) |
|
|
protected |
◆ getAlreadySentNotifications()
ilTimingsCronReminder::getAlreadySentNotifications |
( |
|
$user_id, |
|
|
|
$for_exceeded = true |
|
) |
| |
|
protected |
◆ getDefaultScheduleType()
ilTimingsCronReminder::getDefaultScheduleType |
( |
| ) |
|
◆ getDefaultScheduleValue()
ilTimingsCronReminder::getDefaultScheduleValue |
( |
| ) |
|
◆ getDescription()
ilTimingsCronReminder::getDescription |
( |
| ) |
|
◆ getExceededObjectsForUser()
ilTimingsCronReminder::getExceededObjectsForUser |
( |
|
$user_id | ) |
|
|
protected |
◆ 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().
223 $users_with_new_started_object = array();
225 if (is_array($this->users) && count($this->users) > 0) {
226 foreach ($this->users as
$key => $user_id) {
228 if (is_array($objects) && count($objects) > 0) {
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) {
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];
242 $this->log->debug(
'End is already older than today no notification send for user_id ' . $user_id .
' on ref_id ' . $ref_id);
248 $this->log->debug(
'Found ' . count($users_with_new_started_object) .
' users with freshly started timings.');
getAlreadySentNotifications($user_id, $for_exceeded=true)
buildFreshlyStartedMails($users_with_freshly_started_objects)
getInformationForRefId($ref_id)
getObjectsWithTimingsForUser($user_id)
◆ getId()
ilTimingsCronReminder::getId |
( |
| ) |
|
◆ getInformationForRefId()
ilTimingsCronReminder::getInformationForRefId |
( |
|
$ref_id | ) |
|
|
protected |
- Parameters
-
- Returns
- mixed
Definition at line 506 of file class.ilTimingsCronReminder.php.
References $type, and ilLink\_getLink().
Referenced by getFreshlyStartedObjectsForUser(), and getNewExceededObjectForUser().
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),
516 self::$objects_information[$ref_id] = $value;
518 $this->log->debug(
'ilTimingsCronReminder->getInformationForRefId: ...cached object information for => ' . $value[
'type'] .
' => ' . $value[
'title']);
520 return self::$objects_information[$ref_id];
static _getLink($a_ref_id, $a_type='', $a_params=array(), $append="")
◆ 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().
194 $users_with_exceeded_objects = array();
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) {
199 if (is_array($objects) && count($objects) > 0) {
202 $objects = array_diff_key($objects, $already_notified);
203 foreach ($objects as $ref_id => $v) {
205 $obj_data[$ref_id] = $detail_data;
207 if (count($obj_data) > 0) {
208 $users_with_exceeded_objects[$user_id] = $obj_data;
212 $this->log->debug(
'Found ' .
sizeof($users_with_exceeded_objects) .
' users with new exceeded timings.');
buildExceededMails($users_with_exceeded_objects)
getAlreadySentNotifications($user_id, $for_exceeded=true)
getExceededObjectsForUser($user_id)
getInformationForRefId($ref_id)
◆ getObjectsWithTimingsForUser()
ilTimingsCronReminder::getObjectsWithTimingsForUser |
( |
|
$user_id | ) |
|
|
protected |
◆ getTitle()
ilTimingsCronReminder::getTitle |
( |
| ) |
|
◆ getUserLanguage()
ilTimingsCronReminder::getUserLanguage |
( |
|
$user_id | ) |
|
|
protected |
- Parameters
-
Definition at line 345 of file class.ilTimingsCronReminder.php.
References ilLanguageFactory\_getLanguageOfUser().
Referenced by buildTopMailBody().
347 $this->log->debug(
'start...');
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.');
static _getLanguageOfUser($a_usr_id)
Get language object of user.
◆ hasAutoActivation()
ilTimingsCronReminder::hasAutoActivation |
( |
| ) |
|
◆ hasCustomSettings()
ilTimingsCronReminder::hasCustomSettings |
( |
| ) |
|
◆ hasFlexibleSchedule()
ilTimingsCronReminder::hasFlexibleSchedule |
( |
| ) |
|
◆ hasUserActivatedNotification()
ilTimingsCronReminder::hasUserActivatedNotification |
( |
|
$user_id | ) |
|
|
protected |
◆ 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().
444 foreach ($ref_ids as $ref_id =>
$data) {
445 $this->db->manipulateF(
448 array(
'integer',
'integer',
'integer'),
449 array($user_id, $ref_id, $this->now)
452 $this->log->debug(
'ilTimingsCronReminder->markExceededInDatabase: Marked exceeded in Database. User ' . $user_id .
' ref_id ' . $ref_id);
const CRON_TIMINGS_EXCEEDED_TABLE
◆ markFreshlyStartedInDatabase()
ilTimingsCronReminder::markFreshlyStartedInDatabase |
( |
|
$user_id, |
|
|
|
$ref_ids |
|
) |
| |
|
protected |
◆ run()
ilTimingsCronReminder::run |
( |
| ) |
|
◆ 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().
387 $mail =
new ilMail(ANONYMOUS_USER_ID);
393 $this->user_lang->txt(
'timings_cron_reminder_exceeded_subject'),
399 $this->log->debug(
'...mail send for user ' . $user_id .
' to mail ' .
$login .
' has exceeded timings for ' . $mail_body);
402 $this->log->debug(
'... no mail was sent because user ' . $user_id .
' has deactivated their notifications and has no coaches assigned.');
405 $this->log->debug(
'Not send. User ' . $user_id .
' has no email.');
static _lookupLogin($a_user_id)
lookup login
markExceededInDatabase($user_id, $ref_ids)
hasUserActivatedNotification($user_id)
◆ sendFreshlyStartedMail()
ilTimingsCronReminder::sendFreshlyStartedMail |
( |
|
$user_id, |
|
|
|
$ref_ids, |
|
|
|
$mail_body |
|
) |
| |
|
protected |
◆ $coaches_emails
ilTimingsCronReminder::$coaches_emails |
|
staticprotected |
◆ $db
ilTimingsCronReminder::$db |
|
protected |
◆ $lng
ilTimingsCronReminder::$lng |
|
protected |
◆ $log
ilTimingsCronReminder::$log |
|
protected |
◆ $now
ilTimingsCronReminder::$now |
|
protected |
◆ $obj_data_cache
ilTimingsCronReminder::$obj_data_cache |
|
protected |
◆ $objects_information
ilTimingsCronReminder::$objects_information |
|
staticprotected |
◆ $user_lang
ilTimingsCronReminder::$user_lang |
|
protected |
◆ $users
ilTimingsCronReminder::$users |
|
protected |
◆ $users_with_exceeded_timings
ilTimingsCronReminder::$users_with_exceeded_timings |
|
protected |
The documentation for this class was generated from the following file: