ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilConsultationHourGroups.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4
11{
12
18 public static function getGroupsOfUser($a_user_id)
19 {
20 global $DIC;
21
22 $ilDB = $DIC['ilDB'];
23
24 $query = 'SELECT grp_id FROM cal_ch_group ' .
25 'WHERE usr_id = ' . $ilDB->quote($a_user_id, 'integer');
26 $res = $ilDB->query($query);
27 $groups = array();
28 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
29 include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourGroup.php';
30 $groups[] = new ilConsultationHourGroup($row->grp_id);
31 }
32 return $groups;
33 }
34
41 public static function getCountGroupsOfUser($a_user_id)
42 {
43 global $DIC;
44
45 $ilDB = $DIC['ilDB'];
46
47 $query = 'SELECT COUNT(grp_id) num FROM cal_ch_group ' .
48 'WHERE usr_id = ' . $ilDB->quote($a_user_id, 'integer') . ' ' .
49 'GROUP BY grp_id';
50
51 $res = $ilDB->query($query);
52 $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
53 return (int) $row->num;
54 }
55
59 public static function lookupAssignedAppointments()
60 {
61 global $DIC;
62
63 $ilDB = $DIC['ilDB'];
64
65 //@todo
66 }
67
71 public static function lookupTitle($a_group_id)
72 {
73 global $DIC;
74
75 $ilDB = $DIC['ilDB'];
76
77 $query = 'SELECT title from cal_ch_group ' .
78 'WHERE grp_id = ' . $ilDB->quote($a_group_id, 'integer');
79 $res = $ilDB->query($query);
80 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
81 return $row->title;
82 }
83 return '';
84 }
85
92 public static function lookupMaxBookings($a_group_id)
93 {
94 global $DIC;
95
96 $ilDB = $DIC['ilDB'];
97
98 $query = 'SELECT multiple_assignments from cal_ch_group ' .
99 'WHERE grp_id = ' . $ilDB->quote($a_group_id, 'integer');
100 $res = $ilDB->query($query);
101 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
102 return $row->multiple_assignments;
103 }
104 return 0;
105 }
106
107
112 public static function getGroupSelectOptions($a_user_id)
113 {
114 global $DIC;
115
116 $lng = $DIC['lng'];
117
118 $groups = self::getGroupsOfUser($a_user_id);
119 if (!count($groups)) {
120 return array();
121 }
122 $options = array();
123 foreach ($groups as $group) {
124 $options[(string) $group->getGroupId()] = $group->getTitle();
125 }
126 asort($options, SORT_STRING);
127 $sorted_options = array();
128 $sorted_options[0] = $lng->txt('cal_ch_grp_no_assignment');
129 foreach ($options as $key => $opt) {
130 $sorted_options[$key] = $opt;
131 }
132 return $sorted_options;
133 }
134}
An exception for terminatinating execution or to throw for unit testing.
static lookupAssignedAppointments()
Lookup number of assigned appointments.
static lookupMaxBookings($a_group_id)
Lookup max number of bookings for group @global type $ilDB.
static lookupTitle($a_group_id)
Lookup group title.
static getGroupsOfUser($a_user_id)
Get a all groups of an user.
static getCountGroupsOfUser($a_user_id)
Get number of consultation hour groups @global type $ilDB.
static getGroupSelectOptions($a_user_id)
Get group selection options.
$query
$lng
foreach($_POST as $key=> $value) $res
global $ilDB
$DIC
Definition: xapitoken.php:46