diff --git a/main/course_info/download.php b/main/course_info/download.php index f173f692b9..a2958e36ca 100644 --- a/main/course_info/download.php +++ b/main/course_info/download.php @@ -24,29 +24,29 @@ session_cache_limiter('public'); -include('../inc/global.inc.php'); -$this_section=SECTION_COURSES; +require '../inc/global.inc.php'; +$this_section = SECTION_COURSES; -include_once(api_get_path(LIBRARY_PATH).'fileManage.lib.php'); +require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php'; -$archivePath = api_get_path(SYS_PATH).$archiveDirName.'/'; -$archiveFile = $_GET['archive']; +$archive_path = api_get_path(SYS_ARCHIVE_PATH); +$archive_file = $_GET['archive']; -$archiveFile = str_replace(array('..', '/', '\\'), '', $archiveFile); +$archive_file = str_replace(array('..', '/', '\\'), '', $archive_file); -list($extension) = getextension($archiveFile); +list($extension) = getextension($archive_file); -if (empty($extension) || !file_exists($archivePath.$archiveFile)) { +if (empty($extension) || !file_exists($archive_path.$archive_file)) { exit(); } $content_type = ''; if (in_array(strtolower($extension), array('xml','csv')) && api_is_platform_admin(true)) { - $content_type='application/force-download'; + $content_type = 'application/force-download'; } elseif (strtolower($extension) == 'zip' && $_cid && $is_courseAdmin) { - $content_type='application/force-download'; + $content_type = 'application/force-download'; } if (empty($content_type)) { @@ -59,8 +59,7 @@ header('Cache-Control: public'); header('Pragma: no-cache'); header('Content-Type: '.$content_type); -header('Content-Length: '.filesize($archivePath.$archiveFile)); -header('Content-Disposition: attachment; filename='.$archiveFile); +header('Content-Length: '.filesize($archive_path.$archive_file)); +header('Content-Disposition: attachment; filename='.$archive_file); -readfile($archivePath.$archiveFile); -?> \ No newline at end of file +readfile($archive_path.$archive_file); diff --git a/main/mySpace/access_details.php b/main/mySpace/access_details.php index 7bf3742cf6..c072fecff0 100644 --- a/main/mySpace/access_details.php +++ b/main/mySpace/access_details.php @@ -5,7 +5,7 @@ Dokeos - elearning and course management software Copyright (c) 2009 Dokeos SPRL - Copyright (c) 2008 Furio Petrossi + Copyright (c) 2008 Furio Petrossi For a full list of contributors, see "credits.txt". The full license can be read in "license.txt". @@ -38,12 +38,12 @@ $language_file = array ('registration', 'index', 'tracking'); // including the global Dokeos file -require_once '../inc/global.inc.php'; +require '../inc/global.inc.php'; // including additional libraries -include_once api_get_path(LIBRARY_PATH).'pchart/pData.class.php'; -include_once api_get_path(LIBRARY_PATH).'pchart/pChart.class.php'; -include_once api_get_path(LIBRARY_PATH).'pchart/pCache.class.php'; +require_once api_get_path(LIBRARY_PATH).'pchart/pData.class.php'; +require_once api_get_path(LIBRARY_PATH).'pchart/pChart.class.php'; +require_once api_get_path(LIBRARY_PATH).'pchart/pCache.class.php'; // the section (for the tabs) $this_section = "session_my_space"; @@ -59,116 +59,112 @@ if (api_is_xml_http_request()) { $main_year = $main_month_year = $main_day = array(); // get last 8 days/months $last_days = 8; - $last_months = 5; + $last_months = 5; for ($i = $last_days; $i >= 0; $i--) { - $main_day[date ('d-m-Y', mktime () - $i * 3600 * 24)] = 0; - } + $main_day[date ('d-m-Y', mktime () - $i * 3600 * 24)] = 0; + } for ($i = $last_months; $i >= 0; $i--) { - $main_month_year[date ('m-Y', mktime () - $i*30 * 3600 * 24)] = 0; - } + $main_month_year[date ('m-Y', mktime () - $i * 30 * 3600 * 24)] = 0; + } $i = 0; if (is_array($connections) && count($connections) > 0) { - foreach ($connections as $key => $data) { - //creating the main array - //$main_year[date('Y', $data['login'])] += calculHours($data['logout'] - $data['login']) * 60; - //$main_month_year[date('m-Y', $data['login'])] += calculHours($data['logout'] - $data['login']) * 60; + foreach ($connections as $key => $data) { + //creating the main array $main_month_year[date('m-Y', $data['login'])] += float_format(($data['logout'] - $data['login']) / 60, 0); - //$main_day[date('d-m-Y', $data['login'])] += calculHours($data['logout'] - $data['login']) * 60; $main_day[date('d-m-Y', $data['login'])] += float_format(($data['logout'] - $data['login']) / 60, 0); - if ($i > 500) { - break; + if ($i > 500) { + break; + } + $i++; } - $i++; - } - //var_dump($main_month_year); - switch ($type) { - case 'day': - $main_date = $main_day; - break; - case 'month': - $main_date = $main_month_year ; - break; - case 'year': - $main_date = $main_year; - break; - } - //echo '
'; print_r($main_date);
- // the nice graphics :D
- $labels = array_keys($main_date);
- if (count($main_date) == 1) {
- $labels = $labels[0];
- $main_date = $main_date[$labels];
- }
+ switch ($type) {
+ case 'day':
+ $main_date = $main_day;
+ break;
+ case 'month':
+ $main_date = $main_month_year;
+ break;
+ case 'year':
+ $main_date = $main_year;
+ break;
+ }
- $DataSet = new pData;
- $DataSet->AddPoint($main_date, 'Q');
- if (count($main_date)!= 1) {
- $DataSet->AddPoint($labels, 'Date');
- }
- $DataSet->AddAllSeries();
- $DataSet->RemoveSerie('Date');
- $DataSet->SetAbsciseLabelSerie('Date');
- $DataSet->SetYAxisName(get_lang('Minutes'));
- $graph_id = api_get_user_id().'AccessDetails'.api_get_course_id();
- $DataSet->AddAllSeries();
-
- $Cache = new pCache();
- // the graph id
- $data = $DataSet->GetData();
-
- if ($Cache->IsInCache($graph_id, $DataSet->GetData())) {
- //if (0) {
- //if we already created the img
- // echo 'in cache';
- $img_file = $Cache->GetHash($graph_id, $DataSet->GetData());
- } else {
- // if the image does not exist in the archive/ folder
- // Initialise the graph
- $Test = new pChart(760, 230);
-
- //which schema of color will be used
- $quant_resources = count($data[0]) - 1;
- // Adding the color schemma
- $Test->loadColorPalette(api_get_path(LIBRARY_PATH)."pchart/palette/default.txt");
-
- $Test->setFontProperties(api_get_path(LIBRARY_PATH)."pchart/fonts/tahoma.ttf", 8);
- $Test->setGraphArea(70, 30, 680, 200);
- $Test->drawFilledRoundedRectangle(7, 7, 693, 223, 5, 240, 240, 240);
- $Test->drawRoundedRectangle(5, 5, 695, 225, 5, 230, 230, 230);
- $Test->drawGraphArea(255, 255, 255, TRUE);
- $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_START0, 150, 150, 150, TRUE, 0, 0);
- $Test->drawGrid(4, TRUE, 230, 230, 230, 50);
- $Test->setLineStyle(2);
- // Draw the 0 line
- $Test->setFontProperties(api_get_path(LIBRARY_PATH)."pchart/fonts/tahoma.ttf", 6);
- $Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
-
- if (count($main_date) == 1) {
- //Draw a graph
- echo ''.$labels.'
';
- $Test->drawBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), TRUE);
- } else {
- //Draw the line graph
- $Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription());
- $Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 2, 255, 255, 255);
- }
-
- // Finish the graph
- $Test->setFontProperties(api_get_path(LIBRARY_PATH)."pchart/fonts/tahoma.ttf", 8);
-
- $Test->setFontProperties(api_get_path(LIBRARY_PATH)."pchart/fonts/tahoma.ttf", 10);
- $Test->drawTitle(60, 22, get_lang('AccessDetails'), 50, 50, 50, 585);
-
- //------------------
- //echo 'not in cache';
- $Cache->WriteToCache($graph_id,$DataSet->GetData(),$Test);
- ob_start();
- $Test->Stroke();
- ob_end_clean();
- $img_file = $Cache->GetHash($graph_id,$DataSet->GetData());
- }
+ // the nice graphics :D
+ $labels = array_keys($main_date);
+ if (count($main_date) == 1) {
+ $labels = $labels[0];
+ $main_date = $main_date[$labels];
+ }
+
+ $DataSet = new pData;
+ $DataSet->AddPoint($main_date, 'Q');
+ if (count($main_date)!= 1) {
+ $DataSet->AddPoint($labels, 'Date');
+ }
+ $DataSet->AddAllSeries();
+ $DataSet->RemoveSerie('Date');
+ $DataSet->SetAbsciseLabelSerie('Date');
+ $DataSet->SetYAxisName(get_lang('Minutes'));
+ $graph_id = api_get_user_id().'AccessDetails'.api_get_course_id();
+ $DataSet->AddAllSeries();
+
+ $Cache = new pCache();
+ // the graph id
+ $data = $DataSet->GetData();
+
+ if ($Cache->IsInCache($graph_id, $DataSet->GetData())) {
+ //if (0) {
+ //if we already created the img
+ // echo 'in cache';
+ $img_file = $Cache->GetHash($graph_id, $DataSet->GetData());
+ } else {
+ // if the image does not exist in the archive/ folder
+ // Initialise the graph
+ $Test = new pChart(760, 230);
+
+ //which schema of color will be used
+ $quant_resources = count($data[0]) - 1;
+ // Adding the color schemma
+ $Test->loadColorPalette(api_get_path(LIBRARY_PATH).'pchart/palette/default.txt');
+
+ $Test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf', 8);
+ $Test->setGraphArea(70, 30, 680, 200);
+ $Test->drawFilledRoundedRectangle(7, 7, 693, 223, 5, 240, 240, 240);
+ $Test->drawRoundedRectangle(5, 5, 695, 225, 5, 230, 230, 230);
+ $Test->drawGraphArea(255, 255, 255, TRUE);
+ $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_START0, 150, 150, 150, TRUE, 0, 0);
+ $Test->drawGrid(4, TRUE, 230, 230, 230, 50);
+ $Test->setLineStyle(2);
+ // Draw the 0 line
+ $Test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf', 6);
+ $Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
+
+ if (count($main_date) == 1) {
+ //Draw a graph
+ echo ''.$labels.'
';
+ $Test->drawBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), TRUE);
+ } else {
+ //Draw the line graph
+ $Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription());
+ $Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 2, 255, 255, 255);
+ }
+
+ // Finish the graph
+ $Test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf', 8);
+
+ $Test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf', 10);
+ $Test->drawTitle(60, 22, get_lang('AccessDetails'), 50, 50, 50, 585);
+
+ //------------------
+ //echo 'not in cache';
+ $Cache->WriteToCache($graph_id, $DataSet->GetData(), $Test);
+ ob_start();
+ $Test->Stroke();
+ ob_end_clean();
+ $img_file = $Cache->GetHash($graph_id,$DataSet->GetData());
+ }
echo '
';
} else {
Display::display_warning_message (get_lang('GraphicNotAvailable'));
@@ -176,7 +172,7 @@ if (api_is_xml_http_request()) {
exit;
}
-$nameTools= get_lang('AccessDetails');
+$nameTools = get_lang('AccessDetails');
//StudentDetails
if (isset($_GET['origin']) && strcmp($_GET['origin'], 'tracking_course') === 0) {
@@ -197,10 +193,10 @@ $htmlHeadXtra[] = '
$(function() {
- $("#container-9").tabs({ remote: true});
+ $("#container-9").tabs({ remote: true});
});
-
-' ;
+
+';
Display :: display_header('');
$TBL_USERINFO_DEF = Database :: get_course_table(TABLE_USER_INFO);
@@ -209,8 +205,8 @@ $mainUserInfo = api_get_user_info($user_id);
$result_to_print = '';
$main_date_array = array();
-foreach ($connections as $key => $data) {
- $result_to_print .= ' '.date('d-m-Y (H:i:s)', $data['login']).' - '.calculHours($data['logout'] - $data['login']).'
'."\n";
+foreach ($connections as $key => $data) {
+ $result_to_print .= ' '.date('d-m-Y (H:i:s)', $data['login']).' - '.api_time_to_hms($data['logout'] - $data['login']).'
'."\n";
}
api_display_tool_title(get_lang('DetailsStudentInCourse'));
echo '';
@@ -218,11 +214,11 @@ echo ''.get_lang('User').': '.api_get_person_name($mainUserInfo['firstNa
?>
';?>
+ '; ?>
$data) {
- echo ("".date("d-m-Y (H:i:s)",$data['login'])." ".date("d-m-Y (H:i:s)",$data['logout'])." ");
+ echo ("".date("d-m-Y (H:i:s)", $data['login'])." ".date("d-m-Y (H:i:s)", $data['logout'])." ");
}
*/
/*
foreach ($connections as $key => $data) {
- echo ("".date("d-m-Y (H:i:s)",$data['login'])." ".calculHours($data['logout']-$data['login'])." ");
+ echo ("".date("d-m-Y (H:i:s)", $data['login'])." ".api_time_to_hms($data['logout'] - $data['login'])." ");
}
echo ("");
*/
+
Display:: display_footer();
@@ -264,10 +261,10 @@ function get_connections_to_course($user_id, $course_code) {
$sql_query = 'SELECT visual_code as course_code FROM '.$tbl_main.' c WHERE code="'.Database::escape_string($course_code).'";';
$result = Database::query($sql_query, __FILE__, __LINE__);
- $row_query = Database::fetch_array($result,'ASSOC');
+ $row_query = Database::fetch_array($result, 'ASSOC');
$course_true = isset($row_query['course_code']) ? $row_query['course_code']: $course_code;
- $sql = 'SELECT login_course_date, logout_course_date FROM ' . $tbl_track_course . '
+ $sql = 'SELECT login_course_date, logout_course_date FROM ' . $tbl_track_course . '
WHERE user_id = ' . intval($user_id) . '
AND course_code="' . Database::escape_string($course_true) . '" ORDER BY login_course_date ASC';
@@ -307,44 +304,19 @@ function get_connections_to_course_by_time($user_id, $course_code, $year = '', $
$row_query = Database::fetch_array($result,'ASSOC');
$course_true = isset($row_query['course_code']) ? $row_query['course_code']: $course_code;
- $sql = 'SELECT login_course_date, logout_course_date FROM ' . $tbl_track_course . '
+ $sql = 'SELECT login_course_date, logout_course_date FROM ' . $tbl_track_course . '
WHERE user_id = ' . intval($user_id) . '
- AND course_code="' . Database::escape_string($course_true) . '"
+ AND course_code="' . Database::escape_string($course_true) . '"
ORDER BY login_course_date DESC';
$rs = Database::query($sql, __FILE__, __LINE__);
- $connections = array();
- while ($a_connections = Database::fetch_array($rs)) {
+ $connections = array();
+ while ($a_connections = Database::fetch_array($rs)) {
$s_login_date = $a_connections['login_course_date'];
- $s_logout_date = $a_connections['logout_course_date'];
+ $s_logout_date = $a_connections['logout_course_date'];
$i_timestamp_login_date = strtotime($s_login_date);
- $i_timestamp_logout_date = strtotime($s_logout_date);
- $connections[] = array('login' => $i_timestamp_login_date, 'logout' => $i_timestamp_logout_date);
- }
+ $i_timestamp_logout_date = strtotime($s_logout_date);
+ $connections[] = array('login' => $i_timestamp_login_date, 'logout' => $i_timestamp_logout_date);
+ }
return $connections;
}
-
-/**
- * Transforms seconds into a time format
- *
- * @param unknown_type $seconds
- * @return unknown
- */
-function calculHours($seconds) {
- //How many hours ?
- $hours = floor($seconds / 3600);
-
- //How many minutes ?
- $min = floor(($seconds - ($hours * 3600)) / 60);
- if ($min < 10) {
- $min = '0'.$min;
- }
-
- //How many seconds
- $sec = $seconds - ($hours * 3600) - ($min * 60);
- if ($sec < 10) {
- $sec = '0'.$sec;
- }
-
- return $hours.get_lang('HourShort').' '.$min.':'.$sec;
-}
diff --git a/main/mySpace/admin.php b/main/mySpace/admin.php
index 979fc630fa..de14ecd1e1 100644
--- a/main/mySpace/admin.php
+++ b/main/mySpace/admin.php
@@ -7,9 +7,11 @@
ob_start();
// name of the language file that needs to be included
-$language_file = array ('registration', 'index','trad4all', 'tracking');
+$language_file = array ('registration', 'index', 'trad4all', 'tracking');
$cidReset = true;
+
require '../inc/global.inc.php';
+require_once api_get_path(SYS_CODE_PATH).'mySpace/myspace.lib.php';
$this_section = "session_my_space";
@@ -30,56 +32,12 @@ $tbl_session_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_USER);
$tbl_admin = Database :: get_main_table(TABLE_MAIN_ADMIN);
-/*
- ===============================================================================
- FUNCTION
- ===============================================================================
- */
-
-function exportCsv($a_header, $a_data) {
- global $archiveDirName;
-
- $fileName = 'administrators.csv';
- $archivePath = api_get_path(SYS_ARCHIVE_PATH);
- $archiveURL = api_get_path(WEB_CODE_PATH).'course_info/download.php?archive=';
-
- if (!$open = fopen($archivePath.$fileName, 'w+')) {
- $message = get_lang('noOpen');
- } else {
- $info = '';
-
- foreach ($a_header as $header) {
- $info .= $header.';';
- }
- $info .= "\r\n";
-
- foreach ($a_data as $data) {
- foreach ($data as $infos) {
- $info .= $infos.';';
- }
- $info .= "\r\n";
- }
-
- fwrite($open, $info);
- fclose($open);
- $perm = api_get_setting('permissions_for_new_files');
- $perm = octdec(!empty($perm) ? $perm : '0660');
- chmod($fileName, $perm);
-
- header("Location:".$archiveURL.$fileName);
- }
- return $message;
-}
-
-
/**
* MAIN PART
*/
/*
- * liste nominative avec coordonn�es et lien vers les cours et
-les stagiaires dont il est le
-responsable.
+ * liste nominative avec coordonnies et lien vers les cours et les stagiaires dont il est le responsable.
*/
if (isset($_POST['export'])) {
@@ -87,10 +45,10 @@ if (isset($_POST['export'])) {
} else {
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname' : ' ORDER BY lastname, firstname';
}
-$sqlAdmins = "SELECT user.user_id,lastname,firstname,email
+$sql_admins = "SELECT user.user_id,lastname,firstname,email
FROM $tbl_user as user, $tbl_admin as admin
WHERE admin.user_id=user.user_id".$order_clause;
-$resultAdmins = Database::query($sqlAdmins, __FILE__, __LINE__);
+$result_admins = Database::query($sql_admins, __FILE__, __LINE__);
if (api_is_western_name_order()) {
echo '| '.get_lang('FirstName').' | '.get_lang('LastName').' | '.get_lang('Email').' |
|---|---|---|
| '.get_lang('FirstName').' | '.get_lang('LastName').' | '.get_lang('Email').' |
| $s_firstname | $s_lastname | $s_email |
| $firstname | $lastname | |
| $s_lastname | $s_firstname | $s_email |
| $lastname | $firstname | |
| '.get_lang("NoResults").' | ||
| '.get_lang('NoResults').' | ||