ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilConsultationHourAppointments Class Reference

Consultation hour appointments. More...

+ Collaboration diagram for ilConsultationHourAppointments:

Static Public Member Functions

static getAppointmentIds (int $a_user_id, ?int $a_context_id=null, ?ilDateTime $a_start=null, ?int $a_type=null, bool $a_check_owner=true)
 
static getAppointmentIdsByGroup (int $a_user_id, int $a_ch_group_id, ?ilDateTime $start=null)
 Get appointment ids by consultation hour group. More...
 
static getAppointments (int $a_user_id)
 Get all appointments. More...
 
static getManager (bool $a_as_name=false, bool $a_full_name=false, ?int $a_user_id=null)
 Get consultation hour manager for current user or specific user. More...
 
static setManager (string $a_user_name)
 Set consultation hour manager for current user. More...
 
static getManagedUsers ()
 Get all managed consultation hours users for current users. More...
 

Detailed Description

Consultation hour appointments.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 26 of file class.ilConsultationHourAppointments.php.

Member Function Documentation

◆ getAppointmentIds()

static ilConsultationHourAppointments::getAppointmentIds ( int  $a_user_id,
?int  $a_context_id = null,
?ilDateTime  $a_start = null,
?int  $a_type = null,
bool  $a_check_owner = true 
)
static
Returns
int[]

Definition at line 31 of file class.ilConsultationHourAppointments.php.

37 : array {
38 global $DIC;
39
40 $ilDB = $DIC->database();
41
42 if (!$a_type) {
44 }
45 $owner = ' ';
46 if ($a_check_owner) {
47 $owner = " AND be.obj_id = " . $ilDB->quote($a_user_id, 'integer');
48 }
49
50 $query = "SELECT ce.cal_id FROM cal_entries ce" .
51 " JOIN cal_cat_assignments cca ON ce.cal_id = cca.cal_id" .
52 " JOIN cal_categories cc ON cca.cat_id = cc.cat_id" .
53 " JOIN booking_entry be ON ce.context_id = be.booking_id" .
54 " WHERE cc.obj_id = " . $ilDB->quote($a_user_id, 'integer') .
55 $owner .
56 " AND cc.type = " . $ilDB->quote($a_type, 'integer');
57
58 if ($a_context_id) {
59 $query .= " AND ce.context_id = " . $ilDB->quote($a_context_id, 'integer');
60 }
61 if ($a_start) {
62 $query .= " AND ce.starta = " . $ilDB->quote($a_start->get(IL_CAL_DATETIME, '', 'UTC'), 'text');
63 }
64 $query .= (' ORDER BY ce.starta ASC');
65 $res = $ilDB->query($query);
66 $entries = array();
67 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
68 $entries[] = (int) $row->cal_id;
69 }
70 return $entries;
71 }
const IL_CAL_DATETIME
$res
Definition: ltiservices.php:69
global $DIC
Definition: shib_login.php:26

References ilCalendarCategory\TYPE_CH.

Referenced by ilConsultationHoursGUI\bookingList(), ilConsultationHourUtils\cancelBooking(), ilCalendarAppointmentGUI\cancelConfirmed(), ilAppointmentPresentationConsultationHoursGUI\collectPropertiesAndActions(), ilCalendarAppointmentPanelGUI\getHTML(), ilConsultationHoursGUI\initAppointmentIdsFromTableAction(), and ilCalendarEntry\parseDynamicTitle().

+ Here is the caller graph for this function:

◆ getAppointmentIdsByGroup()

static ilConsultationHourAppointments::getAppointmentIdsByGroup ( int  $a_user_id,
int  $a_ch_group_id,
?ilDateTime  $start = null 
)
static

Get appointment ids by consultation hour group.

Returns
int[]
Todo:
check start time

Definition at line 78 of file class.ilConsultationHourAppointments.php.

82 : array {
83 global $DIC;
84
85 $ilDB = $DIC->database();
87 $start_limit = '';
88 if ($start instanceof ilDateTime) {
89 $start_limit = 'AND ce.starta >= ' . $ilDB->quote($start->get(IL_CAL_DATETIME, '', 'UTC'), 'timestamp');
90 }
91 $query = 'SELECT ce.cal_id FROM cal_entries ce ' .
92 'JOIN cal_cat_assignments ca ON ce.cal_id = ca.cal_id ' .
93 'JOIN cal_categories cc ON ca.cat_id = cc.cat_id ' .
94 'JOIN booking_entry be ON ce.context_id = be.booking_id ' .
95 'WHERE cc.obj_id = ' . $ilDB->quote($a_user_id, 'integer') . ' ' .
96 'AND cc.type = ' . $ilDB->quote($type, 'integer') . ' ' .
97 'AND be.booking_group = ' . $ilDB->quote($a_ch_group_id, 'integer') . ' ' .
98 $start_limit . ' ' .
99 'ORDER BY ce.starta ';
100 $res = $ilDB->query($query);
101 $app_ids = [];
102 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
103 $app_ids[] = (int) $row->cal_id;
104 }
105 return $app_ids;
106 }
@classDescription Date and time handling

References $ilDB, and IL_CAL_DATETIME.

◆ getAppointments()

static ilConsultationHourAppointments::getAppointments ( int  $a_user_id)
static

Get all appointments.

Returns
ilCalendarEntry[]

Definition at line 112 of file class.ilConsultationHourAppointments.php.

112 : array
113 {
114 $entries = [];
115 foreach (self::getAppointmentIds($a_user_id) as $app_id) {
116 $entries[] = new ilCalendarEntry($app_id);
117 }
118 return $entries;
119 }
Model for a calendar entry.

Referenced by ilCalendarBlockGUI\getHTML(), ilConsultationHoursTableGUI\parse(), and ILIAS\Calendar\ConsultationHours\BookingDataProvider\read().

+ Here is the caller graph for this function:

◆ getManagedUsers()

static ilConsultationHourAppointments::getManagedUsers ( )
static

Get all managed consultation hours users for current users.

Returns
array

Definition at line 187 of file class.ilConsultationHourAppointments.php.

187 : array
188 {
189 global $DIC;
190
191 $ilDB = $DIC->database();
192 $ilUser = $DIC->user();
193
194 $all = array();
195 $set = $ilDB->query('SELECT user_id FROM cal_ch_settings' .
196 ' WHERE admin_id = ' . $ilDB->quote($ilUser->getId(), 'integer'));
197 while ($row = $ilDB->fetchAssoc($set)) {
198 $all[(int) $row['user_id']] = ilObjUser::_lookupLogin((int) $row['user_id']);
199 }
200 return $all;
201 }
static _lookupLogin(int $a_user_id)

References $DIC, $ilDB, ilObjUser\_lookupLogin(), and ILIAS\Repository\int().

Referenced by ilConsultationHoursGUI\__construct(), and ilConsultationHoursGUI\setTabs().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getManager()

static ilConsultationHourAppointments::getManager ( bool  $a_as_name = false,
bool  $a_full_name = false,
?int  $a_user_id = null 
)
static

Get consultation hour manager for current user or specific user.

Returns
int | string

Definition at line 125 of file class.ilConsultationHourAppointments.php.

126 {
127 global $DIC;
128
129 $ilDB = $DIC->database();
130 $ilUser = $DIC->user();
131
132 if (!$a_user_id) {
133 $user_id = $ilUser->getId();
134 } else {
135 $user_id = $a_user_id;
136 }
137
138 $set = $ilDB->query('SELECT admin_id FROM cal_ch_settings' .
139 ' WHERE user_id = ' . $ilDB->quote($user_id, 'integer'));
140 $row = $ilDB->fetchAssoc($set);
141 if ($row && $row['admin_id']) {
142 if ($a_as_name && $a_full_name) {
143 return ilObjUser::_lookupFullname((int) $row['admin_id']);
144 } elseif ($a_as_name) {
145 return ilObjUser::_lookupLogin((int) $row['admin_id']);
146 }
147 return (int) $row['admin_id'];
148 }
149 return 0;
150 }
static _lookupFullname(int $a_user_id)

References $DIC, $ilDB, $user_id, ilObjUser\_lookupFullname(), and ilObjUser\_lookupLogin().

Referenced by ilConsultationHourUtils\bookAppointment(), ilAppointmentPresentationConsultationHoursGUI\collectPropertiesAndActions(), and ilConsultationHoursGUI\initSettingsForm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setManager()

static ilConsultationHourAppointments::setManager ( string  $a_user_name)
static

Set consultation hour manager for current user.

Parameters
string$a_user_name
Returns
bool

Definition at line 157 of file class.ilConsultationHourAppointments.php.

157 : bool
158 {
159 global $DIC;
160
161 $ilDB = $DIC->database();
162 $ilUser = $DIC->user();
163
164 $user_id = false;
165 if ($a_user_name) {
166 $user_id = ilObjUser::_loginExists($a_user_name);
167 if (!$user_id) {
168 return false;
169 }
170 }
171
172 $ilDB->manipulate('DELETE FROM cal_ch_settings' .
173 ' WHERE user_id = ' . $ilDB->quote($ilUser->getId(), 'integer'));
174
175 if ($user_id && $user_id != $ilUser->getId()) {
176 $ilDB->manipulate('INSERT INTO cal_ch_settings (user_id, admin_id)' .
177 ' VALUES (' . $ilDB->quote($ilUser->getId(), 'integer') . ',' .
178 $ilDB->quote($user_id, 'integer') . ')');
179 }
180 return true;
181 }
static _loginExists(string $a_login, int $a_user_id=0)

References $DIC, $ilDB, $user_id, and ilObjUser\_loginExists().

Referenced by ilConsultationHoursGUI\updateSettings().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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