ILIAS  release_8 Revision v8.23
ilConsultationHourCron Class Reference

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

+ Inheritance diagram for ilConsultationHourCron:
+ Collaboration diagram for ilConsultationHourCron:

Public Member Functions

 __construct ()
 
 getId ()
 
 getTitle ()
 
 getDescription ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 hasAutoActivation ()
 
 hasFlexibleSchedule ()
 
 hasCustomSettings ()
 
 run ()
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 
- Public Member Functions inherited from ilCronJob
 setDateTimeProvider (?Closure $date_time_provider)
 
 isDue (?DateTimeImmutable $last_run, ?int $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 (?int $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 ()
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 
 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 Attributes

ilLanguage $lng
 
ilDBInterface $db
 
ilSetting $setting
 
- Protected Attributes inherited from ilCronJob
int $schedule_type = null
 
int $schedule_value = null
 
Closure $date_time_provider = null
 

Additional Inherited Members

- Data Fields inherited from ilCronJob
const SCHEDULE_TYPE_DAILY = 1
 This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_IN_MINUTES = 2
 This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_IN_HOURS = 3
 This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_IN_DAYS = 4
 This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_WEEKLY = 5
 This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_MONTHLY = 6
 This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_QUARTERLY = 7
 This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_YEARLY = 8
 This will be replaced with an ENUM in ILIAS 9 More...
 

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 Reminders for consultation hours

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

Definition at line 26 of file class.ilConsultationHourCron.php.

Constructor & Destructor Documentation

◆ __construct()

ilConsultationHourCron::__construct ( )

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

References $DIC, and ILIAS\Repository\lng().

33  {
34  global $DIC;
35 
36  $this->lng = $DIC->language();
37  $this->lng->loadLanguageModule('dateplaner');
38  $this->db = $DIC->database();
39  $this->setting = $DIC->settings();
40  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ addCustomSettingsToForm()

ilConsultationHourCron::addCustomSettingsToForm ( ilPropertyFormGUI  $a_form)

Definition at line 122 of file class.ilConsultationHourCron.php.

References ilPropertyFormGUI\addItem(), ILIAS\Repository\lng(), and ilNumberInputGUI\setMinValue().

122  : void
123  {
124  $consultation_days = new ilNumberInputGUI($this->lng->txt('cal_ch_cron_reminder_days'), 'ch_reminder_days');
125  $consultation_days->setMinValue(1);
126  $consultation_days->setMaxLength(2);
127  $consultation_days->setSize(2);
128  $consultation_days->setValue((string) $this->setting->get('ch_reminder_days', '2'));
129  $consultation_days->setRequired(true);
130  $a_form->addItem($consultation_days);
131  }
This class represents a number property in a property form.
setMinValue(float $a_minvalue, bool $a_display_always=false)
+ Here is the call graph for this function:

◆ getDefaultScheduleType()

ilConsultationHourCron::getDefaultScheduleType ( )

Definition at line 57 of file class.ilConsultationHourCron.php.

57  : int
58  {
59  return self::SCHEDULE_TYPE_DAILY;
60  }

◆ getDefaultScheduleValue()

ilConsultationHourCron::getDefaultScheduleValue ( )

Definition at line 62 of file class.ilConsultationHourCron.php.

62  : ?int
63  {
64  return null;
65  }

◆ getDescription()

ilConsultationHourCron::getDescription ( )

Definition at line 52 of file class.ilConsultationHourCron.php.

References ILIAS\Repository\lng().

52  : string
53  {
54  return $this->lng->txt("cal_ch_cron_reminder_info");
55  }
+ Here is the call graph for this function:

◆ getId()

ilConsultationHourCron::getId ( )

Definition at line 42 of file class.ilConsultationHourCron.php.

42  : string
43  {
44  return "cal_consultation";
45  }

◆ getTitle()

ilConsultationHourCron::getTitle ( )

Definition at line 47 of file class.ilConsultationHourCron.php.

References ILIAS\Repository\lng().

47  : string
48  {
49  return $this->lng->txt("cal_ch_cron_reminder");
50  }
+ Here is the call graph for this function:

◆ hasAutoActivation()

ilConsultationHourCron::hasAutoActivation ( )

Definition at line 67 of file class.ilConsultationHourCron.php.

67  : bool
68  {
69  return false;
70  }

◆ hasCustomSettings()

ilConsultationHourCron::hasCustomSettings ( )

Definition at line 77 of file class.ilConsultationHourCron.php.

77  : bool
78  {
79  return true;
80  }

◆ hasFlexibleSchedule()

ilConsultationHourCron::hasFlexibleSchedule ( )

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

72  : bool
73  {
74  return false;
75  }

◆ run()

ilConsultationHourCron::run ( )

Definition at line 82 of file class.ilConsultationHourCron.php.

References $query, $res, ilDBConstants\FETCHMODE_OBJECT, IL_CAL_DATETIME, IL_CAL_DAY, IL_CAL_UNIX, ILIAS\Repository\int(), ilCronJobResult\STATUS_NO_ACTION, ilCronJobResult\STATUS_OK, ilCalendarMailNotification\TYPE_BOOKING_REMINDER, and ilTimeZone\UTC.

83  {
85 
86  $days_before = (int) $this->setting->get('ch_reminder_days');
87  $now = new ilDateTime(time(), IL_CAL_UNIX);
88  $limit = clone $now;
89  $limit->increment(IL_CAL_DAY, $days_before);
90 
91  $counter = 0;
92  $query = 'SELECT * FROM booking_user ' .
93  'JOIN cal_entries ON entry_id = cal_id ' .
94  'WHERE notification_sent = ' . $this->db->quote(0, 'integer') . ' ' .
95  'AND starta > ' . $this->db->quote($now->get(IL_CAL_DATETIME, '', ilTimeZone::UTC), 'timestamp') . ' ' .
96  'AND starta <= ' . $this->db->quote($limit->get(IL_CAL_DATETIME, '', ilTimeZone::UTC), 'timestamp');
97  $res = $this->db->query($query);
98  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
99  $mail = new ilCalendarMailNotification();
100  $mail->setAppointmentId((int) $row->entry_id);
101  $mail->setRecipients(array((int) $row->user_id));
103  $mail->send();
104 
105  // update notification
106  $query = 'UPDATE booking_user ' .
107  'SET notification_sent = ' . $this->db->quote(1, 'integer') . ' ' .
108  'WHERE user_id = ' . $this->db->quote($row->user_id, 'integer') . ' ' .
109  'AND entry_id = ' . $this->db->quote($row->entry_id, 'integer');
110  $this->db->manipulate($query);
111  $counter++;
112  }
113 
114  if ($counter) {
115  $status = ilCronJobResult::STATUS_OK;
116  }
117  $result = new ilCronJobResult();
118  $result->setStatus($status);
119  return $result;
120  }
$res
Definition: ltiservices.php:69
const IL_CAL_DATETIME
Distributes calendar mail notifications.
const IL_CAL_UNIX
const IL_CAL_DAY
$query
+ Here is the call graph for this function:

◆ saveCustomSettings()

ilConsultationHourCron::saveCustomSettings ( ilPropertyFormGUI  $a_form)

Definition at line 133 of file class.ilConsultationHourCron.php.

References ilPropertyFormGUI\getInput().

133  : bool
134  {
135  $this->setting->set('ch_reminder_days', (string) $a_form->getInput('ch_reminder_days'));
136  return true;
137  }
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilDBInterface ilConsultationHourCron::$db
protected

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

◆ $lng

ilLanguage ilConsultationHourCron::$lng
protected

Definition at line 28 of file class.ilConsultationHourCron.php.

◆ $setting

ilSetting ilConsultationHourCron::$setting
protected

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


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