ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 $ilDB;
21 
22  $query = 'SELECT grp_id FROM cal_ch_group '.
23  'WHERE usr_id = '.$ilDB->quote($a_user_id,'integer');
24  $res = $ilDB->query($query);
25  $groups = array();
26  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
27  {
28  include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourGroup.php';
29  $groups[] = new ilConsultationHourGroup($row->grp_id);
30  }
31  return $groups;
32  }
33 
40  public static function getCountGroupsOfUser($a_user_id)
41  {
42  global $ilDB;
43 
44  $query = 'SELECT COUNT(grp_id) num FROM cal_ch_group '.
45  'WHERE usr_id = '.$ilDB->quote($a_user_id,'integer').' '.
46  'GROUP BY grp_id';
47 
48  $res = $ilDB->query($query);
49  $row = $res->fetchRow(DB_FETCHMODE_OBJECT);
50  return (int) $row->num;
51  }
52 
56  public static function lookupAssignedAppointments()
57  {
58  global $ilDB;
59 
60  //@todo
61  }
62 
66  public static function lookupTitle($a_group_id)
67  {
68  global $ilDB;
69 
70  $query = 'SELECT title from cal_ch_group '.
71  'WHERE grp_id = '.$ilDB->quote($a_group_id,'integer');
72  $res = $ilDB->query($query);
73  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
74  {
75  return $row->title;
76  }
77  return '';
78  }
79 
86  public static function lookupMaxBookings($a_group_id)
87  {
88  global $ilDB;
89 
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(DB_FETCHMODE_OBJECT))
94  {
95  return $row->multiple_assignments;
96  }
97  return 0;
98  }
99 
100 
105  public static function getGroupSelectOptions($a_user_id)
106  {
107  global $lng;
108 
109  $groups = self::getGroupsOfUser($a_user_id);
110  if(!count($groups))
111  {
112  return array();
113  }
114  $options = array();
115  foreach($groups as $group)
116  {
117  $options[(string) $group->getGroupId()] = $group->getTitle();
118  }
119  asort($options,SORT_STRING);
120  $sorted_options = array();
121  $sorted_options[0] = $lng->txt('cal_ch_grp_no_assignment');
122  foreach($options as $key => $opt)
123  {
124  $sorted_options[$key] = $opt;
125  }
126  return $sorted_options;
127  }
128 }
129 ?>