ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 $waiting_list = null;
38 protected $wait = array();
39 protected $wait_user_ids = array();
40
41 protected static $all_columns = null;
42 protected static $has_odf_definitions = FALSE;
43
44
52 public function __construct($a_parent_obj,$waiting_list,$show_content = true)
53 {
54 global $lng,$ilCtrl;
55
56 $this->lng = $lng;
57 $this->lng->loadLanguageModule('grp');
58 $this->lng->loadLanguageModule('crs');
59 $this->lng->loadLanguageModule('sess');
60 $this->lng->loadLanguageModule('ps');
61 $this->ctrl = $ilCtrl;
62
63 $this->setId('crs_wait_'. $a_parent_obj->object->getId());
64 parent::__construct($a_parent_obj,'members');
65
66 $this->setFormName('waiting');
67 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj,'members'));
68
69 $this->addColumn('','f',"1");
70 $this->addColumn($this->lng->txt('name'),'lastname','20%');
71
72 $all_cols = $this->getSelectableColumns();
73 foreach($this->getSelectedColumns() as $col)
74 {
75 $this->addColumn($all_cols[$col]['txt'], $col);
76 }
77
78 $this->addColumn($this->lng->txt('application_date'),'sub_time',"10%");
79 $this->addColumn('','mail','10%');
80
81 $this->addMultiCommand('confirmAssignFromWaitingList',$this->lng->txt('assign'));
82 $this->addMultiCommand('confirmRefuseFromList',$this->lng->txt('refuse'));
83 $this->addMultiCommand('sendMailToSelectedUsers',$this->lng->txt('crs_mem_send_mail'));
84
85 $this->setPrefix('waiting');
86 $this->setSelectAllCheckbox('waiting');
87 $this->setRowTemplate("tpl.show_waiting_list_row.html","Services/Membership");
88
89 if($show_content)
90 {
91 $this->enable('sort');
92 $this->enable('header');
93 $this->enable('numinfo');
94 $this->enable('select_all');
95 }
96 else
97 {
98 $this->disable('content');
99 $this->disable('header');
100 $this->disable('footer');
101 $this->disable('numinfo');
102 $this->disable('select_all');
103 }
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->getParentObject()->object->getId());
109
110 }
111
119 public function setUsers($a_sub)
120 {
121 $this->wait = $a_sub;
122 foreach($this->wait as $usr_id => $usr_data)
123 {
124 $this->wait_user_ids[] = $usr_id;
125 }
126
127 $this->readUserData();
128 }
129
134 public function getSelectableColumns()
135 {
136 if(self::$all_columns)
137 {
138 return self::$all_columns;
139 }
140
141 include_once './Services/PrivacySecurity/classes/class.ilExportFieldsInfo.php';
142 $ef = ilExportFieldsInfo::_getInstanceByType($this->getParentObject()->object->getType());
143 self::$all_columns = $ef->getSelectableFieldsInfo($this->getParentObject()->object->getId());
144 return self::$all_columns;
145 }
146
147
155 public function fillRow($a_set)
156 {
157 global $ilUser;
158
159 include_once('./Services/Calendar/classes/class.ilDateTime.php');
160 include_once './Modules/Course/classes/class.ilObjCourseGrouping.php';
161
162 if(!ilObjCourseGrouping::_checkGroupingDependencies($this->getParentObject()->object,$a_set['usr_id']) and
164 {
165 $prefix = $this->getParentObject()->object->getType();
166 $this->tpl->setVariable('ALERT_MSG',
167 sprintf($this->lng->txt($prefix.'_lim_assigned'),
168 ilObject::_lookupTitle(current($ids))
169 ));
170
171 }
172
173 $this->tpl->setVariable('VAL_ID',$a_set['usr_id']);
174 $this->tpl->setVariable('VAL_NAME',$a_set['lastname'].', '.$a_set['firstname']);
175
176 foreach($this->getSelectedColumns() as $field)
177 {
178 switch($field)
179 {
180 case 'gender':
181 $a_set['gender'] = $a_set['gender'] ? $this->lng->txt('gender_' . $a_set['gender']) : '';
182 $this->tpl->setCurrentBlock('custom_fields');
183 $this->tpl->setVariable('VAL_CUST', $a_set[$field]);
184 $this->tpl->parseCurrentBlock();
185 break;
186
187 case 'birthday':
188 $a_set['birthday'] = $a_set['birthday'] ? ilDatePresentation::formatDate(new ilDate($a_set['birthday'], IL_CAL_DATE)) : $this->lng->txt('no_date');
189 $this->tpl->setCurrentBlock('custom_fields');
190 $this->tpl->setVariable('VAL_CUST', $a_set[$field]);
191 $this->tpl->parseCurrentBlock();
192 break;
193
194 case 'odf_last_update':
195 $this->tpl->setVariable('VAL_CUST',(string) $a_set['odf_info_txt']);
196 break;
197
198
199 default:
200 $this->tpl->setCurrentBlock('custom_fields');
201 $this->tpl->setVariable('VAL_CUST', isset($a_set[$field]) ? (string) $a_set[$field] : '');
202 $this->tpl->parseCurrentBlock();
203 break;
204 }
205 }
206
207 $this->tpl->setVariable('VAL_SUBTIME',ilDatePresentation::formatDate(new ilDateTime($a_set['sub_time'],IL_CAL_UNIX)));
208
209 #$this->tpl->setVariable('VAL_LOGIN',$a_set['login']);
210
211 $this->showActionLinks($a_set);
212 }
213
221 public function readUserData()
222 {
223 global $rbacreview;
224
226
227 include_once './Services/User/classes/class.ilUserQuery.php';
228
229 $additional_fields = $this->getSelectedColumns();
230 unset($additional_fields["firstname"]);
231 unset($additional_fields["lastname"]);
232 unset($additional_fields["last_login"]);
233 unset($additional_fields["access_until"]);
234
235 $udf_ids = $usr_data_fields = $odf_ids = array();
236 foreach($additional_fields as $field)
237 {
238 if(substr($field, 0, 3) == 'udf')
239 {
240 $udf_ids[] = substr($field, 4);
241 continue;
242 }
243 if(substr($field, 0, 3) == 'odf')
244 {
245 $odf_ids[] = substr($field, 4);
246 continue;
247 }
248
249 $usr_data_fields[] = $field;
250 }
251
253 $this->getOrderField(),
254 $this->getOrderDirection(),
255 $this->getOffset(),
256 $this->getLimit(),
257 '',
258 '',
259 null,
260 false,
261 false,
262 0,
263 0,
264 null,
265 $usr_data_fields,
266 $this->wait_user_ids
267 );
268
269 foreach((array) $usr_data['set'] as $user)
270 {
271 $usr_ids[] = $user['usr_id'];
272 }
273
274 // merge course data
275 $course_user_data = $this->getParentObject()->readMemberData($usr_ids,$this->type == 'admin');
276 $a_user_data = array();
277 foreach((array) $usr_data['set'] as $ud)
278 {
279 $a_user_data[$ud['usr_id']] = array_merge($ud,$course_user_data[$ud['usr_id']]);
280 }
281
282 // Custom user data fields
283 if($udf_ids)
284 {
285 include_once './Services/User/classes/class.ilUserDefinedData.php';
286 $data = ilUserDefinedData::lookupData($usr_ids, $udf_ids);
287 foreach($data as $usr_id => $fields)
288 {
289 if(!$this->checkAcceptance($usr_id))
290 {
291 continue;
292 }
293
294 foreach($fields as $field_id => $value)
295 {
296 $a_user_data[$usr_id]['udf_' . $field_id] = $value;
297 }
298 }
299 }
300 // Object specific user data fields
301 if($odf_ids)
302 {
303 include_once './Modules/Course/classes/Export/class.ilCourseUserData.php';
304 $data = ilCourseUserData::_getValuesByObjId($this->getParentObject()->object->getId());
305 foreach($data as $usr_id => $fields)
306 {
307 // #7264: as we get data for all course members filter against user data
308 if(!$this->checkAcceptance($usr_id) || !in_array($usr_id, $usr_ids))
309 {
310 continue;
311 }
312
313 foreach($fields as $field_id => $value)
314 {
315 $a_user_data[$usr_id]['odf_' . $field_id] = $value;
316 }
317 }
318
319 // add last edit date
320 include_once './Services/Membership/classes/class.ilObjectCustomUserFieldHistory.php';
321 foreach(ilObjectCustomUserFieldHistory::lookupEntriesByObjectId($this->getParentObject()->object->getId()) as $usr_id => $edit_info)
322 {
323 if(!isset($a_user_data[$usr_id]))
324 {
325 continue;
326 }
327
328 include_once './Services/PrivacySecurity/classes/class.ilPrivacySettings.php';
329 if($usr_id == $edit_info['update_user'])
330 {
331 $a_user_data[$usr_id]['odf_last_update'] = '';
332 $a_user_data[$usr_id]['odf_info_txt'] = $GLOBALS['lng']->txt('cdf_edited_by_self');
333 if(ilPrivacySettings::_getInstance()->enabledAccessTimesByType($this->getParentObject()->object->getType()))
334 {
335 $a_user_data[$usr_id]['odf_last_update'] .= ('_'.$edit_info['editing_time']->get(IL_CAL_UNIX));
336 $a_user_data[$usr_id]['odf_info_txt'] .= (', '.ilDatePresentation::formatDate($edit_info['editing_time']));
337 }
338 }
339 else
340 {
341 $a_user_data[$usr_id]['odf_last_update'] = $edit_info['update_user'];
342 $a_user_data[$usr_id]['odf_last_update'] .= ('_'.$edit_info['editing_time']->get(IL_CAL_UNIX));
343
344 $name = ilObjUser::_lookupName($edit_info['update_user']);
345 $a_user_data[$usr_id]['odf_info_txt'] = ($name['firstname'].' '.$name['lastname'].', '.ilDatePresentation::formatDate($edit_info['editing_time']));
346 }
347 }
348
349 }
350
351 foreach($usr_data['set'] as $user)
352 {
353 // Check acceptance
354 if(!$this->checkAcceptance($user['usr_id']))
355 {
356 continue;
357 }
358 // DONE: accepted
359 foreach($usr_data_fields as $field)
360 {
361 $a_user_data[$user['usr_id']][$field] = $user[$field] ? $user[$field] : '';
362 }
363 }
364
365 // Waiting list subscription
366 foreach($this->wait as $usr_id => $usr_data)
367 {
368 $a_user_data[$usr_id]['sub_time'] = $usr_data['time'];
369 }
370
371 $this->setMaxCount($usr_data['cnt'] ? $usr_data['cnt'] : 0);
372 return $this->setData($a_user_data);
373 }
374
379 public function showActionLinks($a_set)
380 {
381 if(!self::$has_odf_definitions)
382 {
383 $this->ctrl->setParameterByClass(get_class($this->getParentObject()),'member_id',$a_set['usr_id']);
384 $link = $this->ctrl->getLinkTargetByClass(get_class($this->getParentObject()),'sendMailToSelectedUsers');
385 $this->tpl->setVariable('MAIL_LINK',$link);
386 $this->tpl->setVariable('MAIL_TITLE',$this->lng->txt('crs_mem_send_mail'));
387 return TRUE;
388 }
389
390 // show action menu
391 include_once './Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
392 $list = new ilAdvancedSelectionListGUI();
393 $list->setSelectionHeaderClass('small');
394 $list->setItemLinkClass('small');
395 $list->setId('actl_'.$a_set['usr_id'].'_'.$this->getId());
396 $list->setListTitle($this->lng->txt('actions'));
397
398 $this->ctrl->setParameterByClass(get_class($this->getParentObject()),'member_id',$a_set['usr_id']);
399 $this->ctrl->setParameter($this->parent_obj, 'member_id', $a_set['usr_id']);
400 $trans = $this->lng->txt($this->getParentObject()->object->getType().'_mem_send_mail');
401 $link = $this->ctrl->getLinkTargetByClass(get_class($this->getParentObject()),'sendMailToSelectedUsers');
402 $list->addItem($trans, '', $link,'sendMailToSelectedUsers');
403
404 $this->ctrl->setParameterByClass('ilobjectcustomuserfieldsgui','member_id',$a_set['usr_id']);
405 $trans = $this->lng->txt($this->getParentObject()->object->getType().'_cdf_edit_member');
406 $list->addItem($trans, '', $this->ctrl->getLinkTargetByClass('ilobjectcustomuserfieldsgui','editMember'));
407
408 $this->tpl->setVariable('ACTION_USER',$list->getHTML());
409
410 }
411
412
413
414 protected function checkAcceptance()
415 {
416 return true;
417 }
418
419
420
421}
422?>
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)
Format a date @access public.
@classDescription Date and time handling
Class for single dates.
static _getInstanceByType($a_type)
Get Singleton Instance.
_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.
static _lookupTitle($a_id)
lookup object title
static _getInstance()
Get instance of ilPrivacySettings.
Class ilTable2GUI.
getSelectedColumns()
Get selected columns.
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.
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.
addMultiCommand($a_cmd, $a_text)
Add Command button.
setFormName($a_formname)
Set Form name.
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
getOffset()
Get offset.
setId($a_val)
Set id.
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="")
Get data for user administration list.
GUI class for course/group waiting list.
showActionLinks($a_set)
Show action links (mail ; edit crs|grp data)
__construct($a_parent_obj, $waiting_list, $show_content=true)
Constructor.
getSelectableColumns()
Get selectable columns.
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
global $ilUser
Definition: imgupload.php:15