ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilAttendanceList Class Reference

Base class for attendance lists. More...

+ Collaboration diagram for ilAttendanceList:

Public Member Functions

 __construct ($a_parent_obj, ilParticipants $a_participants_object=null, ilWaitingList $a_waiting_list=null)
 Constructor. More...
 
 addPreset ($a_id, $a_caption, $a_selected=false)
 Add user field. More...
 
 addBlank ($a_caption)
 Add blank column preset. More...
 
 setTitle ($a_title, $a_description=null)
 Set titles. More...
 
 addUserFilter ($a_id, $a_caption, $a_checked=false)
 Add user filter. More...
 
 getNonMemberUserData (array &$a_res)
 Get user data for subscribers and waiting list. More...
 
 setBlankColumns (array $a_values)
 Add blank columns. More...
 
 setCallback ($a_callback)
 Set participant detail callback. More...
 
 setId ($a_value)
 Set id (used for user form settings) More...
 
 initForm ($a_cmd="")
 Init form. More...
 
 initFromForm ()
 Set list attributes from post values. More...
 
 getFullscreenHTML ()
 render list in fullscreen mode More...
 
 getHTML ()
 render attendance list More...
 

Protected Member Functions

 addRole ($a_id, $a_caption, $a_type)
 Add role. More...
 
 setRoleSelection ($a_role_ids)
 Set role selection. More...
 

Protected Attributes

 $parent_obj
 
 $participants
 
 $waiting_list
 
 $callback
 
 $presets
 
 $role_data
 
 $roles
 
 $has_local_role
 
 $blank_columns
 
 $title
 
 $description
 
 $pre_blanks
 
 $id
 
 $include_waiting_list
 
 $include_subscribers
 
 $user_filters
 

Detailed Description

Base class for attendance lists.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 13 of file class.ilAttendanceList.php.

Constructor & Destructor Documentation

◆ __construct()

ilAttendanceList::__construct (   $a_parent_obj,
ilParticipants  $a_participants_object = null,
ilWaitingList  $a_waiting_list = null 
)

Constructor.

Parameters
object$a_parent_obj
ilParticipants$a_participants_object
ilWaitingList$a_waiting_list

Definition at line 39 of file class.ilAttendanceList.php.

40 {
41 global $lng;
42
43 $this->parent_obj = $a_parent_obj;
44 $this->participants = $a_participants_object;
45 $this->waiting_list = $a_waiting_list;
46
47 // always available
48 $this->presets['name'] = array($lng->txt('name'), true);
49 $this->presets['login'] = array($lng->txt('login'), true);
50
51 $lng->loadLanguageModule('crs');
52
53 // roles
54 $roles = $this->participants->getRoles();
55 foreach($roles as $role_id)
56 {
58 switch(substr($title, 0, 8))
59 {
60 case 'il_crs_a':
61 case 'il_grp_a':
62 $this->addRole($role_id, $lng->txt('event_tbl_admin'), 'admin');
63 break;
64
65 case 'il_crs_t':
66 $this->addRole($role_id, $lng->txt('event_tbl_tutor'), 'tutor');
67 break;
68
69 case 'il_crs_m':
70 case 'il_grp_m':
71 $this->addRole($role_id, $lng->txt('event_tbl_member'), 'member');
72 break;
73
74 // local
75 default:
76 $this->has_local_role = true;
77 $this->addRole($role_id, $title, 'local');
78 break;
79 }
80 }
81 }
addRole($a_id, $a_caption, $a_type)
Add role.
static _lookupTitle($a_id)
lookup object title
global $lng
Definition: privfeed.php:40

References $lng, $roles, $title, ilObject\_lookupTitle(), and addRole().

+ Here is the call graph for this function:

Member Function Documentation

◆ addBlank()

ilAttendanceList::addBlank (   $a_caption)

Add blank column preset.

Parameters
string$a_caption

Definition at line 100 of file class.ilAttendanceList.php.

101 {
102 $this->pre_blanks[] = $a_caption;
103 }

◆ addPreset()

ilAttendanceList::addPreset (   $a_id,
  $a_caption,
  $a_selected = false 
)

Add user field.

Parameters
string$a_id
string$a_caption
bool$a_selected

Definition at line 90 of file class.ilAttendanceList.php.

91 {
92 $this->presets[$a_id] = array($a_caption, $a_selected);
93 }

Referenced by initFromForm().

+ Here is the caller graph for this function:

◆ addRole()

ilAttendanceList::addRole (   $a_id,
  $a_caption,
  $a_type 
)
protected

Add role.

Parameters
int$a_id
string$a_caption
string$a_type

Definition at line 124 of file class.ilAttendanceList.php.

125 {
126 $this->role_data[$a_id] = array($a_caption, $a_type);
127 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ addUserFilter()

ilAttendanceList::addUserFilter (   $a_id,
  $a_caption,
  $a_checked = false 
)

Add user filter.

Parameters
int$a_id
string$a_caption
bool$a_checked

Definition at line 146 of file class.ilAttendanceList.php.

147 {
148 $this->user_filters[$a_id] = array($a_caption, $a_checked);
149 }

◆ getFullscreenHTML()

ilAttendanceList::getFullscreenHTML ( )

render list in fullscreen mode

Returns
string

Definition at line 414 of file class.ilAttendanceList.php.

415 {
416 $tpl = new ilTemplate('tpl.main.html',true,true);
417 $tpl->setBodyClass("ilBodyPrint");
418
419 // load style sheet depending on user's settings
420 $location_stylesheet = ilUtil::getStyleSheetLocation();
421 $tpl->setVariable("LOCATION_STYLESHEET",$location_stylesheet);
422
423 $tpl->setVariable("BODY_ATTRIBUTES",'onload="window.print()"');
424 $tpl->setVariable("CONTENT", $this->getHTML());
425
426 return $tpl->show();
427 }
global $tpl
Definition: ilias.php:8
getHTML()
render attendance list
special template class to simplify handling of ITX/PEAR
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user

References $tpl, getHTML(), and ilUtil\getStyleSheetLocation().

+ Here is the call graph for this function:

◆ getHTML()

ilAttendanceList::getHTML ( )

render attendance list

Returns
string

Definition at line 434 of file class.ilAttendanceList.php.

435 {
436 $tpl = new ilTemplate('tpl.attendance_list_print.html',true,true,'Services/Membership');
437
438
439 // title
440
441 $time = ilFormat::formatUnixTime(time(),true);
442
443 $tpl->setVariable('TXT_TITLE', $this->title);
444 if($this->description)
445 {
446 $tpl->setVariable('TXT_DESCRIPTION', $this->description." (".$time.")");
447 }
448 else
449 {
450 $tpl->setVariable('TXT_DESCRIPTION', $time);
451 }
452
453
454 // header
455
456 $tpl->setCurrentBlock('head_item');
457 foreach($this->presets as $id => $item)
458 {
459 if($item[1])
460 {
461 $tpl->setVariable('TXT_HEAD', $item[0]);
462 $tpl->parseCurrentBlock();
463 }
464 }
465
466 if($this->blank_columns)
467 {
468 foreach($this->blank_columns as $blank)
469 {
470 $tpl->setVariable('TXT_HEAD', $blank);
471 $tpl->parseCurrentBlock();
472 }
473 }
474
475
476 // handle members
477
478 $valid_user_ids = $filters = array();
479
480 if($this->roles)
481 {
482 if($this->has_local_role)
483 {
484 $members = array();
485 foreach($this->participants->getMembers() as $member_id)
486 {
487 foreach($this->participants->getAssignedRoles($member_id) as $role_id)
488 {
489 $members[$role_id][] = $member_id;
490 }
491 }
492 }
493 else
494 {
495 $members = $this->participants->getMembers();
496 }
497
498 foreach($this->roles as $role_id)
499 {
500 switch($this->role_data[$role_id][1])
501 {
502 case "admin":
503 $valid_user_ids = array_merge($valid_user_ids, $this->participants->getAdmins());
504 break;
505
506 case "tutor":
507 $valid_user_ids = array_merge($valid_user_ids, $this->participants->getTutors());
508 break;
509
510 // member/local
511 default:
512 if(!$this->has_local_role)
513 {
514 $valid_user_ids = array_merge($valid_user_ids, (array)$members);
515 }
516 else
517 {
518 $valid_user_ids = array_merge($valid_user_ids, (array)$members[$role_id]);
519 }
520 break;
521 }
522 }
523 }
524
525 if($this->include_subscribers)
526 {
527 $valid_user_ids = array_merge($valid_user_ids, $this->participants->getSubscribers());
528 }
529
530 if($this->include_waiting_list)
531 {
532 $valid_user_ids = array_merge($valid_user_ids, $this->waiting_list->getUserIds());
533 }
534
535 if($this->user_filters)
536 {
537 foreach($this->user_filters as $sub_id => $sub_item)
538 {
539 $filters[$sub_id] = (bool)$sub_item[2];
540 }
541 }
542
543 $valid_user_ids = ilUtil::_sortIds(array_unique($valid_user_ids),'usr_data','lastname','usr_id');
544
545
546 // rows
547
548 foreach($valid_user_ids as $user_id)
549 {
550 if($this->callback)
551 {
552 $user_data = call_user_func_array($this->callback, array($user_id, $filters));
553 if(!$user_data)
554 {
555 continue;
556 }
557
558 $tpl->setCurrentBlock("row_preset");
559 foreach($this->presets as $id => $item)
560 {
561 if($item[1])
562 {
563 switch($id)
564 {
565 case "name":
566 if(!$user_data[$id])
567 {
568 $name = ilObjUser::_lookupName($user_id);
569 $value = $name["lastname"].", ".$name["firstname"];
570 break;
571 }
572
573
574 case "login":
575 if(!$user_data[$id])
576 {
577 $value = ilObjUser::_lookupLogin($user_id);
578 break;
579 }
580
581 default:
582 $value = (string)$user_data[$id];
583 break;
584 }
585 $tpl->setVariable("TXT_PRESET", $value);
586 $tpl->parseCurrentBlock();
587 }
588 }
589 }
590
591 if($this->blank_columns)
592 {
593 for($loop = 0; $loop < sizeof($this->blank_columns); $loop++)
594 {
595 $tpl->touchBlock('row_blank');
596 }
597 }
598
599 $tpl->touchBlock("member_row");
600 }
601
602 return $tpl->get();
603 }
formatUnixTime($ut, $with_time=false)
static _lookupLogin($a_user_id)
lookup login
static _lookupName($a_user_id)
lookup user name
static _sortIds($a_ids, $a_table, $a_field, $a_id_name)
Function that sorts ids by a given table field using WHERE IN E.g: __sort(array(6,...

References $blank_columns, $id, $tpl, ilObjUser\_lookupLogin(), ilObjUser\_lookupName(), ilUtil\_sortIds(), and ilFormat\formatUnixTime().

Referenced by getFullscreenHTML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNonMemberUserData()

ilAttendanceList::getNonMemberUserData ( array &  $a_res)

Get user data for subscribers and waiting list.

Parameters
array&$a_res

Definition at line 156 of file class.ilAttendanceList.php.

157 {
158 global $lng;
159
160 $subscriber_ids = $this->participants->getSubscribers();
161
162 $user_ids = $subscriber_ids;
163
164 if($this->waiting_list)
165 {
166 $user_ids = array_merge($user_ids, $this->waiting_list->getUserIds());
167 }
168
169 if(sizeof($user_ids))
170 {
171 foreach(array_unique($user_ids) as $user_id)
172 {
173 if(!isset($a_res[$user_id]))
174 {
175 if($tmp_obj = ilObjectFactory::getInstanceByObjId($user_id, false))
176 {
177 $a_res[$user_id]['login'] = $tmp_obj->getLogin();
178 $a_res[$user_id]['name'] = $tmp_obj->getLastname().', '.$tmp_obj->getFirstname();
179
180 if(in_array($user_id, $subscriber_ids))
181 {
182 $a_res[$user_id]['status'] = $lng->txt('crs_subscriber');
183 }
184 else
185 {
186 $a_res[$user_id]['status'] = $lng->txt('crs_waiting_list');
187 }
188 }
189 }
190 }
191 }
192 }
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id

References $lng, and ilObjectFactory\getInstanceByObjId().

+ Here is the call graph for this function:

◆ initForm()

ilAttendanceList::initForm (   $a_cmd = "")

Init form.

Parameters
string$a_cmd
Returns
ilPropertyFormGUI

Definition at line 245 of file class.ilAttendanceList.php.

246 {
247 global $ilCtrl, $lng;
248
249 $lng->loadLanguageModule('crs');
250
251 include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
252 $form = new ilPropertyFormGUI();
253 $form->setFormAction($ilCtrl->getFormAction($this->parent_obj,$a_cmd));
254 $form->setTarget('_blank');
255 $form->setPreventDoubleSubmission(false);
256 $form->setTitle($lng->txt('sess_gen_attendance_list'));
257
258 $title = new ilTextInputGUI($lng->txt('title'), 'title');
259 $title->setValue($this->title);
260 $form->addItem($title);
261
262 $desc = new ilTextInputGUI($lng->txt('description'), 'desc');
263 $desc->setValue($this->description);
264 $form->addItem($desc);
265
266 if(sizeof($this->presets))
267 {
268 $preset = new ilCheckboxGroupInputGUI($lng->txt('user_detail'), 'preset');
269 $preset_value = array();
270 foreach($this->presets as $id => $item)
271 {
272 $preset->addOption(new ilCheckboxOption($item[0], $id));
273 if($item[1])
274 {
275 $preset_value[] = $id;
276 }
277 }
278 $preset->setValue($preset_value);
279 $form->addItem($preset);
280 }
281
282 $blank = new ilTextInputGUI($lng->txt('event_blank_columns'), 'blank');
283 $blank->setMulti(true);
284 $form->addItem($blank);
285
286 if($this->pre_blanks)
287 {
288 $blank->setValue($this->pre_blanks);
289 }
290
291 $checked = array();
292
293 $chk_grp = new ilCheckboxGroupInputGUI($lng->txt('event_user_selection'), 'selection_of_users');
294
295 // participants by roles
296 foreach($this->role_data as $role_id => $role_data)
297 {
298 $chk = new ilCheckboxOption(sprintf($lng->txt('event_user_selection_include_role'),$role_data[0]), 'role_'.$role_id);
299 $checked[] = 'role_'.$role_id;
300 $chk_grp->addOption($chk);
301 }
302
303 if($this->waiting_list)
304 {
305 $chk = new ilCheckboxOption($lng->txt('event_user_selection_include_requests'), 'subscr');
306 $chk_grp->addOption($chk);
307
308 $chk = new ilCheckboxOption($lng->txt('event_user_selection_include_waiting_list'), 'wlist');
309 $chk_grp->addOption($chk);
310 }
311
312 if($this->user_filters)
313 {
314 foreach($this->user_filters as $sub_id => $sub_item)
315 {
316 $chk = new ilCheckboxOption(sprintf($lng->txt('event_user_selection_include_filter'),$sub_item[0]),
317 'members_'.$sub_id);
318 if($sub_item[1])
319 {
320 $checked[] = 'members_'.$sub_id;
321 }
322 $chk_grp->addOption($chk);
323 }
324 }
325 $chk_grp->setValue($checked);
326 $form->addItem($chk_grp);
327
328 $form->addCommandButton($a_cmd,$lng->txt('sess_print_attendance_list'));
329
330 if($this->id && $a_cmd)
331 {
332 include_once "Services/User/classes/class.ilUserFormSettings.php";
333 $settings = new ilUserFormSettings($this->id);
334 $settings->deleteValue('desc'); // #11340
335 $settings->exportToForm($form);
336 }
337
338 return $form;
339 }
This class represents a property in a property form.
This class represents an option in a checkbox group.
This class represents a property form user interface.
This class represents a text property in a property form.
global $ilCtrl
Definition: ilias.php:18

References $id, $ilCtrl, $lng, $role_data, and $title.

Referenced by initFromForm().

+ Here is the caller graph for this function:

◆ initFromForm()

ilAttendanceList::initFromForm ( )

Set list attributes from post values.

Definition at line 344 of file class.ilAttendanceList.php.

345 {
346 $form = $this->initForm();
347 if($form->checkInput())
348 {
349 foreach(array_keys($this->presets) as $id)
350 {
351 $this->presets[$id][1] = false;
352 }
353 foreach($form->getInput('preset') as $value)
354 {
355 if(isset($this->presets[$value]))
356 {
357 $this->presets[$value][1] = true;
358 }
359 else
360 {
361 $this->addPreset($value, $value, true);
362 }
363 }
364
365 $this->setTitle($form->getInput('title'), $form->getInput('desc'));
366 $this->setBlankColumns($form->getInput('blank'));
367
368 $selection_of_users = (array)$form->getInput('selection_of_users'); // #18238
369
370 $roles = array();
371 foreach(array_keys($this->role_data) as $role_id)
372 {
373 if(in_array('role_'.$role_id, $selection_of_users))
374 {
375 $roles[] = $role_id;
376 }
377 }
378 $this->setRoleSelection($roles);
379
380 // not in sessions
381 if($this->waiting_list)
382 {
383 $this->include_subscribers = (bool)in_array('subscr', $selection_of_users);
384 $this->include_waiting_list = (bool)in_array('wlist', $selection_of_users);
385 }
386
387 if($this->user_filters)
388 {
389 foreach(array_keys($this->user_filters) as $msub_id)
390 {
391 $this->user_filters[$msub_id][2] = (bool)in_array("members_".$msub_id, $selection_of_users);
392 }
393 }
394
395 if($this->id)
396 {
397 $form->setValuesByPost();
398
399 include_once "Services/User/classes/class.ilUserFormSettings.php";
400 $settings = new ilUserFormSettings($this->id);
401 $settings->deleteValue('desc'); // #11340
402 $settings->importFromForm($form);
403 $settings->store();
404 }
405
406 }
407 }
initForm($a_cmd="")
Init form.
addPreset($a_id, $a_caption, $a_selected=false)
Add user field.
setRoleSelection($a_role_ids)
Set role selection.
setTitle($a_title, $a_description=null)
Set titles.
setBlankColumns(array $a_values)
Add blank columns.

References $id, $roles, addPreset(), initForm(), setBlankColumns(), setRoleSelection(), and setTitle().

+ Here is the call graph for this function:

◆ setBlankColumns()

ilAttendanceList::setBlankColumns ( array  $a_values)

Add blank columns.

Parameters
array$a_value

Definition at line 199 of file class.ilAttendanceList.php.

200 {
201 if(!implode("", $a_values))
202 {
203 $a_values = array();
204 }
205 else
206 {
207 foreach($a_values as $idx => $value)
208 {
209 $a_values[$idx] = trim($value);
210 if($a_values[$idx] == "")
211 {
212 unset($a_values[$idx]);
213 }
214 }
215 }
216 $this->blank_columns = $a_values;
217 }

Referenced by initFromForm().

+ Here is the caller graph for this function:

◆ setCallback()

ilAttendanceList::setCallback (   $a_callback)

Set participant detail callback.

Parameters
string | array$a_callback

Definition at line 224 of file class.ilAttendanceList.php.

225 {
226 $this->callback = $a_callback;
227 }

◆ setId()

ilAttendanceList::setId (   $a_value)

Set id (used for user form settings)

Parameters
string$a_value

Definition at line 234 of file class.ilAttendanceList.php.

235 {
236 $this->id = (string)$a_value;
237 }

◆ setRoleSelection()

ilAttendanceList::setRoleSelection (   $a_role_ids)
protected

Set role selection.

Parameters
array$a_role_ids

Definition at line 134 of file class.ilAttendanceList.php.

135 {
136 $this->roles = $a_role_ids;
137 }

Referenced by initFromForm().

+ Here is the caller graph for this function:

◆ setTitle()

ilAttendanceList::setTitle (   $a_title,
  $a_description = null 
)

Set titles.

Parameters
string$a_title
string$a_description

Definition at line 111 of file class.ilAttendanceList.php.

112 {
113 $this->title = $a_title;
114 $this->description = $a_description;
115 }

Referenced by initFromForm().

+ Here is the caller graph for this function:

Field Documentation

◆ $blank_columns

ilAttendanceList::$blank_columns
protected

Definition at line 23 of file class.ilAttendanceList.php.

Referenced by getHTML().

◆ $callback

ilAttendanceList::$callback
protected

Definition at line 18 of file class.ilAttendanceList.php.

◆ $description

ilAttendanceList::$description
protected

Definition at line 25 of file class.ilAttendanceList.php.

◆ $has_local_role

ilAttendanceList::$has_local_role
protected

Definition at line 22 of file class.ilAttendanceList.php.

◆ $id

ilAttendanceList::$id
protected

Definition at line 27 of file class.ilAttendanceList.php.

Referenced by getHTML(), initForm(), and initFromForm().

◆ $include_subscribers

ilAttendanceList::$include_subscribers
protected

Definition at line 29 of file class.ilAttendanceList.php.

◆ $include_waiting_list

ilAttendanceList::$include_waiting_list
protected

Definition at line 28 of file class.ilAttendanceList.php.

◆ $parent_obj

ilAttendanceList::$parent_obj
protected

Definition at line 15 of file class.ilAttendanceList.php.

◆ $participants

ilAttendanceList::$participants
protected

Definition at line 16 of file class.ilAttendanceList.php.

◆ $pre_blanks

ilAttendanceList::$pre_blanks
protected

Definition at line 26 of file class.ilAttendanceList.php.

◆ $presets

ilAttendanceList::$presets
protected

Definition at line 19 of file class.ilAttendanceList.php.

◆ $role_data

ilAttendanceList::$role_data
protected

Definition at line 20 of file class.ilAttendanceList.php.

Referenced by initForm().

◆ $roles

ilAttendanceList::$roles
protected

Definition at line 21 of file class.ilAttendanceList.php.

Referenced by __construct(), and initFromForm().

◆ $title

ilAttendanceList::$title
protected

Definition at line 24 of file class.ilAttendanceList.php.

Referenced by __construct(), and initForm().

◆ $user_filters

ilAttendanceList::$user_filters
protected

Definition at line 30 of file class.ilAttendanceList.php.

◆ $waiting_list

ilAttendanceList::$waiting_list
protected

Definition at line 17 of file class.ilAttendanceList.php.


The documentation for this class was generated from the following file: