ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  {
30  // tooltip properties
31  $tt = array();
32  if(trim($event_obj->getTitle()))
33  {
34  $tt[] = $event_obj->getTitle();
35  }
36  if(trim($event_obj->getDescription()))
37  {
38  $tt[] = $event_obj->getDescription();
39  }
40  if(trim($event_obj->getLocation()))
41  {
42  $tt[] = $this->lng->txt("event_location").': '.$event_obj->getLocation();
43  }
44  $tt[] = $this->lng->txt("event_date_time").': '.$event_obj->getFirstAppointment()->appointmentToString();
45 
46  // use title/datetime
47  if(sizeof($this->events) <= 4)
48  {
49  $caption = $event_obj->getFirstAppointment()->appointmentToString();
50  if(sizeof($tt) == 1)
51  {
52  $tt = array();
53  }
54  }
55  // use sequence
56  else
57  {
58  $caption = $idx+1;
59  }
60  $tt = implode("<br />\n", $tt);
61 
62  $this->addColumn($caption,'event_'.$event_obj->getId(), '', false, '', $tt, true);
63  }
64 
65  $this->setDefaultOrderField('name');
66  $this->setDefaultOrderDirection('asc');
67 
68  $this->setRowTemplate('tpl.sess_list_row.html','Modules/Session');
69 
70  $this->getItems($this->events, $a_members);
71  }
72 
73  protected function gatherEvents($a_crs_ref_id)
74  {
75  global $tree, $ilAccess;
76 
77  $events = array();
78  foreach($tree->getSubtree($tree->getNodeData($a_crs_ref_id),false,'sess') as $event_id)
79  {
80  $tmp_event = ilObjectFactory::getInstanceByRefId($event_id,false);
81  if(!is_object($tmp_event) ||
82  !$ilAccess->checkAccess('write','',$event_id))
83  {
84  continue;
85  }
86  // sort by date of 1st appointment
87  $events[$tmp_event->getFirstAppointment()->getStartingTime().'_'.$tmp_event->getId()] = $tmp_event;
88  }
89 
90  ksort($events);
91  return array_values($events);
92  }
93 
94  protected function getItems(array $a_events, array $a_members)
95  {
96  $data = array();
97 
98  include_once 'Modules/Session/classes/class.ilEventParticipants.php';
99 
100  foreach($a_members as $user_id)
101  {
102  $name = ilObjUser::_lookupName($user_id);
103  $data[$user_id] = array(
104  'name' => $name['lastname'].', '.$name['firstname'],
105  'login' => $name['login']
106  );
107 
108  foreach($a_events as $event_obj)
109  {
110  $event_part = new ilEventParticipants($event_obj->getId());
111  $data[$user_id]['event_'.$event_obj->getId()] = $event_part->hasParticipated($user_id);
112  }
113  }
114 
115  $this->setData($data);
116  }
117 
118  public function fillRow($a_set)
119  {
120  $this->tpl->setVariable('NAME', $a_set['name']);
121  $this->tpl->setVariable('LOGIN', $a_set['login']);
122 
123  $this->tpl->setCurrentBlock('eventcols');
124  foreach($this->events as $event_obj)
125  {
126  if((bool)$a_set['event_'.$event_obj->getId()])
127  {
128  $this->tpl->setVariable("IMAGE_PARTICIPATED", ilUtil::getImagePath('icon_ok.svg'));
129  $this->tpl->setVariable("PARTICIPATED", $this->lng->txt('event_participated'));
130  }
131  else
132  {
133  $this->tpl->setVariable("IMAGE_PARTICIPATED", ilUtil::getImagePath('icon_not_ok.svg'));
134  $this->tpl->setVariable("PARTICIPATED", $this->lng->txt('event_not_participated'));
135  }
136  $this->tpl->parseCurrentBlock();
137  }
138  }
139 }
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)
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.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
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.