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

Generated on Fri Dec 13 2013 11:57:59 for ILIAS Release_3_6_x_branch .rev 46809 by  doxygen 1.7.1