ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 $lng;
21
22 $lng->loadLanguageModule('dateplaner');
23 return $lng->txt("cal_ch_cron_reminder");
24 }
25
26 public function getDescription()
27 {
28 global $lng;
29
30 $lng->loadLanguageModule('dateplaner');
31 return $lng->txt("cal_ch_cron_reminder_info");
32 }
33
34 public function getDefaultScheduleType()
35 {
37 }
38
39 public function getDefaultScheduleValue()
40 {
41 return;
42 }
43
44 public function hasAutoActivation()
45 {
46 return false;
47 }
48
49 public function hasFlexibleSchedule()
50 {
51 return false;
52 }
53
54 public function hasCustomSettings()
55 {
56 return true;
57 }
58
59 public function run()
60 {
61 global $ilSetting, $ilDB;
62
64
65 $days_before = $ilSetting->get('ch_reminder_days');
66 $now = new ilDateTime(time(),IL_CAL_UNIX);
67
68 $limit = clone $now;
69 $limit->increment(IL_CAL_DAY,$days_before);
70
71 $counter = 0;
72
73 $query = 'SELECT * FROM booking_user '.
74 'JOIN cal_entries ON entry_id = cal_id '.
75 'WHERE notification_sent = '.$ilDB->quote(0,'integer').' '.
76 'AND starta > '.$ilDB->quote($now->get(IL_CAL_DATETIME,'', ilTimeZone::UTC),'timestamp'). ' '.
77 'AND starta <= '.$ilDB->quote($limit->get(IL_CAL_DATETIME, '', ilTimeZone::UTC),'timestamp');
78 $res = $ilDB->query($query);
79 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
80 {
81 include_once 'Services/Calendar/classes/class.ilCalendarMailNotification.php';
82 $mail = new ilCalendarMailNotification();
83 $mail->setAppointmentId($row->entry_id);
84 $mail->setRecipients(array($row->user_id));
86 $mail->send();
87
88 // update notification
89 $query = 'UPDATE booking_user '.
90 'SET notification_sent = '.$ilDB->quote(1,'integer').' '.
91 'WHERE user_id = '.$ilDB->quote($row->user_id,'integer').' '.
92 'AND entry_id = '.$ilDB->quote($row->entry_id,'integer');
93 $ilDB->manipulate($query);
94
95 $counter++;
96 }
97
98 if($counter)
99 {
101 }
102 $result = new ilCronJobResult();
103 $result->setStatus($status);
104 return $result;
105 }
106
108 {
109 global $lng, $ilSetting;
110
111 $lng->loadLanguageModule('dateplaner');
112
113 $consultation_days = new ilNumberInputGUI($lng->txt('cal_ch_cron_reminder_days'),'ch_reminder_days');
114 $consultation_days->setMinValue(1);
115 $consultation_days->setMaxLength(2);
116 $consultation_days->setSize(2);
117 $consultation_days->setValue($ilSetting->get('ch_reminder_days',2));
118 $consultation_days->setRequired(true);
119 $a_form->addItem($consultation_days);
120 }
121
122 public function saveCustomSettings(ilPropertyFormGUI $a_form)
123 {
124 global $ilSetting;
125
126 $ilSetting->set('ch_reminder_days', $a_form->getInput('ch_reminder_days'));
127
128 return true;
129 }
130}
131
132?>
$result
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
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 $lng
Definition: privfeed.php:40
global $ilSetting
Definition: privfeed.php:40
global $ilDB