ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 $DIC;
31
32 $lng = $DIC['lng'];
33 $ilCtrl = $DIC['ilCtrl'];
34
35 $this->user_id = $a_user_id;
36
37 include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourGroups.php';
38 $this->has_groups = ilConsultationHourGroups::getCountGroupsOfUser($a_user_id);
39
40 $this->setId('chtg_' . $this->getUserId());
41 parent::__construct($a_gui, $a_cmd);
42
43 $this->addColumn('', 'f', 1);
44 $this->addColumn($this->lng->txt('appointment'), 'start');
45
46 if ($this->hasGroups()) {
47 $this->addColumn($this->lng->txt('cal_ch_grp_header'), 'group');
48 }
49
50 $this->addColumn($this->lng->txt('title'), 'title');
51 $this->addColumn($this->lng->txt('cal_ch_num_bookings'), 'num_bookings');
52 $this->addColumn($this->lng->txt('cal_ch_bookings'), 'participants');
53 $this->addColumn($this->lng->txt('cal_ch_target_object'), 'target');
54 $this->addColumn('');
55
56 $this->setRowTemplate('tpl.ch_upcoming_row.html', 'Services/Calendar');
57 $this->setFormAction($ilCtrl->getFormAction($this->getParentObject(), $this->getParentCmd()));
58 $this->setTitle($this->lng->txt('cal_ch_ch'));
59
60 $this->enable('sort');
61 $this->enable('header');
62 $this->enable('numinfo');
63
64 $this->setDefaultOrderField('start');
65 $this->setSelectAllCheckbox('apps');
66 $this->setShowRowsSelector(true);
67 $this->addMultiCommand('edit', $this->lng->txt('edit'));
68 $this->addMultiCommand('searchUsersForAppointments', $this->lng->txt('cal_ch_assign_participants'));
69 $this->addMultiCommand('confirmDelete', $this->lng->txt('delete'));
70 }
71
76 public function getUserId()
77 {
78 return $this->user_id;
79 }
80
84 public function hasGroups()
85 {
86 return $this->has_groups;
87 }
88
93 public function fillRow($row)
94 {
95 global $DIC;
96
97 $ilCtrl = $DIC['ilCtrl'];
98
99 $this->tpl->setVariable('VAL_ID', $row['id']);
100 $this->tpl->setVariable('START', $row['start_p']);
101 $this->tpl->setVariable('TITLE', $row['title']);
102
103 if ($this->hasGroups()) {
104 $this->tpl->setVariable('TITLE_GROUP', $row['group']);
105 }
106
107 $this->tpl->setVariable('NUM_BOOKINGS', $row['num_bookings']);
108
109 foreach ((array) $row['target_links'] as $link) {
110 $this->tpl->setCurrentBlock('links');
111 $this->tpl->setVariable('TARGET', $link['title']);
112 $this->tpl->setVariable('URL_TARGET', $link['link']);
113 $this->tpl->parseCurrentBlock();
114 }
115 if ($row['bookings']) {
116 foreach ($row['bookings'] as $user_id => $name) {
117 $user_profile_prefs = ilObjUser::_getPreferences($user_id);
118 if ($user_profile_prefs["public_profile"] == "y") {
119 $this->tpl->setCurrentBlock('booking_with_link');
120 $ilCtrl->setParameter($this->getParentObject(), 'user', $user_id);
121 $this->tpl->setVariable('URL_BOOKING', $ilCtrl->getLinkTarget($this->getParentObject(), 'showprofile'));
122 } else {
123 $this->tpl->setCurrentBlock('booking_without_link');
124 }
125 $ilCtrl->setParameter($this->getParentObject(), 'user', '');
126 $this->tpl->setVariable('TXT_BOOKING', $name);
127 $this->tpl->parseCurrentBlock();
128 }
129 }
130
131 $this->tpl->setVariable('BOOKINGS', implode(', ', $row['bookings']));
132
133 include_once './Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
134 $list = new ilAdvancedSelectionListGUI();
135 $list->setId('act_cht_' . $row['id']);
136 $list->setListTitle($this->lng->txt('actions'));
137
138 $ilCtrl->setParameter($this->getParentObject(), 'apps', $row['id']);
139 $list->addItem(
140 $this->lng->txt('edit'),
141 '',
142 $ilCtrl->getLinkTarget($this->getParentObject(), 'edit')
143 );
144 $list->addItem(
145 $this->lng->txt('cal_ch_assign_participants'),
146 '',
147 $ilCtrl->getLinkTargetByClass('ilRepositorySearchGUI', '')
148 );
149 $list->addItem(
150 $this->lng->txt('delete'),
151 '',
152 $ilCtrl->getLinkTarget($this->getParentObject(), 'confirmDelete')
153 );
154 $this->tpl->setVariable('ACTIONS', $list->getHTML());
155 }
156
161 public function parse()
162 {
163 global $DIC;
164
165 $ilDB = $DIC['ilDB'];
166 $ilObjDataCache = $DIC['ilObjDataCache'];
167
168 include_once 'Services/Booking/classes/class.ilBookingEntry.php';
169
170 $data = array();
171 $counter = 0;
173 $data[$counter]['id'] = $app->getEntryId();
174 $data[$counter]['title'] = $app->getTitle();
175 $data[$counter]['description'] = $app->getDescription();
176 $data[$counter]['start'] = $app->getStart()->get(IL_CAL_UNIX);
177 $data[$counter]['start_p'] = ilDatePresentation::formatPeriod($app->getStart(), $app->getEnd());
178
179 $booking = new ilBookingEntry($app->getContextId());
180
181 $booked_user_ids = $booking->getCurrentBookings($app->getEntryId());
182 $booked_user_ids = ilUtil::_sortIds($booked_user_ids, 'usr_data', 'lastname', 'usr_id');
183 $users = array();
184 $data[$counter]['participants'] = '';
185 $user_counter = 0;
186 foreach ($booked_user_ids as $user_id) {
187 if (!$user_counter) {
189 $data[$counter]['participants'] = $name['lastname'];
190 }
192 $user_counter++;
193 }
194 $data[$counter]['bookings'] = $users;
195 $data[$counter]['num_bookings'] = $booking->getNumberOfBookings();
196
197 $data[$counter]['group'] = '';
198 $group_id = $booking->getBookingGroup();
199 if ($this->hasGroups() && $group_id) {
200 $data[$counter]['group'] = ilConsultationHourGroups::lookupTitle($group_id);
201 }
202
203 // obj assignments
204 $refs_counter = 0;
205 $obj_ids = ilUtil::_sortIds($booking->getTargetObjIds(), 'object_data', 'title', 'obj_id');
206 foreach ($obj_ids as $obj_id) {
207 if ($refs_counter) {
208 $data[$counter]['target'] = ilObject::_lookupTitle($obj_id);
209 }
210
211 $refs = ilObject::_getAllReferences($obj_id);
212 include_once './Services/Link/classes/class.ilLink.php';
213 $data[$counter]['target_links'][$refs_counter]['title'] = ilObject::_lookupTitle($obj_id);
214 $data[$counter]['target_links'][$refs_counter]['link'] = ilLink::_getLink(end($refs));
215 ++$refs_counter;
216 }
217 $counter++;
218 }
219 $this->setData($data);
220 }
221}
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.
setSelectAllCheckbox($a_select_all_checkbox, $a_select_all_on_top=false)
Set the name of the checkbox that should be toggled with a select all button.
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.
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,...
$app
Definition: cli.php:38
global $ilCtrl
Definition: ilias.php:18
if($format !==null) $name
Definition: metadata.php:230
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $ilDB
$DIC
Definition: xapitoken.php:46