ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
4 include_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 $tree, $ilAccess;
69 
70  $events = array();
71  foreach ($tree->getSubtree($tree->getNodeData($a_crs_ref_id), false, 'sess') as $event_id) {
72  $tmp_event = ilObjectFactory::getInstanceByRefId($event_id, false);
73  if (!is_object($tmp_event) ||
74  !$ilAccess->checkAccess('write', '', $event_id)) {
75  continue;
76  }
77  // sort by date of 1st appointment
78  $events[$tmp_event->getFirstAppointment()->getStartingTime() . '_' . $tmp_event->getId()] = $tmp_event;
79  }
80 
81  ksort($events);
82  return array_values($events);
83  }
84 
85  protected function getItems(array $a_events, array $a_members)
86  {
87  $data = array();
88 
89  include_once 'Modules/Session/classes/class.ilEventParticipants.php';
90 
91  foreach ($a_members as $user_id) {
92  $name = ilObjUser::_lookupName($user_id);
93  $data[$user_id] = array(
94  'name' => $name['lastname'] . ', ' . $name['firstname'],
95  'login' => $name['login']
96  );
97 
98  foreach ($a_events as $event_obj) {
99  $event_part = new ilEventParticipants($event_obj->getId());
100  $data[$user_id]['event_' . $event_obj->getId()] = $event_part->hasParticipated($user_id);
101  }
102  }
103 
104  $this->setData($data);
105  }
106 
107  public function fillRow($a_set)
108  {
109  $this->tpl->setVariable('NAME', $a_set['name']);
110  $this->tpl->setVariable('LOGIN', $a_set['login']);
111 
112  $this->tpl->setCurrentBlock('eventcols');
113  foreach ($this->events as $event_obj) {
114  if ((bool) $a_set['event_' . $event_obj->getId()]) {
115  $this->tpl->setVariable("IMAGE_PARTICIPATED", ilUtil::getImagePath('icon_ok.svg'));
116  $this->tpl->setVariable("PARTICIPATED", $this->lng->txt('event_participated'));
117  } else {
118  $this->tpl->setVariable("IMAGE_PARTICIPATED", ilUtil::getImagePath('icon_not_ok.svg'));
119  $this->tpl->setVariable("PARTICIPATED", $this->lng->txt('event_not_participated'));
120  }
121  $this->tpl->parseCurrentBlock();
122  }
123  }
124 }
static _lookupName($a_user_id)
lookup user name
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
getItems(array $a_events, array $a_members)
Table presentation for session overview.
setId($a_val)
Set id.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
__construct($a_parent_obj, $a_parent_cmd, $a_crs_ref_id, array $a_members)
if($format !==null) $name
Definition: metadata.php:146
Class ilTable2GUI.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
setRowTemplate($a_template, $a_template_dir="")
Set row template.
Create styles array
The data for the language used.
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.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id