ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilConsultationHourCron.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once "Services/Cron/classes/class.ilCronJob.php";
5
12{
13 public function getId()
14 {
15 return "cal_consultation";
16 }
17
18 public function getTitle()
19 {
20 global $DIC;
21
22 $lng = $DIC['lng'];
23
24 $lng->loadLanguageModule('dateplaner');
25 return $lng->txt("cal_ch_cron_reminder");
26 }
27
28 public function getDescription()
29 {
30 global $DIC;
31
32 $lng = $DIC['lng'];
33
34 $lng->loadLanguageModule('dateplaner');
35 return $lng->txt("cal_ch_cron_reminder_info");
36 }
37
38 public function getDefaultScheduleType()
39 {
41 }
42
43 public function getDefaultScheduleValue()
44 {
45 return;
46 }
47
48 public function hasAutoActivation()
49 {
50 return false;
51 }
52
53 public function hasFlexibleSchedule()
54 {
55 return false;
56 }
57
58 public function hasCustomSettings()
59 {
60 return true;
61 }
62
63 public function run()
64 {
65 global $DIC;
66
67 $ilSetting = $DIC['ilSetting'];
68 $ilDB = $DIC['ilDB'];
69
71
72 $days_before = $ilSetting->get('ch_reminder_days');
73 $now = new ilDateTime(time(), IL_CAL_UNIX);
74
75 $limit = clone $now;
76 $limit->increment(IL_CAL_DAY, $days_before);
77
78 $counter = 0;
79
80 $query = 'SELECT * FROM booking_user ' .
81 'JOIN cal_entries ON entry_id = cal_id ' .
82 'WHERE notification_sent = ' . $ilDB->quote(0, 'integer') . ' ' .
83 'AND starta > ' . $ilDB->quote($now->get(IL_CAL_DATETIME, '', ilTimeZone::UTC), 'timestamp') . ' ' .
84 'AND starta <= ' . $ilDB->quote($limit->get(IL_CAL_DATETIME, '', ilTimeZone::UTC), 'timestamp');
85 $res = $ilDB->query($query);
86 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
87 include_once 'Services/Calendar/classes/class.ilCalendarMailNotification.php';
88 $mail = new ilCalendarMailNotification();
89 $mail->setAppointmentId($row->entry_id);
90 $mail->setRecipients(array($row->user_id));
92 $mail->send();
93
94 // update notification
95 $query = 'UPDATE booking_user ' .
96 'SET notification_sent = ' . $ilDB->quote(1, 'integer') . ' ' .
97 'WHERE user_id = ' . $ilDB->quote($row->user_id, 'integer') . ' ' .
98 'AND entry_id = ' . $ilDB->quote($row->entry_id, 'integer');
99 $ilDB->manipulate($query);
100
101 $counter++;
102 }
103
104 if ($counter) {
106 }
107 $result = new ilCronJobResult();
108 $result->setStatus($status);
109 return $result;
110 }
111
113 {
114 global $DIC;
115
116 $lng = $DIC['lng'];
117 $ilSetting = $DIC['ilSetting'];
118
119 $lng->loadLanguageModule('dateplaner');
120
121 $consultation_days = new ilNumberInputGUI($lng->txt('cal_ch_cron_reminder_days'), 'ch_reminder_days');
122 $consultation_days->setMinValue(1);
123 $consultation_days->setMaxLength(2);
124 $consultation_days->setSize(2);
125 $consultation_days->setValue($ilSetting->get('ch_reminder_days', 2));
126 $consultation_days->setRequired(true);
127 $a_form->addItem($consultation_days);
128 }
129
130 public function saveCustomSettings(ilPropertyFormGUI $a_form)
131 {
132 global $DIC;
133
134 $ilSetting = $DIC['ilSetting'];
135
136 $ilSetting->set('ch_reminder_days', $a_form->getInput('ch_reminder_days'));
137
138 return true;
139 }
140}
$result
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
const IL_CAL_DATETIME
const IL_CAL_DAY
Distributes calendar mail notifications.
Reminders for consultation hours.
hasCustomSettings()
Has cron job any custom setting which can be edited?
getDefaultScheduleValue()
Get schedule value.
saveCustomSettings(ilPropertyFormGUI $a_form)
Save custom settings.
hasAutoActivation()
Is to be activated on "installation".
addCustomSettingsToForm(ilPropertyFormGUI $a_form)
Add custom settings to form.
getDefaultScheduleType()
Get schedule type.
hasFlexibleSchedule()
Can the schedule be configured?
Cron job result data container.
Cron job application base class.
const SCHEDULE_TYPE_DAILY
@classDescription Date and time handling
This class represents a number property in a property form.
This class represents a property form user interface.
addItem($a_item)
Add Item (Property, SectionHeader).
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
global $DIC
Definition: goto.php:24
global $ilSetting
Definition: privfeed.php:17
$query
$lng
foreach($_POST as $key=> $value) $res
global $ilDB