parent
f9d5914c2c
commit
400bb10af4
@ -1,200 +0,0 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* @author Thomas Depraetere |
||||
* @author Hugues Peeters |
||||
* @author Christophe Gesche |
||||
* @author Sebastien Piraux |
||||
* |
||||
* @package chamilo.tracking |
||||
*/ |
||||
// TODO: Is this file deprecated? |
||||
|
||||
$reqdate = $_REQUEST['reqdate']; |
||||
$period = $_REQUEST['period']; |
||||
$displayType = $_REQUEST['displayType']; |
||||
require_once '../inc/global.inc.php'; |
||||
|
||||
$courseId = api_get_course_int_id(); |
||||
|
||||
$interbreadcrumb[] = array( |
||||
"url" => "courseLog.php", |
||||
"name" => get_lang('ToolName'), |
||||
); |
||||
|
||||
$nameTools = get_lang('TrafficDetails'); |
||||
|
||||
$htmlHeadXtra[] = "<style type='text/css'> |
||||
/*<![CDATA[*/ |
||||
.secLine {background-color : #E6E6E6;} |
||||
.content {padding-left : 15px;padding-right : 15px; } |
||||
.specialLink{color : #0000FF;} |
||||
/*]]>*/ |
||||
</style> |
||||
<style media='print' type='text/css'> |
||||
/*<![CDATA[*/ |
||||
td {border-bottom: thin dashed gray;} |
||||
/*]]>*/ |
||||
</style>"; |
||||
//@todo use Database library |
||||
$TABLETRACK_ACCESS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS); |
||||
Display::display_header($nameTools, "Tracking"); |
||||
|
||||
// the variables for the days and the months |
||||
// Defining the shorts for the days |
||||
$DaysShort = api_get_week_days_short(); |
||||
// Defining the days of the week to allow translation of the days |
||||
$DaysLong = api_get_week_days_long(); |
||||
// Defining the months of the year to allow translation of the months |
||||
$MonthsLong = api_get_months_long(); |
||||
|
||||
$is_allowedToTrack = $is_courseAdmin; |
||||
|
||||
?> |
||||
<h3> |
||||
<?php echo $nameTools ?> |
||||
</h3> |
||||
<table width="100%" cellpadding="2" cellspacing="3" border="0"> |
||||
<?php |
||||
if ($is_allowedToTrack) { |
||||
if (!isset($reqdate) || $reqdate < 0 || $reqdate > 2149372861) |
||||
$reqdate = time(); |
||||
//** dislayed period |
||||
echo "<tr><td><b>"; |
||||
switch($period) { |
||||
case "year" : |
||||
echo date(" Y", $reqdate); |
||||
break; |
||||
case "month" : |
||||
echo $MonthsLong[date("n", $reqdate)-1].date(" Y", $reqdate); |
||||
break; |
||||
// default == day |
||||
default : |
||||
$period = "day"; |
||||
case "day" : |
||||
echo $DaysLong[date("w" , $reqdate)].date(" d " , $reqdate).$MonthsLong[date("n", $reqdate)-1].date(" Y" , $reqdate); |
||||
break; |
||||
} |
||||
echo "</b></tr></td>"; |
||||
//** menu |
||||
echo "<tr> |
||||
<td>"; |
||||
echo " ".get_lang('PeriodToDisplay')." : [<a href='".api_get_self()."?period=year&reqdate=$reqdate' class='specialLink'>".get_lang('PeriodYear')."</a>] |
||||
[<a href='".api_get_self()."?period=month&reqdate=$reqdate' class='specialLink'>".get_lang('PeriodMonth')."</a>] |
||||
[<a href='".api_get_self()."?period=day&reqdate=$reqdate' class='specialLink'>".get_lang('PeriodDay')."</a>] |
||||
|| |
||||
".get_lang('DetailView')." : |
||||
"; |
||||
|
||||
switch($period) { |
||||
case "year" : |
||||
//-- if period is "year" display can be by month, day or hour |
||||
echo " [<a href='".api_get_self()."?period=$period&reqdate=$reqdate&displayType=month' class='specialLink'>".get_lang('PeriodMonth')."</a>]"; |
||||
case "month" : |
||||
//-- if period is "month" display can be by day or hour |
||||
echo " [<a href='".api_get_self()."?period=$period&reqdate=$reqdate&displayType=day' class='specialLink'>".get_lang('PeriodDay')."</a>]"; |
||||
case "day" : |
||||
//-- if period is "day" display can only be by hour |
||||
echo " [<a href='".api_get_self()."?period=$period&reqdate=$reqdate&displayType=hour' class='specialLink'>".get_lang('PeriodHour')."</a>]"; |
||||
break; |
||||
} |
||||
|
||||
echo " || "; |
||||
|
||||
switch ($period) { |
||||
case "year" : |
||||
// previous and next date must be evaluated |
||||
// 30 days should be a good approximation |
||||
$previousReqDate = mktime(1,1,1,1,1,date("Y",$reqdate)-1); |
||||
$nextReqDate = mktime(1,1,1,1,1,date("Y",$reqdate)+1); |
||||
echo " |
||||
[<a href='".api_get_self()."?period=$period&reqdate=$previousReqDate&displayType=$displayType' class='specialLink'>".get_lang('PreviousYear')."</a>] |
||||
[<a href='".api_get_self()."?period=$period&reqdate=$nextReqDate&displayType=$displayType' class='specialLink'>".get_lang('NextYear')."</a>] |
||||
"; |
||||
break; |
||||
case "month" : |
||||
// previous and next date must be evaluated |
||||
// 30 days should be a good approximation |
||||
$previousReqDate = mktime(1,1,1,date("m",$reqdate)-1,1,date("Y",$reqdate)); |
||||
$nextReqDate = mktime(1,1,1,date("m",$reqdate)+1,1,date("Y",$reqdate)); |
||||
echo " |
||||
[<a href='".api_get_self()."?period=$period&reqdate=$previousReqDate&displayType=$displayType' class='specialLink'>".get_lang('PreviousMonth')."</a>] |
||||
[<a href='".api_get_self()."?period=$period&reqdate=$nextReqDate&displayType=$displayType' class='specialLink'>".get_lang('NextMonth')."</a>] |
||||
"; |
||||
break; |
||||
case "day" : |
||||
// previous and next date must be evaluated |
||||
$previousReqDate = $reqdate - 86400; |
||||
$nextReqDate = $reqdate + 86400; |
||||
echo " |
||||
[<a href='".api_get_self()."?period=$period&reqdate=$previousReqDate&displayType=$displayType' class='specialLink'>".get_lang('PreviousDay')."</a>] |
||||
[<a href='".api_get_self()."?period=$period&reqdate=$nextReqDate&displayType=$displayType' class='specialLink'>".get_lang('NextDay')."</a>] |
||||
"; |
||||
break; |
||||
} |
||||
echo "</td></tr>"; |
||||
// display information about this period |
||||
switch ($period) { |
||||
// all days |
||||
case "year" : |
||||
$sql = "SELECT UNIX_TIMESTAMP( access_date ) |
||||
FROM $TABLETRACK_ACCESS |
||||
WHERE YEAR( access_date ) = YEAR( FROM_UNIXTIME( '$reqdate' ) ) |
||||
AND c_id = $courseId |
||||
AND access_tool IS NULL "; |
||||
if ($displayType == "month") { |
||||
$sql .= "ORDER BY UNIX_TIMESTAMP( access_date)"; |
||||
$month_array = StatsUtils::monthTab($sql); |
||||
StatsUtils::makeHitsTable($month_array,get_lang('PeriodMonth')); |
||||
} elseif($displayType == "day") { |
||||
$sql .= "ORDER BY DAYOFYEAR( access_date)"; |
||||
$days_array = StatsUtils::daysTab($sql); |
||||
StatsUtils::makeHitsTable($days_array,get_lang('PeriodDay')); |
||||
} else { |
||||
// by hours by default |
||||
$sql .= "ORDER BY HOUR( access_date)"; |
||||
$hours_array = StatsUtils::hoursTab($sql); |
||||
StatsUtils::makeHitsTable($hours_array,get_lang('PeriodHour')); |
||||
} |
||||
break; |
||||
// all days |
||||
case "month" : |
||||
$sql = "SELECT UNIX_TIMESTAMP( access_date ) |
||||
FROM $TABLETRACK_ACCESS |
||||
WHERE MONTH(access_date) = MONTH (FROM_UNIXTIME( '$reqdate' ) ) |
||||
AND YEAR( access_date ) = YEAR( FROM_UNIXTIME( '$reqdate' ) ) |
||||
AND c_id = $courseId |
||||
AND access_tool IS NULL "; |
||||
if ($displayType == "day") { |
||||
$sql .= "ORDER BY DAYOFYEAR( access_date)"; |
||||
$days_array = StatsUtils::daysTab($sql); |
||||
StatsUtils::makeHitsTable($days_array,get_lang('PeriodDay')); |
||||
} else { |
||||
// by hours by default |
||||
$sql .= "ORDER BY HOUR( access_date)"; |
||||
$hours_array = StatsUtils::hoursTab($sql); |
||||
StatsUtils:: makeHitsTable($hours_array,get_lang('PeriodHour')); |
||||
} |
||||
break; |
||||
// all hours |
||||
case "day" : |
||||
$sql = "SELECT UNIX_TIMESTAMP( access_date ) |
||||
FROM $TABLETRACK_ACCESS |
||||
WHERE DAYOFMONTH(access_date) = DAYOFMONTH(FROM_UNIXTIME( '$reqdate' ) ) |
||||
AND MONTH(access_date) = MONTH (FROM_UNIXTIME( '$reqdate' ) ) |
||||
AND YEAR( access_date ) = YEAR( FROM_UNIXTIME( '$reqdate' ) ) |
||||
AND c_id = $courseId |
||||
AND access_tool IS NULL |
||||
ORDER BY HOUR( access_date )"; |
||||
$hours_array = StatsUtils::hoursTab($sql,$reqdate); |
||||
StatsUtils::makeHitsTable($hours_array,get_lang('PeriodHour')); |
||||
break; |
||||
} |
||||
} else { |
||||
// not allowed to track |
||||
api_not_allowed(); |
||||
} |
||||
?> |
||||
</table> |
||||
<?php |
||||
Display::display_footer(); |
||||
@ -1,264 +0,0 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
// TODO: Is this file deprecated? |
||||
|
||||
/** |
||||
* @author Thomas Depraetere |
||||
* @author Hugues Peeters |
||||
* @author Christophe Gesche |
||||
* @author Sebastien Piraux |
||||
* |
||||
* @package chamilo.tracking |
||||
*/ |
||||
/** |
||||
* Code |
||||
*/ |
||||
|
||||
/* INIT SECTION */ |
||||
|
||||
$tool = $_REQUEST['tool']; |
||||
$period = $_REQUEST['period']; |
||||
$reqDate = $_REQUEST['reqDate']; |
||||
include '../inc/global.inc.php'; |
||||
|
||||
$nameTools = get_lang('ToolName'); |
||||
|
||||
$interbreadcrumb[]= array ("url"=>"courseLog.php", "name"=> "Statistics"); |
||||
|
||||
$htmlHeadXtra[] = "<style type='text/css'> |
||||
/*<![CDATA[*/ |
||||
.mainLine {font-weight : bold;color : #FFFFFF;background-color : $colorDark;padding-left : 15px;padding-right : 15px;} |
||||
.secLine {color : #000000;background-color : $666666;padding-left : 15px;padding-right : 15px;} |
||||
.content {padding-left : 25px;} |
||||
.specialLink{color : #0000FF;} |
||||
.minilink{} |
||||
.minitext{} |
||||
/*]]>*/ |
||||
</style> |
||||
<style media='print' type='text/css'> |
||||
/*<![CDATA[*/ |
||||
td {border-bottom: thin dashed gray;} |
||||
/*]]>*/ |
||||
</style>"; |
||||
Display::display_header($nameTools,"Tracking"); |
||||
?> |
||||
|
||||
<h3> |
||||
<?php echo $nameTools; ?> |
||||
</h3> |
||||
|
||||
<?php |
||||
|
||||
// the variables for the days and the months |
||||
// Defining the shorts for the days |
||||
$DaysShort = api_get_week_days_short(); |
||||
// Defining the days of the week to allow translation of the days |
||||
$DaysLong = api_get_week_days_long(); |
||||
// Defining the months of the year to allow translation of the months |
||||
$MonthsLong = api_get_months_long(); |
||||
// Defining the months of the year to allow translation of the months |
||||
$MonthsShort = api_get_months_short(); |
||||
|
||||
$tool=$_REQUEST['tool']; |
||||
$period=$_REQUEST['period']; |
||||
$reqdate=$_REQUEST['reqdate']; |
||||
?> |
||||
<table width="100%" cellpadding="2" cellspacing="0" border="0"> |
||||
<?php |
||||
$TABLETRACK_ACCESS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS); |
||||
$courseId = api_get_course_int_id(); |
||||
//stats for the current course |
||||
if(isset($_cid)) { |
||||
// to see stats of one course user must be courseAdmin of this course |
||||
$is_allowedToTrack = $is_courseAdmin; |
||||
$courseCodeEqualcidIfNeeded = "AND c_id = '$courseId'"; |
||||
} else { |
||||
// stats for all courses |
||||
// to see stats of all courses user must be platformAdmin |
||||
$is_allowedToTrack = $is_platformAdmin; |
||||
$courseCodeEqualcidIfNeeded = ""; |
||||
} |
||||
if( $is_allowedToTrack) { |
||||
// list of all tools |
||||
if (!isset($tool)) { |
||||
$sql = "SELECT access_tool, count( access_tool ) |
||||
FROM $TABLETRACK_ACCESS |
||||
WHERE access_tool IS NOT NULL |
||||
$courseCodeEqualcidIfNeeded |
||||
GROUP BY access_tool"; |
||||
echo "<tr><td>"; |
||||
echo "<tr> |
||||
<td> |
||||
"; |
||||
if(isset($_cid)) echo "<b>$_cid : </b>"; |
||||
echo " <b>".get_lang('ToolList')."</b> |
||||
</td> |
||||
</tr> |
||||
"; |
||||
|
||||
$results = StatsUtils::getManyResults2Col($sql); |
||||
echo "<table cellpadding='0' cellspacing='0' border='0' align=center>"; |
||||
echo "<tr bgcolor='#E6E6E6'> |
||||
<td width='70%'> |
||||
$langToolTitleToolnameColumn |
||||
</td> |
||||
<td width='30%'> |
||||
$langToolTitleCountColumn |
||||
</td> |
||||
</tr>"; |
||||
if (is_array($results)) |
||||
{ |
||||
for($j = 0 ; $j < count($results) ; $j++) |
||||
{ |
||||
echo "<tr>"; |
||||
echo "<td><a href='toolaccess_details.php?tool=".urlencode($results[$j][0])."'>".get_lang($results[$j][0])."</a></td>"; |
||||
echo "<td align='right'>".$results[$j][1]."</td>"; |
||||
echo"</tr>"; |
||||
} |
||||
|
||||
} |
||||
else |
||||
{ |
||||
echo "<tr>"; |
||||
echo "<td colspan='2'><center>".get_lang('NoResult')."</center></td>"; |
||||
echo"</tr>"; |
||||
} |
||||
echo "</table></td></tr>"; |
||||
} |
||||
else |
||||
{ |
||||
// this can prevent bug if there is special chars in $tool |
||||
$encodedTool = urlencode($tool); |
||||
$tool = urldecode($tool); |
||||
|
||||
if( !isset($reqdate) ) |
||||
$reqdate = time(); |
||||
echo "<tr> |
||||
<td> |
||||
"; |
||||
if(isset($_cid)) echo "<b>$_cid : </b>"; |
||||
echo " <b>".get_lang($tool)."</b> |
||||
</td> |
||||
</tr> |
||||
"; |
||||
|
||||
/* ------ display ------ */ |
||||
// displayed period |
||||
echo "<tr><td>"; |
||||
switch($period) |
||||
{ |
||||
case "month" : |
||||
echo $MonthsLong[date("n", $reqdate)-1].date(" Y", $reqdate); |
||||
break; |
||||
case "week" : |
||||
$weeklowreqdate = ($reqdate-(86400*date("w" , $reqdate))); |
||||
$weekhighreqdate = ($reqdate+(86400*(6-date("w" , $reqdate)) )); |
||||
echo "<b>".$langFrom."</b> ".date("d " , $weeklowreqdate).$MonthsLong[date("n", $weeklowreqdate)-1].date(" Y" , $weeklowreqdate); |
||||
echo " <b>".$langTo."</b> ".date("d " , $weekhighreqdate ).$MonthsLong[date("n", $weekhighreqdate)-1].date(" Y" , $weekhighreqdate); |
||||
break; |
||||
// default == day |
||||
default : |
||||
$period = "day"; |
||||
case "day" : |
||||
echo $DaysLong[date("w" , $reqdate)].date(" d " , $reqdate).$MonthsLong[date("n", $reqdate)-1].date(" Y" , $reqdate); |
||||
break; |
||||
} |
||||
echo "</tr></td>"; |
||||
// periode choice |
||||
echo "<tr> |
||||
<td> |
||||
<small> |
||||
[<a href='".api_get_self()."?tool=$encodedTool&period=day&reqdate=$reqdate' class='specialLink'>$langPeriodDay</a>] |
||||
[<a href='".api_get_self()."?tool=$encodedTool&period=week&reqdate=$reqdate' class='specialLink'>$langPeriodWeek</a>] |
||||
[<a href='".api_get_self()."?tool=$encodedTool&period=month&reqdate=$reqdate' class='specialLink'>$langPeriodMonth</a>] |
||||
|| |
||||
|
||||
"; |
||||
switch($period) |
||||
{ |
||||
case "month" : |
||||
// previous and next date must be evaluated |
||||
// 30 days should be a good approximation |
||||
$previousReqDate = mktime(1,1,1,date("m",$reqdate)-1,1,date("Y",$reqdate)); |
||||
$nextReqDate = mktime(1,1,1,date("m",$reqdate)+1,1,date("Y",$reqdate)); |
||||
echo " |
||||
[<a href='".api_get_self()."?tool=$encodedTool&period=month&reqdate=$previousReqDate' class='specialLink'>$langPreviousMonth</a>] |
||||
[<a href='".api_get_self()."?tool=$encodedTool&period=month&reqdate=$nextReqDate' class='specialLink'>$langNextMonth</a>] |
||||
"; |
||||
break; |
||||
case "week" : |
||||
// previous and next date must be evaluated |
||||
$previousReqDate = $reqdate - 7*86400; |
||||
$nextReqDate = $reqdate + 7*86400; |
||||
echo " |
||||
[<a href='".api_get_self()."?tool=$encodedTool&period=week&reqdate=$previousReqDate' class='specialLink'>$langPreviousWeek</a>] |
||||
[<a href='".api_get_self()."?tool=$encodedTool&period=week&reqdate=$nextReqDate' class='specialLink'>$langNextWeek</a>] |
||||
"; |
||||
break; |
||||
case "day" : |
||||
// previous and next date must be evaluated |
||||
$previousReqDate = $reqdate - 86400; |
||||
$nextReqDate = $reqdate + 86400; |
||||
echo " |
||||
[<a href='".api_get_self()."?tool=$encodedTool&period=day&reqdate=$previousReqDate' class='specialLink'>$langPreviousDay</a>] |
||||
[<a href='".api_get_self()."?tool=$encodedTool&period=day&reqdate=$nextReqDate' class='specialLink'>$langNextDay</a>] |
||||
"; |
||||
break; |
||||
} |
||||
|
||||
echo" || |
||||
[<a href='".api_get_self()."' class='specialLink'>$langViewToolList</a>] |
||||
</small> |
||||
</td> |
||||
</tr> |
||||
"; |
||||
// display information about this period |
||||
switch($period) |
||||
{ |
||||
// all days |
||||
case "month" : |
||||
$sql = "SELECT UNIX_TIMESTAMP(access_date) |
||||
FROM $TABLETRACK_ACCESS |
||||
WHERE access_tool = '$tool' |
||||
$courseCodeEqualcidIfNeeded |
||||
AND MONTH(access_date) = MONTH(FROM_UNIXTIME('$reqdate')) |
||||
AND YEAR(access_date) = YEAR(FROM_UNIXTIME('$reqdate')) |
||||
ORDER BY access_date ASC"; |
||||
|
||||
$days_array = StatsUtils::daysTab($sql); |
||||
StatsUtils::makeHitsTable($days_array,$langDay); |
||||
break; |
||||
// all days |
||||
case "week" : |
||||
$sql = "SELECT UNIX_TIMESTAMP(access_date) |
||||
FROM $TABLETRACK_ACCESS |
||||
WHERE access_tool = '$tool' |
||||
$courseCodeEqualcidIfNeeded |
||||
AND WEEK(access_date) = WEEK(FROM_UNIXTIME('$reqdate')) |
||||
AND YEAR(access_date) = YEAR(FROM_UNIXTIME('$reqdate')) |
||||
ORDER BY access_date ASC"; |
||||
|
||||
$days_array = StatsUtils::daysTab($sql); |
||||
StatsUtils::makeHitsTable($days_array,$langDay); |
||||
break; |
||||
// all hours |
||||
case "day" : |
||||
$sql = "SELECT UNIX_TIMESTAMP(access_date) |
||||
FROM $TABLETRACK_ACCESS |
||||
WHERE access_tool = '$tool' |
||||
$courseCodeEqualcidIfNeeded |
||||
AND DAYOFYEAR(access_date) = DAYOFYEAR(FROM_UNIXTIME('$reqdate')) |
||||
AND YEAR(access_date) = YEAR(FROM_UNIXTIME('$reqdate')) |
||||
ORDER BY access_date ASC"; |
||||
|
||||
$hours_array = StatsUtils::hoursTab($sql,$reqdate); |
||||
StatsUtils::makeHitsTable($hours_array,$langHour); |
||||
break; |
||||
} |
||||
} |
||||
} else { // not allowed to track |
||||
echo get_lang('NotAllowed'); |
||||
} |
||||
echo '</table>'; |
||||
// footer |
||||
Display::display_footer(); |
||||
Loading…
Reference in new issue