ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilConsultationHoursTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once './Services/Table/classes/class.ilTable2GUI.php';
5include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourAppointments.php';
6
17{
18 private $user_id = 0;
19 private $has_groups = false;
20
28 public function __construct($a_gui, $a_cmd, $a_user_id)
29 {
30 global $lng,$ilCtrl;
31
32 $this->user_id = $a_user_id;
33
34 include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourGroups.php';
35 $this->has_groups = ilConsultationHourGroups::getCountGroupsOfUser($a_user_id);
36
37 $this->setId('chtg_' . $this->getUserId());
38 parent::__construct($a_gui, $a_cmd);
39
40 $this->addColumn('', 'f', 1);
41 $this->addColumn($this->lng->txt('appointment'), 'start');
42
43 if ($this->hasGroups()) {
44 $this->addColumn($this->lng->txt('cal_ch_grp_header'), 'group');
45 }
46
47 $this->addColumn($this->lng->txt('title'), 'title');
48 $this->addColumn($this->lng->txt('cal_ch_num_bookings'), 'num_bookings');
49 $this->addColumn($this->lng->txt('cal_ch_bookings'), 'participants');
50 $this->addColumn($this->lng->txt('cal_ch_target_object'), 'target');
51 $this->addColumn('');
52
53 $this->setRowTemplate('tpl.ch_upcoming_row.html', 'Services/Calendar');
54 $this->setFormAction($ilCtrl->getFormAction($this->getParentObject(), $this->getParentCmd()));
55 $this->setTitle($this->lng->txt('cal_ch_ch'));
56
57 $this->enable('sort');
58 $this->enable('header');
59 $this->enable('numinfo');
60
61 $this->setDefaultOrderField('start');
62 $this->setSelectAllCheckbox('apps');
63 $this->setShowRowsSelector(true);
64 $this->addMultiCommand('edit', $this->lng->txt('edit'));
65 $this->addMultiCommand('searchUsersForAppointments', $this->lng->txt('cal_ch_assign_participants'));
66 $this->addMultiCommand('confirmDelete', $this->lng->txt('delete'));
67 }
68
73 public function getUserId()
74 {
75 return $this->user_id;
76 }
77
81 public function hasGroups()
82 {
83 return $this->has_groups;
84 }
85
90 public function fillRow($row)
91 {
92 global $ilCtrl;
93
94 $this->tpl->setVariable('VAL_ID', $row['id']);
95 $this->tpl->setVariable('START', $row['start_p']);
96 $this->tpl->setVariable('TITLE', $row['title']);
97
98 if ($this->hasGroups()) {
99 $this->tpl->setVariable('TITLE_GROUP', $row['group']);
100 }
101
102 $this->tpl->setVariable('NUM_BOOKINGS', $row['num_bookings']);
103
104 foreach ((array) $row['target_links'] as $link) {
105 $this->tpl->setCurrentBlock('links');
106 $this->tpl->setVariable('TARGET', $link['title']);
107 $this->tpl->setVariable('URL_TARGET', $link['link']);
108 $this->tpl->parseCurrentBlock();
109 }
110 if ($row['bookings']) {
111 foreach ($row['bookings'] as $user_id => $name) {
112 $user_profile_prefs = ilObjUser::_getPreferences($user_id);
113 if ($user_profile_prefs["public_profile"] == "y") {
114 $this->tpl->setCurrentBlock('booking_with_link');
115 $ilCtrl->setParameter($this->getParentObject(), 'user', $user_id);
116 $this->tpl->setVariable('URL_BOOKING', $ilCtrl->getLinkTarget($this->getParentObject(), 'showprofile'));
117 } else {
118 $this->tpl->setCurrentBlock('booking_without_link');
119 }
120 $ilCtrl->setParameter($this->getParentObject(), 'user', '');
121 $this->tpl->setVariable('TXT_BOOKING', $name);
122 $this->tpl->parseCurrentBlock();
123 }
124 }
125
126 $this->tpl->setVariable('BOOKINGS', implode(', ', $row['bookings']));
127
128 include_once './Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
130 $list->setId('act_cht_' . $row['id']);
131 $list->setListTitle($this->lng->txt('actions'));
132
133 $ilCtrl->setParameter($this->getParentObject(), 'apps', $row['id']);
134 $list->addItem(
135 $this->lng->txt('edit'),
136 '',
137 $ilCtrl->getLinkTarget($this->getParentObject(), 'edit')
138 );
139 $list->addItem(
140 $this->lng->txt('cal_ch_assign_participants'),
141 '',
142 $ilCtrl->getLinkTargetByClass('ilRepositorySearchGUI', '')
143 );
144 $list->addItem(
145 $this->lng->txt('delete'),
146 '',
147 $ilCtrl->getLinkTarget($this->getParentObject(), 'confirmDelete')
148 );
149 $this->tpl->setVariable('ACTIONS', $list->getHTML());
150 }
151
156 public function parse()
157 {
158 global $ilDB, $ilObjDataCache;
159
160 include_once 'Services/Booking/classes/class.ilBookingEntry.php';
161
162 $data = array();
163 $counter = 0;
165 $data[$counter]['id'] = $app->getEntryId();
166 $data[$counter]['title'] = $app->getTitle();
167 $data[$counter]['description'] = $app->getDescription();
168 $data[$counter]['start'] = $app->getStart()->get(IL_CAL_UNIX);
169 $data[$counter]['start_p'] = ilDatePresentation::formatPeriod($app->getStart(), $app->getEnd());
170
171 $booking = new ilBookingEntry($app->getContextId());
172
173 $booked_user_ids = $booking->getCurrentBookings($app->getEntryId());
174 $booked_user_ids = ilUtil::_sortIds($booked_user_ids, 'usr_data', 'lastname', 'usr_id');
175 $users = array();
176 $data[$counter]['participants'] = '';
177 $user_counter = 0;
178 foreach ($booked_user_ids as $user_id) {
179 if (!$user_counter) {
181 $data[$counter]['participants'] = $name['lastname'];
182 }
184 $user_counter++;
185 }
186 $data[$counter]['bookings'] = $users;
187 $data[$counter]['num_bookings'] = $booking->getNumberOfBookings();
188
189 $data[$counter]['group'] = '';
190 $group_id = $booking->getBookingGroup();
191 if ($this->hasGroups() && $group_id) {
193 }
194
195 // obj assignments
196 $refs_counter = 0;
197 $obj_ids = ilUtil::_sortIds($booking->getTargetObjIds(), 'object_data', 'title', 'obj_id');
198 foreach ($obj_ids as $obj_id) {
199 if ($refs_counter) {
200 $data[$counter]['target'] = ilObject::_lookupTitle($obj_id);
201 }
202
203 $refs = ilObject::_getAllReferences($obj_id);
204 include_once './Services/Link/classes/class.ilLink.php';
205 $data[$counter]['target_links'][$refs_counter]['title'] = ilObject::_lookupTitle($obj_id);
206 $data[$counter]['target_links'][$refs_counter]['link'] = ilLink::_getLink(end($refs));
207 ++$refs_counter;
208 }
209 $counter++;
210 }
211 $this->setData($data);
212 }
213}
$users
Definition: authpage.php:44
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
User interface class for advanced drop-down selection lists.
Booking definition.
static getAppointments($a_user_id)
Get all appointments.
static lookupTitle($a_group_id)
Lookup group title.
static getCountGroupsOfUser($a_user_id)
Get number of consultation hour groups @global type $ilDB.
Consultation hours administration.
__construct($a_gui, $a_cmd, $a_user_id)
Constructor.
hasGroups()
Check if user has created groups.
static formatPeriod(ilDateTime $start, ilDateTime $end, $a_skip_starting_day=false)
Format a period of two date Shows: 14.
static _getPreferences($user_id)
get preferences for user
static _lookupName($a_user_id)
lookup user name
static _lookupFullname($a_user_id)
Lookup Full Name.
static _lookupTitle($a_id)
lookup object title
static _getAllReferences($a_id)
get all reference ids of object
Class ilTable2GUI.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
getParentObject()
Get parent object.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addMultiCommand($a_cmd, $a_text)
Add Command button.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
enable($a_module_name)
enables particular modules of table
static _sortIds($a_ids, $a_table, $a_field, $a_id_name)
Function that sorts ids by a given table field using WHERE IN E.g: __sort(array(6,...
$counter
global $ilCtrl
Definition: ilias.php:18
if($format !==null) $name
Definition: metadata.php:146
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
global $ilDB