ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
4 include_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  {
36  return self::SCHEDULE_TYPE_DAILY;
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(ilDBConstants::FETCHMODE_OBJECT)) {
80  include_once 'Services/Calendar/classes/class.ilCalendarMailNotification.php';
81  $mail = new ilCalendarMailNotification();
82  $mail->setAppointmentId($row->entry_id);
83  $mail->setRecipients(array($row->user_id));
85  $mail->send();
86 
87  // update notification
88  $query = 'UPDATE booking_user ' .
89  'SET notification_sent = ' . $ilDB->quote(1, 'integer') . ' ' .
90  'WHERE user_id = ' . $ilDB->quote($row->user_id, 'integer') . ' ' .
91  'AND entry_id = ' . $ilDB->quote($row->entry_id, 'integer');
92  $ilDB->manipulate($query);
93 
94  $counter++;
95  }
96 
97  if ($counter) {
99  }
100  $result = new ilCronJobResult();
101  $result->setStatus($status);
102  return $result;
103  }
104 
106  {
107  global $lng, $ilSetting;
108 
109  $lng->loadLanguageModule('dateplaner');
110 
111  $consultation_days = new ilNumberInputGUI($lng->txt('cal_ch_cron_reminder_days'), 'ch_reminder_days');
112  $consultation_days->setMinValue(1);
113  $consultation_days->setMaxLength(2);
114  $consultation_days->setSize(2);
115  $consultation_days->setValue($ilSetting->get('ch_reminder_days', 2));
116  $consultation_days->setRequired(true);
117  $a_form->addItem($consultation_days);
118  }
119 
120  public function saveCustomSettings(ilPropertyFormGUI $a_form)
121  {
122  global $ilSetting;
123 
124  $ilSetting->set('ch_reminder_days', $a_form->getInput('ch_reminder_days'));
125 
126  return true;
127  }
128 }
const IL_CAL_DATETIME
$result
This class represents a property form user interface.
Cron job application base class.
Distributes calendar mail notifications.
addItem($a_item)
Add Item (Property, SectionHeader).
const IL_CAL_UNIX
$counter
const IL_CAL_DAY
setMinValue($a_minvalue, $a_display_always=false)
Set Minimum Value.
foreach($_POST as $key=> $value) $res
This class represents a number property in a property form.
Date and time handling
$query
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
Create styles array
The data for the language used.
addCustomSettingsToForm(ilPropertyFormGUI $a_form)
Reminders for consultation hours.
saveCustomSettings(ilPropertyFormGUI $a_form)
global $ilSetting
Definition: privfeed.php:17
global $lng
Definition: privfeed.php:17
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
Cron job result data container.