ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 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 Attributes

ilLanguage $lng
 
ilDBInterface $db
 
ilSetting $setting
 
- Protected Attributes inherited from ILIAS\Cron\CronJob
JobScheduleType $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 29 of file class.ilConsultationHourCron.php.

Constructor & Destructor Documentation

◆ __construct()

ilConsultationHourCron::__construct ( )

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

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

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

Member Function Documentation

◆ addCustomSettingsToForm()

ilConsultationHourCron::addCustomSettingsToForm ( ilPropertyFormGUI  $a_form)

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

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

125  : void
126  {
127  $consultation_days = new ilNumberInputGUI($this->lng->txt('cal_ch_cron_reminder_days'), 'ch_reminder_days');
128  $consultation_days->setMinValue(1);
129  $consultation_days->setMaxLength(2);
130  $consultation_days->setSize(2);
131  $consultation_days->setValue((string) $this->setting->get('ch_reminder_days', '2'));
132  $consultation_days->setRequired(true);
133  $a_form->addItem($consultation_days);
134  }
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 60 of file class.ilConsultationHourCron.php.

61  {
62  return JobScheduleType::DAILY;
63  }

◆ getDefaultScheduleValue()

ilConsultationHourCron::getDefaultScheduleValue ( )

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

References null.

65  : ?int
66  {
67  return null;
68  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ getDescription()

ilConsultationHourCron::getDescription ( )

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

References ILIAS\Repository\lng().

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

◆ getId()

ilConsultationHourCron::getId ( )

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

45  : string
46  {
47  return "cal_consultation";
48  }

◆ getTitle()

ilConsultationHourCron::getTitle ( )

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

References ILIAS\Repository\lng().

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

◆ hasAutoActivation()

ilConsultationHourCron::hasAutoActivation ( )

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

70  : bool
71  {
72  return false;
73  }

◆ hasCustomSettings()

ilConsultationHourCron::hasCustomSettings ( )

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

80  : bool
81  {
82  return true;
83  }

◆ hasFlexibleSchedule()

ilConsultationHourCron::hasFlexibleSchedule ( )

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

75  : bool
76  {
77  return false;
78  }

◆ run()

ilConsultationHourCron::run ( )

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

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

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

◆ saveCustomSettings()

ilConsultationHourCron::saveCustomSettings ( ilPropertyFormGUI  $a_form)

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

References ilPropertyFormGUI\getInput().

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

◆ $lng

ilLanguage ilConsultationHourCron::$lng
protected

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

◆ $setting

ilSetting ilConsultationHourCron::$setting
protected

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


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