ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilConsultationHourUtils Class Reference

Description of class. More...

+ Collaboration diagram for ilConsultationHourUtils:

Static Public Member Functions

static findCalendarAppointmentsForBooking (\ilBookingEntry $booking, \ilDateTime $start, \ilDateTime $end)
 
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 49 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().

50  {
51  global $lng;
52 
53  // Create new default consultation hour calendar
54  include_once './Services/Language/classes/class.ilLanguageFactory.php';
55  $cal_lang = ilLanguageFactory::_getLanguage($lng->getDefaultLanguage());
56  $cal_lang->loadLanguageModule('dateplaner');
57 
58  include_once './Services/Calendar/classes/class.ilCalendarUtil.php';
59  include_once './Services/Calendar/classes/class.ilCalendarCategory.php';
62  $a_usr_id,
63  $cal_lang->txt('cal_ch_personal_ch'),
64  true
65  );
66 
67  // duplicate appointment
68  include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
69  $app = new ilCalendarEntry($a_app_id);
70  $personal_app = clone $app;
71  $personal_app->save();
72 
73  // assign appointment to category
74  include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
75  $assignment = new ilCalendarCategoryAssignments($personal_app->getEntryId());
76  $assignment->addAssignment($ch->getCategoryID());
77 
78  // book appointment
79  include_once './Services/Booking/classes/class.ilBookingEntry.php';
80  $booking = new ilBookingEntry($app->getContextId());
81  $booking->book($app->getEntryId(), $a_usr_id);
82  return true;
83  }
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 91 of file class.ilConsultationHourUtils.php.

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

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

92  {
93  // Delete personal copy of appointment
94  include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
95  $app = new ilCalendarEntry($a_app_id);
96 
97  include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourAppointments.php';
99  $a_usr_id,
100  $app->getContextId(),
101  $app->getStart(),
103  false
104  );
105  foreach ($user_apps as $uapp_id) {
106  $uapp = new ilCalendarEntry($uapp_id);
107  $uapp->delete();
108 
109  include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
111 
112  break;
113  }
114 
115  // Delete booking entries
116  // Send notification
117  $booking = new ilBookingEntry($app->getContextId());
118  if ($a_send_notification) {
119  $booking->cancelBooking($a_app_id, $a_usr_id);
120  } else {
121  $booking->deleteBooking($a_app_id, $a_usr_id);
122  }
123  return true;
124  }
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:

◆ findCalendarAppointmentsForBooking()

static ilConsultationHourUtils::findCalendarAppointmentsForBooking ( \ilBookingEntry  $booking,
\ilDateTime  $start,
\ilDateTime  $end 
)
static
Parameters
ilBookingEntry$booking
ilDateTime$start
ilDateTime$end
Returns
int[]
Exceptions
ilDatabaseException

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

References $DIC, $query, $res, $row, ilDBConstants\FETCHMODE_OBJECT, ilDateTime\get(), ilBookingEntry\getId(), IL_CAL_DATETIME, ilDBConstants\T_TIMESTAMP, ilCalendarCategory\TYPE_CH, and ilTimeZone\UTC.

Referenced by ilConsultationHoursGUI\rewriteBookingIdsForAppointments().

21  {
22  global $DIC;
23 
24  $db = $DIC->database();
25 
26  $query = 'select ce.cal_id from cal_entries ce ' .
27  'join cal_cat_assignments cca on ce.cal_id = cca.cal_id ' .
28  'join cal_categories cc on cca.cat_id = cc.cat_id '.
29  'where context_id = ' . $db->quote($booking->getId(), 'integer') . ' ' .
30  'and starta = ' . $db->quote($start->get(IL_CAL_DATETIME, '', \ilTimeZone::UTC), \ilDBConstants::T_TIMESTAMP) . ' ' .
31  'and enda = ' . $db->quote($end->get(IL_CAL_DATETIME, '', \ilTimeZone::UTC), \ilDBConstants::T_TIMESTAMP) . ' ' .
32  'and type = ' . $db->quote(\ilCalendarCategory::TYPE_CH, 'integer');
33  $res = $db->query($query);
34 
35  $calendar_apppointments = [];
36  while ($row = $res->fetchRow(\ilDBConstants::FETCHMODE_OBJECT)) {
37  $calendar_apppointments[] = $row->cal_id;
38  }
39  return $calendar_apppointments;
40  }
const IL_CAL_DATETIME
global $DIC
Definition: saml.php:7
$end
Definition: saml1-acs.php:18
foreach($_POST as $key=> $value) $res
$query
+ 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 130 of file class.ilConsultationHourUtils.php.

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

Referenced by ilBookingEntry\lookupManagedBookingsForObject().

131  {
132  global $ilDB;
133 
134  $query = 'SELECT user_id FROM cal_ch_settings ' .
135  'WHERE admin_id = ' . $ilDB->quote($a_usr_id, 'integer');
136  $res = $ilDB->query($query);
137 
138  $users = array();
139  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
140  $users[] = $row->user_id;
141  }
142  return $users;
143  }
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
$users
Definition: authpage.php:44
global $ilDB
+ Here is the caller graph for this function:

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