ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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 
24 include_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(false);
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 
152  public function numericOrdering($a_field)
153  {
154  switch ($a_field) {
155  case 'sub_time':
156  return true;
157  }
158  return parent::numericOrdering($a_field);
159  }
160 
165  public function getSelectableColumns()
166  {
167  if (self::$all_columns) {
168  return self::$all_columns;
169  }
170 
171  include_once './Services/PrivacySecurity/classes/class.ilExportFieldsInfo.php';
173  self::$all_columns = $ef->getSelectableFieldsInfo($this->getRepositoryObject()->getId());
174 
175  // #25215
176  if (
177  is_array(self::$all_columns) &&
178  array_key_exists('consultation_hour', self::$all_columns)
179  ) {
180  unset(self::$all_columns['consultation_hour']);
181  }
182 
183  if (
184  !is_array(self::$all_columns) ||
185  !array_key_exists('login', self::$all_columns)
186  ) {
187  self::$all_columns['login'] = [
188  'default' => 1,
189  'txt' => $this->lng->txt('login')
190  ];
191  }
192  return self::$all_columns;
193  }
194 
195 
203  public function fillRow($a_set)
204  {
205  global $DIC;
206 
207  $ilUser = $DIC['ilUser'];
208 
209  include_once('./Services/Calendar/classes/class.ilDateTime.php');
210  include_once './Modules/Course/classes/class.ilObjCourseGrouping.php';
211 
212  if (!ilObjCourseGrouping::_checkGroupingDependencies($this->getRepositoryObject(), $a_set['usr_id']) and
214  $prefix = $this->getRepositoryObject()->getType();
215  $this->tpl->setVariable(
216  'ALERT_MSG',
217  sprintf(
218  $this->lng->txt($prefix . '_lim_assigned'),
219  ilObject::_lookupTitle(current($ids))
220  )
221  );
222  }
223 
224  $this->tpl->setVariable('VAL_ID', $a_set['usr_id']);
225  $this->tpl->setVariable('VAL_NAME', $a_set['lastname'] . ', ' . $a_set['firstname']);
226 
227  foreach ($this->getSelectedColumns() as $field) {
228  switch ($field) {
229  case 'gender':
230  $a_set['gender'] = $a_set['gender'] ? $this->lng->txt('gender_' . $a_set['gender']) : '';
231  $this->tpl->setCurrentBlock('custom_fields');
232  $this->tpl->setVariable('VAL_CUST', $a_set[$field]);
233  $this->tpl->parseCurrentBlock();
234  break;
235 
236  case 'birthday':
237  $a_set['birthday'] = $a_set['birthday'] ? ilDatePresentation::formatDate(new ilDate($a_set['birthday'], IL_CAL_DATE)) : $this->lng->txt('no_date');
238  $this->tpl->setCurrentBlock('custom_fields');
239  $this->tpl->setVariable('VAL_CUST', $a_set[$field]);
240  $this->tpl->parseCurrentBlock();
241  break;
242 
243  case 'odf_last_update':
244  $this->tpl->setVariable('VAL_CUST', (string) $a_set['odf_info_txt']);
245  break;
246 
247  case 'org_units':
248  $this->tpl->setCurrentBlock('custom_fields');
249  include_once './Modules/OrgUnit/classes/PathStorage/class.ilOrgUnitPathStorage.php';
250  $this->tpl->setVariable('VAL_CUST', (string) ilOrgUnitPathStorage::getTextRepresentationOfUsersOrgUnits($a_set['usr_id']));
251  $this->tpl->parseCurrentBlock();
252  break;
253 
254 
255  default:
256  $this->tpl->setCurrentBlock('custom_fields');
257  $this->tpl->setVariable('VAL_CUST', isset($a_set[$field]) ? (string) $a_set[$field] : '');
258  $this->tpl->parseCurrentBlock();
259  break;
260  }
261  }
262 
263  $this->tpl->setVariable('VAL_SUBTIME', ilDatePresentation::formatDate(new ilDateTime($a_set['sub_time'], IL_CAL_UNIX)));
264 
265  #$this->tpl->setVariable('VAL_LOGIN',$a_set['login']);
266 
267  $this->showActionLinks($a_set);
268  }
269 
277  public function readUserData()
278  {
279  $this->determineOffsetAndOrder();
280 
281  include_once './Services/User/classes/class.ilUserQuery.php';
282 
283  $additional_fields = $this->getSelectedColumns();
284  unset($additional_fields["firstname"]);
285  unset($additional_fields["lastname"]);
286  unset($additional_fields["last_login"]);
287  unset($additional_fields["access_until"]);
288  unset($additional_fields['org_units']);
289 
290  $udf_ids = $usr_data_fields = $odf_ids = array();
291  foreach ($additional_fields as $field) {
292  if (substr($field, 0, 3) == 'udf') {
293  $udf_ids[] = substr($field, 4);
294  continue;
295  }
296  if (substr($field, 0, 3) == 'odf') {
297  $odf_ids[] = substr($field, 4);
298  continue;
299  }
300 
301  $usr_data_fields[] = $field;
302  }
303 
304  $l = $this->getLimit();
305  $usr_data = ilUserQuery::getUserListData(
306  $this->getOrderField(),
307  $this->getOrderDirection(),
308  $this->getOffset(),
309  $this->getLimit(),
310  '',
311  '',
312  null,
313  false,
314  false,
315  0,
316  0,
317  null,
318  $usr_data_fields,
319  $this->wait_user_ids
320  );
321  if (0 === count($usr_data['set']) && $this->getOffset() > 0 && $this->getExternalSegmentation()) {
322  $this->resetOffset();
323 
324  $usr_data = ilUserQuery::getUserListData(
325  $this->getOrderField(),
326  $this->getOrderDirection(),
327  $this->getOffset(),
328  $this->getLimit(),
329  '',
330  '',
331  null,
332  false,
333  false,
334  0,
335  0,
336  null,
337  $usr_data_fields,
338  $this->wait_user_ids
339  );
340  }
341 
342  ilLoggerFactory::getLogger('mem')->dump($this->wait_user_ids);
343  ilLoggerFactory::getLogger('mem')->dump($usr_data);
344 
345  foreach ((array) $usr_data['set'] as $user) {
346  $usr_ids[] = $user['usr_id'];
347  }
348 
349  // merge course data
350  $course_user_data = $this->getParentObject()->readMemberData($usr_ids, array());
351  $a_user_data = array();
352  foreach ((array) $usr_data['set'] as $ud) {
353  $a_user_data[$ud['usr_id']] = array_merge($ud, $course_user_data[$ud['usr_id']]);
354  }
355 
356  // Custom user data fields
357  if ($udf_ids) {
358  include_once './Services/User/classes/class.ilUserDefinedData.php';
359  $data = ilUserDefinedData::lookupData($usr_ids, $udf_ids);
360  foreach ($data as $usr_id => $fields) {
361  if (!$this->checkAcceptance($usr_id)) {
362  continue;
363  }
364 
365  foreach ($fields as $field_id => $value) {
366  $a_user_data[$usr_id]['udf_' . $field_id] = $value;
367  }
368  }
369  }
370  // Object specific user data fields
371  if ($odf_ids) {
372  include_once './Modules/Course/classes/Export/class.ilCourseUserData.php';
374  foreach ($data as $usr_id => $fields) {
375  // #7264: as we get data for all course members filter against user data
376  if (!$this->checkAcceptance($usr_id) || !in_array($usr_id, $usr_ids)) {
377  continue;
378  }
379 
380  foreach ($fields as $field_id => $value) {
381  $a_user_data[$usr_id]['odf_' . $field_id] = $value;
382  }
383  }
384 
385  // add last edit date
386  include_once './Services/Membership/classes/class.ilObjectCustomUserFieldHistory.php';
387  foreach (ilObjectCustomUserFieldHistory::lookupEntriesByObjectId($this->getRepositoryObject()->getId()) as $usr_id => $edit_info) {
388  if (!isset($a_user_data[$usr_id])) {
389  continue;
390  }
391 
392  include_once './Services/PrivacySecurity/classes/class.ilPrivacySettings.php';
393  if ($usr_id == $edit_info['update_user']) {
394  $a_user_data[$usr_id]['odf_last_update'] = '';
395  $a_user_data[$usr_id]['odf_info_txt'] = $GLOBALS['DIC']['lng']->txt('cdf_edited_by_self');
396  if (ilPrivacySettings::_getInstance()->enabledAccessTimesByType($this->getRepositoryObject()->getType())) {
397  $a_user_data[$usr_id]['odf_last_update'] .= ('_' . $edit_info['editing_time']->get(IL_CAL_UNIX));
398  $a_user_data[$usr_id]['odf_info_txt'] .= (', ' . ilDatePresentation::formatDate($edit_info['editing_time']));
399  }
400  } else {
401  $a_user_data[$usr_id]['odf_last_update'] = $edit_info['update_user'];
402  $a_user_data[$usr_id]['odf_last_update'] .= ('_' . $edit_info['editing_time']->get(IL_CAL_UNIX));
403 
404  $name = ilObjUser::_lookupName($edit_info['update_user']);
405  $a_user_data[$usr_id]['odf_info_txt'] = ($name['firstname'] . ' ' . $name['lastname'] . ', ' . ilDatePresentation::formatDate($edit_info['editing_time']));
406  }
407  }
408  }
409 
410  foreach ($usr_data['set'] as $user) {
411  // Check acceptance
412  if (!$this->checkAcceptance($user['usr_id'])) {
413  continue;
414  }
415  // DONE: accepted
416  foreach ($usr_data_fields as $field) {
417  $a_user_data[$user['usr_id']][$field] = $user[$field] ? $user[$field] : '';
418  }
419  }
420 
421  // Waiting list subscription
422  foreach ($this->wait as $usr_id => $wait_usr_data) {
423  if (isset($a_user_data[$usr_id])) {
424  $a_user_data[$usr_id]['sub_time'] = $wait_usr_data['time'];
425  }
426  }
427 
428  $this->setMaxCount($usr_data['cnt'] ? $usr_data['cnt'] : 0);
429  return $this->setData($a_user_data);
430  }
431 
436  public function showActionLinks($a_set)
437  {
438  if (!self::$has_odf_definitions) {
439  $this->ctrl->setParameterByClass(get_class($this->getParentObject()), 'member_id', $a_set['usr_id']);
440  $link = $this->ctrl->getLinkTargetByClass(get_class($this->getParentObject()), 'sendMailToSelectedUsers');
441  $this->tpl->setVariable('MAIL_LINK', $link);
442  $this->tpl->setVariable('MAIL_TITLE', $this->lng->txt('crs_mem_send_mail'));
443  $this->ctrl->setParameterByClass(get_class($this->getParentObject()), 'member_id', null);
444  return true;
445  }
446 
447  // show action menu
448  include_once './Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
449  $list = new ilAdvancedSelectionListGUI();
450  $list->setSelectionHeaderClass('small');
451  $list->setItemLinkClass('small');
452  $list->setId('actl_' . $a_set['usr_id'] . '_' . $this->getId());
453  $list->setListTitle($this->lng->txt('actions'));
454 
455  $this->ctrl->setParameterByClass(get_class($this->getParentObject()), 'member_id', $a_set['usr_id']);
456  $this->ctrl->setParameter($this->parent_obj, 'member_id', $a_set['usr_id']);
457  $trans = $this->lng->txt($this->getRepositoryObject()->getType() . '_mem_send_mail');
458  $link = $this->ctrl->getLinkTargetByClass(get_class($this->getParentObject()), 'sendMailToSelectedUsers');
459  $list->addItem($trans, '', $link, 'sendMailToSelectedUsers');
460 
461  $this->ctrl->setParameterByClass('ilobjectcustomuserfieldsgui', 'member_id', $a_set['usr_id']);
462  $trans = $this->lng->txt($this->getRepositoryObject()->getType() . '_cdf_edit_member');
463  $list->addItem($trans, '', $this->ctrl->getLinkTargetByClass('ilobjectcustomuserfieldsgui', 'editMember'));
464  $this->ctrl->setParameterByClass(get_class($this->getParentObject()), 'member_id', null);
465 
466  $this->tpl->setVariable('ACTION_USER', $list->getHTML());
467  }
468 
469 
470 
471  protected function checkAcceptance()
472  {
473  return true;
474  }
475 }
static _lookupName($a_user_id)
lookup user name
setExternalSorting($a_val)
Set external sorting.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
static _getValuesByObjId($a_obj_id)
Get values by obj_id (for all users)
setExternalSegmentation($a_val)
Set external segmentation.
resetOffset($a_in_determination=false)
Reset offset.
static getAssignedObjects()
Alway call checkGroupingDependencies before.
static _lookupTitle($a_id)
lookup object title
const IL_CAL_UNIX
getOrderDirection()
Get order direction.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
getParentObject()
Get parent object.
setId($a_val)
Set id.
showActionLinks($a_set)
Show action links (mail ; edit crs|grp data)
static lookupData($a_user_ids, $a_field_ids)
Lookup data.
__construct($a_parent_obj, ilObject $rep_object, $waiting_list)
ilWaitingListTableGUI constructor.
if($format !==null) $name
Definition: metadata.php:230
Class for single dates.
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.
static _getInstanceByType($a_type)
Get Singleton Instance.
getOffset()
Get offset.
getExternalSegmentation()
Get external segmentation.
global $DIC
Definition: goto.php:24
addMultiCommand($a_cmd, $a_text)
Add Command button.
enable($a_module_name)
enables particular modules of table
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
setPrefix($a_prefix)
getSelectedColumns()
Get selected columns.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
static _hasFields($a_container_id)
Check if there are any define fields.
static _checkGroupingDependencies(&$container_obj, $a_user_id=null)
determineOffsetAndOrder($a_omit_offset=false)
Determine offset and order.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
const IL_CAL_DATE
setFormName($a_formname="")
Set Form name.
__construct(Container $dic, ilPlugin $plugin)
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.
numericOrdering($a_field)
configure numeric ordering
GUI class for course/group waiting list.
static getLogger($a_component_id)
Get component logger.
getLimit()
Get limit.
static _getInstance()
Get instance of ilPrivacySettings.
getSelectableColumns()
Get selectable columns.
setUserIds($a_user_ids)
Set user ids.
$ilUser
Definition: imgupload.php:18
setMaxCount($a_max_count)
set max.
getId()
Get element id.
static lookupEntriesByObjectId($a_obj_id)
Get entries by obj_id type $ilDB.
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.
getRepositoryObject()
Get repository object.