ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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
53 public function __construct($a_parent_obj, ilObject $rep_object, $waiting_list)
54 {
55 global $DIC;
56
57 $lng = $DIC['lng'];
58 $ilCtrl = $DIC['ilCtrl'];
59
60 $this->lng = $lng;
61 $this->lng->loadLanguageModule('grp');
62 $this->lng->loadLanguageModule('crs');
63 $this->lng->loadLanguageModule('sess');
64 $this->lng->loadLanguageModule('ps');
65 $this->ctrl = $ilCtrl;
66
67 $this->rep_object = $rep_object;
68
69 $this->setExternalSorting(true);
70 $this->setExternalSegmentation(true);
71 $this->setId('crs_wait_' . $this->getRepositoryObject()->getId());
72 $this->setFormName('waiting');
73 $this->setPrefix('waiting');
74
75 parent::__construct($a_parent_obj, 'participants');
76
77 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, 'participants'));
78
79 $this->addColumn('', 'f', "1", true);
80 $this->addColumn($this->lng->txt('name'), 'lastname', '20%');
81
82 $all_cols = $this->getSelectableColumns();
83 foreach ($this->getSelectedColumns() as $col) {
84 $this->addColumn($all_cols[$col]['txt'], $col);
85 }
86
87 $this->addColumn($this->lng->txt('application_date'), 'sub_time', "10%");
88 $this->addColumn('', 'mail', '10%');
89
90 $this->addMultiCommand('confirmAssignFromWaitingList', $this->lng->txt('assign'));
91 $this->addMultiCommand('confirmRefuseFromList', $this->lng->txt('refuse'));
92 $this->addMultiCommand('sendMailToSelectedUsers', $this->lng->txt('crs_mem_send_mail'));
93
94 $this->setDefaultOrderField('sub_time');
95 $this->setPrefix('waiting');
96 $this->setSelectAllCheckbox('waiting', true);
97
98 $this->setRowTemplate("tpl.show_waiting_list_row.html", "Services/Membership");
99
100 $this->enable('sort');
101 $this->enable('header');
102 $this->enable('numinfo');
103 $this->enable('select_all');
104
105 $this->waiting_list = $waiting_list;
106
107 include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
108 self::$has_odf_definitions = ilCourseDefinedFieldDefinition::_hasFields($this->getRepositoryObject()->getId());
109 }
110
114 protected function getWaitingList()
115 {
116 return $this->waiting_list;
117 }
118
123 protected function getRepositoryObject()
124 {
125 return $this->rep_object;
126 }
127
132 public function setUserIds($a_user_ids)
133 {
134 $this->wait_user_ids = $this->wait = [];
135 foreach ($a_user_ids as $usr_id) {
136 $this->wait_user_ids[] = $usr_id;
137 $this->wait[$usr_id] = $this->getWaitingList()->getUser($usr_id);
138 }
139 }
140
145 public function getSelectableColumns()
146 {
147 if (self::$all_columns) {
148 return self::$all_columns;
149 }
150
151 include_once './Services/PrivacySecurity/classes/class.ilExportFieldsInfo.php';
153 self::$all_columns = $ef->getSelectableFieldsInfo($this->getRepositoryObject()->getId());
154
155 // #25215
156 if (
157 is_array(self::$all_columns) &&
158 array_key_exists('consultation_hour', self::$all_columns)
159 ) {
160 unset(self::$all_columns['consultation_hour']);
161 }
162
163 if (
164 !is_array(self::$all_columns) ||
165 !array_key_exists('login', self::$all_columns)
166 ) {
167 self::$all_columns['login'] = [
168 'default' => 1,
169 'txt' => $this->lng->txt('login')
170 ];
171 }
172 return self::$all_columns;
173 }
174
175
183 public function fillRow($a_set)
184 {
185 global $DIC;
186
187 $ilUser = $DIC['ilUser'];
188
189 include_once('./Services/Calendar/classes/class.ilDateTime.php');
190 include_once './Modules/Course/classes/class.ilObjCourseGrouping.php';
191
194 $prefix = $this->getRepositoryObject()->getType();
195 $this->tpl->setVariable(
196 'ALERT_MSG',
197 sprintf(
198 $this->lng->txt($prefix . '_lim_assigned'),
199 ilObject::_lookupTitle(current($ids))
200 )
201 );
202 }
203
204 $this->tpl->setVariable('VAL_ID', $a_set['usr_id']);
205 $this->tpl->setVariable('VAL_NAME', $a_set['lastname'] . ', ' . $a_set['firstname']);
206
207 foreach ($this->getSelectedColumns() as $field) {
208 switch ($field) {
209 case 'gender':
210 $a_set['gender'] = $a_set['gender'] ? $this->lng->txt('gender_' . $a_set['gender']) : '';
211 $this->tpl->setCurrentBlock('custom_fields');
212 $this->tpl->setVariable('VAL_CUST', $a_set[$field]);
213 $this->tpl->parseCurrentBlock();
214 break;
215
216 case 'birthday':
217 $a_set['birthday'] = $a_set['birthday'] ? ilDatePresentation::formatDate(new ilDate($a_set['birthday'], IL_CAL_DATE)) : $this->lng->txt('no_date');
218 $this->tpl->setCurrentBlock('custom_fields');
219 $this->tpl->setVariable('VAL_CUST', $a_set[$field]);
220 $this->tpl->parseCurrentBlock();
221 break;
222
223 case 'odf_last_update':
224 $this->tpl->setVariable('VAL_CUST', (string) $a_set['odf_info_txt']);
225 break;
226
227 case 'org_units':
228 $this->tpl->setCurrentBlock('custom_fields');
229 include_once './Modules/OrgUnit/classes/PathStorage/class.ilOrgUnitPathStorage.php';
230 $this->tpl->setVariable('VAL_CUST', (string) ilOrgUnitPathStorage::getTextRepresentationOfUsersOrgUnits($a_set['usr_id']));
231 $this->tpl->parseCurrentBlock();
232 break;
233
234
235 default:
236 $this->tpl->setCurrentBlock('custom_fields');
237 $this->tpl->setVariable('VAL_CUST', isset($a_set[$field]) ? (string) $a_set[$field] : '');
238 $this->tpl->parseCurrentBlock();
239 break;
240 }
241 }
242
243 $this->tpl->setVariable('VAL_SUBTIME', ilDatePresentation::formatDate(new ilDateTime($a_set['sub_time'], IL_CAL_UNIX)));
244
245 #$this->tpl->setVariable('VAL_LOGIN',$a_set['login']);
246
247 $this->showActionLinks($a_set);
248 }
249
257 public function readUserData()
258 {
260
261 include_once './Services/User/classes/class.ilUserQuery.php';
262
263 $additional_fields = $this->getSelectedColumns();
264 unset($additional_fields["firstname"]);
265 unset($additional_fields["lastname"]);
266 unset($additional_fields["last_login"]);
267 unset($additional_fields["access_until"]);
268 unset($additional_fields['org_units']);
269
270 $udf_ids = $usr_data_fields = $odf_ids = array();
271 foreach ($additional_fields as $field) {
272 if (substr($field, 0, 3) == 'udf') {
273 $udf_ids[] = substr($field, 4);
274 continue;
275 }
276 if (substr($field, 0, 3) == 'odf') {
277 $odf_ids[] = substr($field, 4);
278 continue;
279 }
280
281 $usr_data_fields[] = $field;
282 }
283
284 $l = $this->getLimit();
286 $this->getOrderField(),
287 $this->getOrderDirection(),
288 $this->getOffset(),
289 $this->getLimit(),
290 '',
291 '',
292 null,
293 false,
294 false,
295 0,
296 0,
297 null,
298 $usr_data_fields,
299 $this->wait_user_ids
300 );
301 if (0 === count($usr_data['set']) && $this->getOffset() > 0 && $this->getExternalSegmentation()) {
302 $this->resetOffset();
303
305 $this->getOrderField(),
306 $this->getOrderDirection(),
307 $this->getOffset(),
308 $this->getLimit(),
309 '',
310 '',
311 null,
312 false,
313 false,
314 0,
315 0,
316 null,
317 $usr_data_fields,
318 $this->wait_user_ids
319 );
320 }
321
322 ilLoggerFactory::getLogger('mem')->dump($this->wait_user_ids);
323 ilLoggerFactory::getLogger('mem')->dump($usr_data);
324
325 foreach ((array) $usr_data['set'] as $user) {
326 $usr_ids[] = $user['usr_id'];
327 }
328
329 // merge course data
330 $course_user_data = $this->getParentObject()->readMemberData($usr_ids, array());
331 $a_user_data = array();
332 foreach ((array) $usr_data['set'] as $ud) {
333 $a_user_data[$ud['usr_id']] = array_merge($ud, $course_user_data[$ud['usr_id']]);
334 }
335
336 // Custom user data fields
337 if ($udf_ids) {
338 include_once './Services/User/classes/class.ilUserDefinedData.php';
339 $data = ilUserDefinedData::lookupData($usr_ids, $udf_ids);
340 foreach ($data as $usr_id => $fields) {
341 if (!$this->checkAcceptance($usr_id)) {
342 continue;
343 }
344
345 foreach ($fields as $field_id => $value) {
346 $a_user_data[$usr_id]['udf_' . $field_id] = $value;
347 }
348 }
349 }
350 // Object specific user data fields
351 if ($odf_ids) {
352 include_once './Modules/Course/classes/Export/class.ilCourseUserData.php';
354 foreach ($data as $usr_id => $fields) {
355 // #7264: as we get data for all course members filter against user data
356 if (!$this->checkAcceptance($usr_id) || !in_array($usr_id, $usr_ids)) {
357 continue;
358 }
359
360 foreach ($fields as $field_id => $value) {
361 $a_user_data[$usr_id]['odf_' . $field_id] = $value;
362 }
363 }
364
365 // add last edit date
366 include_once './Services/Membership/classes/class.ilObjectCustomUserFieldHistory.php';
367 foreach (ilObjectCustomUserFieldHistory::lookupEntriesByObjectId($this->getRepositoryObject()->getId()) as $usr_id => $edit_info) {
368 if (!isset($a_user_data[$usr_id])) {
369 continue;
370 }
371
372 include_once './Services/PrivacySecurity/classes/class.ilPrivacySettings.php';
373 if ($usr_id == $edit_info['update_user']) {
374 $a_user_data[$usr_id]['odf_last_update'] = '';
375 $a_user_data[$usr_id]['odf_info_txt'] = $GLOBALS['DIC']['lng']->txt('cdf_edited_by_self');
376 if (ilPrivacySettings::_getInstance()->enabledAccessTimesByType($this->getRepositoryObject()->getType())) {
377 $a_user_data[$usr_id]['odf_last_update'] .= ('_' . $edit_info['editing_time']->get(IL_CAL_UNIX));
378 $a_user_data[$usr_id]['odf_info_txt'] .= (', ' . ilDatePresentation::formatDate($edit_info['editing_time']));
379 }
380 } else {
381 $a_user_data[$usr_id]['odf_last_update'] = $edit_info['update_user'];
382 $a_user_data[$usr_id]['odf_last_update'] .= ('_' . $edit_info['editing_time']->get(IL_CAL_UNIX));
383
384 $name = ilObjUser::_lookupName($edit_info['update_user']);
385 $a_user_data[$usr_id]['odf_info_txt'] = ($name['firstname'] . ' ' . $name['lastname'] . ', ' . ilDatePresentation::formatDate($edit_info['editing_time']));
386 }
387 }
388 }
389
390 foreach ($usr_data['set'] as $user) {
391 // Check acceptance
392 if (!$this->checkAcceptance($user['usr_id'])) {
393 continue;
394 }
395 // DONE: accepted
396 foreach ($usr_data_fields as $field) {
397 $a_user_data[$user['usr_id']][$field] = $user[$field] ? $user[$field] : '';
398 }
399 }
400
401 // Waiting list subscription
402 foreach ($this->wait as $usr_id => $wait_usr_data) {
403 if (isset($a_user_data[$usr_id])) {
404 $a_user_data[$usr_id]['sub_time'] = $wait_usr_data['time'];
405 }
406 }
407
408 $this->setMaxCount($usr_data['cnt'] ? $usr_data['cnt'] : 0);
409 return $this->setData($a_user_data);
410 }
411
416 public function showActionLinks($a_set)
417 {
418 if (!self::$has_odf_definitions) {
419 $this->ctrl->setParameterByClass(get_class($this->getParentObject()), 'member_id', $a_set['usr_id']);
420 $link = $this->ctrl->getLinkTargetByClass(get_class($this->getParentObject()), 'sendMailToSelectedUsers');
421 $this->tpl->setVariable('MAIL_LINK', $link);
422 $this->tpl->setVariable('MAIL_TITLE', $this->lng->txt('crs_mem_send_mail'));
423 return true;
424 }
425
426 // show action menu
427 include_once './Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
429 $list->setSelectionHeaderClass('small');
430 $list->setItemLinkClass('small');
431 $list->setId('actl_' . $a_set['usr_id'] . '_' . $this->getId());
432 $list->setListTitle($this->lng->txt('actions'));
433
434 $this->ctrl->setParameterByClass(get_class($this->getParentObject()), 'member_id', $a_set['usr_id']);
435 $this->ctrl->setParameter($this->parent_obj, 'member_id', $a_set['usr_id']);
436 $trans = $this->lng->txt($this->getRepositoryObject()->getType() . '_mem_send_mail');
437 $link = $this->ctrl->getLinkTargetByClass(get_class($this->getParentObject()), 'sendMailToSelectedUsers');
438 $list->addItem($trans, '', $link, 'sendMailToSelectedUsers');
439
440 $this->ctrl->setParameterByClass('ilobjectcustomuserfieldsgui', 'member_id', $a_set['usr_id']);
441 $trans = $this->lng->txt($this->getRepositoryObject()->getType() . '_cdf_edit_member');
442 $list->addItem($trans, '', $this->ctrl->getLinkTargetByClass('ilobjectcustomuserfieldsgui', 'editMember'));
443
444 $this->tpl->setVariable('ACTION_USER', $list->getHTML());
445 }
446
447
448
449 protected function checkAcceptance()
450 {
451 return true;
452 }
453}
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, $include_seconds=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.
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.
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.
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.
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.
__construct($a_parent_obj, ilObject $rep_object, $waiting_list)
ilWaitingListTableGUI constructor.
getRepositoryObject()
Get repository object.
setUserIds($a_user_ids)
Set user ids.
showActionLinks($a_set)
Show action links (mail ; edit crs|grp data)
getSelectableColumns()
Get selectable columns.
global $ilCtrl
Definition: ilias.php:18
$user
Definition: migrateto20.php:57
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18