ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilUserLPTableGUI.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 
15 {
16  public function __construct($a_parent_obj, $a_parent_cmd, $a_ref_id)
17  {
18  global $DIC;
19 
20  $ilCtrl = $DIC['ilCtrl'];
21  $lng = $DIC['lng'];
22  $ilAccess = $DIC['ilAccess'];
23  $lng = $DIC['lng'];
24  $rbacsystem = $DIC['rbacsystem'];
25 
26  $this->ref_id = $a_ref_id;
27  $this->setId("admusrlp");
28 
29  parent::__construct($a_parent_obj, $a_parent_cmd);
30  // $this->setTitle($this->lng->txt("obj_usr"));
31 
32  $this->addColumn($this->lng->txt("login"), "login");
33  $this->addColumn($this->lng->txt("firstname"), "firstname");
34  $this->addColumn($this->lng->txt("lastname"), "lastname");
35  $this->addColumn($this->lng->txt("online_time"), "online_time");
36  $this->addColumn($this->lng->txt("last_login"), "last_login");
37  $this->setExternalSorting(true);
38  $this->setExternalSegmentation(true);
39 
40  $this->setFormAction($ilCtrl->getFormAction($this->parent_obj));
41 
42  $this->setRowTemplate("tpl.user_list_lp_row.html", "Services/User");
43 
44  $this->setDefaultOrderField("login");
45  $this->setDefaultOrderDirection("asc");
46 
47  $this->setExportFormats(array(self::EXPORT_EXCEL));
48 
49  $this->getItems();
50  }
51 
52  public function getItems()
53  {
54  $this->determineOffsetAndOrder();
55 
56  include_once("./Services/User/classes/class.ilUserQuery.php");
57  $usr_data = ilUserQuery::getUserListData(
62  null,
63  null,
64  null,
65  null,
66  null,
67  null,
68  null,
69  null,
70  array("online_time"),
71  null,
72  null
73  );
74 
75  if (count($usr_data["set"]) == 0 && $this->getOffset() > 0) {
76  $this->resetOffset();
77  $usr_data = ilUserQuery::getUserListData(
82  null,
83  null,
84  null,
85  null,
86  null,
87  null,
88  null,
89  null,
90  array("online_time"),
91  null,
92  null
93  );
94  }
95 
96  $this->setMaxCount($usr_data["cnt"]);
97  $this->setData($usr_data["set"]);
98 
99  include_once 'Services/Tracking/classes/class.ilObjUserTracking.php';
100  $this->lp_active = ilObjUserTracking::_enabledLearningProgress();
101  }
102 
103  protected function fillRow($user)
104  {
105  global $DIC;
106 
107  $ilCtrl = $DIC['ilCtrl'];
108 
109  if ($this->lp_active) {
110  $ilCtrl->setParameterByClass("illearningprogressgui", "ref_id", $this->ref_id);
111  $ilCtrl->setParameterByClass("illearningprogressgui", "obj_id", $user["usr_id"]);
112  $link = $ilCtrl->getLinkTargetByClass(array("ilobjusergui",'illearningprogressgui'), "");
113 
114  $this->tpl->setCurrentBlock("login_link");
115  $this->tpl->setVariable("HREF_LOGIN", $link);
116  $this->tpl->setVariable("VAL_LOGIN", $user["login"]);
117  $this->tpl->parseCurrentBlock();
118  } else {
119  $this->tpl->setCurrentBlock("login_plain");
120  $this->tpl->setVariable("VAL_LOGIN_PLAIN", $user["login"]);
121  $this->tpl->parseCurrentBlock();
122  }
123 
124  $this->tpl->setVariable("VAL_FIRSTNAME", $user["firstname"]);
125  $this->tpl->setVariable("VAL_LASTNAME", $user["lastname"]);
126  $this->tpl->setVariable(
127  "VAL_ONLINE_TIME",
128  self::secondsToShortString($user["online_time"])
129  );
130  $this->tpl->setVariable(
131  "VAL_LAST_LOGIN",
133  );
134  }
135 
136  protected function fillRowExcel(ilExcel $a_excel, &$a_row, $a_set)
137  {
138  $a_excel->setCell($a_row, 0, $a_set["login"]);
139  $a_excel->setCell($a_row, 1, $a_set["firstname"]);
140  $a_excel->setCell($a_row, 2, $a_set["lastname"]);
141  $a_excel->setCell(
142  $a_row,
143  3,
144  self::secondsToShortString($a_set["online_time"])
145  );
146  $a_excel->setCell($a_row, 4, new ilDateTime($a_set["last_login"], IL_CAL_DATETIME));
147  }
148 
156  protected static function secondsToShortString($seconds)
157  {
158  global $DIC;
159 
160  $lng = $DIC['lng'];
161 
162  $seconds = $seconds ? $seconds : 0;
163 
164  global $DIC;
165 
166  $lng = $DIC['lng'];
167 
168  $days = floor($seconds / 86400);
169  $rest = $seconds % 86400;
170 
171  $hours = floor($rest / 3600);
172  $rest = $rest % 3600;
173 
174  $minutes = floor($rest / 60);
175  $rest = $rest % 60;
176 
177  return sprintf("%02d:%02d:%02d:%02d", $days, $hours, $minutes, $rest);
178  }
179 }
setExternalSorting($a_val)
Set external sorting.
$rest
Definition: goto.php:46
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
setExportFormats(array $formats)
Set available export formats.
const IL_CAL_DATETIME
global $DIC
Definition: saml.php:7
setExternalSegmentation($a_val)
Set external segmentation.
resetOffset($a_in_determination=false)
Reset offset.
Learning progress account list for user administration.
fillRowExcel(ilExcel $a_excel, &$a_row, $a_set)
getOrderDirection()
Get order direction.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
setId($a_val)
Set id.
global $ilCtrl
Definition: ilias.php:18
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
static _enabledLearningProgress()
check wether learing progress is enabled or not
Class ilTable2GUI.
getOffset()
Get offset.
Date and time handling
setCell($a_row, $a_col, $a_value, $a_datatype=null)
Set cell value.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
$user
Definition: migrateto20.php:57
static secondsToShortString($seconds)
converts seconds to string: Long: 7 days 4 hour(s) ...
setRowTemplate($a_template, $a_template_dir="")
Set row template.
determineOffsetAndOrder($a_omit_offset=false)
Determine offset and order.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
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.
getLimit()
Get limit.
setMaxCount($a_max_count)
set max.
static getUserListData( $a_order_field, $a_order_dir, $a_offset, $a_limit, $a_string_filter="", $a_activation_filter="", $a_last_login_filter=null, $a_limited_access_filter=false, $a_no_courses_filter=false, $a_course_group_filter=0, $a_role_filter=0, $a_user_folder_filter=null, $a_additional_fields='', $a_user_filter=null, $a_first_letter="", $a_authentication_filter=null)
Get data for user administration list.
__construct($a_parent_obj, $a_parent_cmd, $a_ref_id)