ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilBookingEntry.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
14 {
18  protected $db;
19 
23  protected $user;
24 
25  private $id = 0;
26  private $obj_id = 0;
27 
28  private $deadline = 0;
29  private $num_bookings = 1;
30  private $target_obj_ids = array();
31  private $booking_group = 0;
32 
33 
37  public function __construct($a_booking_id = 0)
38  {
39  global $DIC;
40 
41  $this->db = $DIC->database();
42  $this->user = $DIC->user();
43  $this->setId($a_booking_id);
44  if ($this->getId()) {
45  $this->read();
46  }
47  }
48 
55  public static function resetGroup($a_group_id)
56  {
57  global $DIC;
58 
59  $ilDB = $DIC->database();
60 
61  $query = 'UPDATE booking_entry SET booking_group = ' . $ilDB->quote(0, 'integer') . ' ' .
62  'WHERE booking_group = ' . $ilDB->quote($a_group_id, 'integer');
63  $ilDB->manipulate($query);
64  return true;
65  }
66 
72  public static function lookupBookingsOfUser($a_app_ids, $a_usr_id, ilDateTime $start = null)
73  {
74  global $DIC;
75 
76  $ilDB = $DIC->database();
77 
78  $query = 'SELECT entry_id FROM booking_user ' .
79  'WHERE ' . $ilDB->in('entry_id', $a_app_ids, false, 'integer') . ' ' .
80  'AND user_id = ' . $ilDB->quote($a_usr_id, 'integer');
81 
82  $res = $ilDB->query($query);
83 
84  $booked_entries = array();
85  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
86  $booked_entries[] = $row->entry_id;
87  }
88  return $booked_entries;
89  }
90 
96  protected function setId($a_id)
97  {
98  $this->id = (int) $a_id;
99  }
100 
105  public function getId()
106  {
107  return $this->id;
108  }
109 
110  public function setBookingGroup($a_id)
111  {
112  $this->booking_group = $a_id;
113  }
114 
115  public function getBookingGroup()
116  {
117  return $this->booking_group;
118  }
119 
125  public function setObjId($a_id)
126  {
127  $this->obj_id = (int) $a_id;
128  }
129 
134  public function getObjId()
135  {
136  return $this->obj_id;
137  }
138 
144  public function setDeadlineHours($a_hours)
145  {
146  $this->deadline = (int) $a_hours;
147  }
148 
153  public function getDeadlineHours()
154  {
155  return $this->deadline;
156  }
157 
163  public function setNumberOfBookings($a_num)
164  {
165  $this->num_bookings = (int) $a_num;
166  }
167 
172  public function getNumberOfBookings()
173  {
174  return $this->num_bookings;
175  }
176 
182  public function setTargetObjIds($a_obj_id)
183  {
184  $this->target_obj_ids = $a_obj_id;
185  }
186 
191  public function getTargetObjIds()
192  {
193  return $this->target_obj_ids;
194  }
195 
200  public function isTargetObjectVisible($a_ref_id)
201  {
202  // no course/group filter
203  if (!$this->getTargetObjIds()) {
204  return true;
205  }
206 
207  $obj_id = ilObject::_lookupObjId($a_ref_id);
208  return in_array($obj_id, $this->getTargetObjIds());
209  }
210 
215  public function save()
216  {
217  $ilDB = $this->db;
218 
219  $this->setId($ilDB->nextId('booking_entry'));
220  $query = 'INSERT INTO booking_entry (booking_id,obj_id,deadline,num_bookings,booking_group) ' .
221  "VALUES ( " .
222  $ilDB->quote($this->getId(), 'integer') . ', ' .
223  $ilDB->quote($this->getObjId(), 'integer') . ', ' .
224  $ilDB->quote($this->getDeadlineHours(), 'integer') . ', ' .
225  $ilDB->quote($this->getNumberOfBookings(), 'integer') . ',' .
226  $ilDB->quote($this->getBookingGroup(), 'integer') . ' ' .
227  ") ";
228  $ilDB->manipulate($query);
229 
230  foreach ((array) $this->target_obj_ids as $obj_id) {
231  $query = 'INSERT INTO booking_obj_assignment (booking_id, target_obj_id) ' .
232  'VALUES( ' .
233  $ilDB->quote($this->getId(), 'integer') . ', ' .
234  $ilDB->quote($obj_id, 'integer') . ' ' .
235  ')';
236  $ilDB->manipulate($query);
237  }
238  return true;
239  }
240 
245  public function update()
246  {
247  $ilDB = $this->db;
248 
249  if (!$this->getId()) {
250  return false;
251  }
252 
253  $query = "UPDATE booking_entry SET " .
254  " obj_id = " . $ilDB->quote($this->getObjId(), 'integer') . ", " .
255  " deadline = " . $ilDB->quote($this->getDeadlineHours(), 'integer') . ", " .
256  " num_bookings = " . $ilDB->quote($this->getNumberOfBookings(), 'integer') . ', ' .
257  'booking_group = ' . $ilDB->quote($this->getBookingGroup(), 'integer') . ' ' .
258  'WHERE booking_id = ' . $ilDB->quote($this->getId(), 'integer');
259  $ilDB->manipulate($query);
260 
261  // obj assignments
262  $query = 'DELETE FROM booking_obj_assignment ' .
263  'WHERE booking_id = ' . $ilDB->quote($this->getId(), 'integer');
264  $ilDB->manipulate($query);
265 
266  foreach ((array) $this->target_obj_ids as $obj_id) {
267  $query = 'INSERT INTO booking_obj_assignment (booking_id, target_obj_id) ' .
268  'VALUES( ' .
269  $ilDB->quote($this->getId(), 'integer') . ', ' .
270  $ilDB->quote($obj_id, 'integer') . ' ' .
271  ')';
272  $ilDB->manipulate($query);
273  }
274  return true;
275  }
276 
281  public function delete()
282  {
283  $ilDB = $this->db;
284 
285  $query = "DELETE FROM booking_entry " .
286  "WHERE booking_id = " . $ilDB->quote($this->getId(), 'integer');
287  $ilDB->manipulate($query);
288 
289  $query = 'DELETE FROM booking_obj_assignment ' .
290  'WHERE booking_id = ' . $ilDB->quote($this->getId(), 'integer');
291  $ilDB->manipulate($query);
292 
293  return true;
294  }
295 
300  protected function read()
301  {
302  $ilDB = $this->db;
303 
304  if (!$this->getId()) {
305  return false;
306  }
307 
308  $query = "SELECT * FROM booking_entry " .
309  "WHERE booking_id = " . $ilDB->quote($this->getId(), 'integer');
310  $res = $ilDB->query($query);
311  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
312  $this->setObjId($row['obj_id']);
313  $this->setDeadlineHours($row['deadline']);
314  $this->setNumberOfBookings($row['num_bookings']);
315  $this->setBookingGroup($row['booking_group']);
316  }
317 
318  $query = 'SELECT * FROM booking_obj_assignment ' .
319  'WHERE booking_id = ' . $ilDB->quote($this->getId(), 'integer');
320  $res = $ilDB->query($query);
321 
322  $this->target_obj_ids = array();
323  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
324  $this->target_obj_ids[] = $row->target_obj_id;
325  }
326 
327  return true;
328  }
329 
335  public function isOwner($a_user_id = null)
336  {
338 
339  if (!$a_user_id) {
340  $a_user_id = $ilUser->getId();
341  }
342 
343  if ($this->getObjId() == $a_user_id) {
344  return true;
345  }
346  return false;
347  }
348 
352  public static function removeObsoleteEntries()
353  {
354  global $DIC;
355 
356  $ilDB = $DIC->database();
357 
358  $set = $ilDB->query('SELECT DISTINCT(context_id) FROM cal_entries e' .
359  ' JOIN cal_cat_assignments a ON (e.cal_id = a.cal_id)' .
360  ' JOIN cal_categories c ON (a.cat_id = c.cat_id) WHERE c.type = ' . $ilDB->quote(ilCalendarCategory::TYPE_CH, 'integer'));
361 
362  $used = array();
363  while ($row = $ilDB->fetchAssoc($set)) {
364  $used[] = $row['context_id'];
365  }
366 
367  $ilDB->query($q = 'DELETE FROM booking_entry WHERE ' . $ilDB->in('booking_id', $used, true, 'integer'));
368  $ilDB->query($q = 'DELETE FROM booking_obj_assignment WHERE ' . $ilDB->in('booking_id', $used, true, 'integer'));
369  }
370 
376  public static function getInstanceByCalendarEntryId($a_id)
377  {
378  include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
379  $cal_entry = new ilCalendarEntry($a_id);
380  $booking_id = $cal_entry->getContextId();
381  if ($booking_id) {
382  return new self($booking_id);
383  }
384  }
385 
393  public static function isBookable(array $a_obj_ids, $a_target_obj_id = null)
394  {
395  global $DIC;
396 
397  $ilDB = $DIC->database();
398 
399  if ($a_target_obj_id) {
400  $query = 'SELECT DISTINCT(obj_id) FROM booking_entry be ' .
401  'JOIN booking_obj_assignment bo ON be.booking_id = bo.booking_id ' .
402  'WHERE ' . $ilDB->in('obj_id', $a_obj_ids, false, 'integer') . ' ' .
403  'AND bo.target_obj_id = ' . $ilDB->quote($a_target_obj_id, 'integer');
404  } else {
405  $query = 'SELECT DISTINCT(obj_id) FROM booking_entry be ' .
406  'WHERE ' . $ilDB->in('obj_id', $a_obj_ids, false, 'integer') . ' ';
407  }
408 
409  $res = $ilDB->query($query);
410  $all = array();
411  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
412  $all[] = $row->obj_id;
413  }
414  return $all;
415  }
416 
425  public static function lookupBookableUsersForObject($a_obj_id, $a_user_ids)
426  {
427  global $DIC;
428 
429  $ilDB = $DIC->database();
430 
431  $query = 'SELECT be.obj_id bobj FROM booking_entry be ' .
432  'JOIN booking_obj_assignment bo ON be.booking_id = bo.booking_id ' .
433  'JOIN cal_entries ce on be.booking_id = ce.context_id ' .
434  'JOIN cal_cat_assignments cca on ce.cal_id = cca.cal_id ' .
435  'JOIN cal_categories cc on cca.cat_id = cc.cat_id ' .
436  'WHERE ' . $ilDB->in('be.obj_id', (array) $a_user_ids, false, 'integer') . ' ' .
437  'AND ' . $ilDB->in('bo.target_obj_id', (array) $a_obj_id, false, 'integer') . ' ' .
438  'AND cc.obj_id = be.obj_id ' .
439  'AND cc.type = ' . $ilDB->quote(ilCalendarCategory::TYPE_CH, 'integer') . ' ';
440 
441  $res = $ilDB->query($query);
442 
443  $objs = array();
444  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
445  if (!in_array($row->bobj, $objs)) {
446  $objs[] = $row->bobj;
447  }
448  }
449 
450  // non filtered booking entries
451  $query = 'SELECT be.obj_id bobj FROM booking_entry be ' .
452  'LEFT JOIN booking_obj_assignment bo ON be.booking_id = bo.booking_id ' .
453  'JOIN cal_entries ce on be.booking_id = ce.context_id ' .
454  'JOIN cal_cat_assignments cca on ce.cal_id = cca.cal_id ' .
455  'JOIN cal_categories cc on cca.cat_id = cc.cat_id ' .
456  'WHERE bo.booking_id IS NULL ' .
457  'AND ' . $ilDB->in('be.obj_id', (array) $a_user_ids, false, 'integer') . ' ' .
458  'AND cc.obj_id = be.obj_id ' .
459  'AND cc.type = ' . $ilDB->quote(ilCalendarCategory::TYPE_CH, 'integer') . ' ';
460 
461 
462  $res = $ilDB->query($query);
463  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
464  if (!in_array($row->bobj, $objs)) {
465  $objs[] = $row->bobj;
466  }
467  }
468 
469  return $objs;
470  }
471 
477  public static function hasObjectBookingEntries($a_obj_id, $a_usr_id)
478  {
479  global $DIC;
480 
481  $ilDB = $DIC->database();
482 
483  $user_restriction = '';
484  if ($a_usr_id) {
485  $user_restriction = 'AND obj_id = ' . $ilDB->quote($a_usr_id) . ' ';
486  }
487 
488 
489  $query = 'SELECT be.booking_id FROM booking_entry be ' .
490  'JOIN booking_obj_assignment bo ON be.booking_id = bo.booking_id ' .
491  'WHERE bo.target_obj_id = ' . $ilDB->quote($a_obj_id, 'integer') . ' ' .
492  $user_restriction;
493 
494  $res = $ilDB->query($query);
495  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
496  return true;
497  }
498  return false;
499  }
500 
501  public static function lookupBookingMessage($a_entry_id, $a_usr_id)
502  {
503  global $DIC;
504 
505  $ilDB = $DIC->database();
506 
507  $query = 'SELECT * from booking_user ' .
508  'WHERE entry_id = ' . $ilDB->quote($a_entry_id, 'integer') . ' ' .
509  'AND user_id = ' . $ilDB->quote($a_usr_id, 'integer');
510  $res = $ilDB->query($query);
511  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
512  return $row->booking_message;
513  }
514  return '';
515  }
516 
523  public static function writeBookingMessage($a_entry_id, $a_usr_id, $a_message)
524  {
525  global $DIC;
526 
527  $ilDB = $DIC->database();
528 
529  $query = 'UPDATE booking_user SET ' .
530  'booking_message = ' . $ilDB->quote($a_message, 'text') . ' ' .
531  'WHERE entry_id = ' . $ilDB->quote($a_entry_id, 'integer') . ' ' .
532  'AND user_id = ' . $ilDB->quote($a_usr_id, 'integer');
533 
534  $GLOBALS['ilLog']->write(__METHOD__ . ': ' . $query);
535 
536  $ilDB->manipulate($query);
537  return true;
538  }
539 
545  public function getCurrentNumberOfBookings($a_entry_id)
546  {
547  $ilDB = $this->db;
548 
549  $set = $ilDB->query('SELECT COUNT(*) AS counter FROM booking_user' .
550  ' WHERE entry_id = ' . $ilDB->quote($a_entry_id, 'integer'));
551  $row = $ilDB->fetchAssoc($set);
552  return (int) $row['counter'];
553  }
554 
560  public function getCurrentBookings($a_entry_id)
561  {
562  $ilDB = $this->db;
563 
564  $set = $ilDB->query('SELECT user_id FROM booking_user' .
565  ' WHERE entry_id = ' . $ilDB->quote($a_entry_id, 'integer'));
566  $res = array();
567  while ($row = $ilDB->fetchAssoc($set)) {
568  $res[] = $row['user_id'];
569  }
570  return $res;
571  }
572 
579  public static function lookupBookingsForAppointment($a_app_id)
580  {
581  global $DIC;
582 
583  $ilDB = $DIC->database();
584 
585  $query = 'SELECT user_id FROM booking_user ' .
586  'WHERE entry_id = ' . $ilDB->quote($a_app_id, 'integer');
587  $res = $ilDB->query($query);
588 
589  $users = array();
590  while ($row = $ilDB->fetchObject($res)) {
591  $users[] = $row->user_id;
592  }
593  return $users;
594  }
595 
602  public static function lookupBookingsForObject($a_obj_id, $a_usr_id)
603  {
604  global $DIC;
605 
606  $ilDB = $DIC->database();
607 
608 
609  $query = 'SELECT bu.user_id, starta, enda FROM booking_user bu ' .
610  'JOIN cal_entries ca ON entry_id = ca.cal_id ' .
611  'JOIN booking_entry be ON context_id = booking_id ' .
612  'JOIN booking_obj_assignment bo ON be.booking_id = bo.booking_id ' .
613  'WHERE bo.target_obj_id = ' . $ilDB->quote($a_obj_id, 'integer') . ' ' .
614  'AND be.obj_id = ' . $ilDB->quote($a_usr_id) . ' ' .
615  'ORDER BY starta';
616  $res = $ilDB->query($query);
617 
618  $bookings = array();
619  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
620  $dt = new ilDateTime($row->starta, IL_CAL_DATETIME, ilTimeZone::UTC);
621  $dt_end = new ilDateTime($row->enda, IL_CAL_DATETIME, ilTimeZone::UTC);
622  $bookings[$row->user_id][] = array(
623  'dt' => $dt->get(IL_CAL_UNIX),
624  'dtend' => $dt_end->get(IL_CAL_UNIX),
625  'owner' => $a_usr_id);
626  }
627  return $bookings;
628  }
629 
636  public static function lookupManagedBookingsForObject($a_obj_id, $a_usr_id)
637  {
638  $bookings = self::lookupBookingsForObject($a_obj_id, $a_usr_id);
639  include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourUtils.php';
640  foreach (ilConsultationHourUtils::lookupManagedUsers($a_usr_id) as $managed_user_id) {
641  foreach (self::lookupBookingsForObject($a_obj_id, $managed_user_id) as $booked_user => $booking) {
642  $fullname = ilObjUser::_lookupFullname($managed_user_id);
643  foreach ($booking as $booking_entry) {
644  $booking_entry['explanation'] = '(' . $fullname . ')';
645  $bookings[$booked_user][] = $booking_entry;
646  }
647  }
648  }
649  return $bookings;
650  }
651 
652 
659  public function hasBooked($a_entry_id, $a_user_id = null)
660  {
662  $ilDB = $this->db;
663 
664  if (!$a_user_id) {
665  $a_user_id = $ilUser->getId();
666  }
667 
668  $query = 'SELECT COUNT(*) AS counter FROM booking_user' .
669  ' WHERE entry_id = ' . $ilDB->quote($a_entry_id, 'integer') .
670  ' AND user_id = ' . $ilDB->quote($a_user_id, 'integer');
671  $set = $ilDB->query($query);
672  $row = $ilDB->fetchAssoc($set);
673 
674  return (bool) $row['counter'];
675  }
676 
683  public function isBookedOut($a_entry_id, $a_check_current_user = false)
684  {
686 
687  if ($this->getNumberOfBookings() == $this->getCurrentNumberOfBookings($a_entry_id)) {
688  // check against current user
689  if ($a_check_current_user) {
690  if ($this->hasBooked($a_entry_id)) {
691  return false;
692  }
693  if ($ilUser->getId() == $this->getObjId()) {
694  return false;
695  }
696  }
697  return true;
698  }
699 
700  $deadline = $this->getDeadlineHours();
701  if ($deadline) {
702  include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
703  $entry = new ilCalendarEntry($a_entry_id);
704  if (time()+($deadline*60*60) > $entry->getStart()->get(IL_CAL_UNIX)) {
705  return true;
706  }
707  }
708  return false;
709  }
710 
717  public function isAppointmentBookableForUser($a_app_id, $a_user_id)
718  {
719  // #12025
720  if ($a_user_id == ANONYMOUS_USER_ID) {
721  return false;
722  }
723 
724  // Check max bookings
725  if ($this->getNumberOfBookings() <= $this->getCurrentNumberOfBookings($a_app_id)) {
726  #$GLOBALS['ilLog']->write(__METHOD__.': Number of bookings exceeded');
727  return false;
728  }
729 
730  // Check deadline
731  $dead_limit = new ilDateTime(time(), IL_CAL_UNIX);
732  $dead_limit->increment(IL_CAL_HOUR, $this->getDeadlineHours());
733 
734  include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
735  $entry = new ilCalendarEntry($a_app_id);
736  if (ilDateTime::_after($dead_limit, $entry->getStart())) {
737  #$GLOBALS['ilLog']->write(__METHOD__.': Deadline reached');
738  return false;
739  }
740 
741  // Check group restrictions
742  if (!$this->getBookingGroup()) {
743  #$GLOBALS['ilLog']->write(__METHOD__.': No booking group');
744  return true;
745  }
746  include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourAppointments.php';
748  $this->getObjId(),
749  $this->getBookingGroup()
750  );
751 
752  // Number of bookings in group
753  $bookings = self::lookupBookingsOfUser($group_apps, $a_user_id);
754 
755  include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourGroups.php';
756  #$GLOBALS['ilLog']->write(__METHOD__.': '.ilConsultationHourGroups::lookupMaxBookings($this->getBookingGroup()));
757 
758  if (count($bookings) >= ilConsultationHourGroups::lookupMaxBookings($this->getBookingGroup())) {
759  #$GLOBALS['ilLog']->write(__METHOD__.': Personal booking limit reached');
760  return false;
761  }
762  #$GLOBALS['ilLog']->write(__METHOD__.': Is bookable!');
763  return true;
764  }
765 
771  public function book($a_entry_id, $a_user_id = false)
772  {
774  $ilDB = $this->db;
775 
776  if (!$a_user_id) {
777  $a_user_id = $ilUser->getId();
778  }
779 
780  if (!$this->hasBooked($a_entry_id, $a_user_id)) {
781  $ilDB->manipulate('INSERT INTO booking_user (entry_id, user_id, tstamp)' .
782  ' VALUES (' . $ilDB->quote($a_entry_id, 'integer') . ',' .
783  $ilDB->quote($a_user_id, 'integer') . ',' . $ilDB->quote(time(), 'integer') . ')');
784 
785  include_once 'Services/Calendar/classes/class.ilCalendarMailNotification.php';
786  $mail = new ilCalendarMailNotification();
787  $mail->setAppointmentId($a_entry_id);
788  $mail->setRecipients(array($a_user_id));
790  $mail->send();
791  }
792  return true;
793  }
794 
800  public function cancelBooking($a_entry_id, $a_user_id = false)
801  {
803  $ilDB = $this->db;
804 
805  if (!$a_user_id) {
806  $a_user_id = $ilUser->getId();
807  }
808 
809  // @todo do not send mails about past consultation hours
810  $entry = new ilCalendarEntry($a_entry_id);
811 
812  $past = ilDateTime::_before($entry->getStart(), new ilDateTime(time(), IL_CAL_UNIX));
813  if ($this->hasBooked($a_entry_id, $a_user_id) && !$past) {
814  include_once 'Services/Calendar/classes/class.ilCalendarMailNotification.php';
815  $mail = new ilCalendarMailNotification();
816  $mail->setAppointmentId($a_entry_id);
817  $mail->setRecipients(array($a_user_id));
819  $mail->send();
820  }
821  $this->deleteBooking($a_entry_id, $a_user_id);
822  return true;
823  }
824 
832  public function deleteBooking($a_entry_id, $a_user_id)
833  {
834  $ilDB = $this->db;
835 
836  $query = 'DELETE FROM booking_user ' .
837  'WHERE entry_id = ' . $ilDB->quote($a_entry_id, 'integer') . ' ' .
838  'AND user_id = ' . $ilDB->quote($a_user_id, 'integer');
839  $ilDB->manipulate($query);
840  return true;
841  }
842 }
static lookupBookingsForObject($a_obj_id, $a_usr_id)
Lookup booking for an object and user.
Model for a calendar entry.
getNumberOfBookings()
get number of bookings
const IL_CAL_DATETIME
static hasObjectBookingEntries($a_obj_id, $a_usr_id)
Check if object has assigned consultation hour appointments.
setObjId($a_id)
Set obj id.
global $DIC
Definition: saml.php:7
deleteBooking($a_entry_id, $a_user_id)
Delete booking type $ilDB.
static lookupManagedUsers($a_usr_id)
Lookup managed users.
const IL_CAL_HOUR
static _lookupFullname($a_user_id)
Lookup Full Name.
static lookupManagedBookingsForObject($a_obj_id, $a_usr_id)
Lookup bookings for own and managed consultation hours of an object.
static _after(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
compare two dates and check start is after end This method does not consider tz offsets.
setTargetObjIds($a_obj_id)
set target object id
Distributes calendar mail notifications.
static _before(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
compare two dates and check start is before end This method does not consider tz offsets.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
static removeObsoleteEntries()
Remove unused booking entries.
Booking definition.
static getInstanceByCalendarEntryId($a_id)
Get instance by calendar entry.
read()
Read settings from db.
getTargetObjIds()
get target object id
const IL_CAL_UNIX
__construct($a_booking_id=0)
Constructor.
isAppointmentBookableForUser($a_app_id, $a_user_id)
Check if a calendar appointment is bookable for a specific user.
static lookupBookingMessage($a_entry_id, $a_usr_id)
user()
Definition: user.php:4
getCurrentNumberOfBookings($a_entry_id)
get current number of bookings
static writeBookingMessage($a_entry_id, $a_usr_id, $a_message)
Write booking message.
isBookedOut($a_entry_id, $a_check_current_user=false)
get current number of bookings
hasBooked($a_entry_id, $a_user_id=null)
get current number of bookings
static lookupBookableUsersForObject($a_obj_id, $a_user_ids)
Consultation hours are offered if 1) consultation hour owner is admin or tutor and no object assignme...
static lookupBookingsForAppointment($a_app_id)
Lookup booked users for appointment type $ilDB.
foreach($_POST as $key=> $value) $res
isTargetObjectVisible($a_ref_id)
Check if target ref id is visible.
static _lookupObjId($a_id)
getDeadlineHours()
get deadline hours
cancelBooking($a_entry_id, $a_user_id=false)
cancel calendar booking for user
Date and time handling
$ilUser
Definition: imgupload.php:18
static isBookable(array $a_obj_ids, $a_target_obj_id=null)
Which objects are bookable?
$query
static getAppointmentIdsByGroup($a_user_id, $a_ch_group_id, ilDateTime $start=null)
Get appointment ids by consultation hour group.
static lookupBookingsOfUser($a_app_ids, $a_usr_id, ilDateTime $start=null)
Lookup bookings if user.
Create styles array
The data for the language used.
$users
Definition: authpage.php:44
setDeadlineHours($a_hours)
set deadline hours
static lookupMaxBookings($a_group_id)
Lookup max number of bookings for group type $ilDB.
getCurrentBookings($a_entry_id)
get current bookings
save()
Save a new booking entry.
book($a_entry_id, $a_user_id=false)
book calendar entry for user
global $ilDB
static resetGroup($a_group_id)
Reset booking group (in case of deletion) type $ilDB.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
setNumberOfBookings($a_num)
set number of bookings
setId($a_id)
Set id.
isOwner($a_user_id=null)
check if current (or given) user is entry owner
update()
Update an existing booking entry.