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

tracking.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 
00024 
00033 require_once "./include/inc.header.php";
00034 require_once "./tracking/classes/class.ilUserTracking.php";
00035 require_once "./classes/class.ilUtil.php";
00036 require_once "./assessment/classes/class.ilObjTest.php";
00037 
00038 die("This script call is deprecated");
00039 
00040 
00041 switch ($_GET["cmd"])
00042 {
00043         case "search":
00044                 searchForm();
00045                 break;
00046         case "test":
00047                 searchTest();
00048                 break;
00049         default:
00050                 conditionForm();
00051                 break;
00052 }
00053 function conditionForm ()
00054 {
00055                 global $tpl,$lng,$ilias;
00056                 $year = array(2004,2005,2006,2007);
00057                 $month = array(1,2,3,4,5,6,7,8,9,10,11,12);
00058                 $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);
00059                 //subject module
00060                 $tpl->addBlockFile("CONTENT", "content", "tpl.usr_tracking.html");
00061                 $tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00062                 $usertracking = new ilUserTracking();
00063                 $usertracking->_locator();
00064                 $usertracking->_tables();
00065                 $tpl->setVariable("SEARCH_ACTION", "tracking.php?cmd=search");
00066                 $tpl->setVariable("TXT_SUBJECT_MODULE", $lng->txt("subject_module"));
00067                 $tpl->setVariable("TXT_TIME_SEGMENT", $lng->txt("time_segment"));
00068                 $tpl->setVariable("TXT_TIME", $lng->txt("time"));
00069                 $tpl->setVariable("TXT_TIME_H", $lng->txt("time_h"));
00070                 $tpl->setVariable("TXT_TIME_D", $lng->txt("time_d"));
00071                 $tpl->setVariable("TXT_SEARCH_FOR", $lng->txt("search_for"));
00072                 $tpl->setVariable("TXT_USER", $lng->txt("user"));
00073                 $tpl->setVariable("TXT_LANGUAGE",$lng->txt("language"));
00074                 $tpl->setVariable("TXT_LM",$lng->txt("lm"));
00075                 $tpl->setVariable("BTN_SEARCH",$lng->txt("search"));
00076                 
00077                 $languages = $lng->getInstalledLanguages();
00078                 include_once "./tracking/classes/class.ilUserTracking.php";
00079                 $tracking = new ilUserTracking();
00080                 $lm = $tracking->searchTitle($_SESSION["AccountId"]);
00081 
00082                 foreach($year as $key)
00083                 {
00084                         $tpl->setCurrentBlock("fromyear_selection");
00085                         $tpl->setVariable("YEARFR", $key);
00086                         $tpl->setVariable("YEARF", $key);
00087                         $tpl->parseCurrentBlock();
00088                 }
00089                 foreach($month as $key)
00090                 {
00091                         $tpl->setCurrentBlock("frommonth_selection");
00092                         $tpl->setVariable("MONTHFR", $key);
00093                         $tpl->setVariable("MONTHF", $key);
00094                         $tpl->parseCurrentBlock();
00095                 }
00096                 foreach($day as $key)
00097                 {
00098                         $tpl->setCurrentBlock("fromday_selection");
00099                         $tpl->setVariable("DAYFR", $key);
00100                         $tpl->setVariable("DAYF", $key);
00101                         $tpl->parseCurrentBlock();
00102                 }
00103                 foreach($day as $key)
00104                 {
00105                         $tpl->setCurrentBlock("today_selection");
00106                         $tpl->setVariable("DAYTO", $key);
00107                         $tpl->setVariable("DAYT", $key);
00108                         $tpl->parseCurrentBlock();
00109                 }
00110                 foreach($month as $key)
00111                 {
00112                         $tpl->setCurrentBlock("tomonth_selection");
00113                         $tpl->setVariable("MONTHTO", $key);
00114                         $tpl->setVariable("MONTHT", $key);
00115                         $tpl->parseCurrentBlock();
00116                 }
00117                 foreach($year as $key)
00118                 {
00119                         $tpl->setCurrentBlock("toyear_selection");
00120                         $tpl->setVariable("YEARTO", $key);
00121                         $tpl->setVariable("YEART", $key);
00122                         $tpl->parseCurrentBlock();
00123                 }
00124                 foreach ($languages as $lang_key)
00125                 {               
00126                         $tpl->setCurrentBlock("language_selection");
00127                         $tpl->setVariable("LANG", $lng->txt("lang_".$lang_key));
00128                         $tpl->setVariable("LANGSHORT", $lang_key);
00129                         $tpl->parseCurrentBlock();
00130                 }
00131                 for($i=0;$i<count($lm);$i++)
00132                 {
00133                         $tpl->setCurrentBlock("lm_selection");
00134                         $tpl->setVariable("LM",$lm[$i][0]);
00135                         $tpl->setVariable("LM_SELECT",$lng->txt($lm[$i][0]));
00136                         $tpl->parseCurrentBlock();
00137                 }
00138                 //test module
00139                 //arlon modified,if there isn't test of the login,the test tracking module will not display!
00140                 $usertracking = new ilUserTracking();
00141                 $result_test = $usertracking->getTestId($_SESSION["AccountId"]);
00142                 if($result_test!="")
00143                 {
00144                         $tpl->addBlockFile("TESTMODULE", "testmodule", "tpl.test_tracking.html");
00145                         $tpl->setVariable("TEST_ACTION", "tracking.php?cmd=test");
00146                         $tpl->setVariable("TXT_TEST_MODULE", $lng->txt("test_module"));
00147                         $tpl->setVariable("TXT_TIME_SEGMENT", $lng->txt("time_segment"));
00148                         $tpl->setVariable("TXT_SEARCH_FOR", $lng->txt("search_for"));
00149                         $tpl->setVariable("TXT_USER", $lng->txt("user"));
00150                         $tpl->setVariable("TXT_TEST",$lng->txt("test"));
00151                         $tpl->setVariable("BTN_TEST",$lng->txt("search"));
00152                         $tracking = new ilUserTracking();
00153                         $test = $tracking->TestTitle($_SESSION["AccountId"]);
00154                         for($i=0;$i<count($test);$i++)
00155                         {
00156                                 $tpl->setCurrentBlock("test_selection");
00157                                 $tpl->setVariable("TEST",$test[$i][0]);
00158                                 $tpl->setVariable("TEST_SELECT",$lng->txt($test[$i][0]));
00159                                 $tpl->parseCurrentBlock();
00160                         }
00161                         foreach($year as $key)
00162                         {
00163                                 $tpl->setCurrentBlock("fromtyear_selection");
00164                                 $tpl->setVariable("YEARFR", $key);
00165                                 $tpl->setVariable("YEARF", $key);
00166                                 $tpl->parseCurrentBlock();
00167                         }
00168                         foreach($month as $key)
00169                         {
00170                                 $tpl->setCurrentBlock("fromtmonth_selection");
00171                                 $tpl->setVariable("MONTHFR", $key);
00172                                 $tpl->setVariable("MONTHF", $key);
00173                                 $tpl->parseCurrentBlock();
00174                         }
00175                         foreach($day as $key)
00176                         {
00177                                 $tpl->setCurrentBlock("fromtday_selection");
00178                                 $tpl->setVariable("DAYFR", $key);
00179                                 $tpl->setVariable("DAYF", $key);
00180                                 $tpl->parseCurrentBlock();
00181                         }
00182                         foreach($day as $key)
00183                         {
00184                                 $tpl->setCurrentBlock("totday_selection");
00185                                 $tpl->setVariable("DAYTO", $key);
00186                                 $tpl->setVariable("DAYT", $key);
00187                                 $tpl->parseCurrentBlock();
00188                         }
00189                         foreach($month as $key)
00190                         {
00191                                 $tpl->setCurrentBlock("totmonth_selection");
00192                                 $tpl->setVariable("MONTHTO", $key);
00193                                 $tpl->setVariable("MONTHT", $key);
00194                                 $tpl->parseCurrentBlock();
00195                         }
00196                         foreach($year as $key)
00197                         {
00198                                 $tpl->setCurrentBlock("totyear_selection");
00199                                 $tpl->setVariable("YEARTO", $key);
00200                                 $tpl->setVariable("YEART", $key);
00201                                 $tpl->parseCurrentBlock();
00202                         }
00203                 }
00204                 $tpl->show();
00205                 
00206 
00207 }
00208 
00209 function searchTest()
00210 {
00211         global $tpl,$lng,$ilias;
00212         
00213         $yearf = $_POST["Fobject"]["yearf"];
00214         $monthf = $_POST["Fobject"]["monthf"];
00215         $dayf = $_POST["Fobject"]["dayf"];
00216         $yeart = $_POST["Fobject"]["yeart"];
00217         $montht= $_POST["Fobject"]["montht"];
00218         $dayt = $_POST["Fobject"]["dayt"];
00219         $from = $yearf."-".$monthf."-".$dayf;
00220         $to = $yeart."-".$montht."-".$dayt;
00221         //$from = mktime($monthf,$dayf,$yearf);
00222         //$to = mktime($montht,$dayt,$yeart);
00223         //$from = strtotime($from);
00224         //$to = strtotime($to);
00225         //echo $from;
00226         //echo "<br>";
00227         //echo $to;
00228         if(($yearf > $yeart)or($yearf==$yeart and $monthf>$montht)or($yearf==$yeart and $monthf==$montht and $dayf>$dayt))
00229         {
00230                 sendInfo($lng->txt("msg_err_search_time"),true);
00231                 header("location:tracking.php");
00232                 exit();
00233         }
00234         if($_POST["time"]!='ht' and $_POST["time"]!='dt')
00235         {
00236                 sendInfo($lng->txt("msg_no_search_time"),true);
00237                 header("location:tracking.php");
00238                 exit();
00239         }
00240         $usertracking = new ilUserTracking();
00241         $result_id = $usertracking->getSubTest($_SESSION["AccountId"]);
00242         $condition = "(acc_obj_id =". $result_id[0][0];
00243         for($i=1;$i < count($result_id);$i++)
00244         {
00245          $condition = $condition." or acc_obj_id=".$result_id[$i][0];
00246         }
00247         $condition = $condition. " ) and acc_time >='".$from."' and acc_time< '".$to."'";
00248 
00249         if(count($usertracking->countResults($condition))== 0)
00250         {
00251                 sendInfo($lng->txt("msg_no_search_result").true);
00252                 header("location:tracking.php");
00253                 exit();
00254         }
00255         include_once "./classes/class.ilTableGUI.php";
00256         $tbl = new ilTableGUI();
00257 
00258         $tpl->addBlockfile("CONTENT", "content", "tpl.table_ut.html");
00259         $tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00260         $usertracking->_locator();
00261         $usertracking->_tables();
00262         $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
00263         if($_POST["search_for"]["usr"]=="usr")//user selected
00264         {
00265                 $title_new = array("login", "test module","client ip","time");
00266                 if($_POST["search_for"]["learn"]=="test")
00267                 {
00268                         $condition = "b.acc_obj_type = '".$_POST["test"]."'";
00269                 }
00270                 else
00271                 {
00272                                 $result_id = $usertracking->getSubTest($_SESSION["AccountId"]);
00273                                 $condition = "(b.acc_obj_id =". $result_id[0][0];
00274                                 for($i=1;$i < count($result_id);$i++)
00275                                 {
00276                                         $condition = $condition." or b.acc_obj_id=".$result_id[$i][0];
00277                                 }
00278                                 $condition = $condition.")";
00279                 }
00280                 
00281                 $condition = $condition." and b.acc_time>='".$from."' and b.acc_time<'".$to."'";
00282                 $this->data["data"] = $usertracking->searchTestResults($condition);
00283                 $this->maxcount = count($this->data["data"]);
00284                 if(count($this->data["data"])<1)
00285                 {
00286                         sendInfo($lng->txt("msg_no_search_result"),true);
00287                         header("location:tracking.php");
00288                 }
00289                 
00290                 $tbl->setTitle($lng->txt("search_result"),0,0);
00291                 foreach ($title_new as $val)
00292                 {
00293                         $header_names[] = $lng->txt($val);
00294                 }
00295                 $tbl->setHeaderNames($header_names);
00296                 //$tbl->setColumnWidth(array("15","75%","25%"));
00297                 $tbl->setMaxCount($this->maxcount);
00298                 $tbl->render();
00299                 if (is_array($this->data["data"]))
00300                 {
00301                 //table cell
00302                         for ($i=0; $i < count($this->data["data"]); $i++)
00303                         {
00304                                 $data = $this->data["data"][$i];
00305                                 $css_row = $i%2==0?"tblrow1":"tblrow2";
00306                                 foreach ($this->data["data"][$i] as $key => $val)
00307                                 {
00308                                         if($val=="")
00309                                         {
00310                                                 $val=0;
00311                                         }
00312                                         $tpl->setCurrentBlock("text");
00313                                         $tpl->setVariable("TEXT_CONTENT", $val);                                        
00314                                         $tpl->parseCurrentBlock();
00315                                         $tpl->setCurrentBlock("table_cell");
00316                                         $tpl->parseCurrentBlock();
00317                                 } //foreach
00318                                 $tpl->setCurrentBlock("tbl_content");
00319                                 $tpl->setVariable("CSS_ROW", $css_row);
00320                                 $tpl->parseCurrentBlock();
00321                         } //for
00322                         $tpl->show();
00323                 }
00324                 
00325         }
00326         else //user not selected
00327         {
00328                 $title_new = array("count","test module","time");
00329                 if($_POST["search_for"]["learn"]=="test")//lm selected
00330                 {
00331                         $condition = "acc_obj_type = '".$_POST["test"]."'";
00332                         if($_POST["time"]=='ht')//hour selected
00333                         {
00334                                 $num = 24;
00335                         }
00336                         else //day selected
00337                         {
00338                                 $num = $usertracking->numDay($from,$to);
00339                                 $from1 = $usertracking->addDay($from);
00340                         }
00341                         include_once "./classes/class.ilTableGUI.php";
00342                         $tbl = new ilTableGUI();        
00343                         $tbl->setTitle($lng->txt("search_result"),0,0);
00344                         foreach ($title_new as $val)
00345                         {
00346                                 $header_names[] = $lng->txt($val);
00347                         }
00348                         $tbl->setHeaderNames($header_names);
00349                         $tbl->setMaxCount($num);
00350                         $tbl->render();
00351                         if($_POST["time"]=='ht')//hour selected 
00352                         {
00353                                 $time = $usertracking->selectTime($from,$to,$condition);
00354                                 for($i=0;$i<24;$i++)
00355                                 {
00356                                         $k = $i+1;
00357                                         $cou = 0;
00358                                         for($j=0;$j<count($time);$j++)
00359                                         {
00360                                                 $time1 = strtotime($time[$j][0]);
00361                                                 $day = date("d",$time1);
00362                                                 $month = date("m",$time1);
00363                                                 $year = date("Y",$time1);
00364                                                 $hour = date("H",$time1);
00365                                                 $min = date("i",$time1); 
00366                                                 $sec = date("s",$time1); 
00367                                                 $numb = date("H",mktime($hour,$min,$sec,$month,$day,$year)); 
00368                                                 $numb = intval($numb);
00369                                                 if($numb >=$i and $numb <$k)
00370                                                 {
00371                                                         $cou=$cou+1;
00372                                                 }
00373                                         }
00374                                         $data[0] = $cou;
00375                                         $data[1] = $_POST["test"];
00376                                         $data[2] = $i.":00:00  ~  ".$k.":00:00";
00377                                         $css_row = $i%2==0?"tblrow1":"tblrow2";
00378                                         foreach ($data as $key => $val)
00379                                         {
00380                                         
00381                                                 $tpl->setCurrentBlock("text");
00382                                                 $tpl->setVariable("TEXT_CONTENT", $val);
00383                                                 $tpl->parseCurrentBlock();
00384                                                 $tpl->setCurrentBlock("table_cell");
00385                                                 $tpl->parseCurrentBlock();
00386                                         }
00387                                         $tpl->setCurrentBlock("tbl_content");
00388                                         $tpl->setVariable("CSS_ROW", $css_row);
00389                                         $tpl->parseCurrentBlock();
00390                 
00391                                 } //for
00392                         }
00393                         else //day selected
00394                         {
00395                                 for($i=0;$i<$num;$i++)
00396                                 {
00397                                         $data[0] = $usertracking->countNum($from,$from1,$condition);
00398                                         $data[1] = $_POST["test"];
00399                                         $data[2] = $from."  ~  ".$from1;
00400                                         $css_row = $i%2==0?"tblrow1":"tblrow2";
00401         
00402                                         foreach ($data as $key => $val)
00403                                         {
00404                                                 $tpl->setCurrentBlock("text");
00405                                                 $tpl->setVariable("TEXT_CONTENT", $val);
00406                                                 $tpl->parseCurrentBlock();
00407                                                 $tpl->setCurrentBlock("table_cell");
00408                                                 $tpl->parseCurrentBlock();
00409                                         }
00410                                         $tpl->setCurrentBlock("tbl_content");
00411                                         $tpl->setVariable("CSS_ROW", $css_row);
00412                                         $tpl->parseCurrentBlock();
00413                                         $from = $from1;
00414                                         $from1 = $usertracking->addDay($from);          
00415                                 } //for
00416                         }
00417                         $tpl->show();
00418                 }
00419                 else //test not selected
00420                 {
00421                         if($_POST["time"]=='ht')
00422                         {
00423                                 $num = 24;
00424                         }
00425                         else
00426                         {
00427                                 $num = $usertracking->numDay($from,$to);
00428                                 $from1 = $usertracking->addDay($from);
00429                                 $num1 = $num * count($usertracking->getTest($_SESSION["AccountId"]));
00430                         }
00431                         $result = $usertracking->getTest($_SESSION["AccountId"]);
00432                         if(count($result)<1)
00433                         {
00434                                 sendInfo($lng->txt("msg_no_search_result"),true);
00435                                 header("location:tracking.php");
00436                         }
00437                         $sm = $result[0][0];
00438                         for($t=1;$t < count($result);$t++)
00439                         {
00440                                 $sm = $sm.",".$result[$t][0];
00441                         }
00442                         include_once "./classes/class.ilTableGUI.php";
00443                         $tbl = new ilTableGUI();
00444                         $tbl->setTitle($lng->txt("search_result"),0,0);
00445                         foreach ($title_new as $val)
00446                         {
00447                                 $header_names[] = $lng->txt($val);
00448                         }
00449                         $tbl->setHeaderNames($header_names);
00450                         if($_POST["time"]=='ht')
00451                         {
00452                                 $tbl->setMaxCount($num);
00453                                 $tbl->render();
00454                                 $result_id = $usertracking->getSubTest($_SESSION["AccountId"]);
00455                                 $condition = "(acc_obj_id =". $result_id[0][0];
00456                                 for($i=1;$i < count($result_id);$i++)
00457                                 {
00458                                         $condition = $condition." or acc_obj_id=".$result_id[$i][0];
00459                                 }
00460                                 $condition = $condition.")'";
00461                                 $time = $usertracking->selectTime($from,$to,$condition);
00462                                 
00463                                 for($i=0;$i<24;$i++)
00464                                 {       
00465                                         $k = $i+1;
00466                                         $cou = 0;
00467                                         for($j=0;$j<count($time);$j++)
00468                                         {
00469                                                 $time1 = strtotime($time[$j][0]);
00470                                                 $day = date("d",$time1);
00471                                                 $month = date("m",$time1);
00472                                                 $year = date("Y",$time1);
00473                                                 $hour = date("H",$time1);
00474                                                 $min = date("i",$time1); 
00475                                                 $sec = date("s",$time1); 
00476                                                 $numb = date("H",mktime($hour,$min,$sec,$month,$day,$year)); 
00477                                                 $numb = intval($numb);
00478                                                 if($numb >=$i and $numb <$k)
00479                                                 {
00480                                                         $cou=$cou+1;
00481                                                 }
00482                                         }
00483                                         $data[0] = $cou;
00484                                         //$data[1] = $sm;
00485                                         $data[1] = "all of your subjects!";
00486                                         $data[2] = $i.":00:00  ~  ".$k.":00:00";
00487                                         $css_row = $i%2==0?"tblrow1":"tblrow2";
00488                                         foreach ($data as $key => $val)
00489                                         {
00490                                         
00491                                                 $tpl->setCurrentBlock("text");
00492                                                 $tpl->setVariable("TEXT_CONTENT", $val);
00493                                                 $tpl->parseCurrentBlock();
00494                                                 $tpl->setCurrentBlock("table_cell");
00495                                                 $tpl->parseCurrentBlock();
00496                                         }
00497                                         $tpl->setCurrentBlock("tbl_content");
00498                                         $tpl->setVariable("CSS_ROW", $css_row);
00499                                         $tpl->parseCurrentBlock();
00500                 
00501                                 } //for
00502                         }
00503                         else
00504                         {
00505                                 $tbl->setMaxCount($num1);
00506                                 $tbl->render();
00507                                 $from1 = $usertracking->addDay($from);
00508                                 /*
00509                                 $lm = $usertracking->getTest($_SESSION["AccountId"]);
00510                                 $condition2 = $condition." and (acc_obj_type = '".$lm[0][0]."'";
00511                                 for($j=1;$j<count($usertracking->getTest($_SESSION["AccountId"]));$j++)
00512                                 {
00513                                         $condition2 = $condition2." or acc_obj_type = '".$lm[$j][0]."'";
00514                                 }
00515                                 $condition2 = $condition2.")";
00516                                 */
00517                                 for($i=0;$i<$num;$i++)
00518                                 {       
00519                                         $data[$i][0] = $usertracking->countNum($from,$from1,$condition);
00520                                         $data[$i][1] = "all of your tests!";
00521                                         $data[$i][2] = $from."  ~  ".$from1;
00522                                         $css_row = $i%2==0?"tblrow1":"tblrow2";
00523                                         foreach ($data[$i] as $key => $val)
00524                                         {
00525                                                 $tpl->setCurrentBlock("text");
00526                                                 $tpl->setVariable("TEXT_CONTENT", $val);
00527                                                 $tpl->parseCurrentBlock();
00528                                                 $tpl->setCurrentBlock("table_cell");
00529                                                 $tpl->parseCurrentBlock();
00530                                         }
00531                                         $tpl->setCurrentBlock("tbl_content");
00532                                         $tpl->setVariable("CSS_ROW", $css_row);
00533                                         $tpl->parseCurrentBlock();
00534                                         $from = $from1;
00535                                         $from1 = $usertracking->addDay($from);
00536                                 }//for          
00537                         } 
00538                         $tpl->show();
00539                 }
00540         }//else 
00541 }
00542 function searchForm ()
00543 {
00544         global $tpl,$lng,$ilias;
00545         
00546         $yearf = $_POST["Fobject"]["yearf"];
00547         $monthf = $_POST["Fobject"]["monthf"];
00548         $dayf = $_POST["Fobject"]["dayf"];
00549         $yeart = $_POST["Fobject"]["yeart"];
00550         $montht= $_POST["Fobject"]["montht"];
00551         $dayt = $_POST["Fobject"]["dayt"];
00552         $from = $yearf."-".$monthf."-".$dayf;
00553         $to = $yeart."-".$montht."-".$dayt;
00554         //$from = mktime($monthf,$dayf,$yearf);
00555         //$to = mktime($montht,$dayt,$yeart);
00556         //$from = strtotime($from);
00557         //$to = strtotime($to);
00558         //echo $from;
00559         //echo "<br>";
00560         //echo $to;
00561         if(($yearf > $yeart)or($yearf==$yeart and $monthf>$montht)or($yearf==$yeart and $monthf==$montht and $dayf>$dayt))
00562         {
00563                 sendInfo($lng->txt("msg_err_search_time"),true);
00564                 header("location:tracking.php");
00565                 exit();
00566         }
00567         if($_POST["time"]!='h' and $_POST["time"]!='d')
00568         {
00569                 sendInfo($lng->txt("msg_no_search_time"),true);
00570                 header("location:tracking.php");
00571                 exit();
00572         }
00573         $usertracking = new ilUserTracking();
00574         $result_id = $usertracking->getSubId($_SESSION["AccountId"]);
00575         $condition = "(acc_obj_id =". $result_id[0][0];
00576         for($i=1;$i < count($result_id);$i++)
00577         {
00578          $condition = $condition." or acc_obj_id=".$result_id[$i][0];
00579         }
00580         $condition = $condition. " ) and acc_time >='".$from."' and acc_time< '".$to."'";
00581 
00582         if(count($usertracking->countResults($condition))== 0)
00583         {
00584                 sendInfo($lng->txt("msg_no_search_result").true);
00585                 header("location:tracking.php");
00586                 exit();
00587         }
00588         include_once "./classes/class.ilTableGUI.php";
00589         $tbl = new ilTableGUI();
00590 
00591         $tpl->addBlockfile("CONTENT", "content", "tpl.table_ut.html");
00592         $tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00593         $usertracking->_locator();
00594         $usertracking->_tables();
00595         $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
00596         if($_POST["search_for"]["usr"]=="usr")//user selected
00597         {
00598                 $title_new = array("login", "learning module", "language","client ip","time");
00599                 $lan = $_POST["Fobject"]["language"];
00600                 if($_POST["search_for"]["learn"]=="lm")
00601                 {
00602                         $condition = "b.acc_obj_type = '".$_POST["lm"]."'";
00603                         $condition = $condition." and b.language ='".$lan."'";
00604                 }
00605                 else
00606                 {
00607                                 $result_id = $usertracking->getSubId($_SESSION["AccountId"]);
00608                                 $lan = $_POST["Fobject"]["language"];
00609                                 $condition = "(b.acc_obj_id =". $result_id[0][0];
00610                                 for($i=1;$i < count($result_id);$i++)
00611                                 {
00612                                         $condition = $condition." or b.acc_obj_id=".$result_id[$i][0];
00613                                 }
00614                                 $condition = $condition.") and b.language = '".$lan."'";
00615                 }
00616                 
00617                 $condition = $condition." and b.acc_time>='".$from."' and b.acc_time<'".$to."'";
00618                 $this->data["data"] = $usertracking->searchResults($condition);
00619                 $this->maxcount = count($this->data["data"]);
00620                 if(count($this->data["data"])<1)
00621                 {
00622                         sendInfo($lng->txt("msg_no_search_result"),true);
00623                         header("location:tracking.php");
00624                 }
00625                 
00626                 $tbl->setTitle($lng->txt("search_result"),0,0);
00627                 foreach ($title_new as $val)
00628                 {
00629                         $header_names[] = $lng->txt($val);
00630                 }
00631                 $tbl->setHeaderNames($header_names);
00632                 //$tbl->setColumnWidth(array("15","75%","25%"));
00633                 $tbl->setMaxCount($this->maxcount);
00634                 $tbl->render();
00635                 if (is_array($this->data["data"]))
00636                 {
00637                 //table cell
00638                         for ($i=0; $i < count($this->data["data"]); $i++)
00639                         {
00640                                 $data = $this->data["data"][$i];
00641                                 $css_row = $i%2==0?"tblrow1":"tblrow2";
00642                                 foreach ($this->data["data"][$i] as $key => $val)
00643                                 {
00644                                         if($val=="")
00645                                         {
00646                                                 $val=0;
00647                                         }
00648                                         $tpl->setCurrentBlock("text");
00649                                         $tpl->setVariable("TEXT_CONTENT", $val);                                        
00650                                         $tpl->parseCurrentBlock();
00651                                         $tpl->setCurrentBlock("table_cell");
00652                                         $tpl->parseCurrentBlock();
00653                                 } //foreach
00654                                 $tpl->setCurrentBlock("tbl_content");
00655                                 $tpl->setVariable("CSS_ROW", $css_row);
00656                                 $tpl->parseCurrentBlock();
00657                         } //for
00658                         $tpl->show();
00659                 }
00660                 
00661         }
00662         else //user not selected
00663         {
00664                 $title_new = array("count","learning module","language","time");
00665                 if($_POST["search_for"]["learn"]=="lm")//lm selected
00666                 {
00667                         $condition = "acc_obj_type = '".$_POST["lm"]."'";
00668                         $lan = $_POST["Fobject"]["language"];
00669                         $condition = $condition." and language = '".$lan."'";
00670                         if($_POST["time"]=='h')//hour selected
00671                         {
00672                                 $num = 24;
00673                         }
00674                         else //day selected
00675                         {
00676                                 $num = $usertracking->numDay($from,$to);
00677                                 $from1 = $usertracking->addDay($from);
00678                         }
00679                         include_once "./classes/class.ilTableGUI.php";
00680                         $tbl = new ilTableGUI();        
00681                         $tbl->setTitle($lng->txt("search_result"),0,0);
00682                         foreach ($title_new as $val)
00683                         {
00684                                 $header_names[] = $lng->txt($val);
00685                         }
00686                         $tbl->setHeaderNames($header_names);
00687                         $tbl->setMaxCount($num);
00688                         $tbl->render();
00689                         if($_POST["time"]=='h')//hour selected 
00690                         {
00691                                 $time = $usertracking->selectTime($from,$to,$condition);
00692                                 for($i=0;$i<24;$i++)
00693                                 {
00694                                         $k = $i+1;
00695                                         $cou = 0;
00696                                         for($j=0;$j<count($time);$j++)
00697                                         {
00698                                                 $time1 = strtotime($time[$j][0]);
00699                                                 $day = date("d",$time1);
00700                                                 $month = date("m",$time1);
00701                                                 $year = date("Y",$time1);
00702                                                 $hour = date("H",$time1);
00703                                                 $min = date("i",$time1); 
00704                                                 $sec = date("s",$time1); 
00705                                                 $numb = date("H",mktime($hour,$min,$sec,$month,$day,$year)); 
00706                                                 $numb = intval($numb);
00707                                                 if($numb >=$i and $numb <$k)
00708                                                 {
00709                                                         $cou=$cou+1;
00710                                                 }
00711                                         }
00712                                         $data[0] = $cou;
00713                                         $data[1] = $_POST["lm"];
00714                                         $data[2] = $_POST["Fobject"]["language"];
00715                                         $data[3] = $i.":00:00  ~  ".$k.":00:00";
00716                                         $css_row = $i%2==0?"tblrow1":"tblrow2";
00717                                         foreach ($data as $key => $val)
00718                                         {
00719                                         
00720                                                 $tpl->setCurrentBlock("text");
00721                                                 $tpl->setVariable("TEXT_CONTENT", $val);
00722                                                 $tpl->parseCurrentBlock();
00723                                                 $tpl->setCurrentBlock("table_cell");
00724                                                 $tpl->parseCurrentBlock();
00725                                         }
00726                                         $tpl->setCurrentBlock("tbl_content");
00727                                         $tpl->setVariable("CSS_ROW", $css_row);
00728                                         $tpl->parseCurrentBlock();
00729                 
00730                                 } //for
00731                         }
00732                         else //day selected
00733                         {
00734                                 for($i=0;$i<$num;$i++)
00735                                 {
00736                                         $data[0] = $usertracking->countNum($from,$from1,$condition);
00737                                         $data[1] = $_POST["lm"];
00738                                         $data[2] = $_POST["Fobject"]["language"];
00739                                         $data[3] = $from."  ~  ".$from1;
00740                                         $css_row = $i%2==0?"tblrow1":"tblrow2";
00741         
00742                                         foreach ($data as $key => $val)
00743                                         {
00744                                                 $tpl->setCurrentBlock("text");
00745                                                 $tpl->setVariable("TEXT_CONTENT", $val);
00746                                                 $tpl->parseCurrentBlock();
00747                                                 $tpl->setCurrentBlock("table_cell");
00748                                                 $tpl->parseCurrentBlock();
00749                                         }
00750                                         $tpl->setCurrentBlock("tbl_content");
00751                                         $tpl->setVariable("CSS_ROW", $css_row);
00752                                         $tpl->parseCurrentBlock();
00753                                         $from = $from1;
00754                                         $from1 = $usertracking->addDay($from);          
00755                                 } //for
00756                         }
00757                         $tpl->show();
00758                 }
00759                 else //lm not selected
00760                 {
00761                         if($_POST["time"]=='h')
00762                         {
00763                                 $num = 24;
00764                         }
00765                         else
00766                         {
00767                                 $num = $usertracking->numDay($from,$to);
00768                                 $from1 = $usertracking->addDay($from);
00769                                 $num1 = $num * count($usertracking->getlm($_SESSION["AccountId"]));
00770                         }
00771                         $result = $usertracking->getlm($_SESSION["AccountId"]);
00772                         if(count($result)<1)
00773                         {
00774                                 sendInfo($lng->txt("msg_no_search_result"),true);
00775                                 header("location:tracking.php");
00776                         }
00777                         $sm = $result[0][0];
00778                         for($t=1;$t < count($result);$t++)
00779                         {
00780                                 $sm = $sm.",".$result[$t][0];
00781                         }
00782                         $lan = $_POST["Fobject"]["language"];
00783                         $condition ="language = '".$lan."'";
00784                         include_once "./classes/class.ilTableGUI.php";
00785                         $tbl = new ilTableGUI();
00786                         $tbl->setTitle($lng->txt("search_result"),0,0);
00787                         foreach ($title_new as $val)
00788                         {
00789                                 $header_names[] = $lng->txt($val);
00790                         }
00791                         $tbl->setHeaderNames($header_names);
00792                         if($_POST["time"]=='h')
00793                         {
00794                                 $tbl->setMaxCount($num);
00795                                 $tbl->render();
00796                                 $result_id = $usertracking->getSubId($_SESSION["AccountId"]);
00797                                 $lan = $_POST["Fobject"]["language"];
00798                                 $condition = "(acc_obj_id =". $result_id[0][0];
00799                                 for($i=1;$i < count($result_id);$i++)
00800                                 {
00801                                         $condition = $condition." or acc_obj_id=".$result_id[$i][0];
00802                                 }
00803                                 $condition = $condition.") and language = '".$lan."'";
00804                                 $time = $usertracking->selectTime($from,$to,$condition);
00805                                 
00806                                 for($i=0;$i<24;$i++)
00807                                 {       
00808                                         $k = $i+1;
00809                                         $cou = 0;
00810                                         for($j=0;$j<count($time);$j++)
00811                                         {
00812                                                 $time1 = strtotime($time[$j][0]);
00813                                                 $day = date("d",$time1);
00814                                                 $month = date("m",$time1);
00815                                                 $year = date("Y",$time1);
00816                                                 $hour = date("H",$time1);
00817                                                 $min = date("i",$time1); 
00818                                                 $sec = date("s",$time1); 
00819                                                 $numb = date("H",mktime($hour,$min,$sec,$month,$day,$year)); 
00820                                                 $numb = intval($numb);
00821                                                 if($numb >=$i and $numb <$k)
00822                                                 {
00823                                                         $cou=$cou+1;
00824                                                 }
00825                                         }
00826                                         $data[0] = $cou;
00827                                         //$data[1] = $sm;
00828                                         $data[1] = "all of your subjects!";
00829                                         $data[2] = $_POST["Fobject"]["language"];
00830                                         $data[3] = $i.":00:00  ~  ".$k.":00:00";
00831                                         $css_row = $i%2==0?"tblrow1":"tblrow2";
00832                                         foreach ($data as $key => $val)
00833                                         {
00834                                         
00835                                                 $tpl->setCurrentBlock("text");
00836                                                 $tpl->setVariable("TEXT_CONTENT", $val);
00837                                                 $tpl->parseCurrentBlock();
00838                                                 $tpl->setCurrentBlock("table_cell");
00839                                                 $tpl->parseCurrentBlock();
00840                                         }
00841                                         $tpl->setCurrentBlock("tbl_content");
00842                                         $tpl->setVariable("CSS_ROW", $css_row);
00843                                         $tpl->parseCurrentBlock();
00844                 
00845                                 } //for
00846                         }
00847                         else
00848                         {
00849                                 $tbl->setMaxCount($num1);
00850                                 $tbl->render();
00851                                 $lan = $_POST["Fobject"]["language"];
00852                                 $condition ="language = '".$lan."'";
00853                                 $from1 = $usertracking->addDay($from);
00854                                 $lm = $usertracking->getlm($_SESSION["AccountId"]);
00855                                 $condition2 = $condition." and (acc_obj_type = '".$lm[0][0]."'";
00856                                 for($j=1;$j<count($usertracking->getlm($_SESSION["AccountId"]));$j++)
00857                                 {
00858                                         $condition2 = $condition2." or acc_obj_type = '".$lm[$j][0]."'";
00859                                 }
00860                                 $condition2 = $condition2.")";
00861                                 for($i=0;$i<$num;$i++)
00862                                 {       
00863                                         $data[$i][0] = $usertracking->countNum($from,$from1,$condition2);
00864                                         $data[$i][1] = "all of your subjects!";
00865                                         $data[$i][2] = $_POST["Fobject"]["language"];
00866                                         $data[$i][3] = $from."  ~  ".$from1;
00867                                         $css_row = $i%2==0?"tblrow1":"tblrow2";
00868                                         foreach ($data[$i] as $key => $val)
00869                                         {
00870                                                 $tpl->setCurrentBlock("text");
00871                                                 $tpl->setVariable("TEXT_CONTENT", $val);
00872                                                 $tpl->parseCurrentBlock();
00873                                                 $tpl->setCurrentBlock("table_cell");
00874                                                 $tpl->parseCurrentBlock();
00875                                         }
00876                                         $tpl->setCurrentBlock("tbl_content");
00877                                         $tpl->setVariable("CSS_ROW", $css_row);
00878                                         $tpl->parseCurrentBlock();
00879                                         $from = $from1;
00880                                         $from1 = $usertracking->addDay($from);
00881                                 }//for          
00882                         } 
00883                         $tpl->show();
00884                 }
00885         }//else 
00886 }
00887 ?>

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