ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilWaitingListTableGUI.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24include_once('./Services/Table/classes/class.ilTable2GUI.php');
25
26
36{
37 protected $rep_object = null;
38
39 protected $waiting_list = null;
40 protected $wait = array();
41 protected $wait_user_ids = array();
42
43 protected static $all_columns = null;
44 protected static $has_odf_definitions = false;
45
46
54 public function __construct($a_parent_obj, ilObject $rep_object, $waiting_list, $show_content = true)
55 {
56 global $lng,$ilCtrl;
57
58 $this->lng = $lng;
59 $this->lng->loadLanguageModule('grp');
60 $this->lng->loadLanguageModule('crs');
61 $this->lng->loadLanguageModule('sess');
62 $this->lng->loadLanguageModule('ps');
63 $this->ctrl = $ilCtrl;
64
65 $this->rep_object = $rep_object;
66
67 $this->setExternalSorting(true);
68 $this->setExternalSegmentation(true);
69 $this->setId('crs_wait_' . $this->getRepositoryObject()->getId());
70 $this->setFormName('waiting');
71 $this->setPrefix('waiting');
72
73 parent::__construct($a_parent_obj, 'participants');
74
75 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, 'participants'));
76
77 $this->addColumn('', 'f', "1");
78 $this->addColumn($this->lng->txt('name'), 'lastname', '20%');
79
80 $all_cols = $this->getSelectableColumns();
81 foreach ($this->getSelectedColumns() as $col) {
82 $this->addColumn($all_cols[$col]['txt'], $col);
83 }
84
85 $this->addColumn($this->lng->txt('application_date'), 'sub_time', "10%");
86 $this->addColumn('', 'mail', '10%');
87
88 $this->addMultiCommand('confirmAssignFromWaitingList', $this->lng->txt('assign'));
89 $this->addMultiCommand('confirmRefuseFromList', $this->lng->txt('refuse'));
90 $this->addMultiCommand('sendMailToSelectedUsers', $this->lng->txt('crs_mem_send_mail'));
91
92 $this->setDefaultOrderField('sub_time');
93
94 $this->setSelectAllCheckbox('waiting');
95 $this->setRowTemplate("tpl.show_waiting_list_row.html", "Services/Membership");
96
97 if ($show_content) {
98 $this->enable('sort');
99 $this->enable('header');
100 $this->enable('numinfo');
101 $this->enable('select_all');
102 } else {
103 $this->disable('content');
104 $this->disable('header');
105 $this->disable('footer');
106 $this->disable('numinfo');
107 $this->disable('select_all');
108 }
109
110 $this->waiting_list = $waiting_list;
111
112 include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
113 self::$has_odf_definitions = ilCourseDefinedFieldDefinition::_hasFields($this->getRepositoryObject()->getId());
114 }
115
119 protected function getWaitingList()
120 {
121 return $this->waiting_list;
122 }
123
128 protected function getRepositoryObject()
129 {
130 return $this->rep_object;
131 }
132
137 public function setUserIds($a_user_ids)
138 {
139 $this->wait_user_ids = $this->wait = [];
140 foreach ($a_user_ids as $usr_id) {
141 $this->wait_user_ids[] = $usr_id;
142 $this->wait[$usr_id] = $this->getWaitingList()->getUser($usr_id);
143 }
144 }
145
150 public function getSelectableColumns()
151 {
152 if (self::$all_columns) {
153 return self::$all_columns;
154 }
155
156 include_once './Services/PrivacySecurity/classes/class.ilExportFieldsInfo.php';
158 self::$all_columns = $ef->getSelectableFieldsInfo($this->getRepositoryObject()->getId());
159
160 // #25215
161 if (
162 is_array(self::$all_columns) &&
163 array_key_exists('consultation_hour', self::$all_columns)
164 ) {
165 unset(self::$all_columns['consultation_hour']);
166 }
167 return self::$all_columns;
168 }
169
170
178 public function fillRow($a_set)
179 {
180 global $ilUser;
181
182 include_once('./Services/Calendar/classes/class.ilDateTime.php');
183 include_once './Modules/Course/classes/class.ilObjCourseGrouping.php';
184
187 $prefix = $this->getRepositoryObject()->getType();
188 $this->tpl->setVariable(
189 'ALERT_MSG',
190 sprintf(
191 $this->lng->txt($prefix . '_lim_assigned'),
192 ilObject::_lookupTitle(current($ids))
193 )
194 );
195 }
196
197 $this->tpl->setVariable('VAL_ID', $a_set['usr_id']);
198 $this->tpl->setVariable('VAL_NAME', $a_set['lastname'] . ', ' . $a_set['firstname']);
199
200 foreach ($this->getSelectedColumns() as $field) {
201 switch ($field) {
202 case 'gender':
203 $a_set['gender'] = $a_set['gender'] ? $this->lng->txt('gender_' . $a_set['gender']) : '';
204 $this->tpl->setCurrentBlock('custom_fields');
205 $this->tpl->setVariable('VAL_CUST', $a_set[$field]);
206 $this->tpl->parseCurrentBlock();
207 break;
208
209 case 'birthday':
210 $a_set['birthday'] = $a_set['birthday'] ? ilDatePresentation::formatDate(new ilDate($a_set['birthday'], IL_CAL_DATE)) : $this->lng->txt('no_date');
211 $this->tpl->setCurrentBlock('custom_fields');
212 $this->tpl->setVariable('VAL_CUST', $a_set[$field]);
213 $this->tpl->parseCurrentBlock();
214 break;
215
216 case 'odf_last_update':
217 $this->tpl->setVariable('VAL_CUST', (string) $a_set['odf_info_txt']);
218 break;
219
220 case 'org_units':
221 $this->tpl->setCurrentBlock('custom_fields');
222 include_once './Modules/OrgUnit/classes/PathStorage/class.ilOrgUnitPathStorage.php';
223 $this->tpl->setVariable('VAL_CUST', (string) ilOrgUnitPathStorage::getTextRepresentationOfUsersOrgUnits($a_set['usr_id']));
224 $this->tpl->parseCurrentBlock();
225 break;
226
227
228 default:
229 $this->tpl->setCurrentBlock('custom_fields');
230 $this->tpl->setVariable('VAL_CUST', isset($a_set[$field]) ? (string) $a_set[$field] : '');
231 $this->tpl->parseCurrentBlock();
232 break;
233 }
234 }
235
236 $this->tpl->setVariable('VAL_SUBTIME', ilDatePresentation::formatDate(new ilDateTime($a_set['sub_time'], IL_CAL_UNIX)));
237
238 #$this->tpl->setVariable('VAL_LOGIN',$a_set['login']);
239
240 $this->showActionLinks($a_set);
241 }
242
250 public function readUserData()
251 {
253
254 include_once './Services/User/classes/class.ilUserQuery.php';
255
256 $additional_fields = $this->getSelectedColumns();
257 unset($additional_fields["firstname"]);
258 unset($additional_fields["lastname"]);
259 unset($additional_fields["last_login"]);
260 unset($additional_fields["access_until"]);
261 unset($additional_fields['org_units']);
262
263 $udf_ids = $usr_data_fields = $odf_ids = array();
264 foreach ($additional_fields as $field) {
265 if (substr($field, 0, 3) == 'udf') {
266 $udf_ids[] = substr($field, 4);
267 continue;
268 }
269 if (substr($field, 0, 3) == 'odf') {
270 $odf_ids[] = substr($field, 4);
271 continue;
272 }
273
274 $usr_data_fields[] = $field;
275 }
276
277 $l = $this->getLimit();
279 $this->getOrderField(),
280 $this->getOrderDirection(),
281 $this->getOffset(),
282 $this->getLimit(),
283 '',
284 '',
285 null,
286 false,
287 false,
288 0,
289 0,
290 null,
291 $usr_data_fields,
292 $this->wait_user_ids
293 );
294 if (0 === count($usr_data['set']) && $this->getOffset() > 0 && $this->getExternalSegmentation()) {
295 $this->resetOffset();
296
298 $this->getOrderField(),
299 $this->getOrderDirection(),
300 $this->getOffset(),
301 $this->getLimit(),
302 '',
303 '',
304 null,
305 false,
306 false,
307 0,
308 0,
309 null,
310 $usr_data_fields,
311 $this->wait_user_ids
312 );
313 }
314
315 ilLoggerFactory::getLogger('mem')->dump($this->wait_user_ids);
316 ilLoggerFactory::getLogger('mem')->dump($usr_data);
317
318 foreach ((array) $usr_data['set'] as $user) {
319 $usr_ids[] = $user['usr_id'];
320 }
321
322 // merge course data
323 $course_user_data = $this->getParentObject()->readMemberData($usr_ids, array());
324 $a_user_data = array();
325 foreach ((array) $usr_data['set'] as $ud) {
326 $a_user_data[$ud['usr_id']] = array_merge($ud, $course_user_data[$ud['usr_id']]);
327 }
328
329 // Custom user data fields
330 if ($udf_ids) {
331 include_once './Services/User/classes/class.ilUserDefinedData.php';
332 $data = ilUserDefinedData::lookupData($usr_ids, $udf_ids);
333 foreach ($data as $usr_id => $fields) {
334 if (!$this->checkAcceptance($usr_id)) {
335 continue;
336 }
337
338 foreach ($fields as $field_id => $value) {
339 $a_user_data[$usr_id]['udf_' . $field_id] = $value;
340 }
341 }
342 }
343 // Object specific user data fields
344 if ($odf_ids) {
345 include_once './Modules/Course/classes/Export/class.ilCourseUserData.php';
347 foreach ($data as $usr_id => $fields) {
348 // #7264: as we get data for all course members filter against user data
349 if (!$this->checkAcceptance($usr_id) || !in_array($usr_id, $usr_ids)) {
350 continue;
351 }
352
353 foreach ($fields as $field_id => $value) {
354 $a_user_data[$usr_id]['odf_' . $field_id] = $value;
355 }
356 }
357
358 // add last edit date
359 include_once './Services/Membership/classes/class.ilObjectCustomUserFieldHistory.php';
360 foreach (ilObjectCustomUserFieldHistory::lookupEntriesByObjectId($this->getRepositoryObject()->getId()) as $usr_id => $edit_info) {
361 if (!isset($a_user_data[$usr_id])) {
362 continue;
363 }
364
365 include_once './Services/PrivacySecurity/classes/class.ilPrivacySettings.php';
366 if ($usr_id == $edit_info['update_user']) {
367 $a_user_data[$usr_id]['odf_last_update'] = '';
368 $a_user_data[$usr_id]['odf_info_txt'] = $GLOBALS['lng']->txt('cdf_edited_by_self');
369 if (ilPrivacySettings::_getInstance()->enabledAccessTimesByType($this->getRepositoryObject()->getType())) {
370 $a_user_data[$usr_id]['odf_last_update'] .= ('_' . $edit_info['editing_time']->get(IL_CAL_UNIX));
371 $a_user_data[$usr_id]['odf_info_txt'] .= (', ' . ilDatePresentation::formatDate($edit_info['editing_time']));
372 }
373 } else {
374 $a_user_data[$usr_id]['odf_last_update'] = $edit_info['update_user'];
375 $a_user_data[$usr_id]['odf_last_update'] .= ('_' . $edit_info['editing_time']->get(IL_CAL_UNIX));
376
377 $name = ilObjUser::_lookupName($edit_info['update_user']);
378 $a_user_data[$usr_id]['odf_info_txt'] = ($name['firstname'] . ' ' . $name['lastname'] . ', ' . ilDatePresentation::formatDate($edit_info['editing_time']));
379 }
380 }
381 }
382
383 foreach ($usr_data['set'] as $user) {
384 // Check acceptance
385 if (!$this->checkAcceptance($user['usr_id'])) {
386 continue;
387 }
388 // DONE: accepted
389 foreach ($usr_data_fields as $field) {
390 $a_user_data[$user['usr_id']][$field] = $user[$field] ? $user[$field] : '';
391 }
392 }
393
394 // Waiting list subscription
395 foreach ($this->wait as $usr_id => $wait_usr_data) {
396 if (isset($a_user_data[$usr_id])) {
397 $a_user_data[$usr_id]['sub_time'] = $wait_usr_data['time'];
398 }
399 }
400
401 $this->setMaxCount($usr_data['cnt'] ? $usr_data['cnt'] : 0);
402 return $this->setData($a_user_data);
403 }
404
409 public function showActionLinks($a_set)
410 {
411 if (!self::$has_odf_definitions) {
412 $this->ctrl->setParameterByClass(get_class($this->getParentObject()), 'member_id', $a_set['usr_id']);
413 $link = $this->ctrl->getLinkTargetByClass(get_class($this->getParentObject()), 'sendMailToSelectedUsers');
414 $this->tpl->setVariable('MAIL_LINK', $link);
415 $this->tpl->setVariable('MAIL_TITLE', $this->lng->txt('crs_mem_send_mail'));
416 return true;
417 }
418
419 // show action menu
420 include_once './Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
422 $list->setSelectionHeaderClass('small');
423 $list->setItemLinkClass('small');
424 $list->setId('actl_' . $a_set['usr_id'] . '_' . $this->getId());
425 $list->setListTitle($this->lng->txt('actions'));
426
427 $this->ctrl->setParameterByClass(get_class($this->getParentObject()), 'member_id', $a_set['usr_id']);
428 $this->ctrl->setParameter($this->parent_obj, 'member_id', $a_set['usr_id']);
429 $trans = $this->lng->txt($this->getRepositoryObject()->getType() . '_mem_send_mail');
430 $link = $this->ctrl->getLinkTargetByClass(get_class($this->getParentObject()), 'sendMailToSelectedUsers');
431 $list->addItem($trans, '', $link, 'sendMailToSelectedUsers');
432
433 $this->ctrl->setParameterByClass('ilobjectcustomuserfieldsgui', 'member_id', $a_set['usr_id']);
434 $trans = $this->lng->txt($this->getRepositoryObject()->getType() . '_cdf_edit_member');
435 $list->addItem($trans, '', $this->ctrl->getLinkTargetByClass('ilobjectcustomuserfieldsgui', 'editMember'));
436
437 $this->tpl->setVariable('ACTION_USER', $list->getHTML());
438 }
439
440
441
442 protected function checkAcceptance()
443 {
444 return true;
445 }
446}
sprintf('%.4f', $callTime)
global $l
Definition: afr.php:30
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATE
const IL_CAL_UNIX
User interface class for advanced drop-down selection lists.
static _hasFields($a_container_id)
Check if there are any define fields.
static _getValuesByObjId($a_obj_id)
Get values by obj_id (for all users)
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date @access public.
@classDescription Date and time handling
Class for single dates.
static _getInstanceByType($a_type)
Get Singleton Instance.
static getLogger($a_component_id)
Get component logger.
static _checkGroupingDependencies(&$container_obj, $a_user_id=null)
static getAssignedObjects()
Alway call checkGroupingDependencies before.
static _lookupName($a_user_id)
lookup user name
static lookupEntriesByObjectId($a_obj_id)
Get entries by obj_id @global type $ilDB.
Class ilObject Basic functions for all objects.
static _lookupTitle($a_id)
lookup object title
static _getInstance()
Get instance of ilPrivacySettings.
Class ilTable2GUI.
getSelectedColumns()
Get selected columns.
setExternalSorting($a_val)
Set external sorting.
getParentObject()
Get parent object.
setPrefix($a_prefix)
set prefix for sort and offset fields (if you have two or more tables on a page that you want to sort...
determineOffsetAndOrder($a_omit_offset=false)
Determine offset and order.
getId()
Get element id.
setData($a_data)
set table data @access public
getLimit()
Get limit.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
resetOffset($a_in_determination=false)
Reset offset.
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.
getExternalSegmentation()
Get external segmentation.
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.
getOffset()
Get offset.
setExternalSegmentation($a_val)
Set external segmentation.
setId($a_val)
Set id.
setFormName($a_formname="")
Set Form name.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
getOrderDirection()
Get order direction.
setMaxCount($a_max_count)
set max.
disable($a_module_name)
diesables particular modules of table
enable($a_module_name)
enables particular modules of table
static lookupData($a_user_ids, $a_field_ids)
Lookup data.
static getUserListData( $a_order_field, $a_order_dir, $a_offset, $a_limit, $a_string_filter="", $a_activation_filter="", $a_last_login_filter=null, $a_limited_access_filter=false, $a_no_courses_filter=false, $a_course_group_filter=0, $a_role_filter=0, $a_user_folder_filter=null, $a_additional_fields='', $a_user_filter=null, $a_first_letter="", $a_authentication_filter=null)
Get data for user administration list.
GUI class for course/group waiting list.
getRepositoryObject()
Get repository object.
__construct($a_parent_obj, ilObject $rep_object, $waiting_list, $show_content=true)
Constructor.
setUserIds($a_user_ids)
Set user ids.
showActionLinks($a_set)
Show action links (mail ; edit crs|grp data)
getSelectableColumns()
Get selectable columns.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
global $ilCtrl
Definition: ilias.php:18
if($format !==null) $name
Definition: metadata.php:146
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
$ilUser
Definition: imgupload.php:18