• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Services/Tracking/classes/class.ilObjUserTrackingGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00039 include_once "classes/class.ilObjectGUI.php";
00040 
00041 class ilObjUserTrackingGUI extends ilObjectGUI
00042 {
00047         var $conditions;
00048 
00049         var $tpl = null;
00050         var $ilErr = null;
00051         var $lng = null;
00052         var $ctrl = null;
00053 
00054         function ilObjUserTrackingGUI($a_data,$a_id,$a_call_by_reference)
00055         {
00056                 global $tpl,$ilErr,$lng,$ilCtrl;
00057 
00058                 $this->type = "trac";
00059                 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference, false);
00060 
00061                 $this->tpl =& $tpl;
00062                 $this->ilErr =& $ilErr;
00063                 $this->lng =& $lng;
00064                 $this->lng->loadLanguageModule('trac');
00065 
00066                 $this->ctrl =& $ilCtrl;
00067         }
00068 
00069         function &executeCommand()
00070         {
00071                 $next_class = $this->ctrl->getNextClass();
00072                 $this->ctrl->setReturn($this, "show");
00073                 $this->prepareOutput();
00074 
00075                 switch($next_class)
00076                 {
00077                         case 'ilpermissiongui':
00078                                 include_once("./classes/class.ilPermissionGUI.php");
00079                                 $perm_gui =& new ilPermissionGUI($this);
00080                                 $ret =& $this->ctrl->forwardCommand($perm_gui);
00081                                 break;
00082 
00083                         case 'illearningprogressgui':
00084                                 $this->tabs_gui->setTabActive('learning_progress');
00085                                 include_once("./Services/Tracking/classes/class.ilLearningProgressGUI.php");
00086                                 $lp_gui =& new ilLearningProgressGUI(LP_MODE_ADMINISTRATION);
00087                                 $ret =& $this->ctrl->forwardCommand($lp_gui);
00088                                 break;
00089                                 
00090                         default:
00091                                 $cmd = $this->ctrl->getCmd();
00092                                 if ($cmd == "view" || $cmd == "")
00093                                 {
00094                                         $cmd = "trackingDataQueryForm";
00095                                 }
00096                                 $cmd .= "Object";
00097                                 $this->$cmd();
00098                                 break;
00099                 }
00100                 
00101                 return true;
00102         }
00103         
00104         function getAdminTabs(&$tabs_gui)
00105         {
00106                 $this->getTabs($tabs_gui);
00107         }
00108 
00109         function getTabs(&$tabs_gui)
00110         {
00111                 global $rbacsystem;
00112 
00113                 $this->ctrl->setParameter($this,"ref_id",$this->ref_id);
00114 
00115                 if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
00116                 {
00117                         $tabs_gui->addTarget("tracking_data",
00118                                                                  $this->ctrl->getLinkTarget($this,
00119                                                                                                                         "trackingDataQueryForm"),
00120                                                                  "trackingDataQueryForm",
00121                                                                  get_class($this));
00122                         $tabs_gui->addTarget("settings",
00123                                                                  $this->ctrl->getLinkTarget($this,
00124                                                                                                                         "settings"),
00125                                                                  "settings",
00126                                                                  get_class($this));
00127                         $tabs_gui->addTarget("manage_tracking_data",
00128                                                                  $this->ctrl->getLinkTarget($this,
00129                                                                                                                         "manageData"),
00130                                                                  "manageData",
00131                                                                  get_class($this));
00132 
00133                         if (ilObjUserTracking::_enabledLearningProgress())
00134                         {
00135                                 $tabs_gui->addTarget("learning_progress",
00136                                                                          $this->ctrl->getLinkTargetByClass("illearningprogressgui",
00137                                                                                                                                            "show"),
00138                                                                          "",
00139                                                                          "illearningprogressgui");
00140                         }
00141                         $tabs_gui->addTarget("perm_settings",
00142                                                                  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), 
00143                                                                  array("perm","info","owner"),
00144                                                                  'ilpermissiongui');
00145                 }
00146         }
00147 
00148 
00152         function settingsObject()
00153         {
00154                 global $rbacsystem;
00155 
00156                 if (!$rbacsystem->checkAccess('read',$this->object->getRefId()))
00157                 {
00158                         $ilErr->raiseError($this->lng->txt("msg_no_perm_read_track"),$ilErr->WARNING);
00159                 }
00160 
00161                 $this->tabs_gui->setTabActive('settings');
00162                 
00163                 // Tracking settings
00164                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.trac_settings.html","Services/Tracking");
00165                 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormaction($this));
00166                 
00167                 // some language variables
00168                 $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_trac.gif'));
00169                 $this->tpl->setVariable("ALT_IMG",$this->lng->txt('tracking_settings'));
00170                 $this->tpl->setVariable("TXT_TRACKING_SETTINGS", $this->lng->txt("tracking_settings"));
00171                 $this->tpl->setVariable("TXT_ACTIVATE_TRACKING", $this->lng->txt("activate_tracking"));
00172                 $this->tpl->setVariable("TXT_USER_RELATED_DATA", $this->lng->txt("trac_anonymized"));
00173                 $this->tpl->setVariable("INFO_USER_RELATED_DATA",$this->lng->txt("trac_anonymized_info"));
00174                 $this->tpl->setVariable("TXT_VALID_REQUEST",$this->lng->txt('trac_valid_request'));
00175                 $this->tpl->setVariable("INFO_VALID_REQUEST",$this->lng->txt('info_valid_request'));
00176                 $this->tpl->setVariable("SECONDS",$this->lng->txt('seconds'));
00177 
00178                 #$this->tpl->setVariable("TXT_NUMBER_RECORDS", $this->lng->txt("number_of_records"));
00179                 #$this->tpl->setVariable("NUMBER_RECORDS", $this->object->getRecordsTotal());
00180                 $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
00181 
00182                 $this->__showActivationSelect();
00183                 
00184                 // Anonymized
00185                 if(!$this->object->_enabledUserRelatedData())
00186                 {
00187                         $this->tpl->setVariable("USER_RELATED_CHECKED", " checked=\"1\" ");
00188                 }
00189                 // Max time gap
00190                 $this->tpl->setVariable("VALID_REQUEST",$this->object->getValidTimeSpan());
00191 
00192                 $this->tpl->parseCurrentBlock();
00193 
00194         }
00195 
00199         function saveSettingsObject()
00200         {
00201                 $this->object->setActivationStatus((int) $_POST['act_track']);
00202                 $this->object->enableUserRelatedData((int) !$_POST['user_related']);
00203                 $this->object->setValidTimeSpan($_POST['valid_request']);
00204 
00205                 if(!$this->object->validateSettings())
00206                 {
00207                         sendInfo($this->lng->txt('tracking_time_span_not_valid'));
00208                         $this->settingsObject();
00209 
00210                         return false;
00211                 }
00212                 
00213                 $this->object->updateSettings();
00214                 sendinfo($this->lng->txt("msg_obj_modified"));
00215                 $this->settingsObject();
00216                 
00217                 return true;
00218         }
00219 
00223         function manageDataObject()
00224         {
00225                 global $tpl,$lng,$ilias;
00226 
00227                 // tracking settings
00228                 $tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.tracking_manage_data.html");
00229                 $tpl->setVariable("FORMACTION",$this->ctrl->getFormaction($this,'gateway'));
00230                 $tpl->setVariable("TXT_TRACKING_DATA", $this->lng->txt("tracking_data"));
00231                 $tpl->setVariable("TXT_MONTH", $lng->txt("month"));
00232                 $tpl->setVariable("TXT_NUMBER_OF_ACC", $lng->txt("number_of_accesses"));
00233                 $tpl->setVariable("TXT_DELETE_OLDER", $lng->txt("delete"));
00234                 $overw = $this->object->getMonthTotalOverview();
00235                 foreach($overw as $month)
00236                 {
00237                         $tpl->setCurrentBlock("load_row");
00238                         $rcol = ($rcol != "tblrow1") ? "tblrow1" : "tblrow2";
00239                         $tpl->setVariable("ROWCOL", $rcol);
00240                         $tpl->setVariable("VAL_MONTH", $month["month"]);
00241                         $tpl->setVariable("VAL_NUMBER_OF_ACC", $month["cnt"]);
00242                         $tpl->parseCurrentBlock();
00243                 }
00244                 $tpl->parseCurrentBlock();
00245         }
00246 
00250         function confirmDeletionDataObject()
00251         {
00252                 global $tpl, $lng, $rbacsystem;
00253 
00254                 if (!$rbacsystem->checkAccess('delete',$this->object->getRefId()))
00255                 {
00256                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_delete_track"),$this->ilias->error_obj->WARNING);
00257                 }
00258 
00259                 if (!isset($_POST["month"]))
00260                 {
00261                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00262                 }
00263                 $nr = $this->object->getTotalOlderThanMonth($_POST["month"]);
00264                 $tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.tracking_confirm_data_deletion.html");
00265                 #$tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$_GET["ref_id"].
00266                 #       "&cmd=gateway&month=".$_POST["month"]);
00267                 $this->ctrl->setParameter($this,'month',$_POST['month']);
00268                 $tpl->setVariable("FORMACTION",$this->ctrl->getFormaction($this,'gateway'));
00269 
00270                 $tpl->setVariable("TXT_CONFIRMATION", $this->lng->txt("tracking_data_del_confirm"));
00271                 $tpl->setVariable("TXT_MONTH", $lng->txt("month"));
00272                 $tpl->setVariable("VAL_MONTH", $_POST["month"]);
00273                 $tpl->setVariable("TXT_NUMBER_OF_RECORDS", $lng->txt("number_of_records"));
00274                 $tpl->setVariable("VAL_NUMBER_OF_RECORDS", $nr);
00275                 $tpl->setVariable("TXT_NUMBER_OF_ACC", $lng->txt("number_of_accesses"));
00276                 $tpl->setVariable("TXT_DELETE_DATA", $lng->txt("delete_tr_data"));
00277                 $tpl->setVariable("TXT_CANCEL", $lng->txt("cancel"));
00278         }
00279 
00283         function cancelDeleteDataObject()
00284         {
00285                 sendInfo($this->lng->txt("msg_cancel"),true);
00286 
00287                 #ilUtil::redirect("adm_object.php?ref_id=".$_GET["ref_id"]."&cmd=manageData");
00288 
00289                 $this->ctrl->redirect($this,'manageData');
00290         }
00291 
00295         function deleteDataObject()
00296         {
00297                 global $rbacsystem;
00298                 
00299                 if (!$rbacsystem->checkAccess('read',$this->object->getRefId()))
00300                 {
00301                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_delete_track"),$this->ilias->error_obj->WARNING);
00302                 }
00303 
00304                 $this->object->deleteTrackingDataBeforeMonth($_GET["month"]);
00305 
00306                 sendInfo($this->lng->txt("tracking_data_deleted"),true);
00307                 $this->ctrl->redirect($this,'manageData');
00308 
00309                 #ilUtil::redirect("adm_object.php?ref_id=".$_GET["ref_id"]."&cmd=manageData");
00310         }
00311 
00315         function trackingDataQueryFormObject()
00316         {
00317                 global $tpl;
00318                 $tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.usr_tracking.html");
00319                 $tpl->setVariable("FORM", $this->showForm());
00320         }
00321         
00322         function showForm()
00323         {
00324                 global $lng,$ilias;
00325                 for ($i = 2004; $i <= date("Y"); $i++) $year[] = $i;
00326                 $month = array(1,2,3,4,5,6,7,8,9,10,11,12);
00327                 $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);
00328                 //subject module
00329                 $tpl = new ilTemplate("tpl.tracking_form.html", true, true);
00330                 
00331                 // Tabs gui
00332                 $this->tabs_gui->setTabActive('tracking_data');
00333 
00334                 if (ilObjUserTracking::_enabledUserRelatedData())
00335                 {
00336                         $tpl->setCurrentBlock("user_stat");
00337                         $tpl->setVariable("TXT_VIEW_MODE_U", $lng->txt("vm_access_of_users"));
00338                         if ($_SESSION["il_track_stat"] == "u")
00339                         {
00340                                 $tpl->setVariable("U_SEL", "selected");
00341                         }
00342                         $tpl->parseCurrentBlock();
00343                 }
00344 
00345                 //$tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00346                 #$tpl->setVariable("SEARCH_ACTION", "adm_object.php?ref_id=".$_GET["ref_id"].
00347                 #       "&cmd=gateway");
00348                 
00349                 $tpl->setVariable("SEARCH_ACTION",$this->ctrl->getFormaction($this,'gateway'));
00350                 $tpl->setVariable("TXT_TRACKING_DATA", $lng->txt("tracking_data"));
00351                 $tpl->setVariable("TXT_SEARCH_TERMS", $lng->txt("search_terms"));
00352                 $tpl->setVariable("VAL_SEARCH_TERMS", ilUtil::prepareFormOutput($_SESSION["il_track_search_terms"], true));
00353                 $tpl->setVariable("TXT_TIME_SEGMENT", $lng->txt("time_segment"));
00354                 $tpl->setVariable("TXT_VIEW_MODE", $lng->txt("view_mode"));
00355                 $tpl->setVariable("TXT_VIEW_MODE_H", $lng->txt("vm_times_of_day"));
00356                 $tpl->setVariable("TXT_VIEW_MODE_D", $lng->txt("vm_days_of_period"));
00357                 $tpl->setVariable("TXT_USER_LANGUAGE",$lng->txt("user_language"));
00358                 $tpl->setVariable("TXT_LM",$lng->txt("lm"));
00359                 $tpl->setVariable("TXT_HTLM",$lng->txt("htlm"));
00360 #               $tpl->setVariable("TXT_TST",$lng->txt("test"));
00361                 $tpl->setVariable("TXT_SHOW_TR_DATA",$lng->txt("query_data"));
00362                 $tpl->setVariable("TXT_TRACKED_OBJECTS",$lng->txt("tracked_objects"));
00363                 $tpl->setVariable("TXT_FILTER_AREA",$lng->txt("trac_filter_area"));
00364                 $tpl->setVariable("TXT_CHANGE",$lng->txt("change"));
00365 
00366                 $languages = $lng->getInstalledLanguages();
00367 
00368                 // get all learning modules
00369                 // $lms = ilObject::_getObjectsDataForType("lm", true);
00370 /*              $authors = ilObjUserTracking::allAuthor("usr","lm");
00371                 if(count($authors)>0)
00372                 {
00373                         $tpl->setCurrentBlock("javascript");
00374                         $tpl->setVariable("ALL_LMS", $this->lng->txt("all_lms"));
00375                         foreach ($authors as $author)
00376                         {
00377                                 $lms = ilObjUserTracking::authorLms($author["obj_id"],"lm");
00378                                 //echo count($lms);
00379                                 foreach ($lms as $lm)
00380                                 {
00381                                         $tpl->setCurrentBlock("select_value");
00382                                         $tpl->setVariable("VALUE", $author["title"]);
00383                                         $tpl->setVariable("LMVALUE", $lm["title"]);
00384                                         $tpl->parseCurrentBlock();
00385                                 }
00386                         
00387                         }
00388                         $tpl->parseCurrentBlock();
00389                 }
00390                 $authors1 = ilObjUserTracking::allAuthor("usr","tst");
00391                 if(count($authors1)>0)
00392                 {
00393                         $tpl->setCurrentBlock("javascript1");
00394                         $tpl->setVariable("ALL_TSTS", $this->lng->txt("all_tsts"));
00395                         foreach ($authors1 as $author1)
00396                         {
00397                                 $tsts = ilObjUserTracking::authorLms($author1["obj_id"],"tst");
00398                                 foreach ($tsts as $tst)
00399                                 {
00400                                         $tpl->setCurrentBlock("select_value1");
00401                                         $tpl->setVariable("VALUE1", $author1["title"]);
00402                                         $tpl->setVariable("TSTVALUE", $tst["title"]);
00403                                         $tpl->parseCurrentBlock();
00404                                 }
00405                         }
00406                         $tpl->parseCurrentBlock();
00407                 }*/
00408 
00409                 if ($_SESSION["il_track_yearf"] == "") $_SESSION["il_track_yearf"] = date("Y");
00410 
00411                 if ($_SESSION["il_track_yeart"] == "") $_SESSION["il_track_yeart"] = date("Y");
00412                 if ($_SESSION["il_track_montht"] == "") $_SESSION["il_track_montht"] = date("m");
00413                 if ($_SESSION["il_track_dayt"] == "") $_SESSION["il_track_dayt"] = date("d");
00414 
00415                 foreach($year as $key)
00416                 {
00417                         $tpl->setCurrentBlock("fromyear_selection");
00418                         $tpl->setVariable("YEARFR", $key);
00419                         $tpl->setVariable("YEARF", $key);
00420                         if ($_SESSION["il_track_yearf"] == $key)
00421                         {
00422                                 $tpl->setVariable("YEARF_SEL", " selected=\"1\" ");
00423                         }
00424                         $tpl->parseCurrentBlock();
00425                 }
00426                 foreach($month as $key)
00427                 {
00428                         $tpl->setCurrentBlock("frommonth_selection");
00429                         $tpl->setVariable("MONTHFR", $key);
00430                         $tpl->setVariable("MONTHF", $key);
00431                         if ($_SESSION["il_track_monthf"] == $key)
00432                         {
00433                                 $tpl->setVariable("MONTHF_SEL", " selected=\"1\" ");
00434                         }
00435                         $tpl->parseCurrentBlock();
00436                 }
00437                 foreach($day as $key)
00438                 {
00439                         $tpl->setCurrentBlock("fromday_selection");
00440                         $tpl->setVariable("DAYFR", $key);
00441                         $tpl->setVariable("DAYF", $key);
00442                         if ($_SESSION["il_track_dayf"] == $key)
00443                         {
00444                                 $tpl->setVariable("DAYF_SEL", " selected=\"1\" ");
00445                         }
00446                         $tpl->parseCurrentBlock();
00447                 }
00448                 foreach($day as $key)
00449                 {
00450                         $tpl->setCurrentBlock("today_selection");
00451                         $tpl->setVariable("DAYTO", $key);
00452                         $tpl->setVariable("DAYT", $key);
00453                         if ($_SESSION["il_track_dayt"] == $key)
00454                         {
00455                                 $tpl->setVariable("DAYT_SEL", " selected=\"1\" ");
00456                         }
00457                         $tpl->parseCurrentBlock();
00458                 }
00459                 foreach($month as $key)
00460                 {
00461                         $tpl->setCurrentBlock("tomonth_selection");
00462                         $tpl->setVariable("MONTHTO", $key);
00463                         $tpl->setVariable("MONTHT", $key);
00464                         if ($_SESSION["il_track_montht"] == $key)
00465                         {
00466                                 $tpl->setVariable("MONTHT_SEL", " selected=\"1\" ");
00467                         }
00468                         $tpl->parseCurrentBlock();
00469                 }
00470                 foreach($year as $key)
00471                 {
00472                         $tpl->setCurrentBlock("toyear_selection");
00473                         $tpl->setVariable("YEARTO", $key);
00474                         $tpl->setVariable("YEART", $key);
00475                         if ($_SESSION["il_track_yeart"] == $key)
00476                         {
00477                                 $tpl->setVariable("YEART_SEL", " selected=\"1\" ");
00478                         }
00479                         $tpl->parseCurrentBlock();
00480                 }
00481                 // language selection
00482                 $tpl->setCurrentBlock("language_selection");
00483                 $tpl->setVariable("LANG", $lng->txt("any_language"));
00484                 $tpl->setVariable("LANGSHORT", "0");
00485                 $tpl->parseCurrentBlock();
00486                 foreach ($languages as $lang_key)
00487                 {
00488                         $tpl->setCurrentBlock("language_selection");
00489                         $tpl->setVariable("LANG", $lng->txt("lang_".$lang_key));
00490                         $tpl->setVariable("LANGSHORT", $lang_key);
00491                         if ($_SESSION["il_track_language"] == $lang_key)
00492                         {
00493                                 $tpl->setVariable("LANG_SEL", " selected=\"1\" ");
00494                         }
00495                         $tpl->parseCurrentBlock();
00496                 }
00497 
00498                 // statistic type
00499                 if (!in_array($_SESSION["il_track_stat"], array("d", "h", "o", "u"))) $_SESSION["il_track_stat"] = "d";
00500 
00501                 if ($_SESSION["il_track_stat"] == "d")
00502                 {
00503                         $tpl->setVariable("D_SEL", "selected");
00504                 }
00505                 elseif ($_SESSION["il_track_stat"] == "h")
00506                 {
00507                         $tpl->setVariable("H_SEL", "selected");
00508                 }
00509                 
00510                 // tracked object type
00511                 $tpl->setVariable(strtoupper($_SESSION["il_object_type"])."_SEL", "selected");
00512 
00513                 // author selection
00514 /*              $tpl->setCurrentBlock("author_selection");
00515                 $tpl->setVariable("AUTHOR", 0);
00516                 $tpl->setVariable("AUTHOR_SELECT", $this->lng->txt("all_authors"));
00517                 $tpl->parseCurrentBlock();
00518                 foreach ($authors as $author)
00519                 {
00520                         $tpl->setCurrentBlock("author_selection");
00521                         $tpl->setVariable("AUTHOR", $author["title"]);
00522                         $tpl->setVariable("AUTHOR_SELECT", $author["title"]);
00523                         if ($_SESSION["il_track_author"] == $author["title"])
00524                         {
00525                                 $tpl->setVariable("AUTHOR_SEL", " selected=\"1\" ");
00526                         }
00527                         $tpl->parseCurrentBlock();
00528                 }
00529                 $tpl->setCurrentBlock("author_selection_tst");
00530                 $tpl->setVariable("AUTHOR1", 0);
00531                 $tpl->setVariable("AUTHOR1_SELECT", $this->lng->txt("all_authors"));
00532                 $tpl->parseCurrentBlock();
00533                 foreach ($authors1 as $author1)
00534                 {
00535                         $tpl->setCurrentBlock("author_selection_tst");
00536                         $tpl->setVariable("AUTHOR1", $author1["title"]);
00537                         $tpl->setVariable("AUTHOR1_SELECT", $author1["title"]);
00538                         if ($_SESSION["il_track_author1"] == $author1["title"])
00539                         {
00540                                 $tpl->setVariable("AUTHOR1_SEL", " selected=\"1\" ");
00541                         }
00542                         $tpl->parseCurrentBlock();
00543                 }
00544                 //test module
00545                 
00546                 $result_test = ilObjUserTracking::getTestId($_SESSION["AccountId"]);
00547 
00548                 //$test = $tracking->TestTitle($_SESSION["AccountId"]);
00549 
00550                 $tsts = ilObject::_getObjectsDataForType($type, true);
00551                 $tpl->setCurrentBlock("test_selection");
00552                 $tpl->setVariable("TEST", 0);
00553                 $tpl->setVariable("TEST_SELECT", $this->lng->txt("all_tsts"));
00554                 $tpl->parseCurrentBlock();
00555                 foreach($tsts as $tst)
00556                 {
00557                         $tpl->setCurrentBlock("test_selection");
00558                         $tpl->setVariable("TEST", $tst["id"]);
00559                         $tpl->setVariable("TEST_SELECT", $tst["title"]." [".$tst["id"]."]");
00560                         $tpl->parseCurrentBlock();
00561                 }*/
00562                 
00563                 return $tpl->get();
00564 
00565         }
00566 
00570         function outputTrackingDataObject()
00571         {
00572                 global $tpl,$lng,$ilias,$ilSetting;
00573 
00574                 $TYPES = array(
00575                         'lm' => $lng->txt("lm"),
00576                         'htlm' => $lng->txt("htlm"),
00577                         'tst' => $lng->txt("test")
00578                 );
00579 
00580                 include_once "./classes/class.ilTableGUI.php";
00581 
00582                 if(!in_array($_POST["stat"], array("d", "h", "o", "u")))
00583                 {
00584                         $_POST["stat"] = "d";
00585                 }
00586                 if ($_POST["author"] == "") $_POST["author"] = "0";
00587                 if ($_POST["author1"] == "") $_POST["author1"] = "0";
00588  
00589                 // save selected values in session
00590                 $_SESSION["il_track_search_terms"] = ilUtil::stripSlashes($_POST["search_terms"]);
00591                 $_SESSION["il_track_yearf"] = $_POST["yearf"];
00592                 $_SESSION["il_track_yeart"] = $_POST["yeart"];
00593                 $_SESSION["il_track_monthf"] = $_POST["monthf"];
00594                 $_SESSION["il_track_montht"] = $_POST["montht"];
00595                 $_SESSION["il_track_dayf"] = $_POST["dayf"];
00596                 $_SESSION["il_track_dayt"] = $_POST["dayt"];
00597                 $_SESSION["il_track_stat"] = $_POST["stat"];
00598                 $_SESSION["il_track_language"] = $_POST["language"];
00599                 $_SESSION["il_track_author"] = $_POST["author"];
00600                 $_SESSION["il_track_author1"] = $_POST["author1"];
00601                 $_SESSION["il_track_lm"] = $_POST["lm"];
00602                 $_SESSION["il_track_htlm"] = $_POST["htlm"];
00603                 $_SESSION["il_track_tst"] = $_POST["tst"];
00604                 $_SESSION["il_object_type"] = $_POST["object_type"];
00605 
00606                 $yearf = $_POST["yearf"];
00607                 $monthf = $_POST["monthf"];
00608                 $dayf = $_POST["dayf"];
00609                 $yeart = $_POST["yeart"];
00610                 $montht= $_POST["montht"];
00611                 $dayt = $_POST["dayt"];
00612                 $from = date("Y-m-d", mktime(12, 0, 0, $monthf, $dayf, $yearf));
00613                 $to = date("Y-m-d", mktime(12, 0, 0, $montht, $dayt, $yeart));
00614 
00615                 if(($yearf > $yeart)or($yearf==$yeart and $monthf>$montht)or($yearf==$yeart and $monthf==$montht and $dayf>$dayt))
00616                 {
00617                         $this->ilias->raiseError($lng->txt("msg_err_search_time"),
00618                                 $this->ilias->error_obj->MESSAGE);
00619                 }
00620 
00621                 $condition = $this->getCondition()." and acc_time >= '".$from." 00:00:00' and acc_time <= '".$to." 23:59:59'";
00622 
00623                 /*
00624                 if($_POST["stat"]!='h' and $_POST["stat"]!='d')
00625                 {
00626                         $this->ilias->raiseError($lng->txt("msg_no_search_time"),
00627                                 $this->ilias->error_obj->MESSAGE);
00628                 }*/
00629 
00630                 $tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.tracking_result.html");
00631                 $tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00632 
00633                 $tpl->setVariable("FORM", $this->showForm());
00634 
00635                 $objectCondition = "";
00636 
00637                 if (($max_acc_objects = $this->object->countResults($condition)) == 0)
00638                 {
00639                         $this->ilias->raiseError($lng->txt("msg_no_search_result"),
00640                                 $this->ilias->error_obj->MESSAGE);
00641                 }
00642 
00643                 $max_hits = $ilias->getSetting('search_max_hits', 50);
00644 
00645                 if ($_POST["search_terms"] != "")
00646                 {
00647                         $tplTable =& new ilTemplate("tpl.table.html", true, true);
00648                         $tplTable->addBlockFile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
00649         
00650                         $tbl = new ilTableGUI(0, false);
00651                         $tbl->setTemplate($tplTable);
00652                         
00653                         $searchTermsCondition = $this->getSearchTermsCondition();
00654                         $acc_object = $this->object->getAccessTotalPerObj($condition,$searchTermsCondition);
00655                         
00656                         $max_acc_objects = count($acc_object);
00657 
00658                         if ($max_acc_objects < 1)
00659                         {
00660                                 $this->ilias->raiseError($lng->txt("msg_no_search_result"),
00661                                         $this->ilias->error_obj->MESSAGE);
00662                         }
00663                         else
00664                         {
00665                                 $info = sprintf($lng->txt("info_found_objects"), $TYPES[$_POST["object_type"]]);
00666 
00667                                 if ($max_hits < $max_acc_objects)
00668                                 {
00669                                         $info .= " ".sprintf($lng->txt("found_too_much_objects"), $max_hits);
00670                                         unset($tmp);
00671                                         for ($i = 0; $i < count($acc_object) && $i < $max_hits; $i++)
00672                                         {
00673                                                 $tmp[$i] = $acc_object[$i];
00674                                         }
00675                                         $acc_object = $tmp;
00676                                         $max_acc_objects = $max_hits;
00677                                 }
00678 
00679                                 $tpl->setVariable("INFO", $info);
00680                         }
00681 
00682                         $tbl->setTitle($lng->txt("found_objects"),0,0);
00683 #                       if(($_POST["object_type"]=="lm" and $_POST["author"] == "0") or ($_POST["object_type"]=="tst" and $_POST["author1"] == "0"))
00684 #                       {
00685                                 $title_new = array("author", "subject", "total_dwell_time", "count","");        
00686                                 $tbl->setColumnWidth(array("20%", "30%", "20%", "10%", "*"));
00687 #                       }
00688 #                       else
00689 #                       {
00690 #                               $title_new = array("subject", "count","");
00691 #                               $tbl->setColumnWidth(array("30%", "10%", "*"));
00692 #                       }
00693                         foreach ($title_new as $val)
00694                         {
00695                                 $header_names[] = $lng->txt($val);
00696                         }
00697                         $tbl->disable("sort");
00698                         $tbl->setHeaderNames($header_names);
00699                         $tbl->setMaxCount($max_acc_objects);
00700         #                       $tbl->setStyle("table", "std");
00701         
00702                         $max = 0;
00703                         unset($ids);
00704                         for ($i = 0; $i < count($acc_object); $i++)
00705                         {
00706                                 $max = ($max > $acc_object[$i]["cnt"]) ? $max : $acc_object[$i]["cnt"];
00707                                 $ids[$i] = $acc_object[$i]["id"];
00708                         }
00709                         if (is_array($ids))
00710                         {
00711                                 $objectCondition = " AND acc_obj_id IN (".implode(",", $ids).") ";
00712                         }
00713         
00714                         for ($i = 0; $i < count($acc_object); $i++)
00715                         {
00716                                 unset($data);
00717 #                               if(($_POST["object_type"]=="lm" and $_POST["author"]=="0") or ($_POST["object_type"]=="tst" and $_POST["author1"]=="0"))
00718 #                               {
00719                                         $data[0] = $acc_object[$i]["author"];
00720                                         $data[1] = $acc_object[$i]["title"];
00721                                         $data[2] = ilFormat::_secondsToString($acc_object[$i]["duration"]);
00722                                         $data[3] = $acc_object[$i]["cnt"];
00723                                         $width = ($max > 0)
00724                                                 ? round($data[3] / $max * 100)
00725                                                 : 0;
00726                                         $data[4] = "<img src=\"".ilUtil::getImagePath("ray.gif")."\" border=\"0\" ".
00727                                                 "width=\"".$width."\" height=\"10\"/>";
00728 /*                              }
00729                                 else
00730                                 {
00731                                         $data[0] = $obj["title"];
00732                                         $data[1] = $obj["cnt"];
00733                                         $width = ($max > 0)
00734                                                 ? round($data[1] / $max * 100)
00735                                                 : 0;
00736                                         $data[2] = "<img src=\"".ilUtil::getImagePath("ray.gif")."\" border=\"0\" ".
00737                                                 "width=\"".$width."\" height=\"10\"/>";
00738                                 }*/
00739                                 $css_row = $i%2==0?"tblrow1":"tblrow2";
00740                                 foreach ($data as $key => $val)
00741                                 {
00742                                         if($val=="")
00743                                         {
00744                                                 $val=0;
00745                                         }
00746                                         $tplTable->setCurrentBlock("text");
00747                                         $tplTable->setVariable("TEXT_CONTENT", $val);
00748                                         $tplTable->parseCurrentBlock();
00749                                         $tplTable->setCurrentBlock("table_cell");
00750                                         $tplTable->parseCurrentBlock();
00751                                 } //foreach
00752                                 $tplTable->setCurrentBlock("tbl_content");
00753                                 $tplTable->setVariable("CSS_ROW", $css_row);
00754                                 $tplTable->parseCurrentBlock();
00755                         } //for
00756         
00757                         $tbl->render();
00758                         $tpl->setVariable("OBJECTS_TABLE", $tplTable->get());
00759                         $tpl->setVariable("TXT_INFO_DWELL_TIME", $lng->txt("info_dwell_time"));
00760                         unset($tplTable);
00761                         unset($tbl);
00762                 }
00763                 else
00764                 {
00765                         $tpl->setVariable("INFO", sprintf($lng->txt("info_all_objects"), $TYPES[$_POST["object_type"]]));
00766                 }
00767                 
00768                 if ($max_acc_objects > 0)
00769                 {
00770 
00771                         $tplTable =& new ilTemplate("tpl.table.html", true, true);
00772                         $tplTable->addBlockFile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
00773         
00774                         $tbl = new ilTableGUI(0, false);
00775                         $tbl->setTemplate($tplTable);
00776         
00777                         // user access statistic
00778                         if($_POST["stat"] == "u")       // user access
00779                         {
00780                                 if($_POST["mode"] == "user")
00781                                 {
00782                                         $tpl->setCurrentBlock("user_mode");
00783                                         #$tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$_GET["ref_id"].
00784                                         #"&cmd=gateway");
00785                                         $tpl->setVariable("FORMACTION",$this->ctrl->getFormaction($this,'gateway'));
00786                                         if($_POST["object_type"]=="lm")
00787                                         {
00788                                                 $tpl->setVariable("AUTHOR", "author");
00789                                                 $tpl->setVariable("AUTHORS", $_POST["author"]);
00790                                                 $tpl->setVariable("OBJECT", "lm");
00791                                                 $tpl->setVariable("OBJECTS", $_POST["lm"]);
00792                                         }
00793                                         else if($_POST["object_type"]=="htlm")
00794                                         {
00795                                                 $tpl->setVariable("AUTHOR", "author");
00796                                                 $tpl->setVariable("AUTHORS", $_POST["author"]);
00797                                                 $tpl->setVariable("OBJECT", "htlm");
00798                                                 $tpl->setVariable("OBJECTS", $_POST["htlm"]);
00799                                         }
00800                                         else
00801                                         {
00802                                                 $tpl->setVariable("AUTHOR", "author1");
00803                                                 $tpl->setVariable("AUTHORS", $_POST["author1"]);
00804                                                 $tpl->setVariable("OBJECT", "tst");
00805                                                 $tpl->setVariable("OBJECTS", $_POST["tst"]);
00806                                         }
00807                                         $tpl->setVariable("YEARF",$_POST["yearf"]);
00808                                         $tpl->setVariable("MONTHF",$_POST["monthf"]);
00809                                         $tpl->setVariable("DAYF",$_POST["dayf"]);
00810                                         $tpl->setVariable("YEART",$_POST["yeart"]);
00811                                         $tpl->setVariable("MONTHT",$_POST["montht"]);
00812                                         $tpl->setVariable("DAYT",$_POST["dayt"]);
00813                                         $tpl->setVariable("LAN", $_POST["language"]);
00814                                         $tpl->setVariable("TYPE", $_POST["object_type"]);
00815                                         $tpl->setVariable("SEARCH_TERMS", ilUtil::prepareFormOutput($_POST["search_terms"]));
00816                                         $tpl->setVariable("FROM", $from);
00817                                         $tpl->setVariable("TO", $to);
00818                                         $tpl->setVariable("TXT_SHOW_USER_DATA", $lng->txt("user_statistics"));
00819                                         $tpl->parseCurrentBlock();
00820         
00821                                         $title_new = array("user","client_ip","language","object","time");
00822                                         $condition = $this->getConditions()." and acc_time >= '".$from." 00:00:00' and acc_time <= '".$to." 23:59:59'";
00823                                         $searchTermsCondition = $this->getSearchTermsCondition();
00824                                         $user_acc = $this->object->getAccessPerUserDetail($condition, $searchTermsCondition, $objectCondition);
00825                                         $this->maxcount = count($user_acc);
00826                                         if ($this->maxcount < 1)
00827                                         {
00828                                                 $this->ilias->raiseError($lng->txt("msg_no_search_result"),
00829                                                         $this->ilias->error_obj->MESSAGE);
00830                                         }
00831         
00832 #                                       $tbl->setTitle($lng->txt("search_result"),0,0);
00833                                         $tbl->setTitle($lng->txt("obj_trac").": ".$lng->txt("vm_access_of_users")." [".$lng->txt("details")."]",0,0);
00834                                         unset($header_names);
00835                                         foreach ($title_new as $val)
00836                                         {
00837                                                 $header_names[] = $lng->txt($val);
00838                                         }
00839                                         $tbl->disable("sort");
00840         
00841                                         $tbl->setHeaderNames($header_names);
00842                                         $tbl->setColumnWidth(array("20%", "15%", "15%", "30%", "*"));
00843                                         $tbl->setMaxCount($this->maxcount);
00844         #                               $tbl->setStyle("table", "std");
00845         
00846                                         $max = 0;
00847         
00848                                         $i = 0;
00849                                         foreach ($user_acc as $user)
00850                                         {
00851                                                 unset($data);
00852                                                 $data[0] = $user["name"];
00853                                                 $data[1] = $user["client_ip"];
00854                                                 $data[2] = $user["language"];
00855                                                 $data[3] = $user["acc_obj_id"];
00856                                                 $data[4] = $user["acc_time"];
00857                                                 $css_row = $i%2==0?"tblrow1":"tblrow2";
00858                                                 foreach ($data as $key => $val)
00859                                                 {
00860                                                         if($val=="")
00861                                                         {
00862                                                                 $val=0;
00863                                                         }
00864                                                         $tplTable->setCurrentBlock("text");
00865                                                         $tplTable->setVariable("TEXT_CONTENT", $val);
00866                                                         $tplTable->parseCurrentBlock();
00867                                                         $tplTable->setCurrentBlock("table_cell");
00868                                                         $tplTable->parseCurrentBlock();
00869                                                 } //foreach
00870                                                 $tplTable->setCurrentBlock("tbl_content");
00871                                                 $tplTable->setVariable("CSS_ROW", $css_row);
00872                                                 $tplTable->parseCurrentBlock();
00873                                                 $i++;
00874                                         } //for
00875                                 }
00876                                 else
00877                                 {
00878                                         $tpl->setCurrentBlock("user_mode");
00879                                         #$tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$_GET["ref_id"].
00880                                         #"&cmd=gateway");
00881                                         $tpl->setVariable("FORMACTION",$this->ctrl->getFormaction($this,'gateway'));
00882                                         if($_POST["object_type"]=="lm")
00883                                         {
00884                                                 $tpl->setVariable("AUTHOR", "author");
00885                                                 $tpl->setVariable("AUTHORS", $_POST["author"]);
00886                                                 $tpl->setVariable("OBJECT", "lm");
00887                                                 $tpl->setVariable("OBJECTS", $_POST["lm"]);
00888                                         }
00889                                         else if($_POST["object_type"]=="htlm")
00890                                         {
00891                                                 $tpl->setVariable("AUTHOR", "author");
00892                                                 $tpl->setVariable("AUTHORS", $_POST["author"]);
00893                                                 $tpl->setVariable("OBJECT", "htlm");
00894                                                 $tpl->setVariable("OBJECTS", $_POST["htlm"]);
00895                                         }
00896                                         else
00897                                         {
00898                                                 $tpl->setVariable("AUTHOR", "author1");
00899                                                 $tpl->setVariable("AUTHORS", $_POST["author1"]);
00900                                                 $tpl->setVariable("OBJECT", "tst");
00901                                                 $tpl->setVariable("OBJECTS", $_POST["tst"]);
00902                                         }
00903                                         $tpl->setVariable("YEARF",$_POST["yearf"]);
00904                                         $tpl->setVariable("MONTHF",$_POST["monthf"]);
00905                                         $tpl->setVariable("DAYF",$_POST["dayf"]);
00906                                         $tpl->setVariable("YEART",$_POST["yeart"]);
00907                                         $tpl->setVariable("MONTHT",$_POST["montht"]);
00908                                         $tpl->setVariable("DAYT",$_POST["dayt"]);
00909                                         $tpl->setVariable("USER", "user");
00910                                         $tpl->setVariable("LAN", $_POST["language"]);
00911                                         $tpl->setVariable("TYPE", $_POST["object_type"]);
00912                                         $tpl->setVariable("SEARCH_TERMS", ilUtil::prepareFormOutput($_POST["search_terms"]));
00913                                         $tpl->setVariable("FROM", $from);
00914                                         $tpl->setVariable("TO", $to);
00915                                         $tpl->setVariable("TXT_SHOW_USER_DATA", $lng->txt("user_detail"));
00916                                         $tpl->parseCurrentBlock();
00917                                         $title_new = array("user", "count", "");
00918         
00919                                         $searchTermsCondition = $this->getSearchTermsCondition();
00920                                         $user_acc = $this->object->getAccessTotalPerUser($condition, $searchTermsCondition, $objectCondition);
00921         
00922                                         $this->maxcount = count($user_acc);
00923         
00924                                         // check if result is given
00925                                         if ($this->maxcount < 1)
00926                                         {
00927                                                 $this->ilias->raiseError($lng->txt("msg_no_search_result"),
00928                                                         $this->ilias->error_obj->MESSAGE);
00929                                         }
00930         
00931 #                                       $tbl->setTitle($lng->txt("search_result"),0,0);
00932                                         $tbl->setTitle($lng->txt("obj_trac").": ".$lng->txt("vm_access_of_users"),0,0);
00933                                         unset($header_names);
00934                                         foreach ($title_new as $val)
00935                                         {
00936                                                 $header_names[] = $lng->txt($val);
00937                                         }
00938                                         $tbl->disable("sort");
00939                                         $tbl->setHeaderNames($header_names);
00940                                         $tbl->setColumnWidth(array("20%", "10%", "*"));
00941                                         $tbl->setMaxCount($this->maxcount);
00942         #                               $tbl->setStyle("table", "std");
00943         
00944                                         $max = 0;
00945                                         foreach ($user_acc as $user)
00946                                         {
00947                                                 $max = ($max > $user["cnt"]) ? $max : $user["cnt"];
00948                                         }
00949         
00950                                         $i = 0;
00951                                         foreach ($user_acc as $user)
00952                                         {
00953                                                 unset($data);
00954                                                 $data[0] = $user["name"];
00955                                                 $data[1] = $user["cnt"];
00956                                                 $width = ($max > 0)
00957                                                         ? round($data[1] / $max * 100)
00958                                                         : 0;
00959                                                 $data[2] = "<img src=\"".ilUtil::getImagePath("ray.gif")."\" border=\"0\" ".
00960                                                         "width=\"".$width."\" height=\"10\"/>";
00961         
00962                                                 $css_row = $i%2==0?"tblrow1":"tblrow2";
00963                                                 foreach ($data as $key => $val)
00964                                                 {
00965                                                         if($val=="")
00966                                                         {
00967                                                                 $val=0;
00968                                                         }
00969                                                         $tplTable->setCurrentBlock("text");
00970                                                         $tplTable->setVariable("TEXT_CONTENT", $val);
00971                                                         $tplTable->parseCurrentBlock();
00972                                                         $tplTable->setCurrentBlock("table_cell");
00973                                                         $tplTable->parseCurrentBlock();
00974                                                 } //foreach
00975                                                 $tplTable->setCurrentBlock("tbl_content");
00976                                                 $tplTable->setVariable("CSS_ROW", $css_row);
00977                                                 $tplTable->parseCurrentBlock();
00978                                                 $i++;
00979                                         } //for
00980                                 }
00981         
00982                         }
00983                         else //user not selected
00984                         {
00985                                 $title_new = array("time", "count", "");
00986         
00987 #                               $tbl->setTitle($lng->txt("obj_trac"),0,0);
00988                                 unset($header_names);
00989                                 foreach ($title_new as $val)
00990                                 {
00991                                         $header_names[] = $lng->txt($val);
00992                                 }
00993                                 $tbl->disable("sort");
00994                                 $tbl->setHeaderNames($header_names);
00995                                 if($_POST["stat"]=='h')         //hours of day
00996                                 {
00997                                         $tbl->setTitle($lng->txt("obj_trac").": ".$lng->txt("vm_times_of_day"),0,0);
00998                                         $tbl->setColumnWidth(array("30%", "10%", "*"));
00999                                 }
01000                                 else
01001                                 {
01002                                         $tbl->setTitle($lng->txt("obj_trac").": ".$lng->txt("vm_days_of_period"),0,0);
01003                                         $tbl->setColumnWidth(array("15%", "10%", "*"));
01004                                 }
01005         
01006                                 if($_POST["stat"]=='h')
01007                                 {
01008                                         $num = 24;
01009                                         $tbl->setMaxCount($num);
01010                                 }
01011                                 else
01012                                 {
01013                                         $num = $this->numDay($from,$to);
01014                                         $from1 = $this->addDay($from);
01015                                         $tbl->setMaxCount($num);
01016                                 }
01017         #                       $tbl->setStyle("table", "std");
01018         
01019                                 // contition
01020                                 $condition = $this->getCondition();
01021         
01022                                 if($_POST["stat"]=='h')         //hours of day
01023                                 {
01024                                         $searchTermsCondition = $this->getSearchTermsCondition();
01025                                         $time = $this->selectTime($from,$to,$condition,$searchTermsCondition,$objectCondition);
01026                                         $max = 0;
01027                                         for($i=0;$i<24;$i++)
01028                                         {
01029                                                 $k = $i+1;
01030         
01031                                                 // count number of accesses in hour $i
01032                                                 $cou = 0;
01033                                                 for($j=0;$j<count($time);$j++)
01034                                                 {
01035                                                         $time1 = strtotime($time[$j][0]);
01036                                                         $day = date("d",$time1);
01037                                                         $month = date("m",$time1);
01038                                                         $year = date("Y",$time1);
01039                                                         $hour = date("H",$time1);
01040                                                         $min = date("i",$time1);
01041                                                         $sec = date("s",$time1);
01042                                                         $numb = date("H",mktime($hour,$min,$sec,$month,$day,$year));
01043                                                         $numb = intval($numb);
01044                                                         if($numb >=$i and $numb <$k)
01045                                                         {
01046                                                                 $cou=$cou+1;
01047                                                         }
01048                                                 }
01049                                                 $count[$i] = $cou;
01050                                                 $max = ($cou > $max) ? $cou : $max;
01051                                         }
01052         
01053                                         for($i=0;$i<24;$i++)
01054                                         {
01055                                                 $k = $i+1;
01056                                                 unset($data);
01057                                                 $data[0] = ($i < 10 ? "0".$i : $i).":00:00  ~  ".($k < 10 ? "0".$k : $k).":00:00";
01058                                                 $data[1] = $count[$i];
01059                                                 $width = ($max > 0)
01060                                                         ? round($count[$i] / $max * 100)
01061                                                         : 0;
01062                                                 $data[2] = "<img src=\"".ilUtil::getImagePath("ray.gif")."\" border=\"0\" ".
01063                                                         "width=\"".$width."\" height=\"10\"/>";
01064         
01065                                                 $css_row = $i%2==0?"tblrow1":"tblrow2";
01066                                                 foreach ($data as $key => $val)
01067                                                 {
01068                                                         $tplTable->setCurrentBlock("text");
01069                                                         $tplTable->setVariable("TEXT_CONTENT", $val);
01070                                                         $tplTable->parseCurrentBlock();
01071                                                         $tplTable->setCurrentBlock("table_cell");
01072                                                         $tplTable->parseCurrentBlock();
01073                                                 }
01074                                                 $tplTable->setCurrentBlock("tbl_content");
01075                                                 $tplTable->setVariable("CSS_ROW", $css_row);
01076                                                 $tplTable->parseCurrentBlock();
01077                                         } //for
01078                                 }
01079                                 else //day selected
01080                                 {
01081                                         $max = 0;
01082                                         $searchTermsCondition = $this->getSearchTermsCondition();
01083                                         for($i=0;$i<$num;$i++)
01084                                         {
01085                                                 $fro[$i] = $from;
01086                                                 $cou[$i] = $this->countNum($from,$from1,$condition,$searchTermsCondition,$objectCondition);
01087                                                 $from = $from1;
01088                                                 $from1 = $this->addDay($from);
01089                                                 $max = ($max > $cou[$i]) ? $max : $cou[$i];
01090                                         }
01091                                         for($i=0;$i<$num;$i++)
01092                                         {
01093                                                 unset($data);
01094                                                 $data[0] = $fro[$i];
01095                                                 $data[1] = $cou[$i];
01096                                                 $width = ($max > 0)
01097                                                         ? round($cou[$i] / $max * 100)
01098                                                         : 0;
01099                                                 $data[2] = "<img src=\"".ilUtil::getImagePath("ray.gif")."\" border=\"0\" ".
01100                                                         "width=\"".$width."\" height=\"10\"/>";
01101         
01102                                                 $css_row = $i%2==0?"tblrow1":"tblrow2";
01103                                                 foreach ($data as $key => $val)
01104                                                 {
01105                                                         $tplTable->setCurrentBlock("text");
01106                                                         $tplTable->setVariable("TEXT_CONTENT", $val);
01107                                                         $tplTable->parseCurrentBlock();
01108                                                         $tplTable->setCurrentBlock("table_cell");
01109                                                         $tplTable->parseCurrentBlock();
01110                                                 }
01111                                                 $tplTable->setCurrentBlock("tbl_content");
01112                                                 $tplTable->setVariable("CSS_ROW", $css_row);
01113                                                 $tplTable->parseCurrentBlock();
01114                                         } //for
01115                                 }
01116                         }//else
01117         
01118                         $tbl->render();
01119                         $tpl->setVariable("TRACK_TABLE", $tplTable->get());
01120                         unset($tplTable);
01121                         unset($tbl);
01122 
01123                 }
01124 
01125                 // output statistic settings
01126 /*              $tpl->setCurrentBlock("adm_content");
01127                 $tpl->setVariable("TXT_TIME_PERIOD", $lng->txt("time_segment"));
01128                 switch ($_POST["stat"])
01129                 {
01130                         case "h":
01131                                 $tpl->setVariable("TXT_STATISTIC", $lng->txt("hours_of_day"));
01132                                 break;
01133 
01134                         case "u":
01135                                 $tpl->setVariable("TXT_STATISTIC", $lng->txt("user_access"));
01136                                 break;
01137 
01138                         case "d":
01139                                 $tpl->setVariable("TXT_STATISTIC", $lng->txt("days_of_period"));
01140                                 break;
01141 
01142                         case "o":
01143                                 $tpl->setVariable("TXT_STATISTIC", $lng->txt("per_object"));
01144                                 break;
01145                 }
01146                 $tpl->setVariable("VAL_DATEF", date("Y-m-d", mktime(0,0,0,$monthf,$dayf,$yearf)));
01147                 $tpl->setVariable("TXT_SEARCH_TERMS", $lng->txt("search_terms"));
01148                 $tpl->setVariable("VAL_SEARCH_TERMS", ilUtil::stripSlashes($_POST["search_terms"]));
01149                 $tpl->setVariable("TXT_TO", $lng->txt("to"));
01150                 $tpl->setVariable("VAL_DATET", date("Y-m-d", mktime(0,0,0,$montht,$dayt,$yeart)));
01151                 $tpl->setVariable("TXT_USER_LANGUAGE", $lng->txt("user_language"));
01152                 if ($_POST["language"] == "0")
01153                 {
01154                         $tpl->setVariable("VAL_LANGUAGE", $lng->txt("any_language"));
01155                 }
01156                 else
01157                 {
01158                         $tpl->setVariable("VAL_LANGUAGE", $lng->txt("lang_".$_POST["language"]));
01159                 }
01160                 $tpl->setVariable("TXT_TRACKED_OBJECTS", $lng->txt("tracked_objects"));
01161                 if ($_POST[$_POST["object_type"]] != 0)
01162                 {
01163                         $tpl->setVariable("VAL_TRACKED_OBJECTS",
01164                                 ilObject::_lookupTitle($_POST[$_POST["object_type"]]));
01165                 }
01166                 else
01167                 {
01168                         $tpl->setVariable("VAL_TRACKED_OBJECTS",
01169                                 $lng->txt("all_".$_POST["object_type"]."s"));
01170                 }
01171                 $tpl->parseCurrentBlock();*/
01172         }
01173 
01177         function getCondition()
01178         {
01179                 $lang_cond = $this->getLanguageCondition();
01180                 //echo ":$lang_cond:";
01181                 if ($lang_cond == "")
01182                 {
01183                         $this->setConditions($this->getObjectCondition());
01184                         return $this->getObjectCondition();
01185                 }
01186                 else
01187                 {
01188                         $this->setConditions($lang_cond." AND ".$this->getObjectCondition());
01189                         return $lang_cond." AND ".$this->getObjectCondition();
01190                 }
01191         }
01192 
01193 
01197         function getObjectCondition()
01198         {
01199                 global $ilDB;
01200 
01201                 $type = $_POST["object_type"];
01202                 $condition = "";
01203                 if($_POST["object_type"]=="lm")
01204                 {
01205                         if($_POST["author"]=="0")
01206                         {
01207                                 return " acc_obj_type = 'lm'";
01208                         }
01209                         elseif($_POST["lm"]=="0" or $_POST["lm"]=="")
01210                         {
01211                                 if (is_array($authors = ilObjUserTracking::allAuthor("usr","lm")))
01212                                 {
01213                                         foreach ($authors as $author)
01214                                         {
01215                                                 if($author["title"]==$_POST["author"])
01216                                                 {
01217                                                         if (is_array($lms = ilObjUserTracking::authorLms($author["obj_id"],"lm")))
01218                                                         {
01219                                                                 foreach ($lms as $lm)
01220                                                                 {
01221                                                                         $condition = $condition." or acc_obj_id = ".$lm["obj_id"];
01222                                                                 }
01223                                                         }
01224                                                 }
01225                                         }
01226                                 }
01227                                 return " ( 0 ".$condition." ) ";
01228                         }
01229                         else
01230                         {
01231                                 $condition.= " acc_obj_id = ".ilObjUserTracking::getObjId($_POST["lm"],$type);
01232                                 return $condition;
01233                         }
01234 
01235                 }
01236                 else if($_POST["object_type"]=="htlm")
01237                 {
01238                         if($_POST["author"]=="0")
01239                         {
01240                                 return " acc_obj_type = 'htlm'";
01241                         }
01242                         elseif($_POST["htlm"]=="0" or $_POST["htlm"]=="")
01243                         {
01244                                 if (is_array($authors = ilObjUserTracking::allAuthor("usr","htlm")))
01245                                 {
01246                                         foreach ($authors as $author)
01247                                         {
01248                                                 if($author["title"]==$_POST["author"])
01249                                                 {
01250                                                         if (is_array($htlms = ilObjUserTracking::authorLms($author["obj_id"],"htlm")))
01251                                                         {
01252                                                                 foreach ($htlms as $htlm)
01253                                                                 {
01254                                                                         $condition = $condition." or acc_obj_id = ".$htlm["obj_id"];
01255                                                                 }
01256                                                         }
01257                                                 }
01258                                         }
01259                                 }
01260                                 return " ( 0 ".$condition." ) ";
01261                         }
01262                         else
01263                         {
01264                                 $condition.= " acc_obj_id = ".ilObjUserTracking::getObjId($_POST["htlm"],$type);
01265                                 return $condition;
01266                         }
01267 
01268                 }
01269                 else
01270                 {
01271                         if($_POST["author1"]=="0")
01272                         {
01273                                 return " acc_obj_type = 'tst'";
01274                         }
01275                         elseif($_POST["tst"]=="0" or $_POST["tst"]=="")
01276                         {
01277                                 if (is_array($authors = ilObjUserTracking::allAuthor("usr","tst")))
01278                                 {
01279                                         foreach ($authors as $author)
01280                                         {
01281                                                 if($author["title"]==$_POST["author1"])
01282                                                 {
01283                                                         if (is_array($lms = ilObjUserTracking::authorLms($author["obj_id"],"tst")))
01284                                                         {
01285                                                                 foreach ($lms as $lm)
01286                                                                 {
01287                                                                         $condition = $condition." or acc_obj_id = ".$lm["obj_id"];
01288                                                                 }
01289                                                         }
01290                                                 }
01291                                         }
01292                                 }
01293                                 return " ( 0 ".$condition." ) ";
01294                         }
01295                         else
01296                         {
01297                                 $condition.= " acc_obj_id = ".ilObjUserTracking::getObjId($_POST["tst"],$type);
01298                                 return $condition;
01299                         }
01300                 }
01301         }
01302 
01306         function getLanguageCondition()
01307         {
01308                 global $ilDB;
01309 
01310                 if ($_POST["language"] != "0")
01311                 {
01312                         return "ut_access.language =".$ilDB->quote($_POST["language"]);
01313                 }
01314 
01315                 return "";
01316         }       
01317 
01321         function getSearchTermsCondition()
01322         {
01323                 global $ilDB;
01324 
01325                 if (trim($_POST["search_terms"]) != "")
01326                 {
01327                         $sub_ret = "";
01328                         $terms = explode(" ", $_POST["search_terms"]);
01329                         for ($i = 0; $i < count($terms); $i++)
01330                         {
01331                                 if (trim($terms[$i]) != "") $sub_ret .= "oa.title LIKE '%".ilUtil::addSlashes(trim($terms[$i]))."%' OR ";
01332                         }
01333                         if ($sub_ret != "")
01334                         {
01335                                 return " INNER JOIN object_data AS oa ON oa.obj_id = acc_obj_id WHERE (".substr($sub_ret, 0, strlen($sub_ret)-4) . ") AND ";
01336                         }
01337                 }
01338 
01339                 return "";
01340         }       
01341 
01342         function setConditions($con)
01343         {
01344                 $this->conditions = $con;
01345         }
01346         function getConditions()
01347         {
01348                 return $this->conditions;
01349         }
01350         
01354         function numDay($from,$to)
01355         {
01356 
01357                 $from = strtotime($from);
01358                 $to = strtotime($to);
01359 
01360                 $dayf = date ("d",$from);
01361                 $dayt = date ("d",$to);
01362                 $yearf = date ("Y",$from); 
01363                 $yeart = date ("Y",$to); 
01364                 $montht = date ("m",$to); 
01365                 $monthf = date ("m",$from); 
01366 
01367 #               $ret = ( mktime(0,0,0,$montht,$dayt,$yeart) - mktime(0,0,0,$monthf,$dayf,$yearf))/(3600*24); 
01368 #               return $ret; 
01369 
01370                 $from = mktime(12,0,0,$monthf,$dayf,$yearf);
01371                 $to = mktime(12,0,0,$montht,$dayt,$yeart);
01372 
01373                 $ret = (round(($to - $from) / 86400) + 1);
01374                 return $ret;
01375 
01376 #               $x0 = gregoriantojd($monthf,$dayf,$yearf);
01377 #               $x1 = gregoriantojd($montht,$dayt,$yeart); 
01378 #               return (($x1 - $x0)+1);
01379         }
01380         
01384         function numHour($from,$to)
01385         {
01386                 $from = strtotime($from);
01387                 $to = strtotime($to);
01388                 $dayf = date ("d",$from); 
01389                 $dayt = date ("d",$to);
01390                 $yearf = date ("Y",$from); 
01391                 $yeart = date ("Y",$to); 
01392                 $montht = date ("m",$to); 
01393                 $monthf = date ("m",$from); 
01394                 $hourt = date ("h",$to);
01395                 $hourf = date ("h",$from);
01396                 $ret = (mktime($hourt,0,0,$montht,$dayt,$yeart)-mktime($hourf,0,0,$monthf,$dayf,$yearf))/3600; 
01397                 $ret = strftime($ret);
01398                 return $ret; 
01399         }
01400         
01404         function addHour($time)
01405         {
01406                 $time = strtotime($time);
01407                 $day = date("d",$time);
01408                 $month = date("m",$time);
01409                 $year = date("Y",$time);
01410                 $hour = date("H",$time);
01411                 $min = date("i",$time);
01412                 $sec = date("s",$time);
01413                 $hour = $hour+1;
01414                 $ret = date("H:i:s", mktime($hour,$min,$sec,$month,$day,$year));
01415                 return $ret;
01416         }
01417         
01421         function addDay($time)
01422         {
01423                 $time = strtotime($time);
01424                 $day = date("d",$time);
01425                 $month = date("m",$time);
01426                 $year = date("y",$time);
01427                 $min = date("i",$time);
01428                 $hour = date("h",$time);
01429                 $sec = date("s",$time);
01430                 $day = $day + 1;
01431                 $ret = date ("Y-m-d", mktime($hour,$min,$sec,$month,$day,$year));
01432                 return $ret;
01433         }
01434         
01438         function selectTime($from,$to,$condition,$searchTermsCondition="",$objectCondition="")
01439         {
01440                 $q = "SELECT acc_time from ut_access "
01441                         .($searchTermsCondition != "" ? $searchTermsCondition : " WHERE ")
01442                         ." (acc_time >= '".$from." 00:00:00'"
01443                         ." AND acc_time <= '".$to." 23:59:59')"
01444                         ." AND ".$condition
01445                         .$objectCondition
01446                         ." GROUP BY acc_time";
01447                 $res = $this->ilias->db->query($q);
01448                 for($i=0;$i<$res->numRows();$i++)
01449                 {
01450                         $result[$i]=$res->fetchRow();
01451                 }
01452                 return $result;
01453         }
01454         
01458         function countNum($from,$from1,$condition,$searchTermsCondition="",$objectCondition="")
01459         {
01460                 $q = "SELECT id FROM ut_access"
01461                         .($searchTermsCondition != "" ? $searchTermsCondition : " WHERE ")
01462                         ." (acc_time >= '".$from." 00:00:00'"
01463                         ." AND acc_time < '".$from1." 00:00:00')"
01464                         ." AND ".$condition
01465                         .$objectCondition
01466                         ." GROUP BY id";
01467                 $res = $this->ilias->db->query($q);
01468                 return $res->numRows();
01469         }
01470 
01471         function __showActivationSelect()
01472         {
01473                 $options = array(UT_ACTIVE_UT => $this->lng->txt('trac_active_ut_only'),
01474                                                  UT_ACTIVE_LP => $this->lng->txt('trac_active_lp_only'),
01475                                                  UT_ACTIVE_BOTH => $this->lng->txt('trac_active_both'),
01476                                                  UT_INACTIVE_BOTH => $this->lng->txt('trac_inactive_both'));
01477 
01478                 foreach($options as $val => $txt)
01479                 {
01480                         $this->tpl->setCurrentBlock("option");
01481 
01482                         if($this->object->getActivationStatus() == $val)
01483                         {
01484                                 $this->tpl->setVariable("OPT_SELECTED",'selected="selected"');
01485                         }
01486                         $this->tpl->setVariable("OPT_VAL",$val);
01487                         $this->tpl->setVariable("OPT_TXT",$txt);
01488                         $this->tpl->parseCurrentBlock();
01489                 }
01490                 return true;
01491         }       
01492 
01493         
01494 } 
01495 ?>

Generated on Fri Dec 13 2013 13:52:12 for ILIAS Release_3_7_x_branch .rev 46817 by  doxygen 1.7.1