ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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.
 addPreset ($a_id, $a_caption, $a_selected=false)
 Add user field.
 addBlank ($a_caption)
 Add blank column preset.
 setTitle ($a_title, $a_description=null)
 Set titles.
 addUserFilter ($a_id, $a_caption, $a_checked=false)
 Add user filter.
 getNonMemberUserData (array &$a_res)
 Get user data for subscribers and waiting list.
 setBlankColumns (array $a_values)
 Add blank columns.
 setCallback ($a_callback)
 Set participant detail callback.
 setId ($a_value)
 Set id (used for user form settings)
 initForm ($a_cmd="")
 Init form.
 initFromForm ()
 Set list attributes from post values.
 getFullscreenHTML ()
 render list in fullscreen mode
 getHTML ()
 render attendance list

Protected Member Functions

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

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

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.

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

{
global $lng;
$this->parent_obj = $a_parent_obj;
$this->participants = $a_participants_object;
$this->waiting_list = $a_waiting_list;
// always available
$this->presets['name'] = array($lng->txt('name'), true);
$this->presets['login'] = array($lng->txt('login'), true);
$this->presets['email'] = array($lng->txt('email'));
$lng->loadLanguageModule('crs');
// roles
$roles = $this->participants->getRoles();
foreach($roles as $role_id)
{
switch(substr($title, 0, 8))
{
case 'il_crs_a':
case 'il_grp_a':
$this->addRole($role_id, $lng->txt('event_tbl_admins'), 'admin');
break;
case 'il_crs_t':
$this->addRole($role_id, $lng->txt('event_tbl_tutors'), 'tutor');
break;
case 'il_crs_m':
case 'il_grp_m':
$this->addRole($role_id, $lng->txt('event_tbl_members'), 'member');
break;
// local
default:
$this->has_local_role = true;
$this->addRole($role_id, $title, 'local');
break;
}
}
}

+ Here is the call graph for this function:

Member Function Documentation

ilAttendanceList::addBlank (   $a_caption)

Add blank column preset.

Parameters
string$a_caption

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

{
$this->pre_blanks[] = $a_caption;
}
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.

Referenced by initFromForm().

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

+ Here is the caller graph for this function:

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.

Referenced by __construct().

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

+ Here is the caller graph for this function:

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.

{
$this->user_filters[$a_id] = array($a_caption, $a_checked);
}
ilAttendanceList::getFullscreenHTML ( )

render list in fullscreen mode

Returns
string

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

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

{
$tpl = new ilTemplate('tpl.main.html',true,true);
$tpl->setBodyClass("ilBodyPrint");
// load style sheet depending on user's settings
$location_stylesheet = ilUtil::getStyleSheetLocation();
$tpl->setVariable("LOCATION_STYLESHEET",$location_stylesheet);
$tpl->setVariable("BODY_ATTRIBUTES",'onload="window.print()"');
$tpl->setVariable("CONTENT", $this->getHTML());
return $tpl->show();
}

+ Here is the call graph for this function:

ilAttendanceList::getHTML ( )

render attendance list

Returns
string

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

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

Referenced by getFullscreenHTML().

{
$tpl = new ilTemplate('tpl.attendance_list_print.html',true,true,'Services/Membership');
// title
$time = ilFormat::formatUnixTime(time(),true);
$tpl->setVariable('TXT_TITLE', $this->title);
if($this->description)
{
$tpl->setVariable('TXT_DESCRIPTION', $this->description." (".$time.")");
}
else
{
$tpl->setVariable('TXT_DESCRIPTION', $time);
}
// header
$tpl->setCurrentBlock('head_item');
foreach($this->presets as $id => $item)
{
if($item[1])
{
$tpl->setVariable('TXT_HEAD', $item[0]);
$tpl->parseCurrentBlock();
}
}
if($this->blank_columns)
{
foreach($this->blank_columns as $blank)
{
$tpl->setVariable('TXT_HEAD', $blank);
$tpl->parseCurrentBlock();
}
}
// handle members
$valid_user_ids = $filters = array();
if($this->roles)
{
if($this->has_local_role)
{
$members = array();
foreach($this->participants->getMembers() as $member_id)
{
foreach($this->participants->getAssignedRoles($member_id) as $role_id)
{
$members[$role_id][] = $member_id;
}
}
}
else
{
$members = $this->participants->getMembers();
}
foreach($this->roles as $role_id)
{
switch($this->role_data[$role_id][1])
{
case "admin":
$valid_user_ids = array_merge($valid_user_ids, $this->participants->getAdmins());
break;
case "tutor":
$valid_user_ids = array_merge($valid_user_ids, $this->participants->getTutors());
break;
// member/local
default:
if(!$this->has_local_role)
{
$valid_user_ids = array_merge($valid_user_ids, (array)$members);
}
else
{
$valid_user_ids = array_merge($valid_user_ids, (array)$members[$role_id]);
}
break;
}
}
}
if($this->include_subscribers)
{
$valid_user_ids = array_merge($valid_user_ids, $this->participants->getSubscribers());
}
if($this->include_waiting_list)
{
$valid_user_ids = array_merge($valid_user_ids, $this->waiting_list->getUserIds());
}
if($this->user_filters)
{
foreach($this->user_filters as $sub_id => $sub_item)
{
$filters[$sub_id] = (bool)$sub_item[2];
}
}
$valid_user_ids = ilUtil::_sortIds(array_unique($valid_user_ids),'usr_data','lastname','usr_id');
// rows
foreach($valid_user_ids as $user_id)
{
if($this->callback)
{
$user_data = call_user_func_array($this->callback, array($user_id, $filters));
if(!$user_data)
{
continue;
}
$tpl->setCurrentBlock("row_preset");
foreach($this->presets as $id => $item)
{
if($item[1])
{
switch($id)
{
case "name":
if(!$user_data[$id])
{
$name = ilObjUser::_lookupName($user_id);
$value = $name["lastname"].", ".$name["firstname"];
break;
}
case "email":
if(!$user_data[$id])
{
$value = ilObjUser::_lookupEmail($user_id);
break;
}
case "login":
if(!$user_data[$id])
{
$value = ilObjUser::_lookupLogin($user_id);
break;
}
default:
$value = (string)$user_data[$id];
break;
}
$tpl->setVariable("TXT_PRESET", $value);
$tpl->parseCurrentBlock();
}
}
}
if($this->blank_columns)
{
for($loop = 0; $loop < sizeof($this->blank_columns); $loop++)
{
$tpl->touchBlock('row_blank');
}
}
$tpl->touchBlock("member_row");
}
return $tpl->get();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

References $lng, and ilObjectFactory\getInstanceByObjId().

{
global $lng;
$subscriber_ids = $this->participants->getSubscribers();
$user_ids = $subscriber_ids;
if($this->waiting_list)
{
$user_ids = array_merge($user_ids, $this->waiting_list->getUserIds());
}
if(sizeof($user_ids))
{
foreach(array_unique($user_ids) as $user_id)
{
if(!isset($a_res[$user_id]))
{
if($tmp_obj = ilObjectFactory::getInstanceByObjId($user_id, false))
{
$a_res[$user_id]['login'] = $tmp_obj->getLogin();
$a_res[$user_id]['name'] = $tmp_obj->getLastname().', '.$tmp_obj->getFirstname();
$a_res[$user_id]['email'] = $tmp_obj->getEmail();
if(in_array($user_id, $subscriber_ids))
{
$a_res[$user_id]['status'] = $lng->txt('crs_subscriber');
}
else
{
$a_res[$user_id]['status'] = $lng->txt('crs_waiting_list');
}
}
}
}
}
}

+ Here is the call graph for this function:

ilAttendanceList::initForm (   $a_cmd = "")

Init form.

Parameters
string$a_cmd
Returns
ilPropertyFormGUI

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

References $id, $ilCtrl, $lng, $role_data, $title, ilFormPropertyGUI\setMulti(), ilTextInputGUI\setValue(), and ilCheckboxInputGUI\setValue().

Referenced by initFromForm().

{
global $ilCtrl, $lng;
$lng->loadLanguageModule('crs');
include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
$form = new ilPropertyFormGUI();
$form->setFormAction($ilCtrl->getFormAction($this->parent_obj,$a_cmd));
$form->setTarget('_blank');
$form->setPreventDoubleSubmission(false);
$form->setTitle($lng->txt('sess_gen_attendance_list'));
$title = new ilTextInputGUI($lng->txt('title'), 'title');
$title->setValue($this->title);
$form->addItem($title);
$desc = new ilTextInputGUI($lng->txt('description'), 'desc');
$desc->setValue($this->description);
$form->addItem($desc);
if(sizeof($this->presets))
{
$preset = new ilCheckboxGroupInputGUI($lng->txt('user_detail'), 'preset');
$preset_value = array();
foreach($this->presets as $id => $item)
{
$preset->addOption(new ilCheckboxOption($item[0], $id));
if($item[1])
{
$preset_value[] = $id;
}
}
$preset->setValue($preset_value);
$form->addItem($preset);
}
$blank = new ilTextInputGUI($lng->txt('event_blank_columns'), 'blank');
$blank->setMulti(true);
$form->addItem($blank);
if($this->pre_blanks)
{
$blank->setValue($this->pre_blanks);
}
$part = new ilFormSectionHeaderGUI();
$part->setTitle($lng->txt('event_participant_selection'));
$form->addItem($part);
// participants by roles
foreach($this->role_data as $role_id => $role_data)
{
$chk = new ilCheckboxInputGUI($role_data[0], 'role_'.$role_id);
$chk->setValue(1);
$chk->setChecked(1);
$form->addItem($chk);
}
// not in sessions
if($this->waiting_list)
{
$chk = new ilCheckboxInputGUI($lng->txt('group_new_registrations'), 'subscr');
$chk->setValue(1);
$form->addItem($chk);
$chk = new ilCheckboxInputGUI($lng->txt('crs_waiting_list'), 'wlist');
$chk->setValue(1);
$form->addItem($chk);
}
if($this->user_filters)
{
foreach($this->user_filters as $sub_id => $sub_item)
{
$sub = new ilCheckboxInputGUI($sub_item[0], 'members_'.$sub_id);
if($sub_item[1])
{
$sub->setChecked(true);
}
$form->addItem($sub);
}
}
$form->addCommandButton($a_cmd,$lng->txt('sess_print_attendance_list'));
if($this->id && $a_cmd)
{
include_once "Services/User/classes/class.ilUserFormSettings.php";
$settings = new ilUserFormSettings($this->id);
$settings->deleteValue('desc'); // #11340
$settings->exportToForm($form);
}
return $form;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAttendanceList::initFromForm ( )

Set list attributes from post values.

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

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

{
$form = $this->initForm();
if($form->checkInput())
{
foreach(array_keys($this->presets) as $id)
{
$this->presets[$id][1] = false;
}
foreach($form->getInput('preset') as $value)
{
if(isset($this->presets[$value]))
{
$this->presets[$value][1] = true;
}
else
{
$this->addPreset($value, $value, true);
}
}
$this->setTitle($form->getInput('title'), $form->getInput('desc'));
$this->setBlankColumns($form->getInput('blank'));
$roles = array();
foreach(array_keys($this->role_data) as $role_id)
{
if($form->getInput('role_'.$role_id))
{
$roles[] = $role_id;
}
}
$this->setRoleSelection($roles);
// not in sessions
if($this->waiting_list)
{
$this->include_subscribers = (bool)$form->getInput('subscr');
$this->include_waiting_list = (bool)$form->getInput('wlist');
}
if($this->user_filters)
{
foreach(array_keys($this->user_filters) as $msub_id)
{
$this->user_filters[$msub_id][2] = $form->getInput("members_".$msub_id);
}
}
if($this->id)
{
$form->setValuesByPost();
include_once "Services/User/classes/class.ilUserFormSettings.php";
$settings = new ilUserFormSettings($this->id);
$settings->deleteValue('desc'); // #11340
$settings->importFromForm($form);
$settings->store();
}
}
}

+ Here is the call graph for this function:

ilAttendanceList::setBlankColumns ( array  $a_values)

Add blank columns.

Parameters
array$a_value

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

Referenced by initFromForm().

{
if(!implode("", $a_values))
{
$a_values = array();
}
else
{
foreach($a_values as $idx => $value)
{
$a_values[$idx] = trim($value);
if($a_values[$idx] == "")
{
unset($a_values[$idx]);
}
}
}
$this->blank_columns = $a_values;
}

+ Here is the caller graph for this function:

ilAttendanceList::setCallback (   $a_callback)

Set participant detail callback.

Parameters
string | array$a_callback

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

{
$this->callback = $a_callback;
}
ilAttendanceList::setId (   $a_value)

Set id (used for user form settings)

Parameters
string$a_value

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

{
$this->id = (string)$a_value;
}
ilAttendanceList::setRoleSelection (   $a_role_ids)
protected

Set role selection.

Parameters
array$a_role_ids

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

Referenced by initFromForm().

{
$this->roles = $a_role_ids;
}

+ Here is the caller graph for this function:

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.

Referenced by initFromForm().

{
$this->title = $a_title;
$this->description = $a_description;
}

+ Here is the caller graph for this function:

Field Documentation

ilAttendanceList::$blank_columns
protected

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

Referenced by getHTML().

ilAttendanceList::$callback
protected

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

ilAttendanceList::$description
protected

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

ilAttendanceList::$has_local_role
protected

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

ilAttendanceList::$id
protected

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

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

ilAttendanceList::$include_subscribers
protected

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

ilAttendanceList::$include_waiting_list
protected

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

ilAttendanceList::$parent_obj
protected

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

ilAttendanceList::$participants
protected

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

ilAttendanceList::$pre_blanks
protected

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

ilAttendanceList::$presets
protected

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

ilAttendanceList::$role_data
protected

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

Referenced by initForm().

ilAttendanceList::$roles
protected

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

Referenced by __construct(), and initFromForm().

ilAttendanceList::$title
protected

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

Referenced by __construct(), and initForm().

ilAttendanceList::$user_filters
protected

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

ilAttendanceList::$waiting_list
protected

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


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