ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilConsultationHourUtils Class Reference

Description of class. More...

+ Collaboration diagram for ilConsultationHourUtils:

Static Public Member Functions

static bookAppointment ($a_usr_id, $a_app_id)
 Book an appointment. More...
 
static cancelBooking ($a_usr_id, $a_app_id, $a_send_notification=true)
 Cancel a booking. More...
 
static lookupManagedUsers ($a_usr_id)
 Lookup managed users. More...
 

Detailed Description

Description of class.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

Definition at line 10 of file class.ilConsultationHourUtils.php.

Member Function Documentation

◆ bookAppointment()

static ilConsultationHourUtils::bookAppointment (   $a_usr_id,
  $a_app_id 
)
static

Book an appointment.

All checks (assignment possible, max booking) must be done before

Parameters
type$a_usr_id
type$a_app_id
Returns
bool

Definition at line 20 of file class.ilConsultationHourUtils.php.

References $lng, ilLanguageFactory\_getLanguage(), ilCalendarCategoryAssignments\addAssignment(), ilBookingEntry\book(), ilCalendarUtil\initDefaultCalendarByType(), and ilCalendarCategory\TYPE_CH.

Referenced by ilConsultationHoursGUI\assignUsersToAppointment(), ilConsultationHoursGUI\assignUsersToGroup(), and ilCalendarAppointmentGUI\bookconfirmed().

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  }
Model for a calendar entry.
Booking definition.
static _getLanguage($a_lang_key='')
Get langauge object.
book($a_entry_id, $a_user_id=false)
book calendar entry for user
global $lng
Definition: privfeed.php:17
static initDefaultCalendarByType($a_type_id, $a_usr_id, $a_title, $a_create=false)
Init the default calendar for given type and user.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cancelBooking()

static ilConsultationHourUtils::cancelBooking (   $a_usr_id,
  $a_app_id,
  $a_send_notification = true 
)
static

Cancel a booking.

Parameters
type$a_usr_id
type$a_app_id
Returns
bool

Definition at line 62 of file class.ilConsultationHourUtils.php.

References ilCalendarCategoryAssignments\_deleteByAppointmentId(), ilBookingEntry\cancelBooking(), ilConsultationHourAppointments\getAppointmentIds(), and ilCalendarCategory\TYPE_CH.

Referenced by ilConsultationHoursGUI\delete(), and ilConsultationHoursGUI\rejectBooking().

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  }
Model for a calendar entry.
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.
cancelBooking($a_entry_id, $a_user_id=false)
cancel calendar booking for user
static _deleteByAppointmentId($a_app_id)
Delete appointment assignment.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookupManagedUsers()

static ilConsultationHourUtils::lookupManagedUsers (   $a_usr_id)
static

Lookup managed users.

Parameters
type$a_usr_id

Definition at line 105 of file class.ilConsultationHourUtils.php.

References $ilDB, $query, $res, $row, array, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilBookingEntry\lookupManagedBookingsForObject().

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  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: