ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 protected $has_collection; // bool
31 protected $has_multi; // bool
32
36 function __construct($a_parent_obj, $a_parent_cmd, $a_obj_id, $a_ref_id, $a_print_view = false)
37 {
38 global $ilCtrl, $ilUser, $tree, $rbacsystem;
39
40 $this->setId("troup");
41 $this->obj_id = $a_obj_id;
42 $this->ref_id = $a_ref_id;
43 $this->type = ilObject::_lookupType($a_obj_id);
44
45 $this->in_group = $tree->checkForParentType($this->ref_id, "grp");
46 if($this->in_group)
47 {
48 $this->in_group = ilObject::_lookupObjId($this->in_group);
49 }
50 else
51 {
52 $this->in_course = $tree->checkForParentType($this->ref_id, "crs");
53 if($this->in_course)
54 {
55 $this->in_course = ilObject::_lookupObjId($this->in_course);
56 }
57 }
58
59 parent::__construct($a_parent_obj, $a_parent_cmd);
60
61 $this->parseTitle($a_obj_id, "trac_participants");
62
63 if($a_print_view)
64 {
65 $this->setPrintMode(true);
66 }
67
68 if(!$this->getPrintMode())
69 {
70 // see ilObjCourseGUI::addMailToMemberButton()
71 include_once "Services/Mail/classes/class.ilMail.php";
72 $mail = new ilMail($ilUser->getId());
73 if($rbacsystem->checkAccess("internal_mail", $mail->getMailObjectReferenceId()))
74 {
75 $this->addMultiCommand("mailselectedusers", $this->lng->txt("send_mail"));
76 }
77 $this->lng->loadLanguageModule('user');
78 $this->addMultiCommand(
79 'addToClipboard',
80 $this->lng->txt('clipboard_add_btn')
81 );
82 $this->addColumn("", "", 1);
83 $this->has_multi = true;
84 }
85
86 $labels = $this->getSelectableColumns();
87 foreach ($this->getSelectedColumns() as $c)
88 {
89 $first = $c;
90
91 // list cannot be sorted by udf fields (separate query)
92 // because of pagination only core fields can be sorted
93 $sort_id = (substr($c, 0, 4) == "udf_") ? "" : $c;
94
95 $this->addColumn($labels[$c]["txt"], $sort_id);
96 }
97
98 if(!$this->getPrintMode())
99 {
100 $this->addColumn($this->lng->txt("actions"), "");
101 }
102 $this->setSelectAllCheckbox('uid');
103 $this->setExternalSorting(true);
104 $this->setExternalSegmentation(true);
105 $this->setEnableHeader(true);
106 $this->setFormAction($ilCtrl->getFormActionByClass(get_class($this)));
107 $this->setRowTemplate("tpl.object_users_props_row.html", "Services/Tracking");
108 $this->setEnableTitle(true);
109 $this->setShowTemplates(true);
110 $this->setExportFormats(array(self::EXPORT_CSV, self::EXPORT_EXCEL));
111
112 if($first)
113 {
114 $this->setDefaultOrderField($first);
115 $this->setDefaultOrderDirection("asc");
116 }
117
118 $this->initFilter();
119
120 $this->getItems();
121
122 // #13807
123 include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
124 $this->has_edit = ilLearningProgressAccess::checkPermission('edit_learning_progress', $this->ref_id);
125
126 /* currently not active, needs to be revised
127 include_once "Services/Object/classes/class.ilObjectLP.php";
128 include_once "Services/Tracking/classes/collection/class.ilLPCollection.php";
129 $objlp = ilObjectLP::getInstance($this->obj_id);
130 $this->has_collection = in_array($objlp->getCurrentMode(), ilLPCollection::getCollectionModes());
131 */
132 }
133
141 {
142 if($this->selectable_columns)
143 {
145 }
146
147 $cols = $this->getSelectableUserColumns($this->in_course, $this->in_group);
148 $this->user_fields = $cols[1];
149 $this->selectable_columns = $cols[0];
150
152 }
153
157 function getItems()
158 {
159 global $lng;
160
162
163 include_once("./Services/Tracking/classes/class.ilTrQuery.php");
164
165 $additional_fields = $this->getSelectedColumns();
166
167 // only if object is [part of] course/group
168 $check_agreement = false;
169 if($this->in_course)
170 {
171 // privacy (if course agreement is activated)
172 include_once "Services/PrivacySecurity/classes/class.ilPrivacySettings.php";
174 if($privacy->courseConfirmationRequired())
175 {
176 $check_agreement = $this->in_course;
177 }
178 }
179 else if($this->in_group)
180 {
181 // privacy (if group agreement is activated)
182 include_once "Services/PrivacySecurity/classes/class.ilPrivacySettings.php";
184 if($privacy->groupConfirmationRequired())
185 {
186 $check_agreement = $this->in_group;
187 }
188 }
189
191 $this->ref_id,
196 $this->getCurrentFilter(),
197 $additional_fields,
198 $check_agreement,
199 $this->user_fields
200 );
201
202 if (count($tr_data["set"]) == 0 && $this->getOffset() > 0)
203 {
204 $this->resetOffset();
206 $this->ref_id,
211 $this->getCurrentFilter(),
212 $additional_fields,
213 $check_agreement,
214 $this->user_fields
215 );
216 }
217
218 $this->setMaxCount($tr_data["cnt"]);
219 $this->setData($tr_data["set"]);
220 }
221
222
226 function initFilter()
227 {
228 global $lng;
229
230 foreach($this->getSelectableColumns() as $column => $meta)
231 {
232 // no udf!
233 switch($column)
234 {
235 case "firstname":
236 case "lastname":
237 case "mark":
238 case "u_comment":
239 case "institution":
240 case "department":
241 case "title":
242 case "street":
243 case "zipcode":
244 case "city":
245 case "country":
246 case "email":
247 case "matriculation":
248 case "login":
249 if($column != "mark" ||
250 ilObjectLP::supportsMark($this->type))
251 {
252 $item = $this->addFilterItemByMetaType($column, ilTable2GUI::FILTER_TEXT, true, $meta["txt"]);
253 $this->filter[$column] = $item->getValue();
254 }
255 break;
256
257 case "first_access":
258 case "last_access":
259 case "create_date":
260 case 'status_changed':
261 $item = $this->addFilterItemByMetaType($column, ilTable2GUI::FILTER_DATETIME_RANGE, true, $meta["txt"]);
262 $this->filter[$column] = $item->getDate();
263 break;
264
265 case "birthday":
266 $item = $this->addFilterItemByMetaType($column, ilTable2GUI::FILTER_DATE_RANGE, true, $meta["txt"]);
267 $this->filter[$column] = $item->getDate();
268 break;
269
270 case "read_count":
271 case "percentage":
272 $item = $this->addFilterItemByMetaType($column, ilTable2GUI::FILTER_NUMBER_RANGE, true, $meta["txt"]);
273 $this->filter[$column] = $item->getValue();
274 break;
275
276 case "gender":
277 $item = $this->addFilterItemByMetaType("gender", ilTable2GUI::FILTER_SELECT, true, $meta["txt"]);
278 $item->setOptions(array("" => $lng->txt("trac_all"), "m" => $lng->txt("gender_m"), "f" => $lng->txt("gender_f")));
279 $this->filter["gender"] = $item->getValue();
280 break;
281
282 case "sel_country":
283 $item = $this->addFilterItemByMetaType("sel_country", ilTable2GUI::FILTER_SELECT, true, $meta["txt"]);
284
285 $options = array();
286 include_once("./Services/Utilities/classes/class.ilCountry.php");
287 foreach (ilCountry::getCountryCodes() as $c)
288 {
289 $options[$c] = $lng->txt("meta_c_".$c);
290 }
291 asort($options);
292 $item->setOptions(array("" => $lng->txt("trac_all"))+$options);
293
294 $this->filter["sel_country"] = $item->getValue();
295 break;
296
297 case "status":
298 include_once "Services/Tracking/classes/class.ilLPStatus.php";
299 $item = $this->addFilterItemByMetaType("status", ilTable2GUI::FILTER_SELECT, true, $meta["txt"]);
300 $item->setOptions(array("" => $lng->txt("trac_all"),
305 $this->filter["status"] = $item->getValue();
306 if($this->filter["status"])
307 {
308 $this->filter["status"]--;
309 }
310 break;
311
312 case "language":
313 $item = $this->addFilterItemByMetaType("language", ilTable2GUI::FILTER_LANGUAGE, true);
314 $this->filter["language"] = $item->getValue();
315 break;
316
317 case "spent_seconds":
318 if(ilObjectLP::supportsSpentSeconds($this->type))
319 {
320 $item = $this->addFilterItemByMetaType("spent_seconds", ilTable2GUI::FILTER_DURATION_RANGE, true, $meta["txt"]);
321 $this->filter["spent_seconds"]["from"] = $item->getCombinationItem("from")->getValueInSeconds();
322 $this->filter["spent_seconds"]["to"] = $item->getCombinationItem("to")->getValueInSeconds();
323 }
324 break;
325 }
326 }
327 }
328
332 protected function fillRow($data)
333 {
334 global $ilCtrl, $lng, $objDefinition;
335
336 if($this->has_multi)
337 {
338 $this->tpl->setVariable("USER_ID", $data["usr_id"]);
339 }
340
341 foreach ($this->getSelectedColumns() as $c)
342 {
343 if(!(bool)$data["privacy_conflict"])
344 {
345 if($c == 'status' && $data[$c] != ilLPStatus::LP_STATUS_COMPLETED_NUM)
346 {
347 $timing = $this->showTimingsWarning($this->ref_id, $data["usr_id"]);
348 if($timing)
349 {
350 if($timing !== true)
351 {
352 $timing = ": ".ilDatePresentation::formatDate(new ilDate($timing, IL_CAL_UNIX));
353 }
354 else
355 {
356 $timing = "";
357 }
358 $this->tpl->setCurrentBlock('warning_img');
359 $this->tpl->setVariable('WARNING_IMG', ilUtil::getImagePath('time_warn.svg'));
360 $this->tpl->setVariable('WARNING_ALT', $this->lng->txt('trac_time_passed').$timing);
361 $this->tpl->parseCurrentBlock();
362 }
363 }
364
365 // #7694
366 if($c == 'login' && !$data["active"])
367 {
368 $this->tpl->setCurrentBlock('inactive_bl');
369 $this->tpl->setVariable('TXT_INACTIVE', $lng->txt("inactive"));
370 $this->tpl->parseCurrentBlock();
371 }
372
373 $val = $this->parseValue($c, $data[$c], $this->type);
374 }
375 else
376 {
377 if($c == 'login')
378 {
379 $this->tpl->setCurrentBlock('inactive_bl');
380 $this->tpl->setVariable('TXT_INACTIVE', $lng->txt("status_no_permission"));
381 $this->tpl->parseCurrentBlock();
382 }
383
384 $val = "&nbsp;";
385 }
386
387 $this->tpl->setCurrentBlock("user_field");
388 $this->tpl->setVariable("VAL_UF", $val);
389 $this->tpl->parseCurrentBlock();
390 }
391
392 $ilCtrl->setParameterByClass("illplistofobjectsgui", "user_id", $data["usr_id"]);
393
394 if(!$this->getPrintMode() && !(bool)$data["privacy_conflict"])
395 {
396 // details for containers and collections
397 if($this->has_collection ||
398 $objDefinition->isContainer($this->type))
399 {
400 $this->tpl->setCurrentBlock("item_command");
401 $this->tpl->setVariable("HREF_COMMAND", $ilCtrl->getLinkTargetByClass("illplistofobjectsgui", "userdetails"));
402 $this->tpl->setVariable("TXT_COMMAND", $lng->txt('details'));
403 $this->tpl->parseCurrentBlock();
404 }
405
406 if($this->has_edit)
407 {
408 $this->tpl->setCurrentBlock("item_command");
409 $this->tpl->setVariable("HREF_COMMAND", $ilCtrl->getLinkTargetByClass("illplistofobjectsgui", "edituser"));
410 $this->tpl->setVariable("TXT_COMMAND", $lng->txt('edit'));
411 $this->tpl->parseCurrentBlock();
412 }
413 }
414
415 $ilCtrl->setParameterByClass("illplistofobjectsgui", 'user_id', '');
416 }
417
418 protected function fillHeaderExcel(ilExcel $a_excel, &$a_row)
419 {
420 $labels = $this->getSelectableColumns();
421 $cnt = 0;
422 foreach ($this->getSelectedColumns() as $c)
423 {
424 $a_excel->setCell($a_row, $cnt++, $labels[$c]["txt"]);
425 }
426
427 $a_excel->setBold("A".$a_row.":".$a_excel->getColumnCoord($cnt-1).$a_row);
428 }
429
430 protected function fillRowExcel(ilExcel $a_excel, &$a_row, $a_set)
431 {
432 $cnt = 0;
433 foreach ($this->getSelectedColumns() as $c)
434 {
435 if($c != 'status')
436 {
437 $val = $this->parseValue($c, $a_set[$c], $this->type);
438 }
439 else
440 {
441 $val = ilLearningProgressBaseGUI::_getStatusText((int)$a_set[$c]);
442 }
443 $a_excel->setCell($a_row, $cnt++, $val);
444 }
445 }
446
447 protected function fillHeaderCSV($a_csv)
448 {
449 $labels = $this->getSelectableColumns();
450 foreach ($this->getSelectedColumns() as $c)
451 {
452 $a_csv->addColumn($labels[$c]["txt"]);
453 }
454
455 $a_csv->addRow();
456 }
457
458 protected function fillRowCSV($a_csv, $a_set)
459 {
460 foreach ($this->getSelectedColumns() as $c)
461 {
462 if($c != 'status')
463 {
464 $val = $this->parseValue($c, $a_set[$c], $this->type);
465 }
466 else
467 {
468 $val = ilLearningProgressBaseGUI::_getStatusText((int)$a_set[$c]);
469 }
470 $a_csv->addColumn($val);
471 }
472
473 $a_csv->addRow();
474 }
475}
476?>
$column
Definition: 39dropdown.php:62
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
static getCountryCodes()
Get country codes (DIN EN 3166-1)
Class for single dates.
setCell($a_row, $a_col, $a_value)
Set cell value.
setBold($a_coords)
Set cell(s) to bold.
getColumnCoord($a_col)
Get column "name" from number.
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)
static checkPermission($a_permission, $a_ref_id, $a_user_id=null)
wrapper for rbac access checks
static _getStatusText($a_status, $a_lng=null)
Get status alt text.
This class handles base functions for mail handling.
static supportsMark($a_obj_type)
static supportsSpentSeconds($a_obj_type)
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
static _getInstance()
Get instance of ilPrivacySettings.
getSelectedColumns()
Get selected columns.
setEnableHeader($a_enableheader)
Set Enable Header.
setExternalSorting($a_val)
Set external sorting.
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.
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.
addMultiCommand($a_cmd, $a_text)
Add Command button.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
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,...
fillHeaderExcel(ilExcel $a_excel, &$a_row)
Excel Version of Fill Header.
fillRowCSV($a_csv, $a_set)
CSV Version of Fill Row.
fillRowExcel(ilExcel $a_excel, &$a_row, $a_set)
Excel Version of Fill Row.
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.
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:17
if(!is_array($argv)) $options
$ilUser
Definition: imgupload.php:18