ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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 $this->presets['email'] = array($lng->txt('email'));
51
52 $lng->loadLanguageModule('crs');
53
54 // roles
55 $roles = $this->participants->getRoles();
56 foreach($roles as $role_id)
57 {
59 switch(substr($title, 0, 8))
60 {
61 case 'il_crs_a':
62 case 'il_grp_a':
63 $this->addRole($role_id, $lng->txt('event_tbl_admins'), 'admin');
64 break;
65
66 case 'il_crs_t':
67 $this->addRole($role_id, $lng->txt('event_tbl_tutors'), 'tutor');
68 break;
69
70 case 'il_crs_m':
71 case 'il_grp_m':
72 $this->addRole($role_id, $lng->txt('event_tbl_members'), 'member');
73 break;
74
75 // local
76 default:
77 $this->has_local_role = true;
78 $this->addRole($role_id, $title, 'local');
79 break;
80 }
81 }
82 }
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 101 of file class.ilAttendanceList.php.

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

◆ 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 91 of file class.ilAttendanceList.php.

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

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 125 of file class.ilAttendanceList.php.

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

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 147 of file class.ilAttendanceList.php.

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

◆ getFullscreenHTML()

ilAttendanceList::getFullscreenHTML ( )

render list in fullscreen mode

Returns
string

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

416 {
417 $tpl = new ilTemplate('tpl.main.html',true,true);
418 $tpl->setBodyClass("ilBodyPrint");
419
420 // load style sheet depending on user's settings
421 $location_stylesheet = ilUtil::getStyleSheetLocation();
422 $tpl->setVariable("LOCATION_STYLESHEET",$location_stylesheet);
423
424 $tpl->setVariable("BODY_ATTRIBUTES",'onload="window.print()"');
425 $tpl->setVariable("CONTENT", $this->getHTML());
426
427 return $tpl->show();
428 }
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 435 of file class.ilAttendanceList.php.

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

158 {
159 global $lng;
160
161 $subscriber_ids = $this->participants->getSubscribers();
162
163 $user_ids = $subscriber_ids;
164
165 if($this->waiting_list)
166 {
167 $user_ids = array_merge($user_ids, $this->waiting_list->getUserIds());
168 }
169
170 if(sizeof($user_ids))
171 {
172 foreach(array_unique($user_ids) as $user_id)
173 {
174 if(!isset($a_res[$user_id]))
175 {
176 if($tmp_obj = ilObjectFactory::getInstanceByObjId($user_id, false))
177 {
178 $a_res[$user_id]['login'] = $tmp_obj->getLogin();
179 $a_res[$user_id]['name'] = $tmp_obj->getLastname().', '.$tmp_obj->getFirstname();
180 $a_res[$user_id]['email'] = $tmp_obj->getEmail();
181
182 if(in_array($user_id, $subscriber_ids))
183 {
184 $a_res[$user_id]['status'] = $lng->txt('crs_subscriber');
185 }
186 else
187 {
188 $a_res[$user_id]['status'] = $lng->txt('crs_waiting_list');
189 }
190 }
191 }
192 }
193 }
194 }
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 247 of file class.ilAttendanceList.php.

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

348 {
349 $form = $this->initForm();
350 if($form->checkInput())
351 {
352 foreach(array_keys($this->presets) as $id)
353 {
354 $this->presets[$id][1] = false;
355 }
356 foreach($form->getInput('preset') as $value)
357 {
358 if(isset($this->presets[$value]))
359 {
360 $this->presets[$value][1] = true;
361 }
362 else
363 {
364 $this->addPreset($value, $value, true);
365 }
366 }
367
368 $this->setTitle($form->getInput('title'), $form->getInput('desc'));
369 $this->setBlankColumns($form->getInput('blank'));
370
371 $roles = array();
372 foreach(array_keys($this->role_data) as $role_id)
373 {
374 if($form->getInput('role_'.$role_id))
375 {
376 $roles[] = $role_id;
377 }
378 }
379 $this->setRoleSelection($roles);
380
381 // not in sessions
382 if($this->waiting_list)
383 {
384 $this->include_subscribers = (bool)$form->getInput('subscr');
385 $this->include_waiting_list = (bool)$form->getInput('wlist');
386 }
387
388 if($this->user_filters)
389 {
390 foreach(array_keys($this->user_filters) as $msub_id)
391 {
392 $this->user_filters[$msub_id][2] = $form->getInput("members_".$msub_id);
393 }
394 }
395
396 if($this->id)
397 {
398 $form->setValuesByPost();
399
400 include_once "Services/User/classes/class.ilUserFormSettings.php";
401 $settings = new ilUserFormSettings($this->id);
402 $settings->deleteValue('desc'); // #11340
403 $settings->importFromForm($form);
404 $settings->store();
405 }
406
407 }
408 }
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 201 of file class.ilAttendanceList.php.

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

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 226 of file class.ilAttendanceList.php.

227 {
228 $this->callback = $a_callback;
229 }

◆ setId()

ilAttendanceList::setId (   $a_value)

Set id (used for user form settings)

Parameters
string$a_value

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

237 {
238 $this->id = (string)$a_value;
239 }

◆ setRoleSelection()

ilAttendanceList::setRoleSelection (   $a_role_ids)
protected

Set role selection.

Parameters
array$a_role_ids

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

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

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 112 of file class.ilAttendanceList.php.

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

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: