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

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