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

Consultation hour appointments. More...

+ Collaboration diagram for ilConsultationHourAppointments:

Static Public Member Functions

static getAppointmentIds ($a_user_id, $a_context_id=null, $a_start=null, $a_type=null, $a_check_owner=true)
 Get all appointment ids. More...
 
static getAppointmentIdsByGroup ($a_user_id, $a_ch_group_id, ilDateTime $start=null)
 Get appointment ids by consultation hour group. More...
 
static getAppointments ($a_user_id)
 Get all appointments. More...
 
static getManager ($a_as_name=false, $a_full_name=false, $a_user_id=null)
 Get consultation hour manager for current user or specific user. More...
 
static setManager ($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
Version
$Id$

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

Member Function Documentation

◆ getAppointmentIds()

static ilConsultationHourAppointments::getAppointmentIds (   $a_user_id,
  $a_context_id = null,
  $a_start = null,
  $a_type = null,
  $a_check_owner = true 
)
static

Get all appointment ids.

Parameters
object$a_user_id
int$a_context_id
string$a_start
int$a_type
Returns

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

27 {
28 global $ilDB;
29
30 if (!$a_type) {
31 include_once './Services/Calendar/classes/class.ilCalendarCategory.php';
33 }
34 $owner = ' ';
35 if ($a_check_owner) {
36 $owner = " AND be.obj_id = " . $ilDB->quote($a_user_id, 'integer');
37 }
38
39 $query = "SELECT ce.cal_id FROM cal_entries ce" .
40 " JOIN cal_cat_assignments cca ON ce.cal_id = cca.cal_id" .
41 " JOIN cal_categories cc ON cca.cat_id = cc.cat_id" .
42 " JOIN booking_entry be ON ce.context_id = be.booking_id" .
43 " WHERE cc.obj_id = " . $ilDB->quote($a_user_id, 'integer') .
44 $owner .
45 " AND cc.type = " . $ilDB->quote($a_type, 'integer');
46
47
48 if ($a_context_id) {
49 $query .= " AND ce.context_id = " . $ilDB->quote($a_context_id, 'integer');
50 }
51 if ($a_start) {
52 $query .= " AND ce.starta = " . $ilDB->quote($a_start->get(IL_CAL_DATETIME, '', 'UTC'), 'text');
53 }
54
55 $query .= (' ORDER BY ce.starta ASC');
56
57 $res = $ilDB->query($query);
58 $entries = array();
59 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
60 $entries[] = $row->cal_id;
61 }
62 return $entries;
63 }
const IL_CAL_DATETIME
$query
foreach($_POST as $key=> $value) $res
global $ilDB
$a_context_id
Definition: workflow.php:97
$a_type
Definition: workflow.php:92

References $a_context_id, $a_type, $ilDB, $query, $res, $row, ilDBConstants\FETCHMODE_OBJECT, IL_CAL_DATETIME, and ilCalendarCategory\TYPE_CH.

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

+ Here is the caller graph for this function:

◆ getAppointmentIdsByGroup()

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

Get appointment ids by consultation hour group.

Parameters
type$a_user_id
type$a_ch_group_id
ilDateTime$start

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

73 {
74 global $ilDB;
75
76 // @todo check start time
77
78 include_once './Services/Calendar/classes/class.ilCalendarCategory.php';
80
81 $start_limit = '';
82 if ($start instanceof ilDateTime) {
83 $start_limit = 'AND ce.starta >= ' . $ilDB->quote($start->get(IL_CAL_DATETIME, '', 'UTC'), 'timestamp');
84 }
85
86 $query = 'SELECT ce.cal_id FROM cal_entries ce ' .
87 'JOIN cal_cat_assignments ca ON ce.cal_id = ca.cal_id ' .
88 'JOIN cal_categories cc ON ca.cat_id = cc.cat_id ' .
89 'JOIN booking_entry be ON ce.context_id = be.booking_id ' .
90 'WHERE cc.obj_id = ' . $ilDB->quote($a_user_id, 'integer') . ' ' .
91 'AND cc.type = ' . $ilDB->quote($type, 'integer') . ' ' .
92 'AND be.booking_group = ' . $ilDB->quote($a_ch_group_id, 'integer') . ' ' .
93 $start_limit . ' ' .
94 'ORDER BY ce.starta ';
95 $res = $ilDB->query($query);
96 $app_ids = array();
97 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
98 $app_ids[] = $row->cal_id;
99 }
100 return $app_ids;
101 }
@classDescription Date and time handling
get($a_format, $a_format_str='', $a_tz='')
get formatted date
$type

References $ilDB, $query, $res, $row, $type, ilDBConstants\FETCHMODE_OBJECT, IL_CAL_DATETIME, and ilCalendarCategory\TYPE_CH.

Referenced by ilConsultationHoursGUI\assignUsersToGroup(), ilBookingEntry\isAppointmentBookableForUser(), and ilConsultationHourGroupTableGUI\parse().

+ Here is the caller graph for this function:

◆ getAppointments()

static ilConsultationHourAppointments::getAppointments (   $a_user_id)
static

Get all appointments.

Returns

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

108 {
109 $entries = array();
110 foreach (self::getAppointmentIds($a_user_id) as $app_id) {
111 $entries[] = new ilCalendarEntry($app_id);
112 }
113 return $entries;
114 }
Model for a calendar entry.

Referenced by ilCalendarBlockGUI\getHTML(), and ilConsultationHoursTableGUI\parse().

+ 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 179 of file class.ilConsultationHourAppointments.php.

180 {
181 global $ilDB, $ilUser;
182
183 $all = array();
184 $set = $ilDB->query('SELECT user_id FROM cal_ch_settings' .
185 ' WHERE admin_id = ' . $ilDB->quote($ilUser->getId(), 'integer'));
186 while ($row = $ilDB->fetchAssoc($set)) {
187 $all[$row['user_id']] = ilObjUser::_lookupLogin($row['user_id']);
188 }
189 return $all;
190 }
static _lookupLogin($a_user_id)
lookup login
$ilUser
Definition: imgupload.php:18

References $ilDB, $ilUser, $row, and ilObjUser\_lookupLogin().

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 (   $a_as_name = false,
  $a_full_name = false,
  $a_user_id = null 
)
static

Get consultation hour manager for current user or specific user.

Parameters
bool$a_as_name
bool$a_full_name
int$a_user_id
Returns
int | string

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

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

References $ilDB, $ilUser, $row, ilObjUser\_lookupFullname(), and ilObjUser\_lookupLogin().

Referenced by 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 (   $a_user_name)
static

Set consultation hour manager for current user.

Parameters
string$a_user_name
Returns
bool

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

152 {
153 global $ilDB, $ilUser;
154
155 $user_id = false;
156 if ($a_user_name) {
157 $user_id = ilObjUser::_loginExists($a_user_name);
158 if (!$user_id) {
159 return false;
160 }
161 }
162
163 $ilDB->manipulate('DELETE FROM cal_ch_settings' .
164 ' WHERE user_id = ' . $ilDB->quote($ilUser->getId(), 'integer'));
165
166 if ($user_id && $user_id != $ilUser->getId()) {
167 $ilDB->manipulate('INSERT INTO cal_ch_settings (user_id, admin_id)' .
168 ' VALUES (' . $ilDB->quote($ilUser->getId(), 'integer') . ',' .
169 $ilDB->quote($user_id, 'integer') . ')');
170 }
171
172 return true;
173 }
static _loginExists($a_login, $a_user_id=0)
check if a login name already exists You may exclude a user from the check by giving his user id as 2...

References $ilDB, $ilUser, 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: