ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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 $ilErr,$ilAccess, $ilUser,$tree;
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 $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.sess_list.html','Modules/Session');
103 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
104
105 // display button
106 $this->tpl->setCurrentBlock("btn_cell");
107 $this->tpl->setVariable("BTN_LINK",$this->ctrl->getLinkTarget($this,'exportCSV'));
108 $this->tpl->setVariable("BTN_TXT",$this->lng->txt('event_csv_export'));
109 $this->tpl->parseCurrentBlock();
110
111 include_once 'Modules/Session/classes/class.ilEventParticipants.php';
112
113 $this->tpl->addBlockfile("EVENTS_TABLE","events_table", "tpl.table.html");
114 $this->tpl->addBlockfile('TBL_CONTENT','tbl_content','tpl.sess_list_row.html','Modules/Session');
115
116 $members = $this->members_obj->getParticipants();
117 $members = ilUtil::_sortIds($members,'usr_data','lastname','usr_id');
118
119 // Table
120 //TODO: Use ilTable2GUI
121 $tbl = new ilTableGUI();
122 $tbl->setTitle($this->lng->txt("event_overview"),
123 '',
124 $this->lng->txt('obj_usr'));
125 $this->ctrl->setParameter($this,'offset',(int) $_GET['offset']);
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 $headerNames = array();
139 $headerVars = array();
140 $colWidth = array();
141
142 $headerNames[] = $this->lng->txt('name');
143 $headerVars[] = "name";
144 $colWidth[] = '20%';
145 $headerNames[] = $this->lng->txt('login');
146 $headerVars[] = "login";
147 $colWidth[] = '20%';
148
149 for ($i = 1; $i <= count($events); $i++)
150 {
151 $headerNames[] = $i;
152 $headerVars[] = "event_".$i;
153 $colWidth[] = 80/count($events)."%";
154 }
155
156 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
157 $tbl->setHeaderNames($headerNames);
158 $tbl->setHeaderVars($headerVars, $this->ctrl->getParameterArray($this,'listSessions'));
159 $tbl->setColumnWidth($colWidth);
160
161 $tbl->setOrderColumn($_GET["sort_by"]);
162 $tbl->setOrderDirection($_GET["sort_order"]);
163 $tbl->setOffset($_GET["offset"]);
164 $tbl->setLimit($ilUser->getPref("hits_per_page"));
165 $tbl->setMaxCount(count($members));
166 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
167
168 $sliced_users = array_slice($members,$_GET['offset'],$_SESSION['tbl_limit']);
169 $tbl->disable('sort');
170 $tbl->render();
171
172 $counter = 0;
173 foreach($sliced_users as $user_id)
174 {
175 foreach($events as $event_obj)
176 {
177 $this->tpl->setCurrentBlock("eventcols");
178
179 $event_part = new ilEventParticipants($event_obj->getId());
180
181 {
182 $this->tpl->setVariable("IMAGE_PARTICIPATED", $event_part->hasParticipated($user_id) ?
183 ilUtil::getImagePath('icon_ok.svg') :
184 ilUtil::getImagePath('icon_not_ok.svg'));
185
186 $this->tpl->setVariable("PARTICIPATED", $event_part->hasParticipated($user_id) ?
187 $this->lng->txt('event_participated') :
188 $this->lng->txt('event_not_participated'));
189 }
190
191 $this->tpl->parseCurrentBlock();
192 }
193
194 $this->tpl->setCurrentBlock("tbl_content");
195 $name = ilObjUser::_lookupName($user_id);
196 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor($counter++,'tblrow1','tblrow2'));
197 $this->tpl->setVariable("LASTNAME",$name['lastname']);
198 $this->tpl->setVariable("FIRSTNAME",$name['firstname']);
199 $this->tpl->setVariable("LOGIN",ilObjUser::_lookupLogin($user_id));
200 $this->tpl->parseCurrentBlock();
201 }
202
203 $this->tpl->setVariable("HEAD_TXT_LEGEND", $this->lng->txt("legend"));
204 $this->tpl->setVariable("HEAD_TXT_DIGIT", $this->lng->txt("event_digit"));
205 $this->tpl->setVariable("HEAD_TXT_EVENT", $this->lng->txt("event"));
206 $this->tpl->setVariable("HEAD_TXT_LOCATION", $this->lng->txt("event_location"));
207 $this->tpl->setVariable("HEAD_TXT_DATE_TIME",$this->lng->txt("event_date_time"));
208 $i = 1;
209 foreach($events as $event_obj)
210 {
211 $this->tpl->setCurrentBlock("legend_loop");
212 $this->tpl->setVariable("LEGEND_CSS_ROW",ilUtil::switchColor($counter++,'tblrow1','tblrow2'));
213 $this->tpl->setVariable("LEGEND_DIGIT", $i++);
214 $this->tpl->setVariable("LEGEND_EVENT_TITLE", $event_obj->getTitle());
215 $this->tpl->setVariable("LEGEND_EVENT_DESCRIPTION", $event_obj->getDescription());
216 $this->tpl->setVariable("LEGEND_EVENT_LOCATION", $event_obj->getLocation());
217 $this->tpl->setVariable("LEGEND_EVENT_APPOINTMENT", $event_obj->getFirstAppointment()->appointmentToString());
218 $this->tpl->parseCurrentBlock();
219 }
220
221 }
222
230 public function exportCSV()
231 {
232 global $tree,$ilAccess;
233
234 include_once('Services/Utilities/classes/class.ilCSVWriter.php');
235 include_once 'Modules/Session/classes/class.ilEventParticipants.php';
236
237 $members = $this->members_obj->getParticipants();
238 $members = ilUtil::_sortIds($members,'usr_data','lastname','usr_id');
239
240 $events = array();
241 foreach($tree->getSubtree($tree->getNodeData($this->course_ref_id),false,'sess') as $event_id)
242 {
243 $tmp_event = ilObjectFactory::getInstanceByRefId($event_id,false);
244 if(!is_object($tmp_event) or !$ilAccess->checkAccess('write','',$event_id))
245 {
246 continue;
247 }
248 $events[] = $tmp_event;
249 }
250
251 $this->csv = new ilCSVWriter();
252 $this->csv->addColumn($this->lng->txt("lastname"));
253 $this->csv->addColumn($this->lng->txt("firstname"));
254 $this->csv->addColumn($this->lng->txt("login"));
255
256 foreach($events as $event_obj)
257 {
258 // TODO: do not export relative dates
259 $this->csv->addColumn($event_obj->getTitle().' ('.$event_obj->getFirstAppointment()->appointmentToString().')');
260 }
261
262 $this->csv->addRow();
263
264 foreach($members as $user_id)
265 {
266 $name = ilObjUser::_lookupName($user_id);
267
268 $this->csv->addColumn($name['lastname']);
269 $this->csv->addColumn($name['firstname']);
270 $this->csv->addColumn(ilObjUser::_lookupLogin($user_id));
271
272 foreach($events as $event_obj)
273 {
274 $event_part = new ilEventParticipants((int) $event_obj->getId());
275
276 $this->csv->addColumn($event_part->hasParticipated($user_id) ?
277 $this->lng->txt('event_participated') :
278 $this->lng->txt('event_not_participated'));
279 }
280
281 $this->csv->addRow();
282 }
283 $date = new ilDate(time(),IL_CAL_UNIX);
284 ilUtil::deliverData($this->csv->getCSVString(),$date->get(IL_CAL_FKT_DATE,'Y-m-d')."_course_events.csv", "text/csv");
285 }
286}
287?>
$_GET["client_id"]
const IL_CAL_UNIX
const IL_CAL_FKT_DATE
Helper class to generate CSV files.
Class for single dates.
_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
Class ilTableGUI.
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.
static switchColor($a_num, $a_css1, $a_css2)
switches style sheets for each even $a_num (used for changing colors of different result rows)
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
global $ilCtrl
Definition: ilias.php:18
$cmd
Definition: sahs_server.php:35
global $ilUser
Definition: imgupload.php:15