ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilSessionOverviewTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once './Services/Table/classes/class.ilTable2GUI.php';
5
13{
14 protected $events; // [array]
15
16 public function __construct($a_parent_obj, $a_parent_cmd, $a_crs_ref_id, array $a_members)
17 {
18 $this->setId('sessov');
19
20 parent::__construct($a_parent_obj, $a_parent_cmd);
21
22 $this->setTitle($this->lng->txt('event_overview'));
23
24 $this->addColumn($this->lng->txt('name'), 'name');
25 $this->addColumn($this->lng->txt('login'), 'login');
26
27 $this->events = $this->gatherEvents($a_crs_ref_id);
28 foreach ($this->events as $idx => $event_obj) {
29 // tooltip properties
30 $tt = array();
31 if (trim($event_obj->getTitle())) {
32 $tt[] = $event_obj->getTitle();
33 }
34 if (trim($event_obj->getDescription())) {
35 $tt[] = $event_obj->getDescription();
36 }
37 if (trim($event_obj->getLocation())) {
38 $tt[] = $this->lng->txt("event_location") . ': ' . $event_obj->getLocation();
39 }
40 $tt[] = $this->lng->txt("event_date_time") . ': ' . $event_obj->getFirstAppointment()->appointmentToString();
41
42 // use title/datetime
43 if (sizeof($this->events) <= 4) {
44 $caption = $event_obj->getFirstAppointment()->appointmentToString();
45 if (sizeof($tt) == 1) {
46 $tt = array();
47 }
48 }
49 // use sequence
50 else {
51 $caption = $idx + 1;
52 }
53 $tt = implode("<br />\n", $tt);
54
55 $this->addColumn($caption, 'event_' . $event_obj->getId(), '', false, '', $tt, true);
56 }
57
58 $this->setDefaultOrderField('name');
59 $this->setDefaultOrderDirection('asc');
60
61 $this->setRowTemplate('tpl.sess_list_row.html', 'Modules/Session');
62
63 $this->getItems($this->events, $a_members);
64 }
65
66 protected function gatherEvents($a_crs_ref_id)
67 {
68 global $DIC;
69
70 $tree = $DIC['tree'];
71 $ilAccess = $DIC['ilAccess'];
72
73 $events = array();
74 foreach ($tree->getSubtree($tree->getNodeData($a_crs_ref_id), false, 'sess') as $event_id) {
75 $tmp_event = ilObjectFactory::getInstanceByRefId($event_id, false);
76 if (!is_object($tmp_event) ||
77 !$ilAccess->checkAccess('manage_members', '', $event_id)) {
78 continue;
79 }
80 // sort by date of 1st appointment
81 $events[$tmp_event->getFirstAppointment()->getStartingTime() . '_' . $tmp_event->getId()] = $tmp_event;
82 }
83
84 ksort($events);
85 return array_values($events);
86 }
87
88 protected function getItems(array $a_events, array $a_members)
89 {
90 $data = array();
91
92 include_once 'Modules/Session/classes/class.ilEventParticipants.php';
93
94 foreach ($a_members as $user_id) {
95 $name = ilObjUser::_lookupName($user_id);
96 $data[$user_id] = array(
97 'name' => $name['lastname'] . ', ' . $name['firstname'],
98 'login' => $name['login']
99 );
100
101 foreach ($a_events as $event_obj) {
102 $event_part = new ilEventParticipants($event_obj->getId());
103 $data[$user_id]['event_' . $event_obj->getId()] = $event_part->hasParticipated($user_id);
104 }
105 }
106
107 $this->setData($data);
108 }
109
110 public function fillRow($a_set)
111 {
112 $this->tpl->setVariable('NAME', $a_set['name']);
113 $this->tpl->setVariable('LOGIN', $a_set['login']);
114
115 $this->tpl->setCurrentBlock('eventcols');
116 foreach ($this->events as $event_obj) {
117 if ((bool) $a_set['event_' . $event_obj->getId()]) {
118 $this->tpl->setVariable("IMAGE_PARTICIPATED", ilUtil::getImagePath('icon_ok.svg'));
119 $this->tpl->setVariable("PARTICIPATED", $this->lng->txt('event_participated'));
120 } else {
121 $this->tpl->setVariable("IMAGE_PARTICIPATED", ilUtil::getImagePath('icon_not_ok.svg'));
122 $this->tpl->setVariable("PARTICIPATED", $this->lng->txt('event_not_participated'));
123 }
124 $this->tpl->parseCurrentBlock();
125 }
126 }
127}
An exception for terminatinating execution or to throw for unit testing.
static _lookupName($a_user_id)
lookup user name
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
Table presentation for session overview.
__construct($a_parent_obj, $a_parent_cmd, $a_crs_ref_id, array $a_members)
fillRow($a_set)
Standard Version of Fill Row.
getItems(array $a_events, array $a_members)
Class ilTable2GUI.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
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.
setId($a_val)
Set id.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
global $DIC
Definition: saml.php:7