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

Services/Tracking/classes/class.ilOnlineTracking.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00038 class ilOnlineTracking
00039 {
00040         // Static
00041         function _getOnlineTime($a_user_id)
00042         {
00043                 global $ilDB;
00044 
00045                 $query = "SELECT * FROM ut_online WHERE usr_id = '".$a_user_id."'";
00046                 $res = $ilDB->query($query);
00047                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00048                 {
00049                         $access_time = $row->access_time;
00050                         $online_time = $row->online_time;
00051                 }
00052                 return (int) $online_time;
00053         }
00054 
00055                 
00056 
00057         function _addUser($a_user_id)
00058         {
00059                 global $ilDB;
00060 
00061                 $query = "SELECT * FROM ut_online WHERE usr_id = '".$a_user_id."'";
00062                 $res = $ilDB->query($query);
00063                 
00064                 if($res->numRows())
00065                 {
00066                         return false;
00067                 }
00068                 $query = "INSERT INTO ut_online SET usr_id = '".$a_user_id."', access_time = '".time()."'";
00069                 $ilDB->query($query);
00070 
00071                 return true;
00072         }
00073 
00074         function _updateAccess($a_usr_id)
00075         {
00076                 global $ilDB,$ilias;
00077 
00078                 $query = "SELECT * FROM ut_online WHERE usr_id = '".$a_usr_id."'";
00079                 $res = $ilDB->query($query);
00080 
00081                 if(!$res->numRows())
00082                 {
00083                         return false;
00084                 }
00085                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00086                 {
00087                         $access_time = $row->access_time;
00088                         $online_time = $row->online_time;
00089                 }
00090                 
00091                 $time_span = (int) $ilias->getSetting("tracking_time_span",300);
00092 
00093                 if(($diff = time() - $access_time) <= $time_span)
00094                 {
00095                         $query = "UPDATE ut_online SET online_time = online_time + '".$diff."', access_time = '".time().
00096                                 "' WHERE usr_id = '".$a_usr_id."'";
00097                         $ilDB->query($query);
00098                 }
00099                 else
00100                 {
00101                         $query = "UPDATE ut_online SET access_time = '".time().
00102                                 "' WHERE usr_id = '".$a_usr_id."'";
00103                         $ilDB->query($query);
00104                 }
00105                 return true;
00106         }
00107 }
00108 ?>

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