ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilTrObjectUsersPropsTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/Tracking/classes/class.ilLPTableBaseGUI.php");
5
24{
25 protected $user_fields; // array
26 protected $filter; // array
27 protected $in_course; // int
28 protected $in_group; // int
29 protected $has_edit; // bool
30
34 function __construct($a_parent_obj, $a_parent_cmd, $a_obj_id, $a_ref_id, $a_print_view = false)
35 {
36 global $ilCtrl, $lng, $tree, $rbacsystem;
37
38 $this->setId("troup");
39 $this->obj_id = $a_obj_id;
40 $this->ref_id = $a_ref_id;
41 $this->type = ilObject::_lookupType($a_obj_id);
42
43 $this->in_group = $tree->checkForParentType($this->ref_id, "grp");
44 if($this->in_group)
45 {
46 $this->in_group = ilObject::_lookupObjId($this->in_group);
47 }
48 else
49 {
50 $this->in_course = $tree->checkForParentType($this->ref_id, "crs");
51 if($this->in_course)
52 {
53 $this->in_course = ilObject::_lookupObjId($this->in_course);
54 }
55 }
56
57 parent::__construct($a_parent_obj, $a_parent_cmd);
58
59 $this->parseTitle($a_obj_id, "trac_participants");
60
61 if($a_print_view)
62 {
63 $this->setPrintMode(true);
64 }
65
66 $labels = $this->getSelectableColumns();
67 foreach ($this->getSelectedColumns() as $c)
68 {
69 $first = $c;
70
71 // list cannot be sorted by udf fields (separate query)
72 // because of pagination only core fields can be sorted
73 $sort_id = (substr($c, 0, 4) == "udf_") ? "" : $c;
74
75 $this->addColumn($labels[$c]["txt"], $sort_id);
76 }
77
78 if(!$this->getPrintMode())
79 {
80 $this->addColumn($this->lng->txt("actions"), "");
81 }
82
83 $this->setExternalSorting(true);
84 $this->setExternalSegmentation(true);
85 $this->setEnableHeader(true);
86 $this->setFormAction($ilCtrl->getFormActionByClass(get_class($this)));
87 $this->setRowTemplate("tpl.object_users_props_row.html", "Services/Tracking");
88 $this->setEnableTitle(true);
89 $this->setShowTemplates(true);
90 $this->setExportFormats(array(self::EXPORT_CSV, self::EXPORT_EXCEL));
91
92 if($first)
93 {
94 $this->setDefaultOrderField($first);
95 $this->setDefaultOrderDirection("asc");
96 }
97
98 $this->initFilter();
99
100 $this->getItems();
101
102 // #13807
103 $this->has_edit = $rbacsystem->checkAccess('edit_learning_progress',$this->ref_id);
104 }
105
113 {
114 if($this->selectable_columns)
115 {
117 }
118
119 $cols = $this->getSelectableUserColumns($this->in_course, $this->in_group);
120 $this->user_fields = $cols[1];
121 $this->selectable_columns = $cols[0];
122
124 }
125
129 function getItems()
130 {
131 global $lng;
132
134
135 include_once("./Services/Tracking/classes/class.ilTrQuery.php");
136
137 $additional_fields = $this->getSelectedColumns();
138
139 // only if object is [part of] course/group
140 $check_agreement = false;
141 if($this->in_course)
142 {
143 // privacy (if course agreement is activated)
144 include_once "Services/PrivacySecurity/classes/class.ilPrivacySettings.php";
146 if($privacy->courseConfirmationRequired())
147 {
148 $check_agreement = $this->in_course;
149 }
150 }
151 else if($this->in_group)
152 {
153 // privacy (if group agreement is activated)
154 include_once "Services/PrivacySecurity/classes/class.ilPrivacySettings.php";
156 if($privacy->groupConfirmationRequired())
157 {
158 $check_agreement = $this->in_group;
159 }
160 }
161
163 $this->ref_id,
168 $this->getCurrentFilter(),
169 $additional_fields,
170 $check_agreement,
171 $this->user_fields
172 );
173
174 if (count($tr_data["set"]) == 0 && $this->getOffset() > 0)
175 {
176 $this->resetOffset();
178 $this->ref_id,
183 $this->getCurrentFilter(),
184 $additional_fields,
185 $check_agreement,
186 $this->user_fields
187 );
188 }
189
190 $this->setMaxCount($tr_data["cnt"]);
191 $this->setData($tr_data["set"]);
192 }
193
194
198 function initFilter()
199 {
200 global $lng;
201
202 foreach($this->getSelectableColumns() as $column => $meta)
203 {
204 // no udf!
205 switch($column)
206 {
207 case "firstname":
208 case "lastname":
209 case "mark":
210 case "u_comment":
211 case "institution":
212 case "department":
213 case "title":
214 case "street":
215 case "zipcode":
216 case "city":
217 case "country":
218 case "email":
219 case "matriculation":
220 case "login":
221 $item = $this->addFilterItemByMetaType($column, ilTable2GUI::FILTER_TEXT, true, $meta["txt"]);
222 $this->filter[$column] = $item->getValue();
223 break;
224
225 case "first_access":
226 case "last_access":
227 case "create_date":
228 case 'status_changed':
229 $item = $this->addFilterItemByMetaType($column, ilTable2GUI::FILTER_DATETIME_RANGE, true, $meta["txt"]);
230 $this->filter[$column] = $item->getDate();
231 break;
232
233 case "birthday":
234 $item = $this->addFilterItemByMetaType($column, ilTable2GUI::FILTER_DATE_RANGE, true, $meta["txt"]);
235 $this->filter[$column] = $item->getDate();
236 break;
237
238 case "read_count":
239 case "percentage":
240 $item = $this->addFilterItemByMetaType($column, ilTable2GUI::FILTER_NUMBER_RANGE, true, $meta["txt"]);
241 $this->filter[$column] = $item->getValue();
242 break;
243
244 case "gender":
245 $item = $this->addFilterItemByMetaType("gender", ilTable2GUI::FILTER_SELECT, true, $meta["txt"]);
246 $item->setOptions(array("" => $lng->txt("trac_all"), "m" => $lng->txt("gender_m"), "f" => $lng->txt("gender_f")));
247 $this->filter["gender"] = $item->getValue();
248 break;
249
250 case "sel_country":
251 $item = $this->addFilterItemByMetaType("sel_country", ilTable2GUI::FILTER_SELECT, true, $meta["txt"]);
252
253 $options = array();
254 include_once("./Services/Utilities/classes/class.ilCountry.php");
255 foreach (ilCountry::getCountryCodes() as $c)
256 {
257 $options[$c] = $lng->txt("meta_c_".$c);
258 }
259 asort($options);
260 $item->setOptions(array("" => $lng->txt("trac_all"))+$options);
261
262 $this->filter["sel_country"] = $item->getValue();
263 break;
264
265 case "status":
266 include_once "Services/Tracking/classes/class.ilLPStatus.php";
267 $item = $this->addFilterItemByMetaType("status", ilTable2GUI::FILTER_SELECT, true, $meta["txt"]);
268 $item->setOptions(array("" => $lng->txt("trac_all"),
273 $this->filter["status"] = $item->getValue();
274 if($this->filter["status"])
275 {
276 $this->filter["status"]--;
277 }
278 break;
279
280 case "language":
281 $item = $this->addFilterItemByMetaType("language", ilTable2GUI::FILTER_LANGUAGE, true);
282 $this->filter["language"] = $item->getValue();
283 break;
284
285 case "spent_seconds":
286 $item = $this->addFilterItemByMetaType("spent_seconds", ilTable2GUI::FILTER_DURATION_RANGE, true, $meta["txt"]);
287 $this->filter["spent_seconds"]["from"] = $item->getCombinationItem("from")->getValueInSeconds();
288 $this->filter["spent_seconds"]["to"] = $item->getCombinationItem("to")->getValueInSeconds();
289 break;
290 }
291 }
292 }
293
297 protected function fillRow($data)
298 {
299 global $ilCtrl, $lng;
300
301 foreach ($this->getSelectedColumns() as $c)
302 {
303 if(!(bool)$data["privacy_conflict"])
304 {
305 if($c == 'status' && $data[$c] != ilLPStatus::LP_STATUS_COMPLETED_NUM)
306 {
307 $timing = $this->showTimingsWarning($this->ref_id, $data["usr_id"]);
308 if($timing)
309 {
310 if($timing !== true)
311 {
312 $timing = ": ".ilDatePresentation::formatDate(new ilDate($timing, IL_CAL_UNIX));
313 }
314 else
315 {
316 $timing = "";
317 }
318 $this->tpl->setCurrentBlock('warning_img');
319 $this->tpl->setVariable('WARNING_IMG', ilUtil::getImagePath('time_warn.svg'));
320 $this->tpl->setVariable('WARNING_ALT', $this->lng->txt('trac_time_passed').$timing);
321 $this->tpl->parseCurrentBlock();
322 }
323 }
324
325 // #7694
326 if($c == 'login' && !$data["active"])
327 {
328 $this->tpl->setCurrentBlock('inactive_bl');
329 $this->tpl->setVariable('TXT_INACTIVE', $lng->txt("inactive"));
330 $this->tpl->parseCurrentBlock();
331 }
332
333 $val = $this->parseValue($c, $data[$c], "user");
334 }
335 else
336 {
337 if($c == 'login')
338 {
339 $this->tpl->setCurrentBlock('inactive_bl');
340 $this->tpl->setVariable('TXT_INACTIVE', $lng->txt("status_no_permission"));
341 $this->tpl->parseCurrentBlock();
342 }
343
344 $val = "&nbsp;";
345 }
346
347 $this->tpl->setCurrentBlock("user_field");
348 $this->tpl->setVariable("VAL_UF", $val);
349 $this->tpl->parseCurrentBlock();
350 }
351
352 $ilCtrl->setParameterByClass("illplistofobjectsgui", "user_id", $data["usr_id"]);
353
354 if(!$this->getPrintMode() && !(bool)$data["privacy_conflict"])
355 {
356 if(in_array($this->type, array("crs", "grp", "cat", "fold")))
357 {
358 $this->tpl->setCurrentBlock("item_command");
359 $this->tpl->setVariable("HREF_COMMAND", $ilCtrl->getLinkTargetByClass("illplistofobjectsgui", "userdetails"));
360 $this->tpl->setVariable("TXT_COMMAND", $lng->txt('details'));
361 $this->tpl->parseCurrentBlock();
362 }
363
364 if($this->has_edit)
365 {
366 $this->tpl->setCurrentBlock("item_command");
367 $this->tpl->setVariable("HREF_COMMAND", $ilCtrl->getLinkTargetByClass("illplistofobjectsgui", "edituser"));
368 $this->tpl->setVariable("TXT_COMMAND", $lng->txt('edit'));
369 $this->tpl->parseCurrentBlock();
370 }
371 }
372
373 $ilCtrl->setParameterByClass("illplistofobjectsgui", 'user_id', '');
374 }
375
376 protected function fillHeaderExcel($worksheet, &$a_row)
377 {
378 $labels = $this->getSelectableColumns();
379 $cnt = 0;
380 foreach ($this->getSelectedColumns() as $c)
381 {
382 $worksheet->write($a_row, $cnt, $labels[$c]["txt"]);
383 $cnt++;
384 }
385 }
386
387 protected function fillRowExcel($worksheet, &$a_row, $a_set)
388 {
389 $cnt = 0;
390 foreach ($this->getSelectedColumns() as $c)
391 {
392 if($c != 'status')
393 {
394 $val = $this->parseValue($c, $a_set[$c], "user");
395 }
396 else
397 {
398 $val = ilLearningProgressBaseGUI::_getStatusText((int)$a_set[$c]);
399 }
400 $worksheet->write($a_row, $cnt, $val);
401 $cnt++;
402 }
403 }
404
405 protected function fillHeaderCSV($a_csv)
406 {
407 $labels = $this->getSelectableColumns();
408 foreach ($this->getSelectedColumns() as $c)
409 {
410 $a_csv->addColumn($labels[$c]["txt"]);
411 }
412
413 $a_csv->addRow();
414 }
415
416 protected function fillRowCSV($a_csv, $a_set)
417 {
418 foreach ($this->getSelectedColumns() as $c)
419 {
420 if($c != 'status')
421 {
422 $val = $this->parseValue($c, $a_set[$c], "user");
423 }
424 else
425 {
426 $val = ilLearningProgressBaseGUI::_getStatusText((int)$a_set[$c]);
427 }
428 $a_csv->addColumn($val);
429 }
430
431 $a_csv->addRow();
432 }
433}
434?>
const IL_CAL_UNIX
static getCountryCodes()
Get country codes (DIN EN 3166-1)
Class for single dates.
const LP_STATUS_COMPLETED_NUM
const LP_STATUS_COMPLETED
const LP_STATUS_FAILED
const LP_STATUS_IN_PROGRESS_NUM
const LP_STATUS_NOT_ATTEMPTED_NUM
const LP_STATUS_FAILED_NUM
const LP_STATUS_NOT_ATTEMPTED
const LP_STATUS_IN_PROGRESS
TableGUI class for learning progress.
parseValue($id, $value, $type)
getCurrentFilter($as_query=false)
showTimingsWarning($a_ref_id, $a_user_id)
getSelectableUserColumns($a_in_course=false, $a_in_group=false)
parseTitle($a_obj_id, $action, $a_user_id=false)
_getStatusText($a_status)
Get status alt text.
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
static _getInstance()
Get instance of ilPrivacySettings.
getSelectedColumns()
Get selected columns.
addColumn($a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="")
Add a column to the header.
setEnableHeader($a_enableheader)
Set Enable Header.
setExternalSorting($a_val)
Set external sorting.
setExportFormats(array $formats)
Set available export formats.
setPrintMode($a_value=false)
Toogle print mode.
determineOffsetAndOrder($a_omit_offset=false)
Determine offset and order.
setData($a_data)
set table data @access public
setEnableTitle($a_enabletitle)
Set Enable Title.
getLimit()
Get limit.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
resetOffset($a_in_determination=false)
Reset offset.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
getPrintMode()
Get print mode.
getOffset()
Get offset.
const FILTER_DURATION_RANGE
setExternalSegmentation($a_val)
Set external segmentation.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
addFilterItemByMetaType($id, $type=self::FILTER_TEXT, $a_optional=false, $caption=NULL)
Add filter by standard type.
const FILTER_NUMBER_RANGE
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setShowTemplates($a_value)
Toggle templates.
const FILTER_DATETIME_RANGE
getOrderDirection()
Get order direction.
setMaxCount($a_max_count)
set max.
Learning progress table: One object, rows: users, columns: properties Example: A course,...
fillRowCSV($a_csv, $a_set)
CSV Version of Fill Row.
fillHeaderExcel($worksheet, &$a_row)
Excel Version of Fill Header.
fillHeaderCSV($a_csv)
CSV Version of Fill Header.
__construct($a_parent_obj, $a_parent_cmd, $a_obj_id, $a_ref_id, $a_print_view=false)
Constructor.
fillRowExcel($worksheet, &$a_row, $a_set)
Excel Version of Fill Row.
static getUserDataForObject($a_ref_id, $a_order_field="", $a_order_dir="", $a_offset=0, $a_limit=9999, array $a_filters=NULL, array $a_additional_fields=NULL, $check_agreement=false, $privacy_fields=NULL)
Get all user-based tracking data for object.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
if(!is_array($argv)) $options