ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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.

References $a_context_id, $a_type, $DIC, $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().

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

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

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

75  {
76  global $DIC;
77 
78  $ilDB = $DIC['ilDB'];
79 
80  // @todo check start time
81 
82  include_once './Services/Calendar/classes/class.ilCalendarCategory.php';
84 
85  $start_limit = '';
86  if ($start instanceof ilDateTime) {
87  $start_limit = 'AND ce.starta >= ' . $ilDB->quote($start->get(IL_CAL_DATETIME, '', 'UTC'), 'timestamp');
88  }
89 
90  $query = 'SELECT ce.cal_id FROM cal_entries ce ' .
91  'JOIN cal_cat_assignments ca ON ce.cal_id = ca.cal_id ' .
92  'JOIN cal_categories cc ON ca.cat_id = cc.cat_id ' .
93  'JOIN booking_entry be ON ce.context_id = be.booking_id ' .
94  'WHERE cc.obj_id = ' . $ilDB->quote($a_user_id, 'integer') . ' ' .
95  'AND cc.type = ' . $ilDB->quote($type, 'integer') . ' ' .
96  'AND be.booking_group = ' . $ilDB->quote($a_ch_group_id, 'integer') . ' ' .
97  $start_limit . ' ' .
98  'ORDER BY ce.starta ';
99  $res = $ilDB->query($query);
100  $app_ids = array();
101  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
102  $app_ids[] = $row->cal_id;
103  }
104  return $app_ids;
105  }
const IL_CAL_DATETIME
$type
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
Date and time handling
$query
get($a_format, $a_format_str='', $a_tz='')
get formatted date
$row
global $ilDB
+ Here is the caller graph for this function:

◆ getAppointments()

static ilConsultationHourAppointments::getAppointments (   $a_user_id)
static

Get all appointments.

Returns

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

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

112  {
113  $entries = array();
114  foreach (self::getAppointmentIds($a_user_id) as $app_id) {
115  $entries[] = new ilCalendarEntry($app_id);
116  }
117  return $entries;
118  }
Model for a calendar entry.
+ 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 189 of file class.ilConsultationHourAppointments.php.

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

Referenced by ilConsultationHoursGUI\__construct(), and ilConsultationHoursGUI\setTabs().

190  {
191  global $DIC;
192 
193  $ilDB = $DIC['ilDB'];
194  $ilUser = $DIC['ilUser'];
195 
196  $all = array();
197  $set = $ilDB->query('SELECT user_id FROM cal_ch_settings' .
198  ' WHERE admin_id = ' . $ilDB->quote($ilUser->getId(), 'integer'));
199  while ($row = $ilDB->fetchAssoc($set)) {
200  $all[$row['user_id']] = ilObjUser::_lookupLogin($row['user_id']);
201  }
202  return $all;
203  }
static _lookupLogin($a_user_id)
lookup login
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18
$row
global $ilDB
+ 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 127 of file class.ilConsultationHourAppointments.php.

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

Referenced by ilAppointmentPresentationConsultationHoursGUI\collectPropertiesAndActions(), and ilConsultationHoursGUI\initSettingsForm().

128  {
129  global $DIC;
130 
131  $ilDB = $DIC['ilDB'];
132  $ilUser = $DIC['ilUser'];
133 
134  if (!$a_user_id) {
135  $user_id = $ilUser->getId();
136  } else {
137  $user_id = $a_user_id;
138  }
139 
140  $set = $ilDB->query('SELECT admin_id FROM cal_ch_settings' .
141  ' WHERE user_id = ' . $ilDB->quote($user_id, 'integer'));
142  $row = $ilDB->fetchAssoc($set);
143  if ($row && $row['admin_id']) {
144  if ($a_as_name && $a_full_name) {
145  return ilObjUser::_lookupFullname($row['admin_id']);
146  } elseif ($a_as_name) {
147  return ilObjUser::_lookupLogin($row['admin_id']);
148  }
149  return (int) $row['admin_id'];
150  }
151  }
static _lookupLogin($a_user_id)
lookup login
global $DIC
Definition: saml.php:7
static _lookupFullname($a_user_id)
Lookup Full Name.
$ilUser
Definition: imgupload.php:18
$row
global $ilDB
+ 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 158 of file class.ilConsultationHourAppointments.php.

References $DIC, $ilDB, $ilUser, and ilObjUser\_loginExists().

Referenced by ilConsultationHoursGUI\updateSettings().

159  {
160  global $DIC;
161 
162  $ilDB = $DIC['ilDB'];
163  $ilUser = $DIC['ilUser'];
164 
165  $user_id = false;
166  if ($a_user_name) {
167  $user_id = ilObjUser::_loginExists($a_user_name);
168  if (!$user_id) {
169  return false;
170  }
171  }
172 
173  $ilDB->manipulate('DELETE FROM cal_ch_settings' .
174  ' WHERE user_id = ' . $ilDB->quote($ilUser->getId(), 'integer'));
175 
176  if ($user_id && $user_id != $ilUser->getId()) {
177  $ilDB->manipulate('INSERT INTO cal_ch_settings (user_id, admin_id)' .
178  ' VALUES (' . $ilDB->quote($ilUser->getId(), 'integer') . ',' .
179  $ilDB->quote($user_id, 'integer') . ')');
180  }
181 
182  return true;
183  }
global $DIC
Definition: saml.php:7
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...
$ilUser
Definition: imgupload.php:18
global $ilDB
+ 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: