ILIAS  release_8 Revision v8.24
class.ilConsultationHourGroups.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
26{
31 public static function getGroupsOfUser(int $a_user_id): array
32 {
33 global $DIC;
34
35 $ilDB = $DIC->database();
36 $query = 'SELECT grp_id FROM cal_ch_group ' .
37 'WHERE usr_id = ' . $ilDB->quote($a_user_id, 'integer');
38 $res = $ilDB->query($query);
39 $groups = array();
40 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
41 $groups[] = new ilConsultationHourGroup((int) $row->grp_id);
42 }
43 return $groups;
44 }
45
49 public static function getCountGroupsOfUser(int $a_user_id): int
50 {
51 global $DIC;
52
53 $ilDB = $DIC->database();
54 $query = 'SELECT COUNT(grp_id) num FROM cal_ch_group ' .
55 'WHERE usr_id = ' . $ilDB->quote($a_user_id, 'integer') . ' ' .
56 'GROUP BY grp_id';
57
58 $res = $ilDB->query($query);
59 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
60 return (int) $row->num;
61 }
62 return 0;
63 }
64
68 public static function lookupTitle(int $a_group_id): string
69 {
70 global $DIC;
71
72 $ilDB = $DIC['ilDB'];
73 $query = 'SELECT title from cal_ch_group ' .
74 'WHERE grp_id = ' . $ilDB->quote($a_group_id, 'integer');
75 $res = $ilDB->query($query);
76 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
77 return $row->title;
78 }
79 return '';
80 }
81
85 public static function lookupMaxBookings(int $a_group_id): int
86 {
87 global $DIC;
88
89 $ilDB = $DIC['ilDB'];
90 $query = 'SELECT multiple_assignments from cal_ch_group ' .
91 'WHERE grp_id = ' . $ilDB->quote($a_group_id, 'integer');
92 $res = $ilDB->query($query);
93 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
94 return (int) $row->multiple_assignments;
95 }
96 return 0;
97 }
98
102 public static function getGroupSelectOptions(int $a_user_id): array
103 {
104 global $DIC;
105
106 $lng = $DIC->language();
107 $groups = self::getGroupsOfUser($a_user_id);
108 if (!count($groups)) {
109 return array();
110 }
111 $options = array();
112 foreach ($groups as $group) {
113 $options[(string) $group->getGroupId()] = $group->getTitle();
114 }
115 asort($options, SORT_STRING);
116 $sorted_options = array();
117 $sorted_options[0] = $lng->txt('cal_ch_grp_no_assignment');
118 foreach ($options as $key => $opt) {
119 $sorted_options[$key] = $opt;
120 }
121 return $sorted_options;
122 }
123}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getGroupSelectOptions(int $a_user_id)
Get group selection options.
static getCountGroupsOfUser(int $a_user_id)
Get number of consultation hour groups.
static getGroupsOfUser(int $a_user_id)
Get a all groups of an user.
static lookupTitle(int $a_group_id)
Lookup group title.
static lookupMaxBookings(int $a_group_id)
Lookup max number of bookings for group.
global $DIC
Definition: feed.php:28
$res
Definition: ltiservices.php:69
string $key
Consumer key/client ID value.
Definition: System.php:193
$query
$lng