ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilSessionOverviewGUI.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
33{
34 protected $course_ref_id = null;
35 protected $course_id = null;
36
37 protected $lng;
38 protected $tpl;
39 protected $ctrl;
40
48 public function __construct($a_crs_ref_id, ilParticipants $a_members)
49 {
50 global $tpl, $ilCtrl, $lng;
51
52 $this->ctrl = $ilCtrl;
53 $this->tpl = $tpl;
54 $this->lng = $lng;
55 $this->lng->loadLanguageModule('event');
56 $this->lng->loadLanguageModule('crs');
57
58 $this->course_ref_id = $a_crs_ref_id;
59 $this->course_id = ilObject::_lookupObjId($this->course_ref_id);
60 $this->members_obj = $a_members;
61 }
62
70 public function executeCommand()
71 {
72 $next_class = $this->ctrl->getNextClass($this);
73 $cmd = $this->ctrl->getCmd();
74
75 switch($next_class)
76 {
77 default:
78 if(!$cmd)
79 {
80 $cmd = "listSessions";
81 }
82 $this->$cmd();
83 break;
84 }
85 }
93 public function listSessions()
94 {
95 global $ilToolbar,$ilErr,$ilAccess;
96
97 if(!$ilAccess->checkAccess('write','',$this->course_ref_id))
98 {
99 $ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$ilErr->MESSAGE);
100 }
101
102 $ilToolbar->addButton($this->lng->txt('event_csv_export'),
103 $this->ctrl->getLinkTarget($this,'exportCSV'));
104
105 include_once 'Modules/Session/classes/class.ilSessionOverviewTableGUI.php';
106 $tbl = new ilSessionOverviewTableGUI($this, 'listSessions', $this->course_ref_id, $this->members_obj->getParticipants());
107 $this->tpl->setContent($tbl->getHTML());
108 }
109
117 public function exportCSV()
118 {
119 global $tree,$ilAccess;
120
121 include_once('Services/Utilities/classes/class.ilCSVWriter.php');
122 include_once 'Modules/Session/classes/class.ilEventParticipants.php';
123
124 $members = $this->members_obj->getParticipants();
125 $members = ilUtil::_sortIds($members,'usr_data','lastname','usr_id');
126
127 $events = array();
128 foreach($tree->getSubtree($tree->getNodeData($this->course_ref_id),false,'sess') as $event_id)
129 {
130 $tmp_event = ilObjectFactory::getInstanceByRefId($event_id,false);
131 if(!is_object($tmp_event) or !$ilAccess->checkAccess('write','',$event_id))
132 {
133 continue;
134 }
135 $events[] = $tmp_event;
136 }
137
138 $this->csv = new ilCSVWriter();
139 $this->csv->addColumn($this->lng->txt("lastname"));
140 $this->csv->addColumn($this->lng->txt("firstname"));
141 $this->csv->addColumn($this->lng->txt("login"));
142
143 foreach($events as $event_obj)
144 {
145 // TODO: do not export relative dates
146 $this->csv->addColumn($event_obj->getTitle().' ('.$event_obj->getFirstAppointment()->appointmentToString().')');
147 }
148
149 $this->csv->addRow();
150
151 foreach($members as $user_id)
152 {
153 $name = ilObjUser::_lookupName($user_id);
154
155 $this->csv->addColumn($name['lastname']);
156 $this->csv->addColumn($name['firstname']);
157 $this->csv->addColumn(ilObjUser::_lookupLogin($user_id));
158
159 foreach($events as $event_obj)
160 {
161 $event_part = new ilEventParticipants((int) $event_obj->getId());
162
163 $this->csv->addColumn($event_part->hasParticipated($user_id) ?
164 $this->lng->txt('event_participated') :
165 $this->lng->txt('event_not_participated'));
166 }
167
168 $this->csv->addRow();
169 }
170 $date = new ilDate(time(),IL_CAL_UNIX);
171 ilUtil::deliverData($this->csv->getCSVString(),$date->get(IL_CAL_FKT_DATE,'Y-m-d')."_course_events.csv", "text/csv");
172 }
173}
174?>
const IL_CAL_UNIX
const IL_CAL_FKT_DATE
Helper class to generate CSV files.
Class for single dates.
static _lookupLogin($a_user_id)
lookup login
static _lookupName($a_user_id)
lookup user name
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static _lookupObjId($a_id)
__construct($a_crs_ref_id, ilParticipants $a_members)
constructor
exportCSV()
Events List CSV Export.
listSessions()
list sessions of all user
Table presentation for session overview.
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,...
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
$tbl
Definition: example_048.php:81
global $ilCtrl
Definition: ilias.php:18
$cmd
Definition: sahs_server.php:35