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

classes/class.ilObjSysUserTrackingGUI.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 
00036 require_once "class.ilObjectGUI.php";
00037 
00038 class ilObjSysUserTrackingGUI extends ilObjectGUI
00039 {
00044         var $conditions;
00045 
00046         function ilObjSysUserTrackingGUI($a_data,$a_id,$a_call_by_reference)
00047         {
00048                 global $rbacsystem;
00049 
00050                 $this->type = "trac";
00051                 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference);
00052 
00053                 if (!$rbacsystem->checkAccess('read',$this->object->getRefId()))
00054                 {
00055                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read_track"),$this->ilias->error_obj->WARNING);
00056                 }
00057 
00058         }
00059 
00064         function saveObject()
00065         {
00066                 global $rbacadmin;
00067 
00068                 // create and insert forum in objecttree
00069                 $newObj = parent::saveObject();
00070 
00071                 // setup rolefolder & default local roles
00072                 //$roles = $newObj->initDefaultRoles();
00073 
00074                 // ...finally assign role to creator of object
00075                 //$rbacadmin->assignUser($roles[0], $newObj->getOwner(), "y");
00076 
00077                 // put here object specific stuff
00078 
00079                 // always send a message
00080                 sendInfo($this->lng->txt("object_added"),true);
00081 
00082                 header("Location:".$this->getReturnLocation("save","adm_object.php?".$this->link_params));
00083                 exit();
00084         }
00085 
00086 
00090         function settingsObject()
00091         {
00092                 global $tpl,$lng,$ilias;
00093 
00094                 // tracking settings
00095                 $tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.tracking_settings.html");
00096                 $tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$_GET["ref_id"].
00097                         "&cmd=gateway");
00098                 $tpl->setVariable("TXT_TRACKING_SETTINGS", $this->lng->txt("tracking_settings"));
00099                 $tpl->setVariable("TXT_ACTIVATE_TRACKING", $this->lng->txt("activate_tracking"));
00100                 $tpl->setVariable("TXT_USER_RELATED_DATA", $this->lng->txt("save_user_related_data"));
00101                 $tpl->setVariable("TXT_NUMBER_RECORDS", $this->lng->txt("number_of_records"));
00102                 $tpl->setVariable("NUMBER_RECORDS", $this->object->getRecordsTotal());
00103                 $tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
00104 
00105                 if($this->object->_enabledTracking())
00106                 {
00107                         $this->tpl->setVariable("ACT_TRACK_CHECKED", " checked=\"1\" ");
00108                 }
00109 
00110                 if($this->object->_enabledUserRelatedData())
00111                 {
00112                         $this->tpl->setVariable("USER_RELATED_CHECKED", " checked=\"1\" ");
00113                 }
00114 
00115                 $tpl->parseCurrentBlock();
00116 
00117         }
00118 
00122         function saveSettingsObject()
00123         {
00124                 // (de)activate tracking
00125                 if ($_POST["act_track"] == "y")
00126                 {
00127                         $this->object->enableTracking(true);
00128                 }
00129                 else
00130                 {
00131                         $this->object->enableTracking(false);
00132                 }
00133 
00134                 // (de)activate tracking of user related data
00135                 if ($_POST["user_related"] == "y")
00136                 {
00137                         $this->object->enableUserRelatedData(true);
00138                 }
00139                 else
00140                 {
00141                         $this->object->enableUserRelatedData(false);
00142                 }
00143 
00144                 sendinfo($this->lng->txt("msg_obj_modified"), true);
00145                 ilUtil::redirect("adm_object.php?ref_id=".$_GET["ref_id"]."&cmd=settings");
00146         }
00147 
00151         function manageDataObject()
00152         {
00153                 global $tpl,$lng,$ilias;
00154 
00155                 // tracking settings
00156                 $tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.tracking_manage_data.html");
00157                 $tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$_GET["ref_id"].
00158                         "&cmd=gateway");
00159                 $tpl->setVariable("TXT_TRACKING_DATA", $this->lng->txt("tracking_data"));
00160                 $tpl->setVariable("TXT_MONTH", $lng->txt("month"));
00161                 $tpl->setVariable("TXT_NUMBER_OF_ACC", $lng->txt("number_of_accesses"));
00162                 $tpl->setVariable("TXT_DELETE_OLDER", $lng->txt("delete"));
00163                 $overw = $this->object->getMonthTotalOverview();
00164                 foreach($overw as $month)
00165                 {
00166                         $tpl->setCurrentBlock("load_row");
00167                         $rcol = ($rcol != "tblrow1") ? "tblrow1" : "tblrow2";
00168                         $tpl->setVariable("ROWCOL", $rcol);
00169                         $tpl->setVariable("VAL_MONTH", $month["month"]);
00170                         $tpl->setVariable("VAL_NUMBER_OF_ACC", $month["cnt"]);
00171                         $tpl->parseCurrentBlock();
00172                 }
00173                 $tpl->parseCurrentBlock();
00174         }
00175 
00179         function confirmDeletionDataObject()
00180         {
00181                 global $tpl, $lng, $rbacsystem;
00182 
00183                 if (!$rbacsystem->checkAccess('delete',$this->object->getRefId()))
00184                 {
00185                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_delete_track"),$this->ilias->error_obj->WARNING);
00186                 }
00187 
00188                 if (!isset($_POST["month"]))
00189                 {
00190                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00191                 }
00192                 $nr = $this->object->getTotalOlderThanMonth($_POST["month"]);
00193                 $tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.tracking_confirm_data_deletion.html");
00194                 $tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$_GET["ref_id"].
00195                         "&cmd=gateway&month=".$_POST["month"]);
00196                 $tpl->setVariable("TXT_CONFIRMATION", $this->lng->txt("tracking_data_del_confirm"));
00197                 $tpl->setVariable("TXT_MONTH", $lng->txt("month"));
00198                 $tpl->setVariable("VAL_MONTH", $_POST["month"]);
00199                 $tpl->setVariable("TXT_NUMBER_OF_RECORDS", $lng->txt("number_of_records"));
00200                 $tpl->setVariable("VAL_NUMBER_OF_RECORDS", $nr);
00201                 $tpl->setVariable("TXT_NUMBER_OF_ACC", $lng->txt("number_of_accesses"));
00202                 $tpl->setVariable("TXT_DELETE_DATA", $lng->txt("delete_tr_data"));
00203                 $tpl->setVariable("TXT_CANCEL", $lng->txt("cancel"));
00204         }
00205 
00209         function cancelDeleteDataObject()
00210         {
00211                 sendInfo($this->lng->txt("msg_cancel"),true);
00212 
00213                 ilUtil::redirect("adm_object.php?ref_id=".$_GET["ref_id"]."&cmd=manageData");
00214         }
00215 
00219         function deleteDataObject()
00220         {
00221                 global $rbacsystem;
00222                 
00223                 if (!$rbacsystem->checkAccess('read',$this->object->getRefId()))
00224                 {
00225                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_delete_track"),$this->ilias->error_obj->WARNING);
00226                 }
00227 
00228                 $this->object->deleteTrackingDataBeforeMonth($_GET["month"]);
00229 
00230                 sendInfo($this->lng->txt("tracking_data_deleted"),true);
00231                 ilUtil::redirect("adm_object.php?ref_id=".$_GET["ref_id"]."&cmd=manageData");
00232         }
00233 
00237         function trackingDataQueryFormObject()
00238         {
00239                 global $tpl,$lng,$ilias;
00240                 $year = array(2004,2005,2006,2007);
00241                 $month = array(1,2,3,4,5,6,7,8,9,10,11,12);
00242                 $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);
00243                 //subject module
00244                 $tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.usr_tracking.html");
00245 
00246                 if (ilObjSysUserTracking::_enabledUserRelatedData())
00247                 {
00248                         $tpl->setCurrentBlock("user_stat");
00249                         $tpl->setVariable("TXT_STATISTIC_U", $lng->txt("user_access"));
00250                         if ($_SESSION["il_track_stat"] == "u")
00251                         {
00252                                 $tpl->setVariable("U_CHK", " checked=\"1\" ");
00253                         }
00254                         $tpl->parseCurrentBlock();
00255                 }
00256 
00257                 //$tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00258                 $tpl->setVariable("SEARCH_ACTION", "adm_object.php?ref_id=".$_GET["ref_id"].
00259                         "&cmd=gateway");
00260                 $tpl->setVariable("TXT_TRACKING_DATA", $lng->txt("tracking_data"));
00261                 $tpl->setVariable("TXT_TIME_SEGMENT", $lng->txt("time_segment"));
00262                 $tpl->setVariable("TXT_STATISTIC", $lng->txt("statistic"));
00263                 $tpl->setVariable("TXT_STATISTIC_H", $lng->txt("hours_of_day"));
00264                 $tpl->setVariable("TXT_STATISTIC_D", $lng->txt("days_of_period"));
00265                 $tpl->setVariable("TXT_STATISTIC_O", $lng->txt("per_object"));
00266                 $tpl->setVariable("TXT_USER_LANGUAGE",$lng->txt("user_language"));
00267                 $tpl->setVariable("TXT_LM",$lng->txt("lm"));
00268                 $tpl->setVariable("TXT_SHOW_TR_DATA",$lng->txt("query_data"));
00269                 $tpl->setVariable("TXT_TRACKED_OBJECTS",$lng->txt("tracked_objects"));
00270 
00271                 $languages = $lng->getInstalledLanguages();
00272 
00273                 // get all learning modules
00274                 // $lms = ilObject::_getObjectsDataForType("lm", true);
00275                 $authors = ilObjSysUserTracking::allAuthor("usr","lm");
00276                 if(count($authors)>0)
00277                 {
00278                         $tpl->setCurrentBlock("javascript");
00279                         $tpl->setVariable("ALL_LMS", $this->lng->txt("all_lms"));
00280                         foreach ($authors as $author)
00281                         {
00282                                 $lms = ilObjSysUserTracking::authorLms($author["obj_id"],"lm");
00283                                 //echo count($lms);
00284                                 foreach ($lms as $lm)
00285                                 {
00286                                         $tpl->setCurrentBlock("select_value");
00287                                         $tpl->setVariable("VALUE", $author["title"]);
00288                                         $tpl->setVariable("LMVALUE", $lm["title"]);
00289                                         $tpl->parseCurrentBlock();
00290                                 }
00291                         
00292                         }
00293                         $tpl->parseCurrentBlock();
00294                 }
00295                 $authors1 = ilObjSysUserTracking::allAuthor("usr","tst");
00296                 if(count($authors1)>0)
00297                 {
00298                         $tpl->setCurrentBlock("javascript1");
00299                         $tpl->setVariable("ALL_TSTS", $this->lng->txt("all_tsts"));
00300                         foreach ($authors1 as $author1)
00301                         {
00302                                 $tsts = ilObjSysUserTracking::authorLms($author1["obj_id"],"tst");
00303                                 foreach ($tsts as $tst)
00304                                 {
00305                                         $tpl->setCurrentBlock("select_value1");
00306                                         $tpl->setVariable("VALUE1", $author1["title"]);
00307                                         $tpl->setVariable("TSTVALUE", $tst["title"]);
00308                                         $tpl->parseCurrentBlock();
00309                                 }
00310                         }
00311                         $tpl->parseCurrentBlock();
00312                 }
00313                 foreach($year as $key)
00314                 {
00315                         $tpl->setCurrentBlock("fromyear_selection");
00316                         $tpl->setVariable("YEARFR", $key);
00317                         $tpl->setVariable("YEARF", $key);
00318                         if ($_SESSION["il_track_yearf"] == $key)
00319                         {
00320                                 $tpl->setVariable("YEARF_SEL", " selected=\"1\" ");
00321                         }
00322                         $tpl->parseCurrentBlock();
00323                 }
00324                 foreach($month as $key)
00325                 {
00326                         $tpl->setCurrentBlock("frommonth_selection");
00327                         $tpl->setVariable("MONTHFR", $key);
00328                         $tpl->setVariable("MONTHF", $key);
00329                         if ($_SESSION["il_track_monthf"] == $key)
00330                         {
00331                                 $tpl->setVariable("MONTHF_SEL", " selected=\"1\" ");
00332                         }
00333                         $tpl->parseCurrentBlock();
00334                 }
00335                 foreach($day as $key)
00336                 {
00337                         $tpl->setCurrentBlock("fromday_selection");
00338                         $tpl->setVariable("DAYFR", $key);
00339                         $tpl->setVariable("DAYF", $key);
00340                         if ($_SESSION["il_track_dayf"] == $key)
00341                         {
00342                                 $tpl->setVariable("DAYF_SEL", " selected=\"1\" ");
00343                         }
00344                         $tpl->parseCurrentBlock();
00345                 }
00346                 foreach($day as $key)
00347                 {
00348                         $tpl->setCurrentBlock("today_selection");
00349                         $tpl->setVariable("DAYTO", $key);
00350                         $tpl->setVariable("DAYT", $key);
00351                         if ($_SESSION["il_track_dayt"] == $key)
00352                         {
00353                                 $tpl->setVariable("DAYT_SEL", " selected=\"1\" ");
00354                         }
00355                         $tpl->parseCurrentBlock();
00356                 }
00357                 foreach($month as $key)
00358                 {
00359                         $tpl->setCurrentBlock("tomonth_selection");
00360                         $tpl->setVariable("MONTHTO", $key);
00361                         $tpl->setVariable("MONTHT", $key);
00362                         if ($_SESSION["il_track_montht"] == $key)
00363                         {
00364                                 $tpl->setVariable("MONTHT_SEL", " selected=\"1\" ");
00365                         }
00366                         $tpl->parseCurrentBlock();
00367                 }
00368                 foreach($year as $key)
00369                 {
00370                         $tpl->setCurrentBlock("toyear_selection");
00371                         $tpl->setVariable("YEARTO", $key);
00372                         $tpl->setVariable("YEART", $key);
00373                         if ($_SESSION["il_track_yeart"] == $key)
00374                         {
00375                                 $tpl->setVariable("YEART_SEL", " selected=\"1\" ");
00376                         }
00377                         $tpl->parseCurrentBlock();
00378                 }
00379                 // language selection
00380                 $tpl->setCurrentBlock("language_selection");
00381                 $tpl->setVariable("LANG", $lng->txt("any_language"));
00382                 $tpl->setVariable("LANGSHORT", "0");
00383                 $tpl->parseCurrentBlock();
00384                 foreach ($languages as $lang_key)
00385                 {
00386                         $tpl->setCurrentBlock("language_selection");
00387                         $tpl->setVariable("LANG", $lng->txt("lang_".$lang_key));
00388                         $tpl->setVariable("LANGSHORT", $lang_key);
00389                         if ($_SESSION["il_track_language"] == $lang_key)
00390                         {
00391                                 $tpl->setVariable("LANG_SEL", " selected=\"1\" ");
00392                         }
00393                         $tpl->parseCurrentBlock();
00394                 }
00395 
00396                 // statistic type
00397                 if ($_SESSION["il_track_stat"] == "d")
00398                 {
00399                         $tpl->setVariable("D_CHK", " checked=\"1\" ");
00400                 }
00401                 elseif ($_SESSION["il_track_stat"] == "h")
00402                 {
00403                         $tpl->setVariable("H_CHK", " checked=\"1\" ");
00404                 }
00405                 elseif($_SESSION["il_track_stat"] == "o")
00406                 {
00407                         $tpl->setVariable("O_CHK", " checked=\"1\" ");
00408                 }
00409                 
00410                 // tracked object type
00411                 if ($_SESSION["il_object_type"] == "tst")
00412                 {
00413                         $tpl->setVariable("TST_CHK", " checked=\"1\" ");
00414                 }
00415                 else
00416                 {
00417                         $tpl->setVariable("LM_CHK", " checked=\"1\" ");
00418                 }
00419 
00420                 // author selection
00421                 $tpl->setCurrentBlock("author_selection");
00422                 $tpl->setVariable("AUTHOR", 0);
00423                 $tpl->setVariable("AUTHOR_SELECT", $this->lng->txt("all_authors"));
00424                 $tpl->parseCurrentBlock();
00425                 foreach ($authors as $author)
00426                 {
00427                         $tpl->setCurrentBlock("author_selection");
00428                         $tpl->setVariable("AUTHOR", $author["title"]);
00429                         $tpl->setVariable("AUTHOR_SELECT", $author["title"]);
00430                         if ($_SESSION["il_track_author"] == $author["title"])
00431                         {
00432                                 $tpl->setVariable("AUTHOR_SEL", " selected=\"1\" ");
00433                         }
00434                         $tpl->parseCurrentBlock();
00435                 }
00436                 $tpl->setCurrentBlock("author_selection_tst");
00437                 $tpl->setVariable("AUTHOR1", 0);
00438                 $tpl->setVariable("AUTHOR1_SELECT", $this->lng->txt("all_authors"));
00439                 $tpl->parseCurrentBlock();
00440                 foreach ($authors1 as $author1)
00441                 {
00442                         $tpl->setCurrentBlock("author_selection_tst");
00443                         $tpl->setVariable("AUTHOR1", $author1["title"]);
00444                         $tpl->setVariable("AUTHOR1_SELECT", $author1["title"]);
00445                         if ($_SESSION["il_track_author1"] == $author1["title"])
00446                         {
00447                                 $tpl->setVariable("AUTHOR1_SEL", " selected=\"1\" ");
00448                         }
00449                         $tpl->parseCurrentBlock();
00450                 }
00451                 //test module
00452                 
00453                 $result_test = ilObjSysUserTracking::getTestId($_SESSION["AccountId"]);
00454 
00455                 $tpl->setVariable("TXT_TEST",$lng->txt("test"));
00456 
00457                 //$test = $tracking->TestTitle($_SESSION["AccountId"]);
00458 
00459                 $tsts = ilObject::_getObjectsDataForType($type, true);
00460                 $tpl->setCurrentBlock("test_selection");
00461                 $tpl->setVariable("TEST", 0);
00462                 $tpl->setVariable("TEST_SELECT", $this->lng->txt("all_tsts"));
00463                 $tpl->parseCurrentBlock();
00464                 foreach($tsts as $tst)
00465                 {
00466                         $tpl->setCurrentBlock("test_selection");
00467                         $tpl->setVariable("TEST", $tst["id"]);
00468                         $tpl->setVariable("TEST_SELECT", $tst["title"]." [".$tst["id"]."]");
00469                         $tpl->parseCurrentBlock();
00470                 }
00471 
00472         }
00473 
00477         function outputTrackingDataObject()
00478         {
00479                 global $tpl,$lng,$ilias;
00480 
00481                 // save selected values in session
00482                 $_SESSION["il_track_yearf"] = $_POST["yearf"];
00483                 $_SESSION["il_track_yeart"] = $_POST["yeart"];
00484                 $_SESSION["il_track_monthf"] = $_POST["monthf"];
00485                 $_SESSION["il_track_montht"] = $_POST["montht"];
00486                 $_SESSION["il_track_dayf"] = $_POST["dayf"];
00487                 $_SESSION["il_track_dayt"] = $_POST["dayt"];
00488                 $_SESSION["il_track_stat"] = $_POST["stat"];
00489                 $_SESSION["il_track_language"] = $_POST["language"];
00490                 $_SESSION["il_track_author"] = $_POST["author"];
00491                 $_SESSION["il_track_author1"] = $_POST["author1"];
00492                 $_SESSION["il_track_lm"] = $_POST["lm"];
00493                 $_SESSION["il_track_tst"] = $_POST["tst"];
00494                 $_SESSION["il_object_type"] = $_POST["object_type"];
00495 
00496                 $yearf = $_POST["yearf"];
00497                 $monthf = $_POST["monthf"];
00498                 $dayf = $_POST["dayf"];
00499                 $yeart = $_POST["yeart"];
00500                 $montht= $_POST["montht"];
00501                 $dayt = $_POST["dayt"];
00502                 $from = $yearf."-".$monthf."-".$dayf;
00503                 $to = $yeart."-".$montht."-".$dayt;
00504 
00505                 if(($yearf > $yeart)or($yearf==$yeart and $monthf>$montht)or($yearf==$yeart and $monthf==$montht and $dayf>$dayt))
00506                 {
00507                         $this->ilias->raiseError($lng->txt("msg_err_search_time"),
00508                                 $this->ilias->error_obj->MESSAGE);
00509                 }
00510 
00511                 /*
00512                 if($_POST["stat"]!='h' and $_POST["stat"]!='d')
00513                 {
00514                         $this->ilias->raiseError($lng->txt("msg_no_search_time"),
00515                                 $this->ilias->error_obj->MESSAGE);
00516                 }*/
00517 
00518                 $condition = $this->getCondition()." and acc_time >='".$from."' and acc_time< '".$to."'";
00519                 if(count(ilObjSysUserTracking::countResults($condition))== 0)
00520                 {
00521                         $this->ilias->raiseError($lng->txt("msg_no_search_result"),
00522                                 $this->ilias->error_obj->MESSAGE);
00523                 }
00524 
00525                 include_once "./classes/class.ilTableGUI.php";
00526                 $tbl = new ilTableGUI();
00527                 $tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.tracking_result.html");
00528                 $tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00529                 $tpl->addBlockfile("TRACK_TABLE", "track_table", "tpl.table.html");
00530                 $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
00531 
00532                 // user access statistic
00533                 if($_POST["stat"] == "u")       // user access
00534                 {
00535                         
00536                         if($_POST["mode"] == "user")
00537                         {
00538                                 $tpl->setCurrentBlock("user_mode");
00539                                 $tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$_GET["ref_id"].
00540                                 "&cmd=gateway");
00541                                 if($_POST["object_type"]=="lm")
00542                                 {
00543                                         $tpl->setVariable("AUTHOR", "author");
00544                                         $tpl->setVariable("AUTHORS", $_POST["author"]);
00545                                         $tpl->setVariable("OBJECT", "lm");
00546                                         $tpl->setVariable("OBJECTS", $_POST["lm"]);
00547                                 }
00548                                 else
00549                                 {
00550                                         $tpl->setVariable("AUTHOR", "author1");
00551                                         $tpl->setVariable("AUTHORS", $_POST["author1"]);
00552                                         $tpl->setVariable("OBJECT", "tst");
00553                                         $tpl->setVariable("OBJECTS", $_POST["tst"]);
00554                                 }
00555                                 $tpl->setVariable("YEARF",$_POST["yearf"]);
00556                                 $tpl->setVariable("MONTHF",$_POST["monthf"]);
00557                                 $tpl->setVariable("DAYF",$_POST["dayf"]);
00558                                 $tpl->setVariable("YEART",$_POST["yeart"]);
00559                                 $tpl->setVariable("MONTHT",$_POST["montht"]);
00560                                 $tpl->setVariable("DAYT",$_POST["dayt"]);
00561                                 $tpl->setVariable("LAN", $_POST["language"]);
00562                                 $tpl->setVariable("TYPE", $_POST["object_type"]);
00563                                 $tpl->setVariable("FROM", $from);
00564                                 $tpl->setVariable("TO", $to);
00565                                 $tpl->setVariable("TXT_SHOW_USER_DATA", $lng->txt("user_statistics"));
00566                                 $tpl->parseCurrentBlock();
00567                                 $title_new = array("user","client_ip","language","object","time");
00568                                 $condition = $this->getConditions()." and acc_time>='".$from."' and acc_time<'".$to."'";
00569                                 $user_acc = $this->object->getAccessPerUserDetail($condition);
00570                                 $this->maxcount = count($user_acc);
00571                                 if (count($user_acc) < 1)
00572                                 {
00573                                         $this->ilias->raiseError($lng->txt("msg_no_search_result"),
00574                                                 $this->ilias->error_obj->MESSAGE);
00575                                 }
00576 
00577                                 $tbl->setTitle($lng->txt("search_result"),0,0);
00578                                 foreach ($title_new as $val)
00579                                 {
00580                                         $header_names[] = $lng->txt($val);
00581                                 }
00582                                 $tbl->disable("sort");
00583                                 $tbl->setHeaderNames($header_names);
00584                                 //$tbl->setColumnWidth(array("15","75%","25%"));
00585                                 $tbl->setMaxCount($this->maxcount);
00586                                 $tbl->setStyle("table", "std");
00587                                 $tbl->render();
00588                                 $max = 0;
00589 
00590                                 foreach ($user_acc as $user)
00591                                 {
00592                                         $data[0] = $user["name"];
00593                                         $data[1] = $user["client_ip"];
00594                                         $data[2] = $user["language"];
00595                                         $data[3] = $user["acc_obj_id"];
00596                                         $data[4] = $user["acc_time"];
00597                                         $css_row = $i%2==0?"tblrow1":"tblrow2";
00598                                         foreach ($data as $key => $val)
00599                                         {
00600                                                 if($val=="")
00601                                                 {
00602                                                         $val=0;
00603                                                 }
00604                                                 $tpl->setCurrentBlock("text");
00605                                                 $tpl->setVariable("TEXT_CONTENT", $val);
00606                                                 $tpl->parseCurrentBlock();
00607                                                 $tpl->setCurrentBlock("table_cell");
00608                                                 $tpl->parseCurrentBlock();
00609                                         } //foreach
00610                                         $tpl->setCurrentBlock("tbl_content");
00611                                         $tpl->setVariable("CSS_ROW", $css_row);
00612                                         $tpl->parseCurrentBlock();
00613                                 } //for
00614                         }
00615                         else
00616                         {
00617                                 $tpl->setCurrentBlock("user_mode");
00618                                 $tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$_GET["ref_id"].
00619                                 "&cmd=gateway");
00620                                 if($_POST["object_type"]=="lm")
00621                                 {
00622                                         $tpl->setVariable("AUTHOR", "author");
00623                                         $tpl->setVariable("AUTHORS", $_POST["author"]);
00624                                         $tpl->setVariable("OBJECT", "lm");
00625                                         $tpl->setVariable("OBJECTS", $_POST["lm"]);
00626                                 }
00627                                 else
00628                                 {
00629                                         $tpl->setVariable("AUTHOR", "author1");
00630                                         $tpl->setVariable("AUTHORS", $_POST["author1"]);
00631                                         $tpl->setVariable("OBJECT", "tst");
00632                                         $tpl->setVariable("OBJECTS", $_POST["tst"]);
00633                                 }
00634                                 $tpl->setVariable("YEARF",$_POST["yearf"]);
00635                                 $tpl->setVariable("MONTHF",$_POST["monthf"]);
00636                                 $tpl->setVariable("DAYF",$_POST["dayf"]);
00637                                 $tpl->setVariable("YEART",$_POST["yeart"]);
00638                                 $tpl->setVariable("MONTHT",$_POST["montht"]);
00639                                 $tpl->setVariable("DAYT",$_POST["dayt"]);
00640                                 $tpl->setVariable("USER", "user");
00641                                 $tpl->setVariable("LAN", $_POST["language"]);
00642                                 $tpl->setVariable("TYPE", $_POST["object_type"]);
00643                                 $tpl->setVariable("FROM", $from);
00644                                 $tpl->setVariable("TO", $to);
00645                                 $tpl->setVariable("TXT_SHOW_USER_DATA", $lng->txt("user_detail"));
00646                                 $tpl->parseCurrentBlock();
00647                                 $title_new = array("user", "count", "");
00648 
00649                                 $user_acc = $this->object->getAccessTotalPerUser($condition);
00650 
00651                                 $this->maxcount = count($user_acc);
00652 
00653                                 // check if result is given
00654                                 if ($this->maxcount < 1)
00655                                 {
00656                                         $this->ilias->raiseError($lng->txt("msg_no_search_result"),
00657                                                 $this->ilias->error_obj->MESSAGE);
00658                                 }
00659 
00660                                 $tbl->setTitle($lng->txt("search_result"),0,0);
00661                                 foreach ($title_new as $val)
00662                                 {
00663                                         $header_names[] = $lng->txt($val);
00664                                 }
00665                                 $tbl->disable("sort");
00666                                 $tbl->setHeaderNames($header_names);
00667                                 //$tbl->setColumnWidth(array("15","75%","25%"));
00668                                 $tbl->setMaxCount($this->maxcount);
00669                                 $tbl->setStyle("table", "std");
00670                                 $tbl->render();
00671                                 $max = 0;
00672                                 foreach ($user_acc as $user)
00673                                 {
00674                                         $max = ($max > $user["cnt"]) ? $max : $user["cnt"];
00675                                 }
00676 
00677                                 foreach ($user_acc as $user)
00678                                 {
00679                                         $data[0] = $user["name"];
00680                                         $data[1] = $user["cnt"];
00681                                         $width = ($max > 0)
00682                                                 ? round($data[1] / $max * 100)
00683                                                 : 0;
00684                                         $data[2] = "<img src=\"".ilUtil::getImagePath("ray.gif")."\" border=\"0\" ".
00685                                                 "width=\"".$width."\" height=\"10\"/>";
00686 
00687                                         $css_row = $i%2==0?"tblrow1":"tblrow2";
00688                                         foreach ($data as $key => $val)
00689                                         {
00690                                                 if($val=="")
00691                                                 {
00692                                                         $val=0;
00693                                                 }
00694                                                 $tpl->setCurrentBlock("text");
00695                                                 $tpl->setVariable("TEXT_CONTENT", $val);
00696                                                 $tpl->parseCurrentBlock();
00697                                                 $tpl->setCurrentBlock("table_cell");
00698                                                 $tpl->parseCurrentBlock();
00699                                         } //foreach
00700                                         $tpl->setCurrentBlock("tbl_content");
00701                                         $tpl->setVariable("CSS_ROW", $css_row);
00702                                         $tpl->parseCurrentBlock();
00703                                 } //for
00704                         }
00705 
00706                 }
00707                 elseif($_POST["stat"] == "o") //Object Access
00708                 {
00709                         if(($_POST["object_type"]=="lm" and $_POST["author"] =="0") or ($_POST["object_type"]=="tst" and $_POST["author1"]=="0"))
00710                         {
00711                                 $title_new = array("author", "subject", "count","");    
00712                         }
00713                         else
00714                         {
00715                                 $title_new = array("subject", "count","");
00716                         }
00717                         $acc_object = $this->object->getAccessTotalPerObj($condition);
00718                         
00719                         $this->maxcount = count($acc_object);
00720                         if ($this->maxcount < 1)
00721                         {
00722                                 $this->ilias->raiseError($lng->txt("msg_no_search_result"),
00723                                         $this->ilias->error_obj->MESSAGE);
00724                         }
00725 
00726                         $tbl->setTitle($lng->txt("search_result"),0,0);
00727                         
00728                         include_once "./classes/class.ilTableGUI.php";
00729                         $tbl = new ilTableGUI();
00730                         $tbl->setTitle($lng->txt("obj_trac"),0,0);
00731                         foreach ($title_new as $val)
00732                         {
00733                                 $header_names[] = $lng->txt($val);
00734                         }
00735                         $tbl->disable("sort");
00736                         $tbl->setHeaderNames($header_names);
00737                         $tbl->setMaxCount($this->maxcount);
00738                         $tbl->setStyle("table", "std");
00739                         $tbl->render();
00740                         $max = 0;
00741                         foreach ($acc_object as $obj)
00742                         {
00743                                 $max = ($max > $obj["cnt"]) ? $max : $obj["cnt"];
00744                         }
00745 
00746                         foreach ($acc_object as $obj)
00747                         {
00748                                 if(($_POST["object_type"]=="lm" and $_POST["author"]=="0") or ($_POST["object_type"]=="tst" and $_POST["author1"]=="0"))
00749                                 {
00750                                         $data[0] = $obj["author"];
00751                                         $data[1] = $obj["title"];
00752                                         $data[2] = $obj["cnt"];
00753                                         $width = ($max > 0)
00754                                                 ? round($data[2] / $max * 100)
00755                                                 : 0;
00756                                         $data[3] = "<img src=\"".ilUtil::getImagePath("ray.gif")."\" border=\"0\" ".
00757                                                 "width=\"".$width."\" height=\"10\"/>";
00758                                 }
00759                                 else
00760                                 {
00761                                         $data[0] = $obj["title"];
00762                                         $data[1] = $obj["cnt"];
00763                                         $width = ($max > 0)
00764                                                 ? round($data[1] / $max * 100)
00765                                                 : 0;
00766                                         $data[2] = "<img src=\"".ilUtil::getImagePath("ray.gif")."\" border=\"0\" ".
00767                                                 "width=\"".$width."\" height=\"10\"/>";
00768                                 }
00769                                 $css_row = $i%2==0?"tblrow1":"tblrow2";
00770                                 foreach ($data as $key => $val)
00771                                 {
00772                                         if($val=="")
00773                                         {
00774                                                 $val=0;
00775                                         }
00776                                         $tpl->setCurrentBlock("text");
00777                                         $tpl->setVariable("TEXT_CONTENT", $val);
00778                                         $tpl->parseCurrentBlock();
00779                                         $tpl->setCurrentBlock("table_cell");
00780                                         $tpl->parseCurrentBlock();
00781                                 } //foreach
00782                                 $tpl->setCurrentBlock("tbl_content");
00783                                 $tpl->setVariable("CSS_ROW", $css_row);
00784                                 $tpl->parseCurrentBlock();
00785                         } //for
00786         
00787                 }
00788                 else //user not selected
00789                 {
00790                         $title_new = array("time", "count", "");
00791 
00792                         include_once "./classes/class.ilTableGUI.php";
00793                         $tbl = new ilTableGUI();
00794                         $tbl->setTitle($lng->txt("obj_trac"),0,0);
00795                         foreach ($title_new as $val)
00796                         {
00797                                 $header_names[] = $lng->txt($val);
00798                         }
00799                         $tbl->disable("sort");
00800                         $tbl->setHeaderNames($header_names);
00801 
00802                         if($_POST["stat"]=='h')
00803                         {
00804                                 $num = 24;
00805                                 $tbl->setMaxCount($num);
00806                         }
00807                         else
00808                         {
00809                                 $num = $this->numDay($from,$to);
00810                                 $from1 = $this->addDay($from);
00811                                 $tbl->setMaxCount($num);
00812                         }
00813                         $tbl->setStyle("table", "std");
00814                         $tbl->render();
00815 
00816                         // contition
00817                         $condition = $this->getCondition();
00818 
00819                         if($_POST["stat"]=='h')         //hours of day
00820                         {
00821                                 $time = $this->selectTime($from,$to,$condition);
00822                                 $max = 0;
00823                                 for($i=0;$i<24;$i++)
00824                                 {
00825                                         $k = $i+1;
00826 
00827                                         // count number of accesses in hour $i
00828                                         $cou = 0;
00829                                         for($j=0;$j<count($time);$j++)
00830                                         {
00831                                                 $time1 = strtotime($time[$j][0]);
00832                                                 $day = date("d",$time1);
00833                                                 $month = date("m",$time1);
00834                                                 $year = date("Y",$time1);
00835                                                 $hour = date("H",$time1);
00836                                                 $min = date("i",$time1);
00837                                                 $sec = date("s",$time1);
00838                                                 $numb = date("H",mktime($hour,$min,$sec,$month,$day,$year));
00839                                                 $numb = intval($numb);
00840                                                 if($numb >=$i and $numb <$k)
00841                                                 {
00842                                                         $cou=$cou+1;
00843                                                 }
00844                                         }
00845                                         $count[$i] = $cou;
00846                                         $max = ($cou > $max) ? $cou : $max;
00847                                 }
00848 
00849                                 for($i=0;$i<24;$i++)
00850                                 {
00851                                         $k = $i+1;
00852                                         $data[0] = $i.":00:00  ~  ".$k.":00:00";
00853                                         $data[1] = $count[$i];
00854                                         $width = ($max > 0)
00855                                                 ? round($count[$i] / $max * 100)
00856                                                 : 0;
00857                                         $data[2] = "<img src=\"".ilUtil::getImagePath("ray.gif")."\" border=\"0\" ".
00858                                                 "width=\"".$width."\" height=\"10\"/>";
00859                                         $css_row = $i%2==0?"tblrow1":"tblrow2";
00860                                         foreach ($data as $key => $val)
00861                                         {
00862 
00863                                                 $tpl->setCurrentBlock("text");
00864                                                 $tpl->setVariable("TEXT_CONTENT", $val);
00865                                                 $tpl->parseCurrentBlock();
00866                                                 $tpl->setCurrentBlock("table_cell");
00867                                                 $tpl->parseCurrentBlock();
00868                                         }
00869                                         $tpl->setCurrentBlock("tbl_content");
00870                                         $tpl->setVariable("CSS_ROW", $css_row);
00871                                         $tpl->parseCurrentBlock();
00872 
00873                                 } //for
00874                         }
00875                         else //day selected
00876                         {
00877                                 $max = 0;
00878                                 for($i=0;$i<$num;$i++)
00879                                 {
00880                                         $fro[$i] = $from;
00881                                         $cou[$i] = $this->countNum($from,$from1,$condition);
00882                                         $from = $from1;
00883                                         $from1 = $this->addDay($from);
00884                                         $max = ($max > $cou[$i]) ? $max : $cou[$i];
00885                                 }
00886                                 for($i=0;$i<$num;$i++)
00887                                 {
00888                                         $data[0] = $fro[$i];
00889                                         $data[1] = $cou[$i];
00890                                         $width = ($max > 0)
00891                                                 ? round($cou[$i] / $max * 100)
00892                                                 : 0;
00893                                         $data[2] = "<img src=\"".ilUtil::getImagePath("ray.gif")."\" border=\"0\" ".
00894                                                 "width=\"".$width."\" height=\"10\"/>";
00895 
00896                                         $css_row = $i%2==0?"tblrow1":"tblrow2";
00897 
00898                                         foreach ($data as $key => $val)
00899                                         {
00900                                                 $tpl->setCurrentBlock("text");
00901                                                 $tpl->setVariable("TEXT_CONTENT", $val);
00902                                                 $tpl->parseCurrentBlock();
00903                                                 $tpl->setCurrentBlock("table_cell");
00904                                                 $tpl->parseCurrentBlock();
00905                                         }
00906                                         $tpl->setCurrentBlock("tbl_content");
00907                                         $tpl->setVariable("CSS_ROW", $css_row);
00908                                         $tpl->parseCurrentBlock();
00909                                 } //for
00910                         }
00911                 }//else
00912                 $tpl->setCurrentBlock("adm_content");
00913 
00914                 // output statistic settings
00915                 $tpl->setVariable("TXT_TIME_PERIOD", $lng->txt("time_segment"));
00916                 switch ($_POST["stat"])
00917                 {
00918                         case "h":
00919                                 $tpl->setVariable("TXT_STATISTIC", $lng->txt("hours_of_day"));
00920                                 break;
00921 
00922                         case "u":
00923                                 $tpl->setVariable("TXT_STATISTIC", $lng->txt("user_access"));
00924                                 break;
00925 
00926                         case "d":
00927                                 $tpl->setVariable("TXT_STATISTIC", $lng->txt("days_of_period"));
00928                                 break;
00929                 }
00930                 $tpl->setVariable("VAL_DATEF", date("Y-m-d", mktime(0,0,0,$monthf,$dayf,$yearf)));
00931                 $tpl->setVariable("TXT_TO", $lng->txt("to"));
00932                 $tpl->setVariable("VAL_DATET", date("Y-m-d", mktime(0,0,0,$montht,$dayt,$yeart)));
00933                 $tpl->setVariable("TXT_USER_LANGUAGE", $lng->txt("user_language"));
00934                 if ($_POST["language"] == "0")
00935                 {
00936                         $tpl->setVariable("VAL_LANGUAGE", $lng->txt("any_language"));
00937                 }
00938                 else
00939                 {
00940                         $tpl->setVariable("VAL_LANGUAGE", $lng->txt("lang_".$_POST["language"]));
00941                 }
00942                 $tpl->setVariable("TXT_TRACKED_OBJECTS", $lng->txt("tracked_objects"));
00943                 if ($_POST[$_POST["object_type"]] != 0)
00944                 {
00945                         $tpl->setVariable("VAL_TRACKED_OBJECTS",
00946                                 ilObject::_lookupTitle($_POST[$_POST["object_type"]]));
00947                 }
00948                 else
00949                 {
00950                         $tpl->setVariable("VAL_TRACKED_OBJECTS",
00951                                 $lng->txt("all_".$_POST["object_type"]."s"));
00952                 }
00953                 $tpl->parseCurrentBlock();
00954         }
00955 
00959         function getCondition()
00960         {
00961                 $lang_cond = $this->getLanguageCondition();
00962                 //echo ":$lang_cond:";
00963                 if ($lang_cond == "")
00964                 {
00965                         $this->setConditions($this->getObjectCondition());
00966                         return $this->getObjectCondition();
00967                 }
00968                 else
00969                 {
00970                         $this->setConditions($lang_cond." AND ".$this->getObjectCondition());
00971                         return $lang_cond." AND ".$this->getObjectCondition();
00972                 }
00973         }
00974 
00975 
00979         function getObjectCondition()
00980         {
00981                 global $ilDB;
00982 
00983                 $type = $_POST["object_type"];
00984                 $condition = "";
00985                 if($_POST["object_type"]=="lm")
00986                 {
00987                         if($_POST["author"]=="0")
00988                         {
00989                                 return " acc_obj_type = 'lm'";
00990                         }
00991                         elseif($_POST["lm"]=="0" or $_POST["lm"]=="")
00992                         {
00993                                 $authors = ilObjSysUserTracking::allAuthor("usr","lm");
00994                                 foreach ($authors as $author)
00995                                 {
00996                                         if($author["title"]==$_POST["author"])
00997                                         $lms = ilObjSysUserTracking::authorLms($author["obj_id"],"lm");
00998                                         foreach ($lms as $lm)
00999                                         {
01000                                                 $condition = $condition." or acc_obj_id = ".$lm["obj_id"];
01001                                         }
01002                                 }
01003                                 return " ( 0 ".$condition." ) ";
01004                         }
01005                         else
01006                         {
01007                                 $condition.= " acc_obj_id = ".ilObjSysUserTracking::getObjId($_POST["lm"],$type);
01008                                 return $condition;
01009                         }
01010 
01011                 }
01012                 else
01013                 {
01014                         if($_POST["author1"]=="0")
01015                         {
01016                                 return " acc_obj_type = 'tst'";
01017                         }
01018                         elseif($_POST["tst"]=="0" or $_POST["tst"]=="")
01019                         {
01020                                 $authors = ilObjSysUserTracking::allAuthor("usr","tst");
01021                                 foreach ($authors as $author)
01022                                 {
01023                                         if($author["title"]==$_POST["author1"])
01024                                         $lms = ilObjSysUserTracking::authorLms($author["obj_id"],"tst");
01025                                         foreach ($lms as $lm)
01026                                         {
01027                                                 $condition = $condition." or acc_obj_id = ".$lm["obj_id"];
01028                                         }
01029                                 }
01030                                 return " ( 0 ".$condition." ) ";
01031                         }
01032                         else
01033                         {
01034                                 $condition.= " acc_obj_id = ".ilObjSysUserTracking::getObjId($_POST["tst"],$type);
01035                                 return $condition;
01036                         }
01037                 }
01038         }
01039 
01043         function getLanguageCondition()
01044         {
01045                 global $ilDB;
01046 
01047                 if ($_POST["language"] != "0")
01048                 {
01049                         return "ut_access.language =".$ilDB->quote($_POST["language"]);
01050                 }
01051 
01052                 return "";
01053         }       
01054         function setConditions($con)
01055         {
01056                 $this->conditions = $con;
01057         }
01058         function getConditions()
01059         {
01060                 return $this->conditions;
01061         }
01062         
01066         function numDay($from,$to)
01067         {
01068                 $from = strtotime($from);
01069                 $to = strtotime($to);
01070                 $dayf = date ("d",$from);
01071                 $dayt = date ("d",$to);
01072                 $yearf = date ("Y",$from); 
01073                 $yeart = date ("Y",$to); 
01074                 $montht = date ("m",$to); 
01075                 $monthf = date ("m",$from); 
01076                 $ret = ( mktime(0,0,0,$montht,$dayt,$yeart) - mktime(0,0,0,$monthf,$dayf,$yearf))/(3600*24); 
01077                 return $ret; 
01078         }
01079         
01083         function numHour($from,$to)
01084         {
01085                 $from = strtotime($from);
01086                 $to = strtotime($to);
01087                 $dayf = date ("d",$from); 
01088                 $dayt = date ("d",$to);
01089                 $yearf = date ("Y",$from); 
01090                 $yeart = date ("Y",$to); 
01091                 $montht = date ("m",$to); 
01092                 $monthf = date ("m",$from); 
01093                 $hourt = date ("h",$to);
01094                 $hourf = date ("h",$from);
01095                 $ret = (mktime($hourt,0,0,$montht,$dayt,$yeart)-mktime($hourf,0,0,$monthf,$dayf,$yearf))/3600; 
01096                 $ret = strftime($ret);
01097                 return $ret; 
01098         }
01099         
01103         function addHour($time)
01104         {
01105                 $time = strtotime($time);
01106                 $day = date("d",$time);
01107                 $month = date("m",$time);
01108                 $year = date("Y",$time);
01109                 $hour = date("H",$time);
01110                 $min = date("i",$time);
01111                 $sec = date("s",$time);
01112                 $hour = $hour+1;
01113                 $ret = date("H:i:s", mktime($hour,$min,$sec,$month,$day,$year));
01114                 return $ret;
01115         }
01116         
01120         function addDay($time)
01121         {
01122                 $time = strtotime($time);
01123                 $day = date("d",$time);
01124                 $month = date("m",$time);
01125                 $year = date("y",$time);
01126                 $min = date("i",$time);
01127                 $hour = date("h",$time);
01128                 $sec = date("s",$time);
01129                 $day = $day + 1;
01130                 $ret = date ("Y-m-d", mktime($hour,$min,$sec,$month,$day,$year));
01131                 return $ret;
01132         }
01133         
01137         function selectTime($from,$to,$condition)
01138         {
01139                 $q = "SELECT acc_time from ut_access "
01140                         ." WHERE (acc_time >= '".$from
01141                         ."' AND acc_time <='".$to."')"
01142                         ." AND ".$condition;
01143                 $res = $this->ilias->db->query($q);
01144                 for($i=0;$i<$res->numRows();$i++)
01145                 {
01146                         $result[$i]=$res->fetchRow();
01147                 }
01148                 return $result;
01149         }
01150         
01154         function countNum($from,$from1,$condition)
01155         {
01156                 $q = "SELECT count(*) from ut_access "
01157                         ." WHERE (acc_time > '".$from
01158                         ."' AND acc_time <='".$from1."')"
01159                         ." AND ".$condition;
01160                 $res = $this->ilias->db->query($q);
01161                 $result = $res->fetchRow();
01162                 return $result[0];
01163         }
01164 } // END class.ilObj<module_name>
01165 ?>

Generated on Fri Dec 13 2013 09:06:34 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1