ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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.

50 {
51 global $DIC;
52
53 $lng = $DIC['lng'];
54
55 // Create new default consultation hour calendar
56 include_once './Services/Language/classes/class.ilLanguageFactory.php';
57 $cal_lang = ilLanguageFactory::_getLanguage($lng->getDefaultLanguage());
58 $cal_lang->loadLanguageModule('dateplaner');
59
60 include_once './Services/Calendar/classes/class.ilCalendarUtil.php';
61 include_once './Services/Calendar/classes/class.ilCalendarCategory.php';
64 $a_usr_id,
65 $cal_lang->txt('cal_ch_personal_ch'),
66 true
67 );
68
69 // duplicate appointment
70 include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
71 $app = new ilCalendarEntry($a_app_id);
72 $personal_app = clone $app;
73 $personal_app->save();
74
75 // assign appointment to category
76 include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
77 $assignment = new ilCalendarCategoryAssignments($personal_app->getEntryId());
78 $assignment->addAssignment($ch->getCategoryID());
79
80 // book appointment
81 include_once './Services/Booking/classes/class.ilBookingEntry.php';
82 $booking = new ilBookingEntry($app->getContextId());
83 $booking->book($app->getEntryId(), $a_usr_id);
84 return true;
85 }
Booking definition.
Model for a calendar entry.
static initDefaultCalendarByType($a_type_id, $a_usr_id, $a_title, $a_create=false)
Init the default calendar for given type and user.
static _getLanguage($a_lang_key='')
Get langauge object.
global $DIC
Definition: saml.php:7
$lng

References $DIC, $lng, ilLanguageFactory\_getLanguage(), ilCalendarUtil\initDefaultCalendarByType(), and ilCalendarCategory\TYPE_CH.

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

+ 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 93 of file class.ilConsultationHourUtils.php.

94 {
95 // Delete personal copy of appointment
96 include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
97 $app = new ilCalendarEntry($a_app_id);
98
99 include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourAppointments.php';
101 $a_usr_id,
102 $app->getContextId(),
103 $app->getStart(),
105 false
106 );
107 foreach ($user_apps as $uapp_id) {
108 $uapp = new ilCalendarEntry($uapp_id);
109 $uapp->delete();
110
111 include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
113
114 break;
115 }
116
117 // Delete booking entries
118 // Send notification
119 $booking = new ilBookingEntry($app->getContextId());
120 if ($a_send_notification) {
121 $booking->cancelBooking($a_app_id, $a_usr_id);
122 } else {
123 $booking->deleteBooking($a_app_id, $a_usr_id);
124 }
125 return true;
126 }
static _deleteByAppointmentId($a_app_id)
Delete appointment assignment.
static getAppointmentIds($a_user_id, $a_context_id=null, $a_start=null, $a_type=null, $a_check_owner=true)
Get all appointment ids.

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

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

+ 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.

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
$row
$query
foreach($_POST as $key=> $value) $res
$start
Definition: bench.php:8

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

Referenced by ilConsultationHoursGUI\rewriteBookingIdsForAppointments().

+ 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 132 of file class.ilConsultationHourUtils.php.

133 {
134 global $DIC;
135
136 $ilDB = $DIC['ilDB'];
137
138 $query = 'SELECT user_id FROM cal_ch_settings ' .
139 'WHERE admin_id = ' . $ilDB->quote($a_usr_id, 'integer');
140 $res = $ilDB->query($query);
141
142 $users = array();
143 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
144 $users[] = $row->user_id;
145 }
146 return $users;
147 }
$users
Definition: authpage.php:44
global $ilDB

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

Referenced by ilBookingEntry\lookupManagedBookingsForObject().

+ Here is the caller graph for this function:

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