ILIAS  Release_5_0_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  $this->showCronJobInfo();
166 
167  include_once("./Services/Tracking/classes/object_statistics/class.ilLPObjectStatisticsTypesTableGUI.php");
168  $lp_table = new ilLPObjectStatisticsTypesTableGUI($this, "types", null, $a_load_data);
169 
170  if(!$a_load_data)
171  {
172  $lp_table->disable("content");
173  $lp_table->disable("header");
174  }
175 
176  $tpl->setContent($lp_table->getHTML());
177  }
178 
179  function showTypesGraph()
180  {
181  global $lng, $tpl;
182 
183  if(!$_POST["item_id"])
184  {
185  ilUtil::sendFailure($lng->txt("no_checkbox"));
186  return $this->types();
187  }
188 
189  $this->tabs_gui->activateSubTab('trac_object_stat_types');
190 
191  include_once("./Services/Tracking/classes/object_statistics/class.ilLPObjectStatisticsTypesTableGUI.php");
192  $lp_table = new ilLPObjectStatisticsTypesTableGUI($this, "types", $_POST["item_id"]);
193 
194  $tpl->setContent($lp_table->getGraph($_POST["item_id"]).$lp_table->getHTML());
195  }
196 
197  function applyDailyFilter()
198  {
199  include_once("./Services/Tracking/classes/object_statistics/class.ilLPObjectStatisticsDailyTableGUI.php");
200  $lp_table = new ilLPObjectStatisticsDailyTableGUI($this, "daily", null, false);
201  $lp_table->resetOffset();
202  $lp_table->writeFilterToSession();
203  $this->daily();
204  }
205 
206  function resetDailyFilter()
207  {
208  include_once("./Services/Tracking/classes/object_statistics/class.ilLPObjectStatisticsDailyTableGUI.php");
209  $lp_table = new ilLPObjectStatisticsDailyTableGUI($this, "daily", null, false);
210  $lp_table->resetOffset();
211  $lp_table->resetFilter();
212  $this->daily();
213  }
214 
215  function dailyFilter()
216  {
217  $this->daily(false);
218  }
219 
220  function daily($a_load_data = true)
221  {
222  global $tpl;
223 
224  $this->tabs_gui->activateSubTab('trac_object_stat_daily');
225 
226  $this->showAggregationInfo();
227 
228  include_once("./Services/Tracking/classes/object_statistics/class.ilLPObjectStatisticsDailyTableGUI.php");
229  $lp_table = new ilLPObjectStatisticsDailyTableGUI($this, "daily", null, $a_load_data);
230 
231  if(!$a_load_data)
232  {
233  $lp_table->disable("content");
234  $lp_table->disable("header");
235  }
236 
237  $tpl->setContent($lp_table->getHTML());
238  }
239 
240  function showDailyGraph()
241  {
242  global $lng, $tpl;
243 
244  if(!$_POST["item_id"])
245  {
246  ilUtil::sendFailure($lng->txt("no_checkbox"));
247  return $this->daily();
248  }
249 
250  $this->tabs_gui->activateSubTab('trac_object_stat_daily');
251 
252  include_once("./Services/Tracking/classes/object_statistics/class.ilLPObjectStatisticsDailyTableGUI.php");
253  $lp_table = new ilLPObjectStatisticsDailyTableGUI($this, "daily", $_POST["item_id"]);
254 
255  $tpl->setContent($lp_table->getGraph($_POST["item_id"]).$lp_table->getHTML());
256  }
257 
258  function admin()
259  {
260  global $tpl, $ilToolbar, $lng, $ilCtrl, $ilAccess;
261 
262  $this->tabs_gui->activateSubTab('trac_object_stat_admin');
263 
264  $this->showAggregationInfo(false);
265 
266  $ilToolbar->addButton($lng->txt("trac_sync_obj_stats"),
267  $ilCtrl->getLinkTarget($this, "adminSync"));
268 
269  if($ilAccess->checkAccess("delete", "", $this->ref_id))
270  {
271  include_once("./Services/Tracking/classes/object_statistics/class.ilLPObjectStatisticsAdminTableGUI.php");
272  $lp_table = new ilLPObjectStatisticsAdminTableGUI($this, "admin");
273 
274  $tpl->setContent($lp_table->getHTML());
275  }
276  }
277 
278  function adminSync()
279  {
280  global $ilCtrl, $lng;
281 
282  include_once "Services/Tracking/classes/class.ilChangeEvent.php";
284 
285  ilUtil::sendSuccess($lng->txt("trac_sync_obj_stats_success"), true);
286  $ilCtrl->redirect($this, "admin");
287  }
288 
289  function confirmDeleteData()
290  {
291  global $lng, $tpl, $ilTabs, $ilCtrl;
292 
293  if(!$_POST["item_id"])
294  {
295  ilUtil::sendFailure($lng->txt("no_checkbox"));
296  return $this->admin();
297  }
298 
299  $ilTabs->clearTargets();
300  $ilTabs->setBackTarget($lng->txt("back"),
301  $ilCtrl->getLinkTarget($this, "admin"));
302 
303  // display confirmation message
304  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
305  $cgui = new ilConfirmationGUI();
306  $cgui->setFormAction($ilCtrl->getFormAction($this));
307  $cgui->setHeaderText($lng->txt("trac_sure_delete_data"));
308  $cgui->setCancel($lng->txt("cancel"), "admin");
309  $cgui->setConfirm($lng->txt("delete"), "deleteData");
310 
311  // list objects that should be deleted
312  foreach ($_POST["item_id"] as $i)
313  {
314  $caption = $lng->txt("month_".str_pad(substr($i, 5), 2, "0", STR_PAD_LEFT)."_long").
315  " ".substr($i, 0, 4);
316 
317  $cgui->addItem("item_id[]", $i, $caption);
318  }
319 
320  $tpl->setContent($cgui->getHTML());
321  }
322 
323  function deleteData()
324  {
325  global $lng;
326 
327  if(!$_POST["item_id"])
328  {
329  ilUtil::sendFailure($lng->txt("no_checkbox"));
330  return $this->admin();
331  }
332 
333  include_once "Services/Tracking/classes/class.ilTrQuery.php";
335  ilUtil::sendSuccess($lng->txt("trac_data_deleted"));
336  $this->admin();
337  }
338 
340  {
341  include_once("./Services/Tracking/classes/object_statistics/class.ilLPObjectStatisticsLPTableGUI.php");
342  $lp_table = new ilLPObjectStatisticsLPTableGUI($this, "learningProgress", null, false);
343  $lp_table->resetOffset();
344  $lp_table->writeFilterToSession();
345  $this->learningProgress();
346  }
347 
349  {
350  include_once("./Services/Tracking/classes/object_statistics/class.ilLPObjectStatisticsLPTableGUI.php");
351  $lp_table = new ilLPObjectStatisticsLPTableGUI($this, "learningProgress", null, false);
352  $lp_table->resetOffset();
353  $lp_table->resetFilter();
354  $this->learningProgress();
355  }
356 
358  {
359  $this->learningProgress(false);
360  }
361 
362  function learningProgress($a_load_data = true)
363  {
364  global $tpl;
365 
366  $this->tabs_gui->activateSubTab('trac_object_stat_lp');
367 
368  $this->showCronJobInfo();
369 
370  include_once("./Services/Tracking/classes/object_statistics/class.ilLPObjectStatisticsLPTableGUI.php");
371  $lp_table = new ilLPObjectStatisticsLPTableGUI($this, "learningProgress", null, $a_load_data);
372 
373  if(!$a_load_data)
374  {
375  $lp_table->disable("content");
376  $lp_table->disable("header");
377  }
378 
379  $tpl->setContent($lp_table->getHTML());
380  }
381 
383  {
384  global $lng, $tpl;
385 
386  if(!$_POST["item_id"])
387  {
388  ilUtil::sendFailure($lng->txt("no_checkbox"));
389  return $this->learningProgress();
390  }
391 
392  $this->tabs_gui->activateSubTab('trac_object_stat_lp');
393 
394  include_once("./Services/Tracking/classes/object_statistics/class.ilLPObjectStatisticsLPTableGUI.php");
395  $lp_table = new ilLPObjectStatisticsLPTableGUI($this, "learningProgress", $_POST["item_id"], true, true);
396 
397  $tpl->setContent($lp_table->getGraph($_POST["item_id"]).$lp_table->getHTML());
398  }
399 
401  {
402  include_once("./Services/Tracking/classes/object_statistics/class.ilLPObjectStatisticsLPTableGUI.php");
403  $lp_table = new ilLPObjectStatisticsLPTableGUI($this, "showLearningProgressDetails", array($_GET["item_id"]), true, false, true);
404 
405  $a_tpl = new ilTemplate("tpl.lp_object_statistics_lp_details.html", true, true, "Services/Tracking");
406  $a_tpl->setVariable("CONTENT", $lp_table->getHTML());
407  $a_tpl->setVariable('CLOSE_IMG_TXT', $this->lng->txt('close'));
408  echo $a_tpl->get();
409  exit();
410  }
411 
412  protected function showAggregationInfo($a_show_link = true)
413  {
414  global $ilAccess, $lng, $ilCtrl;
415 
416  include_once "Services/Tracking/classes/class.ilTrQuery.php";
418  $info_date = ilDatePresentation::formatDate(new ilDateTime($info["tstamp"], IL_CAL_UNIX));
419 
420  $link = "";
421  if($a_show_link && $ilAccess->checkAccess("write", "", $this->ref_id))
422  {
423  $link = " <a href=\"".$ilCtrl->getLinkTarget($this, "admin")."\">&raquo;".
424  $lng->txt("trac_log_info_link")."</a>";
425  }
426 
427  ilUtil::sendInfo(sprintf($lng->txt("trac_log_info"), $info_date, $info["counter"]).$link);
428  }
429 
430  protected function showCronJobInfo()
431  {
432  global $lng;
433 
434  include_once "Services/Cron/classes/class.ilCronManager.php";
435  if(!ilCronManager::isJobActive("lp_object_statistics"))
436  {
437  ilUtil::sendInfo($lng->txt("trac_cron_info"));
438  }
439  }
440 }
441 
442 ?>