ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
96 // begin-patch clipboard
97 $this->lng->loadLanguageModule('user');
98 $this->addMultiCommand('addToClipboard', $this->lng->txt('clipboard_add_btn'));
99 // end-patch clipboard
100
101 $this->setPrefix('waiting');
102 $this->setSelectAllCheckbox('waiting', true);
103
104 $this->setRowTemplate("tpl.show_waiting_list_row.html", "Services/Membership");
105
106 $this->enable('sort');
107 $this->enable('header');
108 $this->enable('numinfo');
109 $this->enable('select_all');
110
111 $this->waiting_list = $waiting_list;
112
113 include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
114 self::$has_odf_definitions = ilCourseDefinedFieldDefinition::_hasFields($this->getRepositoryObject()->getId());
115 }
116
120 protected function getWaitingList()
121 {
122 return $this->waiting_list;
123 }
124
129 protected function getRepositoryObject()
130 {
131 return $this->rep_object;
132 }
133
138 public function setUserIds($a_user_ids)
139 {
140 $this->wait_user_ids = $this->wait = [];
141 foreach ($a_user_ids as $usr_id) {
142 $this->wait_user_ids[] = $usr_id;
143 $this->wait[$usr_id] = $this->getWaitingList()->getUser($usr_id);
144 }
145 }
146
151 public function getSelectableColumns()
152 {
153 if (self::$all_columns) {
154 return self::$all_columns;
155 }
156
157 include_once './Services/PrivacySecurity/classes/class.ilExportFieldsInfo.php';
159 self::$all_columns = $ef->getSelectableFieldsInfo($this->getRepositoryObject()->getId());
160
161 // #25215
162 if (
163 is_array(self::$all_columns) &&
164 array_key_exists('consultation_hour', self::$all_columns)
165 ) {
166 unset(self::$all_columns['consultation_hour']);
167 }
168
169 if (
170 !is_array(self::$all_columns) ||
171 !array_key_exists('login', self::$all_columns)
172 ) {
173 self::$all_columns['login'] = [
174 'default' => 1,
175 'txt' => $this->lng->txt('login')
176 ];
177 }
178 return self::$all_columns;
179 }
180
181
189 public function fillRow($a_set)
190 {
191 global $DIC;
192
193 $ilUser = $DIC['ilUser'];
194
195 include_once('./Services/Calendar/classes/class.ilDateTime.php');
196 include_once './Modules/Course/classes/class.ilObjCourseGrouping.php';
197
200 $prefix = $this->getRepositoryObject()->getType();
201 $this->tpl->setVariable(
202 'ALERT_MSG',
203 sprintf(
204 $this->lng->txt($prefix . '_lim_assigned'),
205 ilObject::_lookupTitle(current($ids))
206 )
207 );
208 }
209
210 $this->tpl->setVariable('VAL_ID', $a_set['usr_id']);
211 $this->tpl->setVariable('VAL_NAME', $a_set['lastname'] . ', ' . $a_set['firstname']);
212
213 foreach ($this->getSelectedColumns() as $field) {
214 switch ($field) {
215 case 'gender':
216 $a_set['gender'] = $a_set['gender'] ? $this->lng->txt('gender_' . $a_set['gender']) : '';
217 $this->tpl->setCurrentBlock('custom_fields');
218 $this->tpl->setVariable('VAL_CUST', $a_set[$field]);
219 $this->tpl->parseCurrentBlock();
220 break;
221
222 case 'birthday':
223 $a_set['birthday'] = $a_set['birthday'] ? ilDatePresentation::formatDate(new ilDate($a_set['birthday'], IL_CAL_DATE)) : $this->lng->txt('no_date');
224 $this->tpl->setCurrentBlock('custom_fields');
225 $this->tpl->setVariable('VAL_CUST', $a_set[$field]);
226 $this->tpl->parseCurrentBlock();
227 break;
228
229 case 'odf_last_update':
230 $this->tpl->setVariable('VAL_CUST', (string) $a_set['odf_info_txt']);
231 break;
232
233 case 'org_units':
234 $this->tpl->setCurrentBlock('custom_fields');
235 include_once './Modules/OrgUnit/classes/PathStorage/class.ilOrgUnitPathStorage.php';
236 $this->tpl->setVariable('VAL_CUST', (string) ilOrgUnitPathStorage::getTextRepresentationOfUsersOrgUnits($a_set['usr_id']));
237 $this->tpl->parseCurrentBlock();
238 break;
239
240
241 default:
242 $this->tpl->setCurrentBlock('custom_fields');
243 $this->tpl->setVariable('VAL_CUST', isset($a_set[$field]) ? (string) $a_set[$field] : '');
244 $this->tpl->parseCurrentBlock();
245 break;
246 }
247 }
248
249 $this->tpl->setVariable('VAL_SUBTIME', ilDatePresentation::formatDate(new ilDateTime($a_set['sub_time'], IL_CAL_UNIX)));
250
251 #$this->tpl->setVariable('VAL_LOGIN',$a_set['login']);
252
253 $this->showActionLinks($a_set);
254 }
255
263 public function readUserData()
264 {
266
267 include_once './Services/User/classes/class.ilUserQuery.php';
268
269 $additional_fields = $this->getSelectedColumns();
270 unset($additional_fields["firstname"]);
271 unset($additional_fields["lastname"]);
272 unset($additional_fields["last_login"]);
273 unset($additional_fields["access_until"]);
274 unset($additional_fields['org_units']);
275
276 $udf_ids = $usr_data_fields = $odf_ids = array();
277 foreach ($additional_fields as $field) {
278 if (substr($field, 0, 3) == 'udf') {
279 $udf_ids[] = substr($field, 4);
280 continue;
281 }
282 if (substr($field, 0, 3) == 'odf') {
283 $odf_ids[] = substr($field, 4);
284 continue;
285 }
286
287 $usr_data_fields[] = $field;
288 }
289
290 $l = $this->getLimit();
292 $this->getOrderField(),
293 $this->getOrderDirection(),
294 $this->getOffset(),
295 $this->getLimit(),
296 '',
297 '',
298 null,
299 false,
300 false,
301 0,
302 0,
303 null,
304 $usr_data_fields,
305 $this->wait_user_ids
306 );
307 if (0 === count($usr_data['set']) && $this->getOffset() > 0 && $this->getExternalSegmentation()) {
308 $this->resetOffset();
309
311 $this->getOrderField(),
312 $this->getOrderDirection(),
313 $this->getOffset(),
314 $this->getLimit(),
315 '',
316 '',
317 null,
318 false,
319 false,
320 0,
321 0,
322 null,
323 $usr_data_fields,
324 $this->wait_user_ids
325 );
326 }
327
328 ilLoggerFactory::getLogger('mem')->dump($this->wait_user_ids);
329 ilLoggerFactory::getLogger('mem')->dump($usr_data);
330
331 foreach ((array) $usr_data['set'] as $user) {
332 $usr_ids[] = $user['usr_id'];
333 }
334
335 // merge course data
336 $course_user_data = $this->getParentObject()->readMemberData($usr_ids, array());
337 $a_user_data = array();
338 foreach ((array) $usr_data['set'] as $ud) {
339 $a_user_data[$ud['usr_id']] = array_merge($ud, $course_user_data[$ud['usr_id']]);
340 }
341
342 // Custom user data fields
343 if ($udf_ids) {
344 include_once './Services/User/classes/class.ilUserDefinedData.php';
345 $data = ilUserDefinedData::lookupData($usr_ids, $udf_ids);
346 foreach ($data as $usr_id => $fields) {
347 if (!$this->checkAcceptance($usr_id)) {
348 continue;
349 }
350
351 foreach ($fields as $field_id => $value) {
352 $a_user_data[$usr_id]['udf_' . $field_id] = $value;
353 }
354 }
355 }
356 // Object specific user data fields
357 if ($odf_ids) {
358 include_once './Modules/Course/classes/Export/class.ilCourseUserData.php';
360 foreach ($data as $usr_id => $fields) {
361 // #7264: as we get data for all course members filter against user data
362 if (!$this->checkAcceptance($usr_id) || !in_array($usr_id, $usr_ids)) {
363 continue;
364 }
365
366 foreach ($fields as $field_id => $value) {
367 $a_user_data[$usr_id]['odf_' . $field_id] = $value;
368 }
369 }
370
371 // add last edit date
372 include_once './Services/Membership/classes/class.ilObjectCustomUserFieldHistory.php';
373 foreach (ilObjectCustomUserFieldHistory::lookupEntriesByObjectId($this->getRepositoryObject()->getId()) as $usr_id => $edit_info) {
374 if (!isset($a_user_data[$usr_id])) {
375 continue;
376 }
377
378 include_once './Services/PrivacySecurity/classes/class.ilPrivacySettings.php';
379 if ($usr_id == $edit_info['update_user']) {
380 $a_user_data[$usr_id]['odf_last_update'] = '';
381 $a_user_data[$usr_id]['odf_info_txt'] = $GLOBALS['DIC']['lng']->txt('cdf_edited_by_self');
382 if (ilPrivacySettings::_getInstance()->enabledAccessTimesByType($this->getRepositoryObject()->getType())) {
383 $a_user_data[$usr_id]['odf_last_update'] .= ('_' . $edit_info['editing_time']->get(IL_CAL_UNIX));
384 $a_user_data[$usr_id]['odf_info_txt'] .= (', ' . ilDatePresentation::formatDate($edit_info['editing_time']));
385 }
386 } else {
387 $a_user_data[$usr_id]['odf_last_update'] = $edit_info['update_user'];
388 $a_user_data[$usr_id]['odf_last_update'] .= ('_' . $edit_info['editing_time']->get(IL_CAL_UNIX));
389
390 $name = ilObjUser::_lookupName($edit_info['update_user']);
391 $a_user_data[$usr_id]['odf_info_txt'] = ($name['firstname'] . ' ' . $name['lastname'] . ', ' . ilDatePresentation::formatDate($edit_info['editing_time']));
392 }
393 }
394 }
395
396 foreach ($usr_data['set'] as $user) {
397 // Check acceptance
398 if (!$this->checkAcceptance($user['usr_id'])) {
399 continue;
400 }
401 // DONE: accepted
402 foreach ($usr_data_fields as $field) {
403 $a_user_data[$user['usr_id']][$field] = $user[$field] ? $user[$field] : '';
404 }
405 }
406
407 // Waiting list subscription
408 foreach ($this->wait as $usr_id => $wait_usr_data) {
409 if (isset($a_user_data[$usr_id])) {
410 $a_user_data[$usr_id]['sub_time'] = $wait_usr_data['time'];
411 }
412 }
413
414 $this->setMaxCount($usr_data['cnt'] ? $usr_data['cnt'] : 0);
415 return $this->setData($a_user_data);
416 }
417
422 public function showActionLinks($a_set)
423 {
424 if (!self::$has_odf_definitions) {
425 $this->ctrl->setParameterByClass(get_class($this->getParentObject()), 'member_id', $a_set['usr_id']);
426 $link = $this->ctrl->getLinkTargetByClass(get_class($this->getParentObject()), 'sendMailToSelectedUsers');
427 $this->tpl->setVariable('MAIL_LINK', $link);
428 $this->tpl->setVariable('MAIL_TITLE', $this->lng->txt('crs_mem_send_mail'));
429 return true;
430 }
431
432 // show action menu
433 include_once './Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
434 $list = new ilAdvancedSelectionListGUI();
435 $list->setSelectionHeaderClass('small');
436 $list->setItemLinkClass('small');
437 $list->setId('actl_' . $a_set['usr_id'] . '_' . $this->getId());
438 $list->setListTitle($this->lng->txt('actions'));
439
440 $this->ctrl->setParameterByClass(get_class($this->getParentObject()), 'member_id', $a_set['usr_id']);
441 $this->ctrl->setParameter($this->parent_obj, 'member_id', $a_set['usr_id']);
442 $trans = $this->lng->txt($this->getRepositoryObject()->getType() . '_mem_send_mail');
443 $link = $this->ctrl->getLinkTargetByClass(get_class($this->getParentObject()), 'sendMailToSelectedUsers');
444 $list->addItem($trans, '', $link, 'sendMailToSelectedUsers');
445
446 $this->ctrl->setParameterByClass('ilobjectcustomuserfieldsgui', 'member_id', $a_set['usr_id']);
447 $trans = $this->lng->txt($this->getRepositoryObject()->getType() . '_cdf_edit_member');
448 $list->addItem($trans, '', $this->ctrl->getLinkTargetByClass('ilobjectcustomuserfieldsgui', 'editMember'));
449
450 $this->tpl->setVariable('ACTION_USER', $list->getHTML());
451 }
452
453
454
455 protected function checkAcceptance()
456 {
457 return true;
458 }
459}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
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
if($format !==null) $name
Definition: metadata.php:230
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ilUser
Definition: imgupload.php:18
$DIC
Definition: xapitoken.php:46