19 declare(strict_types=1);
33 ?
int $a_context_id =
null,
36 bool $a_check_owner =
true 40 $ilDB = $DIC->database();
47 $owner =
" AND be.obj_id = " .
$ilDB->quote($a_user_id,
'integer');
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') .
56 " AND cc.type = " .
$ilDB->quote($a_type,
'integer');
59 $query .=
" AND ce.context_id = " .
$ilDB->quote($a_context_id,
'integer');
64 $query .= (
' ORDER BY ce.starta ASC');
68 $entries[] = (
int) $row->cal_id;
85 $ilDB = $DIC->database();
89 $start_limit =
'AND ce.starta >= ' .
$ilDB->quote($start->get(
IL_CAL_DATETIME,
'',
'UTC'),
'timestamp');
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') .
' ' .
99 'ORDER BY ce.starta ';
103 $app_ids[] = (
int) $row->cal_id;
115 foreach (self::getAppointmentIds($a_user_id) as $app_id) {
125 public static function getManager(
bool $a_as_name =
false,
bool $a_full_name =
false, ?
int $a_user_id =
null)
129 $ilDB = $DIC->database();
130 $ilUser = $DIC->user();
138 $set =
$ilDB->query(
'SELECT admin_id FROM cal_ch_settings' .
140 $row =
$ilDB->fetchAssoc($set);
141 if ($row && $row[
'admin_id']) {
142 if ($a_as_name && $a_full_name) {
144 } elseif ($a_as_name) {
147 return (
int) $row[
'admin_id'];
161 $ilDB = $DIC->database();
162 $ilUser = $DIC->user();
172 $ilDB->manipulate(
'DELETE FROM cal_ch_settings' .
173 ' WHERE user_id = ' .
$ilDB->quote($ilUser->getId(),
'integer'));
176 $ilDB->manipulate(
'INSERT INTO cal_ch_settings (user_id, admin_id)' .
177 ' VALUES (' .
$ilDB->quote($ilUser->getId(),
'integer') .
',' .
191 $ilDB = $DIC->database();
192 $ilUser = $DIC->user();
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)) {
static _lookupFullname(int $a_user_id)
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 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.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static getManagedUsers()
Get all managed consultation hours users for current users.
static getAppointmentIdsByGroup(int $a_user_id, int $a_ch_group_id, ?ilDateTime $start=null)
Get appointment ids by consultation hour group.
static _loginExists(string $a_login, int $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...
static getAppointments(int $a_user_id)
Get all appointments.
static setManager(string $a_user_name)
Set consultation hour manager for current user.
static _lookupLogin(int $a_user_id)