ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilConsultationHourCron Class Reference

Reminders for consultation hours. 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, ?CronJobScheduleType $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 (?CronJobScheduleType $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
CronJobScheduleType $schedule_type = null
 
int $schedule_value = null
 
Closure $date_time_provider = null
 

Detailed Description

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 27 of file class.ilConsultationHourCron.php.

Constructor & Destructor Documentation

◆ __construct()

ilConsultationHourCron::__construct ( )

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

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

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

Member Function Documentation

◆ addCustomSettingsToForm()

ilConsultationHourCron::addCustomSettingsToForm ( ilPropertyFormGUI  $a_form)

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

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

123  : void
124  {
125  $consultation_days = new ilNumberInputGUI($this->lng->txt('cal_ch_cron_reminder_days'), 'ch_reminder_days');
126  $consultation_days->setMinValue(1);
127  $consultation_days->setMaxLength(2);
128  $consultation_days->setSize(2);
129  $consultation_days->setValue((string) $this->setting->get('ch_reminder_days', '2'));
130  $consultation_days->setRequired(true);
131  $a_form->addItem($consultation_days);
132  }
+ Here is the call graph for this function:

◆ getDefaultScheduleType()

ilConsultationHourCron::getDefaultScheduleType ( )

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

59  {
60  return CronJobScheduleType::SCHEDULE_TYPE_DAILY;
61  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ getDefaultScheduleValue()

ilConsultationHourCron::getDefaultScheduleValue ( )

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

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

◆ getDescription()

ilConsultationHourCron::getDescription ( )

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

References ILIAS\Repository\lng().

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

◆ getId()

ilConsultationHourCron::getId ( )

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

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

◆ getTitle()

ilConsultationHourCron::getTitle ( )

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

References ILIAS\Repository\lng().

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

◆ hasAutoActivation()

ilConsultationHourCron::hasAutoActivation ( )

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

68  : bool
69  {
70  return false;
71  }

◆ hasCustomSettings()

ilConsultationHourCron::hasCustomSettings ( )

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

78  : bool
79  {
80  return true;
81  }

◆ hasFlexibleSchedule()

ilConsultationHourCron::hasFlexibleSchedule ( )

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

73  : bool
74  {
75  return false;
76  }

◆ run()

ilConsultationHourCron::run ( )

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

References $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.

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

◆ saveCustomSettings()

ilConsultationHourCron::saveCustomSettings ( ilPropertyFormGUI  $a_form)

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

References ilPropertyFormGUI\getInput().

134  : bool
135  {
136  $this->setting->set('ch_reminder_days', (string) $a_form->getInput('ch_reminder_days'));
137  return true;
138  }
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 30 of file class.ilConsultationHourCron.php.

◆ $lng

ilLanguage ilConsultationHourCron::$lng
protected

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

◆ $setting

ilSetting ilConsultationHourCron::$setting
protected

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


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