ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjUserTrackingGUI.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 "classes/class.ilObjectGUI.php";
5 
21 {
27 
28  var $tpl = null;
29  var $ilErr = null;
30  var $lng = null;
31  var $ctrl = null;
32 
33  function ilObjUserTrackingGUI($a_data,$a_id,$a_call_by_reference)
34  {
35  global $tpl,$ilErr,$lng,$ilCtrl;
36 
37  $this->type = "trac";
38  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference, false);
39 
40  $this->tpl =& $tpl;
41  $this->ilErr =& $ilErr;
42  $this->lng =& $lng;
43  $this->lng->loadLanguageModule('trac');
44 
45  $this->ctrl =& $ilCtrl;
46  }
47 
48  function &executeCommand()
49  {
50  $next_class = $this->ctrl->getNextClass();
51  $this->ctrl->setReturn($this, "show");
52  $this->prepareOutput();
53 
54  switch($next_class)
55  {
56  case 'ilpermissiongui':
57  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
58  $perm_gui =& new ilPermissionGUI($this);
59  $ret =& $this->ctrl->forwardCommand($perm_gui);
60  break;
61 
62  case 'illearningprogressgui':
63  $this->tabs_gui->setTabActive('learning_progress');
64  include_once("./Services/Tracking/classes/class.ilLearningProgressGUI.php");
66  $ret =& $this->ctrl->forwardCommand($lp_gui);
67  break;
68 
69  default:
70  $cmd = $this->ctrl->getCmd();
71  if ($cmd == "view" || $cmd == "")
72  {
73  $cmd = "settings";
74  }
75  $cmd .= "Object";
76  $this->$cmd();
77  break;
78  }
79 
80  return true;
81  }
82 
83  function getAdminTabs(&$tabs_gui)
84  {
85  $this->getTabs($tabs_gui);
86  }
87 
88  function getTabs(&$tabs_gui)
89  {
90  global $rbacsystem;
91 
92  $this->ctrl->setParameter($this,"ref_id",$this->ref_id);
93 
94  if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
95  {
96  $tabs_gui->addTarget("settings",
97  $this->ctrl->getLinkTarget($this,
98  "settings"),
99  "settings",
100  get_class($this));
101 
103  {
104  $tabs_gui->addTarget("learning_progress",
105  $this->ctrl->getLinkTargetByClass("illearningprogressgui",
106  "show"),
107  "",
108  "illearningprogressgui");
109  }
110 
111  $tabs_gui->addTarget("tracking_data",
112  $this->ctrl->getLinkTarget($this,
113  "trackingDataQueryForm"),
114  "trackingDataQueryForm",
115  get_class($this));
116 
117 
118  $tabs_gui->addTarget("manage_tracking_data",
119  $this->ctrl->getLinkTarget($this,
120  "manageData"),
121  "manageData",
122  get_class($this));
123 
124  $tabs_gui->addTarget("perm_settings",
125  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"),
126  array("perm","info","owner"),
127  'ilpermissiongui');
128  }
129  }
130 
131 
135  function settingsObject()
136  {
137  global $rbacsystem;
138 
139  if (!$rbacsystem->checkAccess('read',$this->object->getRefId()))
140  {
141  $ilErr->raiseError($this->lng->txt("msg_no_perm_read_track"),$ilErr->WARNING);
142  }
143 
144  $this->tabs_gui->setTabActive('settings');
145 
146  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
147  $form = new ilPropertyFormGUI();
148  $form->setFormAction($this->ctrl->getFormAction($this));
149  $form->setTitle($this->lng->txt('tracking_settings'));
150 
151  $activate = new ilCheckboxGroupInputGUI($this->lng->txt('activate_tracking'));
152  $form->addItem($activate);
153  $lp = new ilCheckboxInputGUI($this->lng->txt('trac_learning_progress'), 'learning_progress_tracking');
154  $lp->setInfo($this->lng->txt('trac_learning_progress_settings_info'));
155  $activate->addSubItem($lp);
156  $tracking = new ilCheckboxInputGUI($this->lng->txt('trac_user_activities'), 'user_tracking');
157  $activate->addSubItem($tracking);
158  $event = new ilCheckboxInputGUI($this->lng->txt('trac_repository_changes'), 'change_event_tracking');
159  $activate->addSubItem($event);
160 
161  if($this->object->getActivationStatus() == UT_ACTIVE_BOTH ||
162  $this->object->getActivationStatus() == UT_ACTIVE_UT)
163  {
164  $tracking->setChecked(true);
165  }
166  if($this->object->getActivationStatus() == UT_ACTIVE_BOTH ||
167  $this->object->getActivationStatus() == UT_ACTIVE_LP)
168  {
169  $lp->setChecked(true);
170  }
171  if($this->object->isChangeEventTrackingEnabled())
172  {
173  $event->setChecked(true);
174  }
175 
176  $access = new ilCheckboxInputGUI($this->lng->txt('trac_first_and_last_access'), 'lp_access');
177  if($this->object->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_LAST_ACCESS))
178  {
179  $access->setChecked(true);
180  }
181  $lp->addSubItem($access);
182 
183  $read = new ilCheckboxInputGUI($this->lng->txt('trac_read_count'), 'lp_count');
184  if($this->object->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_READ_COUNT))
185  {
186  $read->setChecked(true);
187  }
188  $lp->addSubItem($read);
189 
190  $spent = new ilCheckboxInputGUI($this->lng->txt('trac_spent_seconds'), 'lp_spent');
191  if($this->object->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_SPENT_SECONDS))
192  {
193  $spent->setChecked(true);
194  }
195  $lp->addSubItem($spent);
196 
197  // Anonymized
198  $user = new ilCheckboxInputGUI($this->lng->txt('trac_anonymized'), 'user_related');
199  $user->setInfo($this->lng->txt('trac_anonymized_info'));
200  $user->setChecked(!$this->object->_enabledUserRelatedData());
201  $form->addItem($user);
202 
203  // Max time gap
204  $valid = new ilNumberInputGUI($this->lng->txt('trac_valid_request'), 'valid_request');
205  $valid->setMaxLength(4);
206  $valid->setSize(4);
207  $valid->setSuffix($this->lng->txt('seconds'));
208  $valid->setInfo($this->lng->txt('info_valid_request'));
209  $valid->setValue($this->object->getValidTimeSpan());
210  $form->addItem($valid);
211 
212  $form->addCommandButton('saveSettings', $this->lng->txt('save'));
213 
214  $this->tpl->setContent($form->getHTML());
215  }
216 
221  {
222  // BEGIN ChangeEvent
223  if ($_POST['user_tracking'] == '1')
224  {
225  $activation_status = ($_POST['learning_progress_tracking'] == '1') ? UT_ACTIVE_BOTH : UT_ACTIVE_UT;
226  }
227  else
228  {
229  $activation_status = ($_POST['learning_progress_tracking'] == '1') ? UT_ACTIVE_LP : UT_INACTIVE_BOTH;
230  }
231  $this->object->setActivationStatus($activation_status);
232  $this->object->setChangeEventTrackingEnabled($_POST['change_event_tracking'] == '1');
233  // END ChangeEvent
234 
235  if($_POST['learning_progress_tracking'] == '1')
236  {
237  $code = 0;
238  if($_POST['lp_access'] == '1')
239  {
241  }
242  if($_POST['lp_count'] == '1')
243  {
245  }
246  if($_POST['lp_spent'] == '1')
247  {
249  }
250  $this->object->setExtendedData($code);
251  }
252 
253  $this->object->enableUserRelatedData((int) !$_POST['user_related']);
254  $this->object->setValidTimeSpan($_POST['valid_request']);
255 
256  if(!$this->object->validateSettings())
257  {
258  ilUtil::sendFailure($this->lng->txt('tracking_time_span_not_valid'));
259  $this->settingsObject();
260 
261  return false;
262  }
263 
264  $this->object->updateSettings();
265  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"));
266  $this->settingsObject();
267 
268  return true;
269  }
270 
274  function manageDataObject()
275  {
276  global $tpl,$lng,$ilias;
277 
278  // tracking settings
279  $tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.tracking_manage_data.html");
280  $tpl->setVariable("FORMACTION",$this->ctrl->getFormaction($this,'gateway'));
281  $tpl->setVariable("TXT_TRACKING_DATA", $this->lng->txt("tracking_data"));
282  $tpl->setVariable("TXT_MONTH", $lng->txt("month"));
283  $tpl->setVariable("TXT_NUMBER_OF_ACC", $lng->txt("number_of_accesses"));
284  $tpl->setVariable("TXT_DELETE_OLDER", $lng->txt("delete"));
285  $overw = $this->object->getMonthTotalOverview();
286  foreach($overw as $month)
287  {
288  $tpl->setCurrentBlock("load_row");
289  $rcol = ($rcol != "tblrow1") ? "tblrow1" : "tblrow2";
290  $tpl->setVariable("ROWCOL", $rcol);
291  $tpl->setVariable("VAL_MONTH", $month["month"]);
292  $tpl->setVariable("VAL_NUMBER_OF_ACC", $month["cnt"]);
293  $tpl->parseCurrentBlock();
294  }
295 // $tpl->parseCurrentBlock();
296  }
297 
302  {
303  global $tpl, $lng, $rbacsystem;
304 
305  if (!$rbacsystem->checkAccess('delete',$this->object->getRefId()))
306  {
307  $this->ilias->raiseError($this->lng->txt("msg_no_perm_delete_track"),$this->ilias->error_obj->WARNING);
308  }
309 
310  if (!isset($_POST["month"]))
311  {
312  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
313  }
314  $nr = $this->object->getTotalOlderThanMonth($_POST["month"]);
315  $tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.tracking_confirm_data_deletion.html");
316  #$tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$_GET["ref_id"].
317  # "&cmd=gateway&month=".$_POST["month"]);
318  $this->ctrl->setParameter($this,'month',$_POST['month']);
319  $tpl->setVariable("FORMACTION",$this->ctrl->getFormaction($this,'gateway'));
320 
321  $tpl->setVariable("TXT_CONFIRMATION", $this->lng->txt("tracking_data_del_confirm"));
322  $tpl->setVariable("TXT_MONTH", $lng->txt("month"));
323  $tpl->setVariable("VAL_MONTH", $_POST["month"]);
324  $tpl->setVariable("TXT_NUMBER_OF_RECORDS", $lng->txt("number_of_records"));
325  $tpl->setVariable("VAL_NUMBER_OF_RECORDS", $nr);
326  $tpl->setVariable("TXT_NUMBER_OF_ACC", $lng->txt("number_of_accesses"));
327  $tpl->setVariable("TXT_DELETE_DATA", $lng->txt("delete_tr_data"));
328  $tpl->setVariable("TXT_CANCEL", $lng->txt("cancel"));
329  }
330 
335  {
336  $this->ctrl->redirect($this,'manageData');
337  }
338 
342  function deleteDataObject()
343  {
344  global $rbacsystem;
345 
346  if (!$rbacsystem->checkAccess('read',$this->object->getRefId()))
347  {
348  $this->ilias->raiseError($this->lng->txt("msg_no_perm_delete_track"),$this->ilias->error_obj->WARNING);
349  }
350 
351  $this->object->deleteTrackingDataBeforeMonth($_GET["month"]);
352 
353  ilUtil::sendInfo($this->lng->txt("tracking_data_deleted"),true);
354  $this->ctrl->redirect($this,'manageData');
355 
356  #ilUtil::redirect("adm_object.php?ref_id=".$_GET["ref_id"]."&cmd=manageData");
357  }
358 
363  {
364  global $tpl;
365  $tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.usr_tracking.html");
366  $tpl->setVariable("FORM", $this->showForm());
367  }
368 
369  function showForm()
370  {
371  global $lng,$ilias;
372  for ($i = 2004; $i <= date("Y"); $i++) $year[] = $i;
373  $month = array(1,2,3,4,5,6,7,8,9,10,11,12);
374  $day = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31);
375  //subject module
376  $tpl = new ilTemplate("tpl.tracking_form.html", true, true);
377 
378  // Tabs gui
379  $this->tabs_gui->setTabActive('tracking_data');
380 
382  {
383  $tpl->setCurrentBlock("user_stat");
384  $tpl->setVariable("TXT_VIEW_MODE_U", $lng->txt("vm_access_of_users"));
385  if ($_SESSION["il_track_stat"] == "u")
386  {
387  $tpl->setVariable("U_SEL", "selected");
388  }
389  $tpl->parseCurrentBlock();
390  }
391 
392  //$tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
393  #$tpl->setVariable("SEARCH_ACTION", "adm_object.php?ref_id=".$_GET["ref_id"].
394  # "&cmd=gateway");
395 
396  $tpl->setVariable("SEARCH_ACTION",$this->ctrl->getFormaction($this,'gateway'));
397  $tpl->setVariable("TXT_TRACKING_DATA", $lng->txt("tracking_data"));
398  $tpl->setVariable("TXT_SEARCH_TERMS", $lng->txt("search_terms"));
399  $tpl->setVariable("VAL_SEARCH_TERMS", ilUtil::prepareFormOutput($_SESSION["il_track_search_terms"], true));
400  $tpl->setVariable("TXT_TIME_SEGMENT", $lng->txt("time_segment"));
401  $tpl->setVariable("TXT_VIEW_MODE", $lng->txt("view_mode"));
402  $tpl->setVariable("TXT_VIEW_MODE_H", $lng->txt("vm_times_of_day"));
403  $tpl->setVariable("TXT_VIEW_MODE_D", $lng->txt("vm_days_of_period"));
404  $tpl->setVariable("TXT_USER_LANGUAGE",$lng->txt("user_language"));
405  $tpl->setVariable("TXT_LM",$lng->txt("lm"));
406  $tpl->setVariable("TXT_HTLM",$lng->txt("htlm"));
407 # $tpl->setVariable("TXT_TST",$lng->txt("test"));
408  $tpl->setVariable("TXT_SHOW_TR_DATA",$lng->txt("query_data"));
409  $tpl->setVariable("TXT_TRACKED_OBJECTS",$lng->txt("tracked_objects"));
410  $tpl->setVariable("TXT_FILTER_AREA",$lng->txt("trac_filter_area"));
411  $tpl->setVariable("TXT_CHANGE",$lng->txt("change"));
412 
413  $languages = $lng->getInstalledLanguages();
414 
415  // get all learning modules
416  // $lms = ilObject::_getObjectsDataForType("lm", true);
417 /* $authors = ilObjUserTracking::allAuthor("usr","lm");
418  if(count($authors)>0)
419  {
420  $tpl->setCurrentBlock("javascript");
421  $tpl->setVariable("ALL_LMS", $this->lng->txt("all_lms"));
422  foreach ($authors as $author)
423  {
424  $lms = ilObjUserTracking::authorLms($author["obj_id"],"lm");
425  //echo count($lms);
426  foreach ($lms as $lm)
427  {
428  $tpl->setCurrentBlock("select_value");
429  $tpl->setVariable("VALUE", $author["title"]);
430  $tpl->setVariable("LMVALUE", $lm["title"]);
431  $tpl->parseCurrentBlock();
432  }
433 
434  }
435  $tpl->parseCurrentBlock();
436  }
437  $authors1 = ilObjUserTracking::allAuthor("usr","tst");
438  if(count($authors1)>0)
439  {
440  $tpl->setCurrentBlock("javascript1");
441  $tpl->setVariable("ALL_TSTS", $this->lng->txt("all_tsts"));
442  foreach ($authors1 as $author1)
443  {
444  $tsts = ilObjUserTracking::authorLms($author1["obj_id"],"tst");
445  foreach ($tsts as $tst)
446  {
447  $tpl->setCurrentBlock("select_value1");
448  $tpl->setVariable("VALUE1", $author1["title"]);
449  $tpl->setVariable("TSTVALUE", $tst["title"]);
450  $tpl->parseCurrentBlock();
451  }
452  }
453  $tpl->parseCurrentBlock();
454  }*/
455 
456  if ($_SESSION["il_track_yearf"] == "") $_SESSION["il_track_yearf"] = date("Y");
457 
458  if ($_SESSION["il_track_yeart"] == "") $_SESSION["il_track_yeart"] = date("Y");
459  if ($_SESSION["il_track_montht"] == "") $_SESSION["il_track_montht"] = date("m");
460  if ($_SESSION["il_track_dayt"] == "") $_SESSION["il_track_dayt"] = date("d");
461 
462  foreach($year as $key)
463  {
464  $tpl->setCurrentBlock("fromyear_selection");
465  $tpl->setVariable("YEARFR", $key);
466  $tpl->setVariable("YEARF", $key);
467  if ($_SESSION["il_track_yearf"] == $key)
468  {
469  $tpl->setVariable("YEARF_SEL", " selected=\"1\" ");
470  }
471  $tpl->parseCurrentBlock();
472  }
473  foreach($month as $key)
474  {
475  $tpl->setCurrentBlock("frommonth_selection");
476  $tpl->setVariable("MONTHFR", $key);
477  $tpl->setVariable("MONTHF", $key);
478  if ($_SESSION["il_track_monthf"] == $key)
479  {
480  $tpl->setVariable("MONTHF_SEL", " selected=\"1\" ");
481  }
482  $tpl->parseCurrentBlock();
483  }
484  foreach($day as $key)
485  {
486  $tpl->setCurrentBlock("fromday_selection");
487  $tpl->setVariable("DAYFR", $key);
488  $tpl->setVariable("DAYF", $key);
489  if ($_SESSION["il_track_dayf"] == $key)
490  {
491  $tpl->setVariable("DAYF_SEL", " selected=\"1\" ");
492  }
493  $tpl->parseCurrentBlock();
494  }
495  foreach($day as $key)
496  {
497  $tpl->setCurrentBlock("today_selection");
498  $tpl->setVariable("DAYTO", $key);
499  $tpl->setVariable("DAYT", $key);
500  if ($_SESSION["il_track_dayt"] == $key)
501  {
502  $tpl->setVariable("DAYT_SEL", " selected=\"1\" ");
503  }
504  $tpl->parseCurrentBlock();
505  }
506  foreach($month as $key)
507  {
508  $tpl->setCurrentBlock("tomonth_selection");
509  $tpl->setVariable("MONTHTO", $key);
510  $tpl->setVariable("MONTHT", $key);
511  if ($_SESSION["il_track_montht"] == $key)
512  {
513  $tpl->setVariable("MONTHT_SEL", " selected=\"1\" ");
514  }
515  $tpl->parseCurrentBlock();
516  }
517  foreach($year as $key)
518  {
519  $tpl->setCurrentBlock("toyear_selection");
520  $tpl->setVariable("YEARTO", $key);
521  $tpl->setVariable("YEART", $key);
522  if ($_SESSION["il_track_yeart"] == $key)
523  {
524  $tpl->setVariable("YEART_SEL", " selected=\"1\" ");
525  }
526  $tpl->parseCurrentBlock();
527  }
528  // language selection
529  $tpl->setCurrentBlock("language_selection");
530  $tpl->setVariable("LANG", $lng->txt("any_language"));
531  $tpl->setVariable("LANGSHORT", "0");
532  $tpl->parseCurrentBlock();
533  foreach ($languages as $lang_key)
534  {
535  $tpl->setCurrentBlock("language_selection");
536  $tpl->setVariable("LANG", $lng->txt("lang_".$lang_key));
537  $tpl->setVariable("LANGSHORT", $lang_key);
538  if ($_SESSION["il_track_language"] == $lang_key)
539  {
540  $tpl->setVariable("LANG_SEL", " selected=\"1\" ");
541  }
542  $tpl->parseCurrentBlock();
543  }
544 
545  // statistic type
546  if (!in_array($_SESSION["il_track_stat"], array("d", "h", "o", "u"))) $_SESSION["il_track_stat"] = "d";
547 
548  if ($_SESSION["il_track_stat"] == "d")
549  {
550  $tpl->setVariable("D_SEL", "selected");
551  }
552  elseif ($_SESSION["il_track_stat"] == "h")
553  {
554  $tpl->setVariable("H_SEL", "selected");
555  }
556 
557  // tracked object type
558  $tpl->setVariable(strtoupper($_SESSION["il_object_type"])."_SEL", "selected");
559 
560  // author selection
561 /* $tpl->setCurrentBlock("author_selection");
562  $tpl->setVariable("AUTHOR", 0);
563  $tpl->setVariable("AUTHOR_SELECT", $this->lng->txt("all_authors"));
564  $tpl->parseCurrentBlock();
565  foreach ($authors as $author)
566  {
567  $tpl->setCurrentBlock("author_selection");
568  $tpl->setVariable("AUTHOR", $author["title"]);
569  $tpl->setVariable("AUTHOR_SELECT", $author["title"]);
570  if ($_SESSION["il_track_author"] == $author["title"])
571  {
572  $tpl->setVariable("AUTHOR_SEL", " selected=\"1\" ");
573  }
574  $tpl->parseCurrentBlock();
575  }
576  $tpl->setCurrentBlock("author_selection_tst");
577  $tpl->setVariable("AUTHOR1", 0);
578  $tpl->setVariable("AUTHOR1_SELECT", $this->lng->txt("all_authors"));
579  $tpl->parseCurrentBlock();
580  foreach ($authors1 as $author1)
581  {
582  $tpl->setCurrentBlock("author_selection_tst");
583  $tpl->setVariable("AUTHOR1", $author1["title"]);
584  $tpl->setVariable("AUTHOR1_SELECT", $author1["title"]);
585  if ($_SESSION["il_track_author1"] == $author1["title"])
586  {
587  $tpl->setVariable("AUTHOR1_SEL", " selected=\"1\" ");
588  }
589  $tpl->parseCurrentBlock();
590  }
591  //test module
592 
593  $result_test = ilObjUserTracking::getTestId($_SESSION["AccountId"]);
594 
595  //$test = $tracking->TestTitle($_SESSION["AccountId"]);
596 
597  $tsts = ilObject::_getObjectsDataForType($type, true);
598  $tpl->setCurrentBlock("test_selection");
599  $tpl->setVariable("TEST", 0);
600  $tpl->setVariable("TEST_SELECT", $this->lng->txt("all_tsts"));
601  $tpl->parseCurrentBlock();
602  foreach($tsts as $tst)
603  {
604  $tpl->setCurrentBlock("test_selection");
605  $tpl->setVariable("TEST", $tst["id"]);
606  $tpl->setVariable("TEST_SELECT", $tst["title"]." [".$tst["id"]."]");
607  $tpl->parseCurrentBlock();
608  }*/
609 
610  return $tpl->get();
611 
612  }
613 
618  {
619  global $tpl,$lng,$ilias,$ilSetting;
620 
621  $TYPES = array(
622  'lm' => $lng->txt("lm"),
623  'htlm' => $lng->txt("htlm"),
624  'tst' => $lng->txt("test")
625  );
626 
627  include_once "./Services/Table/classes/class.ilTableGUI.php";
628 
629  if(!in_array($_POST["stat"], array("d", "h", "o", "u")))
630  {
631  $_POST["stat"] = "d";
632  }
633  if ($_POST["author"] == "") $_POST["author"] = "0";
634  if ($_POST["author1"] == "") $_POST["author1"] = "0";
635 
636  // save selected values in session
637  $_SESSION["il_track_search_terms"] = ilUtil::stripSlashes($_POST["search_terms"]);
638  $_SESSION["il_track_yearf"] = $_POST["yearf"];
639  $_SESSION["il_track_yeart"] = $_POST["yeart"];
640  $_SESSION["il_track_monthf"] = $_POST["monthf"];
641  $_SESSION["il_track_montht"] = $_POST["montht"];
642  $_SESSION["il_track_dayf"] = $_POST["dayf"];
643  $_SESSION["il_track_dayt"] = $_POST["dayt"];
644  $_SESSION["il_track_stat"] = $_POST["stat"];
645  $_SESSION["il_track_language"] = $_POST["language"];
646  $_SESSION["il_track_author"] = $_POST["author"];
647  $_SESSION["il_track_author1"] = $_POST["author1"];
648  $_SESSION["il_track_lm"] = $_POST["lm"];
649  $_SESSION["il_track_htlm"] = $_POST["htlm"];
650  $_SESSION["il_track_tst"] = $_POST["tst"];
651  $_SESSION["il_object_type"] = $_POST["object_type"];
652 
653  $yearf = $_POST["yearf"];
654  $monthf = $_POST["monthf"];
655  $dayf = $_POST["dayf"];
656  $yeart = $_POST["yeart"];
657  $montht= $_POST["montht"];
658  $dayt = $_POST["dayt"];
659  $from = date("Y-m-d", mktime(12, 0, 0, $monthf, $dayf, $yearf));
660  $to = date("Y-m-d", mktime(12, 0, 0, $montht, $dayt, $yeart));
661 
662  if(($yearf > $yeart)or($yearf==$yeart and $monthf>$montht)or($yearf==$yeart and $monthf==$montht and $dayf>$dayt))
663  {
664  $this->ilias->raiseError($lng->txt("msg_err_search_time"),
665  $this->ilias->error_obj->MESSAGE);
666  }
667 
668  $condition = $this->getCondition()." and acc_time >= '".$from." 00:00:00' and acc_time <= '".$to." 23:59:59'";
669 
670  /*
671  if($_POST["stat"]!='h' and $_POST["stat"]!='d')
672  {
673  $this->ilias->raiseError($lng->txt("msg_no_search_time"),
674  $this->ilias->error_obj->MESSAGE);
675  }*/
676 
677  $tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.tracking_result.html");
678  $tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
679 
680  $tpl->setVariable("FORM", $this->showForm());
681 
682  $objectCondition = "";
683 
684  if (($max_acc_objects = $this->object->countResults($condition)) == 0)
685  {
686  $this->ilias->raiseError($lng->txt("msg_no_search_result"),
687  $this->ilias->error_obj->MESSAGE);
688  }
689 
690  $max_hits = $ilias->getSetting('search_max_hits', 50);
691 
692  if ($_POST["search_terms"] != "")
693  {
694  $tplTable =& new ilTemplate("tpl.table.html", true, true);
695  $tplTable->addBlockFile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
696 
697  $tbl = new ilTableGUI(0, false);
698  $tbl->setTemplate($tplTable);
699 
700  $searchTermsCondition = $this->getSearchTermsCondition();
701  $acc_object = $this->object->getAccessTotalPerObj($condition,$searchTermsCondition);
702 
703  $max_acc_objects = count($acc_object);
704 
705  if ($max_acc_objects < 1)
706  {
707  $this->ilias->raiseError($lng->txt("msg_no_search_result"),
708  $this->ilias->error_obj->MESSAGE);
709  }
710  else
711  {
712  $info = sprintf($lng->txt("info_found_objects"), $TYPES[$_POST["object_type"]]);
713 
714  if ($max_hits < $max_acc_objects)
715  {
716  $info .= " ".sprintf($lng->txt("found_too_much_objects"), $max_hits);
717  unset($tmp);
718  for ($i = 0; $i < count($acc_object) && $i < $max_hits; $i++)
719  {
720  $tmp[$i] = $acc_object[$i];
721  }
722  $acc_object = $tmp;
723  $max_acc_objects = $max_hits;
724  }
725 
726  $tpl->setVariable("INFO", $info);
727  }
728 
729  $tbl->setTitle($lng->txt("found_objects"),0,0);
730 # if(($_POST["object_type"]=="lm" and $_POST["author"] == "0") or ($_POST["object_type"]=="tst" and $_POST["author1"] == "0"))
731 # {
732  $title_new = array("author", "subject", "total_dwell_time", "count","");
733  $tbl->setColumnWidth(array("20%", "30%", "20%", "10%", "*"));
734 # }
735 # else
736 # {
737 # $title_new = array("subject", "count","");
738 # $tbl->setColumnWidth(array("30%", "10%", "*"));
739 # }
740  foreach ($title_new as $val)
741  {
742  $header_names[] = $lng->txt($val);
743  }
744  $tbl->disable("sort");
745  $tbl->setHeaderNames($header_names);
746  $tbl->setMaxCount($max_acc_objects);
747  # $tbl->setStyle("table", "std");
748 
749  $max = 0;
750  unset($ids);
751  for ($i = 0; $i < count($acc_object); $i++)
752  {
753  $max = ($max > $acc_object[$i]["cnt"]) ? $max : $acc_object[$i]["cnt"];
754  $ids[$i] = $acc_object[$i]["id"];
755  }
756  if (is_array($ids))
757  {
758  $objectCondition = " AND acc_obj_id IN (".implode(",", $ids).") ";
759  }
760 
761  for ($i = 0; $i < count($acc_object); $i++)
762  {
763  unset($data);
764 # if(($_POST["object_type"]=="lm" and $_POST["author"]=="0") or ($_POST["object_type"]=="tst" and $_POST["author1"]=="0"))
765 # {
766  $data[0] = $acc_object[$i]["author"];
767  $data[1] = $acc_object[$i]["title"];
768  $data[2] = ilFormat::_secondsToString($acc_object[$i]["duration"]);
769  $data[3] = $acc_object[$i]["cnt"];
770  $width = ($max > 0)
771  ? round($data[3] / $max * 100)
772  : 0;
773  $data[4] = "<img src=\"".ilUtil::getImagePath("ray.gif")."\" border=\"0\" ".
774  "width=\"".$width."\" height=\"10\"/>";
775 /* }
776  else
777  {
778  $data[0] = $obj["title"];
779  $data[1] = $obj["cnt"];
780  $width = ($max > 0)
781  ? round($data[1] / $max * 100)
782  : 0;
783  $data[2] = "<img src=\"".ilUtil::getImagePath("ray.gif")."\" border=\"0\" ".
784  "width=\"".$width."\" height=\"10\"/>";
785  }*/
786  $css_row = $i%2==0?"tblrow1":"tblrow2";
787  foreach ($data as $key => $val)
788  {
789  if($val=="")
790  {
791  $val=0;
792  }
793  $tplTable->setCurrentBlock("text");
794  $tplTable->setVariable("TEXT_CONTENT", $val);
795  $tplTable->parseCurrentBlock();
796  $tplTable->setCurrentBlock("table_cell");
797  $tplTable->parseCurrentBlock();
798  } //foreach
799  $tplTable->setCurrentBlock("tbl_content");
800  $tplTable->setVariable("CSS_ROW", $css_row);
801  $tplTable->parseCurrentBlock();
802  } //for
803 
804  $tbl->render();
805  $tpl->setVariable("OBJECTS_TABLE", $tplTable->get());
806  $tpl->setVariable("TXT_INFO_DWELL_TIME", $lng->txt("info_dwell_time"));
807  unset($tplTable);
808  unset($tbl);
809  }
810  else
811  {
812  $tpl->setVariable("INFO", sprintf($lng->txt("info_all_objects"), $TYPES[$_POST["object_type"]]));
813  }
814 
815  if ($max_acc_objects > 0)
816  {
817 
818  $tplTable =& new ilTemplate("tpl.table.html", true, true);
819  $tplTable->addBlockFile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
820 
821  $tbl = new ilTableGUI(0, false);
822  $tbl->setTemplate($tplTable);
823 
824  // user access statistic
825  if($_POST["stat"] == "u") // user access
826  {
827  if($_POST["mode"] == "user")
828  {
829  $tpl->setCurrentBlock("user_mode");
830  #$tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$_GET["ref_id"].
831  #"&cmd=gateway");
832  $tpl->setVariable("FORMACTION",$this->ctrl->getFormaction($this,'gateway'));
833  if($_POST["object_type"]=="lm")
834  {
835  $tpl->setVariable("AUTHOR", "author");
836  $tpl->setVariable("AUTHORS", $_POST["author"]);
837  $tpl->setVariable("OBJECT", "lm");
838  $tpl->setVariable("OBJECTS", $_POST["lm"]);
839  }
840  else if($_POST["object_type"]=="htlm")
841  {
842  $tpl->setVariable("AUTHOR", "author");
843  $tpl->setVariable("AUTHORS", $_POST["author"]);
844  $tpl->setVariable("OBJECT", "htlm");
845  $tpl->setVariable("OBJECTS", $_POST["htlm"]);
846  }
847  else
848  {
849  $tpl->setVariable("AUTHOR", "author1");
850  $tpl->setVariable("AUTHORS", $_POST["author1"]);
851  $tpl->setVariable("OBJECT", "tst");
852  $tpl->setVariable("OBJECTS", $_POST["tst"]);
853  }
854  $tpl->setVariable("YEARF",$_POST["yearf"]);
855  $tpl->setVariable("MONTHF",$_POST["monthf"]);
856  $tpl->setVariable("DAYF",$_POST["dayf"]);
857  $tpl->setVariable("YEART",$_POST["yeart"]);
858  $tpl->setVariable("MONTHT",$_POST["montht"]);
859  $tpl->setVariable("DAYT",$_POST["dayt"]);
860  $tpl->setVariable("LAN", $_POST["language"]);
861  $tpl->setVariable("TYPE", $_POST["object_type"]);
862  $tpl->setVariable("SEARCH_TERMS", ilUtil::prepareFormOutput($_POST["search_terms"]));
863  $tpl->setVariable("FROM", $from);
864  $tpl->setVariable("TO", $to);
865  $tpl->setVariable("TXT_SHOW_USER_DATA", $lng->txt("user_statistics"));
866  $tpl->parseCurrentBlock();
867 
868  $title_new = array("user","client_ip","language","object","time");
869  $condition = $this->getConditions()." and acc_time >= '".$from." 00:00:00' and acc_time <= '".$to." 23:59:59'";
870  $searchTermsCondition = $this->getSearchTermsCondition();
871  $user_acc = $this->object->getAccessPerUserDetail($condition, $searchTermsCondition, $objectCondition);
872  $this->maxcount = count($user_acc);
873  if ($this->maxcount < 1)
874  {
875  $this->ilias->raiseError($lng->txt("msg_no_search_result"),
876  $this->ilias->error_obj->MESSAGE);
877  }
878 
879 # $tbl->setTitle($lng->txt("search_result"),0,0);
880  $tbl->setTitle($lng->txt("obj_trac").": ".$lng->txt("vm_access_of_users")." [".$lng->txt("details")."]",0,0);
881  unset($header_names);
882  foreach ($title_new as $val)
883  {
884  $header_names[] = $lng->txt($val);
885  }
886  $tbl->disable("sort");
887 
888  $tbl->setHeaderNames($header_names);
889  $tbl->setColumnWidth(array("20%", "15%", "15%", "30%", "*"));
890  $tbl->setMaxCount($this->maxcount);
891  # $tbl->setStyle("table", "std");
892 
893  $max = 0;
894 
895  $i = 0;
896  foreach ($user_acc as $user)
897  {
898  unset($data);
899  $data[0] = $user["name"];
900  $data[1] = $user["client_ip"];
901  $data[2] = $user["language"];
902  $data[3] = $user["acc_obj_id"];
903  $data[4] = $user["acc_time"];
904  $css_row = $i%2==0?"tblrow1":"tblrow2";
905  foreach ($data as $key => $val)
906  {
907  if($val=="")
908  {
909  $val=0;
910  }
911  $tplTable->setCurrentBlock("text");
912  $tplTable->setVariable("TEXT_CONTENT", $val);
913  $tplTable->parseCurrentBlock();
914  $tplTable->setCurrentBlock("table_cell");
915  $tplTable->parseCurrentBlock();
916  } //foreach
917  $tplTable->setCurrentBlock("tbl_content");
918  $tplTable->setVariable("CSS_ROW", $css_row);
919  $tplTable->parseCurrentBlock();
920  $i++;
921  } //for
922  }
923  else
924  {
925  $tpl->setCurrentBlock("user_mode");
926  #$tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$_GET["ref_id"].
927  #"&cmd=gateway");
928  $tpl->setVariable("FORMACTION",$this->ctrl->getFormaction($this,'gateway'));
929  if($_POST["object_type"]=="lm")
930  {
931  $tpl->setVariable("AUTHOR", "author");
932  $tpl->setVariable("AUTHORS", $_POST["author"]);
933  $tpl->setVariable("OBJECT", "lm");
934  $tpl->setVariable("OBJECTS", $_POST["lm"]);
935  }
936  else if($_POST["object_type"]=="htlm")
937  {
938  $tpl->setVariable("AUTHOR", "author");
939  $tpl->setVariable("AUTHORS", $_POST["author"]);
940  $tpl->setVariable("OBJECT", "htlm");
941  $tpl->setVariable("OBJECTS", $_POST["htlm"]);
942  }
943  else
944  {
945  $tpl->setVariable("AUTHOR", "author1");
946  $tpl->setVariable("AUTHORS", $_POST["author1"]);
947  $tpl->setVariable("OBJECT", "tst");
948  $tpl->setVariable("OBJECTS", $_POST["tst"]);
949  }
950  $tpl->setVariable("YEARF",$_POST["yearf"]);
951  $tpl->setVariable("MONTHF",$_POST["monthf"]);
952  $tpl->setVariable("DAYF",$_POST["dayf"]);
953  $tpl->setVariable("YEART",$_POST["yeart"]);
954  $tpl->setVariable("MONTHT",$_POST["montht"]);
955  $tpl->setVariable("DAYT",$_POST["dayt"]);
956  $tpl->setVariable("USER", "user");
957  $tpl->setVariable("LAN", $_POST["language"]);
958  $tpl->setVariable("TYPE", $_POST["object_type"]);
959  $tpl->setVariable("SEARCH_TERMS", ilUtil::prepareFormOutput($_POST["search_terms"]));
960  $tpl->setVariable("FROM", $from);
961  $tpl->setVariable("TO", $to);
962  $tpl->setVariable("TXT_SHOW_USER_DATA", $lng->txt("user_detail"));
963  $tpl->parseCurrentBlock();
964  $title_new = array("user", "count", "");
965 
966  $searchTermsCondition = $this->getSearchTermsCondition();
967  $user_acc = $this->object->getAccessTotalPerUser($condition, $searchTermsCondition, $objectCondition);
968 
969  $this->maxcount = count($user_acc);
970 
971  // check if result is given
972  if ($this->maxcount < 1)
973  {
974  $this->ilias->raiseError($lng->txt("msg_no_search_result"),
975  $this->ilias->error_obj->MESSAGE);
976  }
977 
978 # $tbl->setTitle($lng->txt("search_result"),0,0);
979  $tbl->setTitle($lng->txt("obj_trac").": ".$lng->txt("vm_access_of_users"),0,0);
980  unset($header_names);
981  foreach ($title_new as $val)
982  {
983  $header_names[] = $lng->txt($val);
984  }
985  $tbl->disable("sort");
986  $tbl->setHeaderNames($header_names);
987  $tbl->setColumnWidth(array("20%", "10%", "*"));
988  $tbl->setMaxCount($this->maxcount);
989  # $tbl->setStyle("table", "std");
990 
991  $max = 0;
992  foreach ($user_acc as $user)
993  {
994  $max = ($max > $user["cnt"]) ? $max : $user["cnt"];
995  }
996 
997  $i = 0;
998  foreach ($user_acc as $user)
999  {
1000  unset($data);
1001  $data[0] = $user["name"];
1002  $data[1] = $user["cnt"];
1003  $width = ($max > 0)
1004  ? round($data[1] / $max * 100)
1005  : 0;
1006  $data[2] = "<img src=\"".ilUtil::getImagePath("ray.gif")."\" border=\"0\" ".
1007  "width=\"".$width."\" height=\"10\"/>";
1008 
1009  $css_row = $i%2==0?"tblrow1":"tblrow2";
1010  foreach ($data as $key => $val)
1011  {
1012  if($val=="")
1013  {
1014  $val=0;
1015  }
1016  $tplTable->setCurrentBlock("text");
1017  $tplTable->setVariable("TEXT_CONTENT", $val);
1018  $tplTable->parseCurrentBlock();
1019  $tplTable->setCurrentBlock("table_cell");
1020  $tplTable->parseCurrentBlock();
1021  } //foreach
1022  $tplTable->setCurrentBlock("tbl_content");
1023  $tplTable->setVariable("CSS_ROW", $css_row);
1024  $tplTable->parseCurrentBlock();
1025  $i++;
1026  } //for
1027  }
1028 
1029  }
1030  else //user not selected
1031  {
1032  $title_new = array("time", "count", "");
1033 
1034 # $tbl->setTitle($lng->txt("obj_trac"),0,0);
1035  unset($header_names);
1036  foreach ($title_new as $val)
1037  {
1038  $header_names[] = $lng->txt($val);
1039  }
1040  $tbl->disable("sort");
1041  $tbl->setHeaderNames($header_names);
1042  if($_POST["stat"]=='h') //hours of day
1043  {
1044  $tbl->setTitle($lng->txt("obj_trac").": ".$lng->txt("vm_times_of_day"),0,0);
1045  $tbl->setColumnWidth(array("30%", "10%", "*"));
1046  }
1047  else
1048  {
1049  $tbl->setTitle($lng->txt("obj_trac").": ".$lng->txt("vm_days_of_period"),0,0);
1050  $tbl->setColumnWidth(array("15%", "10%", "*"));
1051  }
1052 
1053  if($_POST["stat"]=='h')
1054  {
1055  $num = 24;
1056  $tbl->setMaxCount($num);
1057  }
1058  else
1059  {
1060  $num = $this->numDay($from,$to);
1061  $from1 = $this->addDay($from);
1062  $tbl->setMaxCount($num);
1063  }
1064  # $tbl->setStyle("table", "std");
1065 
1066  // contition
1067  $condition = $this->getCondition();
1068 
1069  if($_POST["stat"]=='h') //hours of day
1070  {
1071  $searchTermsCondition = $this->getSearchTermsCondition();
1072  $time = $this->selectTime($from,$to,$condition,$searchTermsCondition,$objectCondition);
1073  $max = 0;
1074  for($i=0;$i<24;$i++)
1075  {
1076  $k = $i+1;
1077 
1078  // count number of accesses in hour $i
1079  $cou = 0;
1080  for($j=0;$j<count($time);$j++)
1081  {
1082  $time1 = strtotime($time[$j][0]);
1083  $day = date("d",$time1);
1084  $month = date("m",$time1);
1085  $year = date("Y",$time1);
1086  $hour = date("H",$time1);
1087  $min = date("i",$time1);
1088  $sec = date("s",$time1);
1089  $numb = date("H",mktime($hour,$min,$sec,$month,$day,$year));
1090  $numb = intval($numb);
1091  if($numb >=$i and $numb <$k)
1092  {
1093  $cou=$cou+1;
1094  }
1095  }
1096  $count[$i] = $cou;
1097  $max = ($cou > $max) ? $cou : $max;
1098  }
1099 
1100  for($i=0;$i<24;$i++)
1101  {
1102  $k = $i+1;
1103  unset($data);
1104  $data[0] = ($i < 10 ? "0".$i : $i).":00:00 ~ ".($k < 10 ? "0".$k : $k).":00:00";
1105  $data[1] = $count[$i];
1106  $width = ($max > 0)
1107  ? round($count[$i] / $max * 100)
1108  : 0;
1109  $data[2] = "<img src=\"".ilUtil::getImagePath("ray.gif")."\" border=\"0\" ".
1110  "width=\"".$width."\" height=\"10\"/>";
1111 
1112  $css_row = $i%2==0?"tblrow1":"tblrow2";
1113  foreach ($data as $key => $val)
1114  {
1115  $tplTable->setCurrentBlock("text");
1116  $tplTable->setVariable("TEXT_CONTENT", $val);
1117  $tplTable->parseCurrentBlock();
1118  $tplTable->setCurrentBlock("table_cell");
1119  $tplTable->parseCurrentBlock();
1120  }
1121  $tplTable->setCurrentBlock("tbl_content");
1122  $tplTable->setVariable("CSS_ROW", $css_row);
1123  $tplTable->parseCurrentBlock();
1124  } //for
1125  }
1126  else //day selected
1127  {
1128  $max = 0;
1129  $searchTermsCondition = $this->getSearchTermsCondition();
1130  for($i=0;$i<$num;$i++)
1131  {
1132  $fro[$i] = $from;
1133  $cou[$i] = $this->countNum($from,$from1,$condition,$searchTermsCondition,$objectCondition);
1134  $from = $from1;
1135  $from1 = $this->addDay($from);
1136  $max = ($max > $cou[$i]) ? $max : $cou[$i];
1137  }
1138  for($i=0;$i<$num;$i++)
1139  {
1140  unset($data);
1141  $data[0] = $fro[$i];
1142  $data[1] = $cou[$i];
1143  $width = ($max > 0)
1144  ? round($cou[$i] / $max * 100)
1145  : 0;
1146  $data[2] = "<img src=\"".ilUtil::getImagePath("ray.gif")."\" border=\"0\" ".
1147  "width=\"".$width."\" height=\"10\"/>";
1148 
1149  $css_row = $i%2==0?"tblrow1":"tblrow2";
1150  foreach ($data as $key => $val)
1151  {
1152  $tplTable->setCurrentBlock("text");
1153  $tplTable->setVariable("TEXT_CONTENT", $val);
1154  $tplTable->parseCurrentBlock();
1155  $tplTable->setCurrentBlock("table_cell");
1156  $tplTable->parseCurrentBlock();
1157  }
1158  $tplTable->setCurrentBlock("tbl_content");
1159  $tplTable->setVariable("CSS_ROW", $css_row);
1160  $tplTable->parseCurrentBlock();
1161  } //for
1162  }
1163  }//else
1164 
1165  $tbl->render();
1166  $tpl->setVariable("TRACK_TABLE", $tplTable->get());
1167  unset($tplTable);
1168  unset($tbl);
1169 
1170  }
1171 
1172  // output statistic settings
1173 /* $tpl->setCurrentBlock("adm_content");
1174  $tpl->setVariable("TXT_TIME_PERIOD", $lng->txt("time_segment"));
1175  switch ($_POST["stat"])
1176  {
1177  case "h":
1178  $tpl->setVariable("TXT_STATISTIC", $lng->txt("hours_of_day"));
1179  break;
1180 
1181  case "u":
1182  $tpl->setVariable("TXT_STATISTIC", $lng->txt("user_access"));
1183  break;
1184 
1185  case "d":
1186  $tpl->setVariable("TXT_STATISTIC", $lng->txt("days_of_period"));
1187  break;
1188 
1189  case "o":
1190  $tpl->setVariable("TXT_STATISTIC", $lng->txt("per_object"));
1191  break;
1192  }
1193  $tpl->setVariable("VAL_DATEF", date("Y-m-d", mktime(0,0,0,$monthf,$dayf,$yearf)));
1194  $tpl->setVariable("TXT_SEARCH_TERMS", $lng->txt("search_terms"));
1195  $tpl->setVariable("VAL_SEARCH_TERMS", ilUtil::stripSlashes($_POST["search_terms"]));
1196  $tpl->setVariable("TXT_TO", $lng->txt("to"));
1197  $tpl->setVariable("VAL_DATET", date("Y-m-d", mktime(0,0,0,$montht,$dayt,$yeart)));
1198  $tpl->setVariable("TXT_USER_LANGUAGE", $lng->txt("user_language"));
1199  if ($_POST["language"] == "0")
1200  {
1201  $tpl->setVariable("VAL_LANGUAGE", $lng->txt("any_language"));
1202  }
1203  else
1204  {
1205  $tpl->setVariable("VAL_LANGUAGE", $lng->txt("lang_".$_POST["language"]));
1206  }
1207  $tpl->setVariable("TXT_TRACKED_OBJECTS", $lng->txt("tracked_objects"));
1208  if ($_POST[$_POST["object_type"]] != 0)
1209  {
1210  $tpl->setVariable("VAL_TRACKED_OBJECTS",
1211  ilObject::_lookupTitle($_POST[$_POST["object_type"]]));
1212  }
1213  else
1214  {
1215  $tpl->setVariable("VAL_TRACKED_OBJECTS",
1216  $lng->txt("all_".$_POST["object_type"]."s"));
1217  }
1218  $tpl->parseCurrentBlock();*/
1219  }
1220 
1224  function getCondition()
1225  {
1226  $lang_cond = $this->getLanguageCondition();
1227  //echo ":$lang_cond:";
1228  if ($lang_cond == "")
1229  {
1230  $this->setConditions($this->getObjectCondition());
1231  return $this->getObjectCondition();
1232  }
1233  else
1234  {
1235  $this->setConditions($lang_cond." AND ".$this->getObjectCondition());
1236  return $lang_cond." AND ".$this->getObjectCondition();
1237  }
1238  }
1239 
1240 
1245  {
1246  global $ilDB;
1247 
1248  $type = $_POST["object_type"];
1249  $condition = "";
1250  if($_POST["object_type"]=="lm")
1251  {
1252  if($_POST["author"]=="0")
1253  {
1254  return " acc_obj_type = 'lm'";
1255  }
1256  elseif($_POST["lm"]=="0" or $_POST["lm"]=="")
1257  {
1258  if (is_array($authors = ilObjUserTracking::allAuthor("usr","lm")))
1259  {
1260  foreach ($authors as $author)
1261  {
1262  if($author["title"]==$_POST["author"])
1263  {
1264  if (is_array($lms = ilObjUserTracking::authorLms($author["obj_id"],"lm")))
1265  {
1266  foreach ($lms as $lm)
1267  {
1268  $condition = $condition." or acc_obj_id = ".$lm["obj_id"];
1269  }
1270  }
1271  }
1272  }
1273  }
1274  return " ( 0 ".$condition." ) ";
1275  }
1276  else
1277  {
1278  $condition.= " acc_obj_id = ".ilObjUserTracking::getObjId($_POST["lm"],$type);
1279  return $condition;
1280  }
1281 
1282  }
1283  else if($_POST["object_type"]=="htlm")
1284  {
1285  if($_POST["author"]=="0")
1286  {
1287  return " acc_obj_type = 'htlm'";
1288  }
1289  elseif($_POST["htlm"]=="0" or $_POST["htlm"]=="")
1290  {
1291  if (is_array($authors = ilObjUserTracking::allAuthor("usr","htlm")))
1292  {
1293  foreach ($authors as $author)
1294  {
1295  if($author["title"]==$_POST["author"])
1296  {
1297  if (is_array($htlms = ilObjUserTracking::authorLms($author["obj_id"],"htlm")))
1298  {
1299  foreach ($htlms as $htlm)
1300  {
1301  $condition = $condition." or acc_obj_id = ".$htlm["obj_id"];
1302  }
1303  }
1304  }
1305  }
1306  }
1307  return " ( 0 ".$condition." ) ";
1308  }
1309  else
1310  {
1311  $condition.= " acc_obj_id = ".ilObjUserTracking::getObjId($_POST["htlm"],$type);
1312  return $condition;
1313  }
1314 
1315  }
1316  else
1317  {
1318  if($_POST["author1"]=="0")
1319  {
1320  return " acc_obj_type = 'tst'";
1321  }
1322  elseif($_POST["tst"]=="0" or $_POST["tst"]=="")
1323  {
1324  if (is_array($authors = ilObjUserTracking::allAuthor("usr","tst")))
1325  {
1326  foreach ($authors as $author)
1327  {
1328  if($author["title"]==$_POST["author1"])
1329  {
1330  if (is_array($lms = ilObjUserTracking::authorLms($author["obj_id"],"tst")))
1331  {
1332  foreach ($lms as $lm)
1333  {
1334  $condition = $condition." or acc_obj_id = ".$lm["obj_id"];
1335  }
1336  }
1337  }
1338  }
1339  }
1340  return " ( 0 ".$condition." ) ";
1341  }
1342  else
1343  {
1344  $condition.= " acc_obj_id = ".ilObjUserTracking::getObjId($_POST["tst"],$type);
1345  return $condition;
1346  }
1347  }
1348  }
1349 
1354  {
1355  global $ilDB;
1356 
1357  if ($_POST["language"] != "0")
1358  {
1359  return "ut_access.language =".$ilDB->quote($_POST["language"], "text");
1360  }
1361 
1362  return "";
1363  }
1364 
1369  {
1370  global $ilDB;
1371 
1372  if (trim($_POST["search_terms"]) != "")
1373  {
1374  $sub_ret = "";
1375  $terms = explode(" ", $_POST["search_terms"]);
1376  for ($i = 0; $i < count($terms); $i++)
1377  {
1378  if (trim($terms[$i]) != "") $sub_ret .= "oa.title LIKE '%".ilUtil::addSlashes(trim($terms[$i]))."%' OR ";
1379  }
1380  if ($sub_ret != "")
1381  {
1382  return " INNER JOIN object_data oa ON oa.obj_id = acc_obj_id WHERE (".substr($sub_ret, 0, strlen($sub_ret)-4) . ") AND ";
1383  }
1384  }
1385 
1386  return "";
1387  }
1388 
1389  function setConditions($con)
1390  {
1391  $this->conditions = $con;
1392  }
1393  function getConditions()
1394  {
1395  return $this->conditions;
1396  }
1397 
1401  function numDay($from,$to)
1402  {
1403 
1404  $from = strtotime($from);
1405  $to = strtotime($to);
1406 
1407  $dayf = date ("d",$from);
1408  $dayt = date ("d",$to);
1409  $yearf = date ("Y",$from);
1410  $yeart = date ("Y",$to);
1411  $montht = date ("m",$to);
1412  $monthf = date ("m",$from);
1413 
1414 # $ret = ( mktime(0,0,0,$montht,$dayt,$yeart) - mktime(0,0,0,$monthf,$dayf,$yearf))/(3600*24);
1415 # return $ret;
1416 
1417  $from = mktime(12,0,0,$monthf,$dayf,$yearf);
1418  $to = mktime(12,0,0,$montht,$dayt,$yeart);
1419 
1420  $ret = (round(($to - $from) / 86400) + 1);
1421  return $ret;
1422 
1423 # $x0 = gregoriantojd($monthf,$dayf,$yearf);
1424 # $x1 = gregoriantojd($montht,$dayt,$yeart);
1425 # return (($x1 - $x0)+1);
1426  }
1427 
1431  function numHour($from,$to)
1432  {
1433  $from = strtotime($from);
1434  $to = strtotime($to);
1435  $dayf = date ("d",$from);
1436  $dayt = date ("d",$to);
1437  $yearf = date ("Y",$from);
1438  $yeart = date ("Y",$to);
1439  $montht = date ("m",$to);
1440  $monthf = date ("m",$from);
1441  $hourt = date ("h",$to);
1442  $hourf = date ("h",$from);
1443  $ret = (mktime($hourt,0,0,$montht,$dayt,$yeart)-mktime($hourf,0,0,$monthf,$dayf,$yearf))/3600;
1444  $ret = strftime($ret);
1445  return $ret;
1446  }
1447 
1451  function addHour($time)
1452  {
1453  $time = strtotime($time);
1454  $day = date("d",$time);
1455  $month = date("m",$time);
1456  $year = date("Y",$time);
1457  $hour = date("H",$time);
1458  $min = date("i",$time);
1459  $sec = date("s",$time);
1460  $hour = $hour+1;
1461  $ret = date("H:i:s", mktime($hour,$min,$sec,$month,$day,$year));
1462  return $ret;
1463  }
1464 
1468  function addDay($time)
1469  {
1470  $time = strtotime($time);
1471  $day = date("d",$time);
1472  $month = date("m",$time);
1473  $year = date("y",$time);
1474  $min = date("i",$time);
1475  $hour = date("h",$time);
1476  $sec = date("s",$time);
1477  $day = $day + 1;
1478  $ret = date ("Y-m-d", mktime($hour,$min,$sec,$month,$day,$year));
1479  return $ret;
1480  }
1481 
1485  function selectTime($from,$to,$condition,$searchTermsCondition="",$objectCondition="")
1486  {
1487  global $ilDB;
1488 
1489  $q = "SELECT acc_time from ut_access "
1490  .($searchTermsCondition != "" ? $searchTermsCondition : " WHERE ")
1491  ." (acc_time >= ".$ilDB->quote($from." 00:00:00", "timestamp")
1492  ." AND acc_time <= ".$ilDB->quote($to." 23:59:59", "timestamp").")"
1493  ." AND ".$condition
1494  .$objectCondition
1495  ." GROUP BY acc_time";
1496  $res = $this->ilias->db->query($q);
1497  for($i=0;$i<$res->numRows();$i++)
1498  {
1499  $result[$i]=$res->fetchRow();
1500  }
1501  return $result;
1502  }
1503 
1507  function countNum($from,$from1,$condition,$searchTermsCondition="",$objectCondition="")
1508  {
1509  global $ilDB;
1510 
1511  $q = "SELECT id FROM ut_access"
1512  .($searchTermsCondition != "" ? $searchTermsCondition : " WHERE ")
1513  ." (acc_time >= ".$ilDB->quote($from." 00:00:00", "timestamp")
1514  ." AND acc_time <= ".$ilDB->quote($from1." 00:00:00", "timestamp").")"
1515  ." AND ".$condition
1516  .$objectCondition
1517  ." GROUP BY id";
1518  $res = $this->ilias->db->query($q);
1519  return $res->numRows();
1520  }
1521 }
1522 ?>