ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilLPObjectStatisticsGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once "Services/Tracking/classes/class.ilLearningProgressBaseGUI.php";
6 
20 {
21  function ilLPObjectStatisticsGUI($a_mode,$a_ref_id = 0)
22  {
23  parent::ilLearningProgressBaseGUI($a_mode,$a_ref_id);
24 
25  if(!$this->ref_id)
26  {
27  $this->ref_id = (int)$_REQUEST["ref_id"];
28  }
29  }
30 
31  protected function setTabs()
32  {
33  global $ilAccess;
34 
35  $this->tabs_gui->addSubTab('trac_object_stat_access',
36  $this->lng->txt('trac_object_stat_access'),
37  $this->ctrl->getLinkTarget($this, 'accessFilter'));
38  $this->tabs_gui->addSubTab('trac_object_stat_daily',
39  $this->lng->txt('trac_object_stat_daily'),
40  $this->ctrl->getLinkTarget($this, 'dailyFilter'));
41  $this->tabs_gui->addSubTab('trac_object_stat_lp',
42  $this->lng->txt('trac_object_stat_lp'),
43  $this->ctrl->getLinkTarget($this, 'learningProgressFilter'));
44  $this->tabs_gui->addSubTab('trac_object_stat_types',
45  $this->lng->txt('trac_object_stat_types'),
46  $this->ctrl->getLinkTarget($this, 'typesFilter'));
47 
48  if($ilAccess->checkAccess("write", "", $this->ref_id))
49  {
50  $this->tabs_gui->addSubTab('trac_object_stat_admin',
51  $this->lng->txt('trac_object_stat_admin'),
52  $this->ctrl->getLinkTarget($this, 'admin'));
53  }
54  }
55 
59  function executeCommand()
60  {
61  $this->ctrl->setReturn($this, "");
62 
63  $this->setTabs();
64 
65  switch($this->ctrl->getNextClass())
66  {
67  default:
68  $cmd = $this->__getDefaultCommand();
69  $this->$cmd();
70  }
71 
72  return true;
73  }
74 
75  function applyAccessFilter()
76  {
77  include_once("./Services/Tracking/classes/object_statistics/class.ilLPObjectStatisticsTableGUI.php");
78  $lp_table = new ilLPObjectStatisticsTableGUI($this, "access", null, false);
79  $lp_table->resetOffset();
80  $lp_table->writeFilterToSession();
81  $this->access();
82  }
83 
84  function resetAccessFilter()
85  {
86  include_once("./Services/Tracking/classes/object_statistics/class.ilLPObjectStatisticsTableGUI.php");
87  $lp_table = new ilLPObjectStatisticsTableGUI($this, "access", null, false);
88  $lp_table->resetOffset();
89  $lp_table->resetFilter();
90  $this->access();
91  }
92 
93  function accessFilter()
94  {
95  $this->access(false);
96  }
97 
98  function access($a_load_data = true)
99  {
100  global $tpl;
101 
102  $this->tabs_gui->activateSubTab('trac_object_stat_access');
103 
104  $this->showAggregationInfo();
105 
106  include_once("./Services/Tracking/classes/object_statistics/class.ilLPObjectStatisticsTableGUI.php");
107  $lp_table = new ilLPObjectStatisticsTableGUI($this, "access", null, $a_load_data);
108 
109  if(!$a_load_data)
110  {
111  $lp_table->disable("content");
112  $lp_table->disable("header");
113  }
114 
115  $tpl->setContent($lp_table->getHTML());
116  }
117 
118  function showAccessGraph()
119  {
120  global $lng, $tpl;
121 
122  if(!$_POST["item_id"])
123  {
124  ilUtil::sendFailure($lng->txt("no_checkbox"));
125  return $this->access();
126  }
127 
128  $this->tabs_gui->activateSubTab('trac_object_stat_access');
129 
130  include_once("./Services/Tracking/classes/object_statistics/class.ilLPObjectStatisticsTableGUI.php");
131  $lp_table = new ilLPObjectStatisticsTableGUI($this, "access", $_POST["item_id"]);
132 
133  $tpl->setContent($lp_table->getGraph($_POST["item_id"]).$lp_table->getHTML());
134  }
135 
136  function applyTypesFilter()
137  {
138  include_once("./Services/Tracking/classes/object_statistics/class.ilLPObjectStatisticsTypesTableGUI.php");
139  $lp_table = new ilLPObjectStatisticsTypesTableGUI($this, "types", null, false);
140  $lp_table->resetOffset();
141  $lp_table->writeFilterToSession();
142  $this->types();
143  }
144 
145  function resetTypesFilter()
146  {
147  include_once("./Services/Tracking/classes/object_statistics/class.ilLPObjectStatisticsTypesTableGUI.php");
148  $lp_table = new ilLPObjectStatisticsTypesTableGUI($this, "types", null, false);
149  $lp_table->resetOffset();
150  $lp_table->resetFilter();
151  $this->types();
152  }
153 
154  function typesFilter()
155  {
156  $this->types(false);
157  }
158 
159  function types($a_load_data = true)
160  {
161  global $tpl;
162 
163  $this->tabs_gui->activateSubTab('trac_object_stat_types');
164 
165  include_once("./Services/Tracking/classes/object_statistics/class.ilLPObjectStatisticsTypesTableGUI.php");
166  $lp_table = new ilLPObjectStatisticsTypesTableGUI($this, "types", null, $a_load_data);
167 
168  if(!$a_load_data)
169  {
170  $lp_table->disable("content");
171  $lp_table->disable("header");
172  }
173 
174  $tpl->setContent($lp_table->getHTML());
175  }
176 
177  function showTypesGraph()
178  {
179  global $lng, $tpl;
180 
181  if(!$_POST["item_id"])
182  {
183  ilUtil::sendFailure($lng->txt("no_checkbox"));
184  return $this->types();
185  }
186 
187  $this->tabs_gui->activateSubTab('trac_object_stat_types');
188 
189  include_once("./Services/Tracking/classes/object_statistics/class.ilLPObjectStatisticsTypesTableGUI.php");
190  $lp_table = new ilLPObjectStatisticsTypesTableGUI($this, "types", $_POST["item_id"]);
191 
192  $tpl->setContent($lp_table->getGraph($_POST["item_id"]).$lp_table->getHTML());
193  }
194 
195  function applyDailyFilter()
196  {
197  include_once("./Services/Tracking/classes/object_statistics/class.ilLPObjectStatisticsDailyTableGUI.php");
198  $lp_table = new ilLPObjectStatisticsDailyTableGUI($this, "daily", null, false);
199  $lp_table->resetOffset();
200  $lp_table->writeFilterToSession();
201  $this->daily();
202  }
203 
204  function resetDailyFilter()
205  {
206  include_once("./Services/Tracking/classes/object_statistics/class.ilLPObjectStatisticsDailyTableGUI.php");
207  $lp_table = new ilLPObjectStatisticsDailyTableGUI($this, "daily", null, false);
208  $lp_table->resetOffset();
209  $lp_table->resetFilter();
210  $this->daily();
211  }
212 
213  function dailyFilter()
214  {
215  $this->daily(false);
216  }
217 
218  function daily($a_load_data = true)
219  {
220  global $tpl;
221 
222  $this->tabs_gui->activateSubTab('trac_object_stat_daily');
223 
224  $this->showAggregationInfo();
225 
226  include_once("./Services/Tracking/classes/object_statistics/class.ilLPObjectStatisticsDailyTableGUI.php");
227  $lp_table = new ilLPObjectStatisticsDailyTableGUI($this, "daily", null, $a_load_data);
228 
229  if(!$a_load_data)
230  {
231  $lp_table->disable("content");
232  $lp_table->disable("header");
233  }
234 
235  $tpl->setContent($lp_table->getHTML());
236  }
237 
238  function showDailyGraph()
239  {
240  global $lng, $tpl;
241 
242  if(!$_POST["item_id"])
243  {
244  ilUtil::sendFailure($lng->txt("no_checkbox"));
245  return $this->daily();
246  }
247 
248  $this->tabs_gui->activateSubTab('trac_object_stat_daily');
249 
250  include_once("./Services/Tracking/classes/object_statistics/class.ilLPObjectStatisticsDailyTableGUI.php");
251  $lp_table = new ilLPObjectStatisticsDailyTableGUI($this, "daily", $_POST["item_id"]);
252 
253  $tpl->setContent($lp_table->getGraph($_POST["item_id"]).$lp_table->getHTML());
254  }
255 
256  function admin()
257  {
258  global $tpl, $ilToolbar, $lng, $ilCtrl, $ilAccess;
259 
260  $this->tabs_gui->activateSubTab('trac_object_stat_admin');
261 
262  $this->showAggregationInfo(false);
263 
264  $ilToolbar->addButton($lng->txt("trac_sync_obj_stats"),
265  $ilCtrl->getLinkTarget($this, "adminSync"));
266 
267  if($ilAccess->checkAccess("delete", "", $this->ref_id))
268  {
269  include_once("./Services/Tracking/classes/object_statistics/class.ilLPObjectStatisticsAdminTableGUI.php");
270  $lp_table = new ilLPObjectStatisticsAdminTableGUI($this, "admin");
271 
272  $tpl->setContent($lp_table->getHTML());
273  }
274  }
275 
276  function adminSync()
277  {
278  global $ilCtrl, $lng;
279 
280  include_once "Services/Tracking/classes/class.ilChangeEvent.php";
282 
283  ilUtil::sendSuccess($lng->txt("trac_sync_obj_stats_success"), true);
284  $ilCtrl->redirect($this, "admin");
285  }
286 
287  function confirmDeleteData()
288  {
289  global $lng, $tpl, $ilTabs, $ilCtrl;
290 
291  if(!$_POST["item_id"])
292  {
293  ilUtil::sendFailure($lng->txt("no_checkbox"));
294  return $this->admin();
295  }
296 
297  $ilTabs->clearTargets();
298  $ilTabs->setBackTarget($lng->txt("back"),
299  $ilCtrl->getLinkTarget($this, "admin"));
300 
301  // display confirmation message
302  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
303  $cgui = new ilConfirmationGUI();
304  $cgui->setFormAction($ilCtrl->getFormAction($this));
305  $cgui->setHeaderText($lng->txt("trac_sure_delete_data"));
306  $cgui->setCancel($lng->txt("cancel"), "admin");
307  $cgui->setConfirm($lng->txt("delete"), "deleteData");
308 
309  // list objects that should be deleted
310  foreach ($_POST["item_id"] as $i)
311  {
312  $caption = $lng->txt("month_".str_pad(substr($i, 5), 2, "0", STR_PAD_LEFT)."_long").
313  " ".substr($i, 0, 4);
314 
315  $cgui->addItem("item_id[]", $i, $caption);
316  }
317 
318  $tpl->setContent($cgui->getHTML());
319  }
320 
321  function deleteData()
322  {
323  global $lng;
324 
325  if(!$_POST["item_id"])
326  {
327  ilUtil::sendFailure($lng->txt("no_checkbox"));
328  return $this->admin();
329  }
330 
331  include_once "Services/Tracking/classes/class.ilTrQuery.php";
333  ilUtil::sendSuccess($lng->txt("trac_data_deleted"));
334  $this->admin();
335  }
336 
338  {
339  include_once("./Services/Tracking/classes/object_statistics/class.ilLPObjectStatisticsLPTableGUI.php");
340  $lp_table = new ilLPObjectStatisticsLPTableGUI($this, "learningProgress", null, false);
341  $lp_table->resetOffset();
342  $lp_table->writeFilterToSession();
343  $this->learningProgress();
344  }
345 
347  {
348  include_once("./Services/Tracking/classes/object_statistics/class.ilLPObjectStatisticsLPTableGUI.php");
349  $lp_table = new ilLPObjectStatisticsLPTableGUI($this, "learningProgress", null, false);
350  $lp_table->resetOffset();
351  $lp_table->resetFilter();
352  $this->learningProgress();
353  }
354 
356  {
357  $this->learningProgress(false);
358  }
359 
360  function learningProgress($a_load_data = true)
361  {
362  global $tpl;
363 
364  $this->tabs_gui->activateSubTab('trac_object_stat_lp');
365 
366  include_once("./Services/Tracking/classes/object_statistics/class.ilLPObjectStatisticsLPTableGUI.php");
367  $lp_table = new ilLPObjectStatisticsLPTableGUI($this, "learningProgress", null, $a_load_data);
368 
369  if(!$a_load_data)
370  {
371  $lp_table->disable("content");
372  $lp_table->disable("header");
373  }
374 
375  $tpl->setContent($lp_table->getHTML());
376  }
377 
379  {
380  global $lng, $tpl;
381 
382  if(!$_POST["item_id"])
383  {
384  ilUtil::sendFailure($lng->txt("no_checkbox"));
385  return $this->learningProgress();
386  }
387 
388  $this->tabs_gui->activateSubTab('trac_object_stat_lp');
389 
390  include_once("./Services/Tracking/classes/object_statistics/class.ilLPObjectStatisticsLPTableGUI.php");
391  $lp_table = new ilLPObjectStatisticsLPTableGUI($this, "learningProgress", $_POST["item_id"], true, true);
392 
393  $tpl->setContent($lp_table->getGraph($_POST["item_id"]).$lp_table->getHTML());
394  }
395 
397  {
398  include_once("./Services/Tracking/classes/object_statistics/class.ilLPObjectStatisticsLPTableGUI.php");
399  $lp_table = new ilLPObjectStatisticsLPTableGUI($this, "showLearningProgressDetails", array($_GET["item_id"]), true, false, true);
400 
401  $a_tpl = new ilTemplate("tpl.lp_object_statistics_lp_details.html", true, true, "Services/Tracking");
402  $a_tpl->setVariable("CONTENT", $lp_table->getHTML());
403  $a_tpl->setVariable('CLOSE_IMG_SRC', ilUtil::getImagePath('icon_close2_s.png'));
404  $a_tpl->setVariable('CLOSE_IMG_TXT', $this->lng->txt('close'));
405  echo $a_tpl->get();
406  exit();
407  }
408 
409  protected function showAggregationInfo($a_show_link = true)
410  {
411  global $ilAccess, $lng, $ilCtrl;
412 
413  include_once "Services/Tracking/classes/class.ilTrQuery.php";
415  $info_date = ilDatePresentation::formatDate(new ilDateTime($info["tstamp"], IL_CAL_UNIX));
416 
417  $link = "";
418  if($a_show_link && $ilAccess->checkAccess("write", "", $this->ref_id))
419  {
420  $link = " <a href=\"".$ilCtrl->getLinkTarget($this, "admin")."\">&raquo;".
421  $lng->txt("trac_log_info_link")."</a>";
422  }
423 
424  ilUtil::sendInfo(sprintf($lng->txt("trac_log_info"), $info_date, $info["counter"]).$link);
425 
426  }
427 }
428 
429 ?>