[svn r10189] various cleanup

skala
Patrick Cool 19 years ago
parent e081704992
commit 7e55c0724a
  1. 4
      main/inc/global.inc.php
  2. 178
      main/inc/lib/auth.lib.inc.php
  3. 84
      main/inc/lib/course.lib.php
  4. 31
      main/inc/lib/database.lib.php
  5. 88
      main/inc/lib/events.lib.inc.php
  6. 204
      main/inc/lib/export.lib.inc.php
  7. 34
      main/inc/lib/statsUtils.lib.inc.php
  8. 9
      main/install/configuration.dist.php

@ -325,9 +325,9 @@ else
$user_language = $_GET["language"]; $user_language = $_GET["language"];
if ($_POST["language_list"]) if ($_POST["language_list"])
{ {
$user_language = str_replace("index.php?language=","",$_POST["language_list"]); $user_language = str_replace("index.php?language=","",$_POST["language_list"]);
} }
// Checking if we have a valid language. If not we set it to the platform language. // Checking if we have a valid language. If not we set it to the platform language.
$valid_languages=api_get_languages(); $valid_languages=api_get_languages();

@ -1,178 +0,0 @@
<?php
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004 Dokeos S.A.
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
Copyright (c) Olivier Brouckaert
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
==============================================================================
*/
/**
==============================================================================
* This is the authentication library for Dokeos.
* Include/require it in your code to use its functionality.
* @deprecated No function in this file is actually used somewhere in the code
* @package dokeos.library
==============================================================================
*/
/**
* Build a string without logic
* to be used as password
*
* @author Christophe Gesche <gesche@ipm.ucl.ac.be>
* @version 1.0
* @param integer $nbcar default 5 define here length of password
* @param boolean $lettresseules default false fix if pass can content digit
* @return string password
* @desc return a string to be use as password
* @see rand()
* @deprecated use api_generate_password located in main_api.lib.php
*/
function generePass($nbcar=5,$lettresseules = false)
{
return api_generate_password($nbcar);
}
/**
* ifsnow's email valid check function SnowCheckMail Ver 0.1
* funtion SnowCheckMail ($Email,$debug=false)
* $Email : E-Mail address to check.
* $debug : Variable for debugging.
* Can use everybody if use without changing the name of function.
* Reference : O'REILLY - Internet Email Programming
* HOMEPAGE : http://www.hellophp.com
* ifsnow is korean phper. Is sorry to be unskillful to English. *^^*;;
* @deprecated Function not in use
*/
function SnowCheckMail($Email,$debug=false)
{
global $_SERVER;
$return = array();
// Variable for return.
// $return[0] : [true|false]
// $return[1] : Processing result save.
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $Email))
{
$return[0]=false;
$return[1]="${Email} is E-Mail form that is not right.";
if ($debug) echo "Error : {$Email} is E-Mail form that is not right.<br />";
return $return;
}
elseif ($debug)
{
echo "Confirmation : {$Email} is E-Mail form that is not right.<br />";
}
// E-Mail @ by 2 by standard divide. if it is $Email this "lsm@ebeecomm.com"..
// $Username : lsm
// $Domain : ebeecomm.com
// list function reference : http://www.php.net/manual/en/function.list.php
// split function reference : http://www.php.net/manual/en/function.split.php
list ( $Username, $Domain ) = split ("@",$Email);
// That MX(mail exchanger) record exists in domain check .
// checkdnsrr function reference : http://www.php.net/manual/en/function.checkdnsrr.php
if ( checkdnsrr ( $Domain, "MX" ) )
{
if($debug) echo "Confirmation : MX record about {$Domain} exists.<br />";
// If MX record exists, save MX record address.
// getmxrr function reference : http://www.php.net/manual/en/function.getmxrr.php
$MXHost = array();
if ( getmxrr ($Domain, $MXHost))
{
if($debug)
{
echo "Confirmation : Is confirming address by MX LOOKUP.<br />";
for ( $i = 0,$j = 1; $i < count($MXHost); $i++,$j++ )
{
echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result($j) - $MXHost[$i]<br />";
}
}
}
// Getmxrr function does to store MX record address about $Domain in arrangement form to $MXHost.
// $ConnectAddress socket connection address.
$ConnectAddress = $MXHost[0];
}
else
{
// If there is no MX record simply @ to next time address socket connection do .
$ConnectAddress = $Domain;
if ($debug) echo "Confirmation : MX record about {$Domain} does not exist.<br />";
}
// fsockopen function reference : http://www.php.net/manual/en/function.fsockopen.php
$Connect = fsockopen ( $ConnectAddress, 25 );
// Success in socket connection
if ($Connect)
{
if ($debug) echo "Connection succeeded to {$ConnectAddress} SMTP.<br />";
// Judgment is that service is preparing though begin by 220 getting string after connection .
// fgets function reference : http://www.php.net/manual/en/function.fgets.php
if ( ereg ( "^220", $Out = fgets ( $Connect, 1024 ) ) )
{
// Inform client's reaching to server who connect.
fputs ( $Connect, "HELO ".$_SERVER['HTTP_HOST']."\r\n" );
if ($debug) echo "Run : HELO ".$_SERVER['HTTP_HOST']."<br />";
$Out = fgets ( $Connect, 1024 ); // Receive server's answering cord.
// Inform sender's address to server.
fputs ( $Connect, "MAIL FROM: <{$Email}>\r\n" );
if ($debug) echo "Run : MAIL FROM: &lt;{$Email}&gt;<br />";
$From = fgets ( $Connect, 1024 ); // Receive server's answering cord.
// Inform listener's address to server.
fputs ( $Connect, "RCPT TO: <{$Email}>\r\n" );
if ($debug) echo "Run : RCPT TO: &lt;{$Email}&gt;<br />";
$To = fgets ( $Connect, 1024 ); // Receive server's answering cord.
// Finish connection.
fputs ( $Connect, "QUIT\r\n");
if ($debug) echo "Run : QUIT<br />";
fclose($Connect);
// Server's answering cord about MAIL and TO command checks.
// Server about listener's address reacts to 550 codes if there does not exist
// checking that mailbox is in own E-Mail account.
if ( !ereg ( "^250", $From ) || !ereg ( "^250", $To ))
{
$return[0]=false;
$return[1]="${Email} is address done not admit in E-Mail server.";
if ($debug) echo "{$Email} is address done not admit in E-Mail server.<br />";
return $return;
}
}
}
// Failure in socket connection
else
{
$return[0]=false;
$return[1]="Can not connect E-Mail server ({$ConnectAddress}).";
if ($debug) echo "Can not connect E-Mail server ({$ConnectAddress}).<br />";
return $return;
}
$return[0]=true;
$return[1]="{$Email} is E-Mail address that there is no any problem.";
return $return;
}
?>

@ -66,7 +66,6 @@
CourseManager::get_target_of_linked_course($virtual_course_code) CourseManager::get_target_of_linked_course($virtual_course_code)
TITLE AND CODE FUNCTIONS TITLE AND CODE FUNCTIONS
DEPRECATED CourseManager::determine_course_title($user_id, $_cid, $_course)
CourseManager::determine_course_title_from_course_info($user_id, $course_info) CourseManager::determine_course_title_from_course_info($user_id, $course_info)
CourseManager::create_combined_name($user_is_registered_in_real_course, $real_course_name, $virtual_course_list) CourseManager::create_combined_name($user_is_registered_in_real_course, $real_course_name, $virtual_course_list)
CourseManager::create_combined_code($user_is_registered_in_real_course, $real_course_code, $virtual_course_list) CourseManager::create_combined_code($user_is_registered_in_real_course, $real_course_code, $virtual_course_list)
@ -227,18 +226,6 @@ class CourseManager
return $result["status"]; return $result["status"];
} }
/**
* Change the status of a user in a course, status can be COURSEMANAGER or STUDENT.
* @deprecated Function not in use
*/
function set_user_in_course_status($user_id, $course_code, $status)
{
$course_user_table = Database :: get_main_table(MAIN_COURSE_USER_TABLE);
$sql_query = "UPDATE $course_user_table SET status = '$status' WHERE `course_code` = '$course_code' AND `user_id` = '$user_id'";
$sql_result = api_sql_query($sql_query, __FILE__, __LINE__);
$result = mysql_fetch_array($sql_result);
return $result["status"];
}
/** /**
* Unsubscribe one or more users from a course * Unsubscribe one or more users from a course
@ -604,77 +591,6 @@ class CourseManager
return $result_array; return $result_array;
} }
/**
* @deprecated use determine_course_title_from_course_info($user_id,
* $course_info) instead Declares global $_course
*/
function determine_course_title($user_id, $_cid, $_course)
{
global $_course;
$real_course_code = $_course['sysCode'];
$real_course_info = Database :: get_course_info($real_course_code);
$real_course_name = $real_course_info["title"];
$real_course_visual_code = $real_course_info["visual_code"];
//is the user registered in the real course?
$table = Database :: get_main_table(MAIN_COURSE_USER_TABLE);
$sql_query = "SELECT * FROM $table WHERE `user_id` = '$user_id' AND `course_code` = '$real_course_code'";
$sql_result = api_sql_query($sql_query, __FILE__, __LINE__);
$result = mysql_fetch_array($sql_result);
if (!isset ($result) || empty ($result))
{
$user_is_registered_in_real_course = false;
}
else
{
$user_is_registered_in_real_course = true;
}
//get a list of virtual courses linked to the current real course
//and to which the current user is subscribed
$user_subscribed_virtual_course_list = CourseManager :: get_list_of_virtual_courses_for_specific_user_and_real_course($user_id, $real_course_code);
if (count($user_subscribed_virtual_course_list) > 0)
{
$virtual_courses_exist = true;
}
else
{
$virtual_courses_exist = false;
}
//now determine course code and name
if ($user_is_registered_in_real_course && $virtual_courses_exist)
{
$_course["name"] = CourseManager :: create_combined_name($user_is_registered_in_real_course, $real_course_name, $user_subscribed_virtual_course_list);
$_course['official_code'] = CourseManager :: create_combined_code($user_is_registered_in_real_course, $real_course_visual_code, $user_subscribed_virtual_course_list);
}
else
if ($user_is_registered_in_real_course)
{
//course name remains real course name
$_course["name"] = $real_course_name;
$_course['official_code'] = $real_course_visual_code;
}
else
if ($virtual_courses_exist)
{
$_course["name"] = CourseManager :: create_combined_name($user_is_registered_in_real_course, $real_course_name, $user_subscribed_virtual_course_list);
$_course['official_code'] = CourseManager :: create_combined_code($user_is_registered_in_real_course, $real_course_visual_code, $user_subscribed_virtual_course_list);
}
else
{
//course name remains real course name
$_course["name"] = $real_course_name;
$_course['official_code'] = $real_course_visual_code;
}
$result_title = $_course["name"];
return $result_title;
}
/** /**
* Find out for which courses the user is registered and determine a visual course code and course title from that. * Find out for which courses the user is registered and determine a visual course code and course title from that.
* Takes virtual courses into account * Takes virtual courses into account

@ -339,14 +339,7 @@ class Database
$result = $result['isocode']; $result = $result['isocode'];
return $result; return $result;
} }
/**
* Returns the name of the login table of the stats database.
* @deprecated use Database::get_statistic_table(STATISTIC_TRACK_E_LOGIN_TABLE);
*/
function get_statistic_track_e_login_table()
{
return Database::get_statistic_table(STATISTIC_TRACK_E_LOGIN_TABLE);
}
/** /**
* Returns the name of the main table of the SCORM database. * Returns the name of the main table of the SCORM database.
* @deprecated use Database::get_scorm_table(SCORM_MAIN_TABLE); * @deprecated use Database::get_scorm_table(SCORM_MAIN_TABLE);
@ -382,18 +375,6 @@ class Database
$result = api_store_result($sql_result); $result = api_store_result($sql_result);
return $result; return $result;
} }
/**
* @return a list (array) of all users.
* @deprecated This function isn't used anywhere in the code.
*/
function get_user_list()
{
$table = Database::get_main_table(MAIN_USER_TABLE);
$sql_query = "SELECT * FROM $table";
$sql_result = api_sql_query($sql_query, __FILE__, __LINE__);
$result = api_store_result($sql_result);
return $result;
}
/** /**
* Returns an array with all database fields for the specified course. * Returns an array with all database fields for the specified course.
@ -497,16 +478,6 @@ class Database
} }
/**
* Changes the title of a course.
* @deprecated Function not in use
*/
function update_course_title($course_code, $new_title)
{
$table = Database::get_main_table(MAIN_COURSE_TABLE);
$sql_query = "UPDATE $table SET `title` = '$new_title' WHERE `code` = '$course_code' LIMIT 1";
api_sql_query($sql_query, __FILE__, __LINE__);
}
/* /*
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
Private Functions Private Functions

@ -494,94 +494,6 @@ function event_exercice($exo_id, $score, $weighting)
//return 0; //return 0;
} }
/**
* @param cours_code (cours.code in maindb))
* @param action ( enum of strings : "sub" or "unsub" )
* @author Sebastien Piraux <piraux_seb@hotmail.com>
* @desc Record information for subscription and unsubscription to courses
* @deprecated Function not in use
*/
function event_subscription($cours_id, $action)
{
global $_configuration;
global $_user;
global $TABLETRACK_SUBSCRIPTIONS;
// if tracking is disabled record nothing
if (!$_configuration['tracking_enabled'])
{
return 0;
}
$sql = "INSERT INTO `$TABLETRACK_SUBSCRIPTIONS`
(`sub_user_id`,
`sub_cours_id`,
`sub_action`)
VALUES
('".$_user['user_id']."',
'".$cours_id."',
'".$action."')";
$res = api_sql_query($sql,__FILE__,__LINE__);
//$mysql_query($sql);
return 1;
}
/**
* @param type_event type of event to record
* @param values indexed array of values (keys are the type of values, values are the event_values)
* @author Sebastien Piraux <piraux_seb@hotmail.com>
* @desc Standard function for all users who wants to add an event recording in their pages
* e.g. : event_default("Exercice Result",array ("ex_id"=>"1", "result"=> "5", "weighting" => "20"));
* @deprecated Function not in use
*/
function event_default($type_event, $values)
{
global $_configuration;
global $_user;
global $_cid;
global $TABLETRACK_DEFAULT;
// if tracking is disabled record nothing
if (!$_configuration['tracking_enabled'])
{
return 0;
}
$reallyNow = time();
if ($_user['user_id'])
{
$user_id = "'".$_user['user_id']."'";
}
else // anonymous
{
$user_id = "NULL";
}
if ($_user['user_id'])
{
$cours_id = "'".$_cid."'";
}
else // anonymous
{
$cours_id = "NULL";
}
$sqlValues = "";
foreach ($values as $type_value => $event_value)
{
if ($sqlValues == "")
{
$sqlValues .= "('','$user_id','$cours_id','$reallyNow','$type_event','$type_value','$event_value')";
}
else
{
$sqlValues .= ",('','$user_id','$cours_id','$reallyNow','$type_event','$type_value','$event_value')";
}
}
$sql = "INSERT INTO `".$TABLETRACK_DEFAULT."`
VALUES ".$sqlValues;
$res = api_sql_query($sql,__FILE__,__LINE__);
return 1;
}
function exercise_attempt($score,$answer,$quesId,$exeId,$j) function exercise_attempt($score,$answer,$quesId,$exeId,$j)
{ {
global $_configuration; global $_configuration;

@ -275,7 +275,7 @@ function copydir($origine, $destination, $verbose = false)
* Export a course to a zip file * Export a course to a zip file
* *
* @param integer $currentCourseID needed sysId Of course to be exported * @param integer $currentCourseID needed sysId Of course to be exported
* @param boolean $verboseBackup def FALSE echo step of work * @param boolean $verbose_backup def FALSE echo step of work
* @param string $ignore def NONE // future param for selected bloc to export. * @param string $ignore def NONE // future param for selected bloc to export.
* @param string $formats def ALL ALL,SQL,PHP,XML,CSV,XLS,HTML * @param string $formats def ALL ALL,SQL,PHP,XML,CSV,XLS,HTML
* *
@ -305,97 +305,60 @@ function copydir($origine, $destination, $verbose = false)
*/ */
function makeTheBackup($exportedCourseId, $verboseBackup = "FALSE", $ignore = "", $formats = "ALL") function makeTheBackup($exportedCourseId, $verbose_backup = FALSE, $ignore = "", $formats = "ALL")
{ {
GLOBAL $error_msg, $error_no, $db, $archiveRepositorySys, $archiveRepositoryWeb, // from configs files global $error_msg, $error_no, $db, $archiveRepositorySys, $archiveRepositoryWeb,
$appendCourse, $appendMainDb, // $appendCourse, $appendMainDb, $archiveName, $_configuration, $clarolineRepositorySys, $_course, $TABLEUSER, $TABLECOURSUSER, $TABLECOURS, $TABLEANNOUNCEMENT;
$archiveName, $_configuration, $clarolineRepositorySys, $_course, $TABLEUSER, $TABLECOURSUSER, $TABLECOURS, $TABLEANNOUNCEMENT, $langArchiveName, $langArchiveLocation, $langSizeOf, $langDisk_free_space, $langCreateMissingDirectories, $langBUCourseDataOfMainBase, $langBUUsersInMainBase, $langBUAnnounceInMainBase, $langCopyDirectoryCourse, $langFileCopied, $langBackupOfDataBase, $langBuildTheCompressedFile;
////////////////////////////////////////////////////
// ****** 1° Check if all data needed are aivailable
// ****** 1° 1. $lang vars
if ($verboseBackup)
{
if ($langArchiveName == "")
$langArchiveName = "Archive name";
if ($langArchiveLocation == "")
$langArchiveLocation = "Archive location";
if ($langSizeOf == "")
$langSizeOf = "Size of";
if ($langDisk_free_space == "")
$langDisk_free_space = "Disk free";
if ($langCreateMissingDirectories == "")
$langCreateMissingDirectories = "Directory missing ";
if ($langBUCourseDataOfMainBase == "")
$langBUCourseDataOfMainBase = "Backup Course data";
if ($langBUUsersInMainBase == "")
$langBUUsersInMainBase = "Backup Users";
if ($langBUAnnounceInMainBase == "")
$langBUAnnounceInMainBase = "Backups announcement";
if ($langCopyDirectoryCourse == "")
$langCopyDirectoryCourse = "Copy files";
if ($langFileCopied == "")
$langFileCopied = "File copied";
if ($langBackupOfDataBase == "")
$langBackupOfDataBase = "Backup of database";
if ($langBuildTheCompressedFile == "")
$langBuildTheCompressedFile = "zip file";
}
// ****** 1° 2. params. // ****** 1° 2. params.
$errorCode = 0; $errorCode = 0;
$stop = FALSE; $stop = FALSE;
// ****** 1° 2. 1 params.needed // ****** 1° 2. 1 params.needed
if (!isset ($exportedCourseId)) if (!isset ($exportedCourseId))
{ {
GLOBAL $error_msg, $error_no;
$error_msg["backup"][] = "[".basename(__FILE__)."][".__LINE__."] Course Id Missing"; $error_msg["backup"][] = "[".basename(__FILE__)."][".__LINE__."] Course Id Missing";
$error_no["backup"][] = "1"; $error_no["backup"][] = "1";
$stop = TRUE; $stop = TRUE;
} }
if (!isset ($_configuration['main_database'])) if (!isset ($_configuration['main_database']))
{ {
GLOBAL $error_msg, $error_no;
$error_msg["backup"][] = "[".basename(__FILE__)."][".__LINE__."] Main Db name is Missing"; $error_msg["backup"][] = "[".basename(__FILE__)."][".__LINE__."] Main Db name is Missing";
$error_no["backup"][] = "2"; $error_no["backup"][] = "2";
$stop = TRUE; $stop = TRUE;
} }
if (!isset ($archiveRepositorySys)) if (!isset ($archiveRepositorySys))
{ {
GLOBAL $error_msg, $error_no;
$error_msg["backup"][] = "[".basename(__FILE__)."][".__LINE__."] archive Path not found"; $error_msg["backup"][] = "[".basename(__FILE__)."][".__LINE__."] archive Path not found";
$error_no["backup"][] = "3"; $error_no["backup"][] = "3";
$stop = TRUE; $stop = TRUE;
} }
if (!isset ($appendMainDb)) if (!isset ($appendMainDb))
{ {
GLOBAL $error_msg, $error_no;
$error_msg["backup"][] = "[".basename(__FILE__)."][".__LINE__."] where place course datas from main db in archive"; $error_msg["backup"][] = "[".basename(__FILE__)."][".__LINE__."] where place course datas from main db in archive";
$error_no["backup"][] = "4"; $error_no["backup"][] = "4";
$stop = TRUE; $stop = TRUE;
} }
if (!isset ($appendCourse)) if (!isset ($appendCourse))
{ {
GLOBAL $error_msg, $error_no;
$error_msg["backup"][] = "[".basename(__FILE__)."][".__LINE__."] where place course datas in archive"; $error_msg["backup"][] = "[".basename(__FILE__)."][".__LINE__."] where place course datas in archive";
$error_no["backup"][] = "5"; $error_no["backup"][] = "5";
$stop = TRUE; $stop = TRUE;
} }
if (!isset ($TABLECOURS)) if (!isset ($TABLECOURS))
{ {
GLOBAL $error_msg, $error_no;
$error_msg["backup"][] = "[".basename(__FILE__)."][".__LINE__."] name of table of course not defined"; $error_msg["backup"][] = "[".basename(__FILE__)."][".__LINE__."] name of table of course not defined";
$error_no["backup"][] = "6"; $error_no["backup"][] = "6";
$stop = TRUE; $stop = TRUE;
} }
if (!isset ($TABLEUSER)) if (!isset ($TABLEUSER))
{ {
GLOBAL $error_msg, $error_no;
$error_msg["backup"][] = "[".basename(__FILE__)."][".__LINE__."] name of table of users not defined"; $error_msg["backup"][] = "[".basename(__FILE__)."][".__LINE__."] name of table of users not defined";
$error_no["backup"][] = "7"; $error_no["backup"][] = "7";
$stop = TRUE; $stop = TRUE;
} }
if (!isset ($TABLECOURSUSER)) if (!isset ($TABLECOURSUSER))
{ {
GLOBAL $error_msg, $error_no;
$error_msg["backup"][] = "[".basename(__FILE__)."][".__LINE__."] name of table of subscription of users in courses not defined"; $error_msg["backup"][] = "[".basename(__FILE__)."][".__LINE__."] name of table of subscription of users in courses not defined";
$error_no["backup"][] = "8"; $error_no["backup"][] = "8";
$stop = TRUE; $stop = TRUE;
@ -404,11 +367,13 @@ function makeTheBackup($exportedCourseId, $verboseBackup = "FALSE", $ignore = ""
{ {
return false; return false;
} }
// ****** 1° 2. 2 params.optional // ****** 1° 2. 2 params.optional
if (!isset ($verboseBackup)) if (!isset ($verbose_backup))
{ {
$verboseBackup = false; $verbose_backup = false;
} }
// ****** 1° 3. check if course exist // ****** 1° 3. check if course exist
// not done // not done
////////////////////////////////////////////// //////////////////////////////////////////////
@ -430,32 +395,32 @@ function makeTheBackup($exportedCourseId, $verboseBackup = "FALSE", $ignore = ""
$systemFileNameOfReadMe = "readme.txt"; $systemFileNameOfReadMe = "readme.txt";
$systemFileNameOfarchiveLog = "readme.txt"; $systemFileNameOfarchiveLog = "readme.txt";
################### ###################
if ($verboseBackup) if ($verbose_backup)
{ {
echo "<hr><u>", $langArchiveName, "</u> : ", "<strong>", basename($systemFileNameOfArchive), "</strong><br><u>", $langArchiveLocation, "</u> : ", "<strong>", realpath($systemFileNameOfArchive), "</strong><br><u>", $langSizeOf, " ", realpath("../../".$exportedCourseId."/"), "</u> : ", "<strong>", DirSize("../../".$exportedCourseId."/"), "</strong> bytes <br>"; echo "<hr><u>", get_lang('ArchiveName'), "</u> : ", "<strong>", basename($systemFileNameOfArchive), "</strong><br><u>", get_lang('ArchiveLocation'), "</u> : ", "<strong>", realpath($systemFileNameOfArchive), "</strong><br><u>", get_lang('SizeOf'), " ", realpath("../../".$exportedCourseId."/"), "</u> : ", "<strong>", DirSize("../../".$exportedCourseId."/"), "</strong> bytes <br>";
if (function_exists(diskfreespace)) if (function_exists(diskfreespace))
echo "<u>".$langDisk_free_space."</u> : <strong>".diskfreespace("/")."</strong> bytes"; echo "<u>".get_lang('DiskFreeSpace')."</u> : <strong>".diskfreespace("/")."</strong> bytes";
echo "<hr>"; echo "<hr />";
} }
mkpath($archiveDirOriginalDocs.$appendMainDb, $verboseBackup); mkpath($archiveDirOriginalDocs.$appendMainDb, $verbose_backup);
mkpath($archiveDirHtml.$appendMainDb, $verboseBackup); mkpath($archiveDirHtml.$appendMainDb, $verbose_backup);
mkpath($archiveDirCsv.$appendMainDb, $verboseBackup); mkpath($archiveDirCsv.$appendMainDb, $verbose_backup);
mkpath($archiveDirXml.$appendMainDb, $verboseBackup); mkpath($archiveDirXml.$appendMainDb, $verbose_backup);
mkpath($archiveDirPhp.$appendMainDb, $verboseBackup); mkpath($archiveDirPhp.$appendMainDb, $verbose_backup);
mkpath($archiveDirLog.$appendMainDb, $verboseBackup); mkpath($archiveDirLog.$appendMainDb, $verbose_backup);
mkpath($archiveDirSql.$appendMainDb, $verboseBackup); mkpath($archiveDirSql.$appendMainDb, $verbose_backup);
mkpath($archiveDirOriginalDocs.$appendCourse, $verboseBackup); mkpath($archiveDirOriginalDocs.$appendCourse, $verbose_backup);
mkpath($archiveDirHtml.$appendCourse, $verboseBackup); mkpath($archiveDirHtml.$appendCourse, $verbose_backup);
mkpath($archiveDirCsv.$appendCourse, $verboseBackup); mkpath($archiveDirCsv.$appendCourse, $verbose_backup);
mkpath($archiveDirXml.$appendCourse, $verboseBackup); mkpath($archiveDirXml.$appendCourse, $verbose_backup);
mkpath($archiveDirPhp.$appendCourse, $verboseBackup); mkpath($archiveDirPhp.$appendCourse, $verbose_backup);
mkpath($archiveDirLog.$appendCourse, $verboseBackup); mkpath($archiveDirLog.$appendCourse, $verbose_backup);
mkpath($archiveDirSql.$appendCourse, $verboseBackup); mkpath($archiveDirSql.$appendCourse, $verbose_backup);
$dirCourBase = $archiveDirSqlCourse; $dirCourBase = $archiveDirSqlCourse;
$dirMainBase = $archiveDirSqlMainDb; $dirMainBase = $archiveDirSqlMainDb;
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// ****** 3° Build exported element and Fill the archive repository tree // ****** 3° Build exported element and Fill the archive repository tree
if ($verboseBackup) if ($verbose_backup)
echo " echo "
build config file build config file
<hr>"; <hr>";
@ -491,10 +456,10 @@ function makeTheBackup($exportedCourseId, $verboseBackup = "FALSE", $ignore = ""
// ******************************************************************** // ********************************************************************
// info about cours // info about cours
// ******************************************************************** // ********************************************************************
if ($verboseBackup) if ($verbose_backup)
echo " echo "
<LI> <LI>
".$langBUCourseDataOfMainBase." ".$exportedCourseId." ".get_lang('BUCourseDataOfMainBase')." ".$exportedCourseId."
<HR> <HR>
<PRE>"; <PRE>";
$sqlInsertCourse = " $sqlInsertCourse = "
@ -530,8 +495,10 @@ function makeTheBackup($exportedCourseId, $verboseBackup = "FALSE", $ignore = ""
# ".$sqlInsertCourse." # ".$sqlInsertCourse."
#------------------------ #------------------------
"; ";
if ($verboseBackup) if ($verbose_backup)
{
echo "</PRE>"; echo "</PRE>";
}
$fcoursql = fopen($archiveDirSql.$appendMainDb."course.sql", "w"); $fcoursql = fopen($archiveDirSql.$appendMainDb."course.sql", "w");
fwrite($fcoursql, $sqlInsertCourse); fwrite($fcoursql, $sqlInsertCourse);
fclose($fcoursql); fclose($fcoursql);
@ -547,10 +514,10 @@ function makeTheBackup($exportedCourseId, $verboseBackup = "FALSE", $ignore = ""
// ******************************************************************** // ********************************************************************
// if ($backupUser ) // if ($backupUser )
{ {
if ($verboseBackup) if ($verbose_backup)
echo " echo "
<LI> <LI>
".$langBUUsersInMainBase." ".$exportedCourseId." ".get_lang('BUUsersInMainBase')." ".$exportedCourseId."
<hR> <hR>
<PRE>"; <PRE>";
// recup users // recup users
@ -622,11 +589,15 @@ function makeTheBackup($exportedCourseId, $verboseBackup = "FALSE", $ignore = ""
} }
else else
{ {
if ($verboseBackup) if ($verbose_backup)
{
echo "<HR><div align=\"center\">NO user in this course !!!!</div><HR>"; echo "<HR><div align=\"center\">NO user in this course !!!!</div><HR>";
}
} }
if ($verboseBackup) if ($verbose_backup)
{
echo "</PRE>"; echo "</PRE>";
}
} }
/* End of backup user */ /* End of backup user */
if ($saveAnnouncement) if ($saveAnnouncement)
@ -634,12 +605,14 @@ function makeTheBackup($exportedCourseId, $verboseBackup = "FALSE", $ignore = ""
// ******************************************************************** // ********************************************************************
// info about announcment // info about announcment
// ******************************************************************** // ********************************************************************
if ($verboseBackup) if ($verbose_backup)
{
echo " echo "
<LI> <LI>
".$langBUAnnounceInMainBase." ".$exportedCourseId." ".get_lang('BUAnnounceInMainBase')." ".$exportedCourseId."
<hR> <hR>
<PRE>"; <PRE>";
}
// recup annonce // recup annonce
$sqlAnnounceOfTheCourse = " $sqlAnnounceOfTheCourse = "
SELECT SELECT
@ -686,8 +659,10 @@ function makeTheBackup($exportedCourseId, $verboseBackup = "FALSE", $ignore = ""
$sqlInsertAnn .= ";"; $sqlInsertAnn .= ";";
$htmlInsertAnn .= "\t</TR>\n"; $htmlInsertAnn .= "\t</TR>\n";
} }
if ($verboseBackup) if ($verbose_backup)
{
echo "</PRE>"; echo "</PRE>";
}
$htmlInsertAnn .= "</TABLE>\n"; $htmlInsertAnn .= "</TABLE>\n";
$stringConfig .= " $stringConfig .= "
#INSERT ANNOUNCE #INSERT ANNOUNCE
@ -707,17 +682,17 @@ function makeTheBackup($exportedCourseId, $verboseBackup = "FALSE", $ignore = ""
/* End of backup Annonces */ /* End of backup Annonces */
} }
// we can copy file of course // we can copy file of course
if ($verboseBackup) if ($verbose_backup)
echo " {
<LI> echo '<li>'.get_lang('CopyDirectoryCourse');
".$langCopyDirectoryCourse; }
$nbFiles = copydir(api_get_path(SYS_COURSE_PATH).$_course['path'], $archiveDirOriginalDocs.$appendCourse, $verboseBackup); $nbFiles = copydir(api_get_path(SYS_COURSE_PATH).$_course['path'], $archiveDirOriginalDocs.$appendCourse, $verbose_backup);
if ($verboseBackup) if ($verbose_backup)
echo " echo "
<strong> <strong>
".$nbFiles." ".$nbFiles."
</strong> </strong>
".$langFileCopied." ".get_lang('FileCopied')."
<br> <br>
</li>"; </li>";
$stringConfig .= " $stringConfig .= "
@ -726,44 +701,44 @@ function makeTheBackup($exportedCourseId, $verboseBackup = "FALSE", $ignore = ""
// Copy of DB course // Copy of DB course
// with mysqldump // with mysqldump
// ******************************************************************** // ********************************************************************
if ($verboseBackup) if ($verbose_backup)
echo " echo "
<LI> <LI>
".$langBackupOfDataBase." ".$exportedCourseId." (SQL) ".get_lang('BackupOfDataBase')." ".$exportedCourseId." (SQL)
<hr>"; <hr>";
backupDatabase($db, $exportedCourseId, true, true, 'SQL', $archiveDirSql.$appendCourse, true, $verboseBackup); backupDatabase($db, $exportedCourseId, true, true, 'SQL', $archiveDirSql.$appendCourse, true, $verbose_backup);
if ($verboseBackup) if ($verbose_backup)
echo " echo "
</LI> </LI>
<LI> <LI>
".$langBackupOfDataBase." ".$exportedCourseId." (PHP) ".get_lang('BackupOfDataBase')." ".$exportedCourseId." (PHP)
<hr>"; <hr>";
backupDatabase($db, $exportedCourseId, true, true, 'PHP', $archiveDirPhp.$appendCourse, true, $verboseBackup); backupDatabase($db, $exportedCourseId, true, true, 'PHP', $archiveDirPhp.$appendCourse, true, $verbose_backup);
if ($verboseBackup) if ($verbose_backup)
echo " echo "
</LI> </LI>
<LI> <LI>
".$langBackupOfDataBase." ".$exportedCourseId." (CSV) ".get_lang('BackupOfDataBase')." ".$exportedCourseId." (CSV)
<hr>"; <hr>";
backupDatabase($db, $exportedCourseId, true, true, 'CSV', $archiveDirCsv.$appendCourse, true, $verboseBackup); backupDatabase($db, $exportedCourseId, true, true, 'CSV', $archiveDirCsv.$appendCourse, true, $verbose_backup);
if ($verboseBackup) if ($verbose_backup)
echo " echo "
<LI> <LI>
".$langBackupOfDataBase." ".$exportedCourseId." (HTML) ".get_lang('BackupOfDataBase')." ".$exportedCourseId." (HTML)
<hr>"; <hr>";
backupDatabase($db, $exportedCourseId, true, true, 'HTML', $archiveDirHtml.$appendCourse, true, $verboseBackup); backupDatabase($db, $exportedCourseId, true, true, 'HTML', $archiveDirHtml.$appendCourse, true, $verbose_backup);
if ($verboseBackup) if ($verbose_backup)
echo " echo "
<LI> <LI>
".$langBackupOfDataBase." ".$exportedCourseId." (XML) ".get_lang('BackupOfDataBase')." ".$exportedCourseId." (XML)
<hr>"; <hr>";
backupDatabase($db, $exportedCourseId, true, true, 'XML', $archiveDirXml.$appendCourse, true, $verboseBackup); backupDatabase($db, $exportedCourseId, true, true, 'XML', $archiveDirXml.$appendCourse, true, $verbose_backup);
if ($verboseBackup) if ($verbose_backup)
echo " echo "
<LI> <LI>
".$langBackupOfDataBase." ".$exportedCourseId." (LOG) ".get_lang('BackupOfDataBase')." ".$exportedCourseId." (LOG)
<hr>"; <hr>";
backupDatabase($db, $exportedCourseId, true, true, 'LOG', $archiveDirLog.$appendCourse, true, $verboseBackup); backupDatabase($db, $exportedCourseId, true, true, 'LOG', $archiveDirLog.$appendCourse, true, $verbose_backup);
// ******************************************************************** // ********************************************************************
// Copy of DB course // Copy of DB course
// with mysqldump // with mysqldump
@ -771,7 +746,7 @@ function makeTheBackup($exportedCourseId, $verboseBackup = "FALSE", $ignore = ""
$fdesc = fopen($archiveDir.$systemFileNameOfArchive, "w"); $fdesc = fopen($archiveDir.$systemFileNameOfArchive, "w");
fwrite($fdesc, $stringConfig); fwrite($fdesc, $stringConfig);
fclose($fdesc); fclose($fdesc);
if ($verboseBackup) if ($verbose_backup)
echo " echo "
</LI> </LI>
</OL> </OL>
@ -800,33 +775,12 @@ function makeTheBackup($exportedCourseId, $verboseBackup = "FALSE", $ignore = ""
echo "<br>"; echo "<br>";
} }
$pathToArchive = $archiveRepositoryWeb.$archiveFileName; $pathToArchive = $archiveRepositoryWeb.$archiveFileName;
if ($verboseBackup) if ($verbose_backup)
echo "<hr>".$langBuildTheCompressedFile; {
echo '<hr>'.get_lang('BuildTheCompressedFile');
}
// removeDir($archivePath); // removeDir($archivePath);
} }
?>
<!--
<hr>
3° - Si demandé suppression des éléments sources qui viennent d'être archivés
<font color="#FF0000">
non réalisé
</font>
-->
<?php
return 1; return 1;
} // function makeTheBackup() } // function makeTheBackup()
/**
* @deprecated Function not in use
*/
function setValueIfNotInSession($varname, $value)
{
global $$varname, $_SESSION;
if (!isset ($_SESSION[$varname]))
{
$$varname = $value;
api_session_register($varname);
}
}
?> ?>

@ -497,38 +497,4 @@ function buildTabDefcon($array_of_results)
} }
echo "</table>\n"; echo "</table>\n";
} }
/**
* @deprecated use format_locale_date in text.lib.php - 19-dec-2005
*/
function dateLocalizer($formatOfDate, $timestamp = -1) //PMAInspiration :)
{
return format_locale_date($formatOfDate, $timestamp = -1);
}
/**
* changeResultOfVisibility($array_of_results)
* @author Christophe Gesché <gesche@ipm.ucl.ac.be>
* @param array_of_results
* @desc complete the content of visibility column a with the literal meaning
*/
function changeResultOfVisibility($array_of_results)
{
$visibility_label = array(
0 => 'closed - hide',
1 => 'open - hide',
2 => 'open - visible',
3 => 'closed - visible',
);
if (is_array($array_of_results))
{
for($j = 0 ; $j < count($array_of_results) ; $j++)
{
$array_of_results[$j][0] = $array_of_results[$j][0].' <small>('.$visibility_label[$array_of_results[$j][0]].')</small>';
}
}
return $array_of_results;
}
?> ?>

@ -130,18 +130,11 @@ $phpMyAdminPath = '';
// $extAuthSource["ldap"]["login"]=$clarolineRepositorySys."auth/ldap/login.php"; // $extAuthSource["ldap"]["login"]=$clarolineRepositorySys."auth/ldap/login.php";
// $extAuthSource["ldap"]["newUser"]=$clarolineRepositorySys."auth/ldap/newUser.php"; // $extAuthSource["ldap"]["newUser"]=$clarolineRepositorySys."auth/ldap/newUser.php";
//============================================================================
// Language settings
//============================================================================
// Available Languages : look at the "lang" directory
$platformLanguage = '{PLATFORM_LANGUAGE}';
$language = $platformLanguage;
//============================================================================ //============================================================================
// Misc. settings // Misc. settings
//============================================================================ //============================================================================
// Verbose backup // Verbose backup
$verboseBackup = false; $_configuration['verbose_backup'] = false;
// security word for password recovery // security word for password recovery
$_configuration['security_key'] = '{SECURITY_KEY}'; $_configuration['security_key'] = '{SECURITY_KEY}';
// Settings for new and future features // Settings for new and future features

Loading…
Cancel
Save