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