ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilConsultationHourUtils.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
11 {
12 
13 
20  public static function bookAppointment($a_usr_id, $a_app_id)
21  {
22  global $lng;
23 
24  // Create new default consultation hour calendar
25  include_once './Services/Language/classes/class.ilLanguageFactory.php';
26  $cal_lang = ilLanguageFactory::_getLanguage($lng->getDefaultLanguage());
27  $cal_lang->loadLanguageModule('dateplaner');
28 
29  include_once './Services/Calendar/classes/class.ilCalendarUtil.php';
30  include_once './Services/Calendar/classes/class.ilCalendarCategory.php';
33  $a_usr_id,
34  $cal_lang->txt('cal_ch_personal_ch'),
35  true
36  );
37 
38  // duplicate appointment
39  include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
40  $app = new ilCalendarEntry($a_app_id);
41  $personal_app = clone $app;
42  $personal_app->save();
43 
44  // assign appointment to category
45  include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
46  $assignment = new ilCalendarCategoryAssignments($personal_app->getEntryId());
47  $assignment->addAssignment($ch->getCategoryID());
48 
49  // book appointment
50  include_once './Services/Booking/classes/class.ilBookingEntry.php';
51  $booking = new ilBookingEntry($app->getContextId());
52  $booking->book($app->getEntryId(),$a_usr_id);
53  return true;
54  }
55 
62  public static function cancelBooking($a_usr_id,$a_app_id, $a_send_notification = true)
63  {
64  // Delete personal copy of appointment
65  include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
66  $app = new ilCalendarEntry($a_app_id);
67 
68  include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourAppointments.php';
70  $a_usr_id,
71  $app->getContextId(),
72  $app->getStart(),
74  false
75  );
76  foreach($user_apps as $uapp_id)
77  {
78  $uapp = new ilCalendarEntry($uapp_id);
79  $uapp->delete();
80 
81  include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
83 
84  break;
85  }
86 
87  // Delete booking entries
88  // Send notification
89  $booking = new ilBookingEntry($app->getContextId());
90  if($a_send_notification)
91  {
92  $booking->cancelBooking($a_app_id,$a_usr_id);
93  }
94  else
95  {
96  $booking->deleteBooking($a_app_id, $a_usr_id);
97  }
98  return true;
99  }
100 
105  public static function lookupManagedUsers($a_usr_id)
106  {
107  global $ilDB;
108 
109  $query = 'SELECT user_id FROM cal_ch_settings '.
110  'WHERE admin_id = '.$ilDB->quote($a_usr_id,'integer');
111  $res = $ilDB->query($query);
112 
113  $users = array();
114  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
115  {
116  $users[] = $row->user_id;
117  }
118  return $users;
119  }
120 }
121 ?>
Model for a calendar entry.
static lookupManagedUsers($a_usr_id)
Lookup managed users.
static getAppointmentIds($a_user_id, $a_context_id=NULL, $a_start=NULL, $a_type=NULL, $a_check_owner=true)
Get all appointment ids.
Booking definition.
static _getLanguage($a_lang_key='')
Get langauge object.
cancelBooking($a_entry_id, $a_user_id=false)
cancel calendar booking for user
static _deleteByAppointmentId($a_app_id)
Delete appointment assignment.
Create styles array
The data for the language used.
static cancelBooking($a_usr_id, $a_app_id, $a_send_notification=true)
Cancel a booking.
book($a_entry_id, $a_user_id=false)
book calendar entry for user
global $lng
Definition: privfeed.php:17
global $ilDB
static initDefaultCalendarByType($a_type_id, $a_usr_id, $a_title, $a_create=false)
Init the default calendar for given type and user.
static bookAppointment($a_usr_id, $a_app_id)
Book an appointment.