Feature #272 - Installation scripts: Cleaning & reformatting, second pass. Some minor corrections.

skala
Ivan Tcholakov 16 years ago
parent 0dc20d6ef9
commit 9bec6eca66
  1. 2
      main/install/INSTALL.txt
  2. 86
      main/install/compare_db.php
  3. 6
      main/install/index.php
  4. 3
      main/install/install_db.inc.php
  5. 147
      main/install/install_functions.inc.php
  6. 19
      main/install/install_upgrade.lib.php
  7. 188
      main/install/update-db-1.6.x-1.8.0.inc.php
  8. 3
      main/install/update-db-1.8.0-1.8.2.inc.php
  9. 3
      main/install/update-db-1.8.2-1.8.3.inc.php
  10. 3
      main/install/update-db-1.8.3-1.8.4.inc.php
  11. 3
      main/install/update-db-1.8.4-1.8.5.inc.php
  12. 3
      main/install/update-db-1.8.5-1.8.6.inc.php
  13. 3
      main/install/update-db-1.8.6-1.8.6.1.inc.php
  14. 3
      main/install/update-db-1.8.6.1-1.8.6.2.inc.php
  15. 3
      main/install/update-db-1.8.6.2-1.8.7.inc.php
  16. 148
      main/install/update-db-scorm-1.6.x-1.8.0.inc.php
  17. 42
      main/install/update-files-1.6.x-1.8.0.inc.php
  18. 41
      main/install/update-files-1.8.3-1.8.4.inc.php
  19. 41
      main/install/update-files-1.8.4-1.8.5.inc.php
  20. 43
      main/install/update-files-1.8.5-1.8.6.inc.php
  21. 48
      main/install/update-files-1.8.6-1.8.6.1.inc.php
  22. 46
      main/install/update-files-1.8.6.1-1.8.6.2.inc.php
  23. 24
      main/install/update-files-1.8.6.2-1.8.7.inc.php
  24. 59
      main/install/update_courses.php
  25. 3
      main/install/update_db.inc.php
  26. 90
      main/install/update_files.inc.php
  27. 330
      main/install/upgrade.php
  28. 75
      main/install/upgrade_lib.php

@ -1,2 +1,2 @@
For installation help, see installation_guide.html or INSTALL.txt at the Dokeos root directory For installation help, see installation_guide.html or INSTALL.txt at the Chamilo root directory
(which should be two directories up from this) (which should be two directories up from this)

@ -26,20 +26,18 @@ $sql_user_new='root';
$sql_pass_new = ''; $sql_pass_new = '';
$prefix_new = 'dokeos180_'; $prefix_new = 'dokeos180_';
$bases_new = array($prefix_new.'dokeos_main', $prefix_new.'dokeos_stats', $prefix_new.'dokeos_user', 'z'.$prefix_new.'COURSE', $prefix_new.'dokeos_scorm'); $bases_new = array($prefix_new.'dokeos_main', $prefix_new.'dokeos_stats', $prefix_new.'dokeos_user', 'z'.$prefix_new.'COURSE', $prefix_new.'dokeos_scorm');
$db_new = mysql_connect($sql_server_new,$sql_user_new,$sql_pass_new) or die(mysql_error());
// The system has not been designed to use special SQL modes that were introduced since MySQL 5 $db_new = mysql_connect($sql_server_new, $sql_user_new, $sql_pass_new) or die(mysql_error());
@mysql_query("set session sql_mode='';", $db_new); @mysql_query("set session sql_mode='';", $db_new); // Disabling special SQL modes (MySQL 5)
$sql_server_old = 'localhost'; $sql_server_old = 'localhost';
$sql_user_old = 'root'; $sql_user_old = 'root';
$sql_pass_old = ''; $sql_pass_old = '';
$prefix_old = 'dokeos160_'; $prefix_old = 'dokeos160_';
$bases_old = array($prefix_old.'dokeos_main', $prefix_old.'dokeos_stats', $prefix_old.'dokeos_user', $prefix_old.'COURSE', $prefix_old.'dokeos_scorm'); $bases_old = array($prefix_old.'dokeos_main', $prefix_old.'dokeos_stats', $prefix_old.'dokeos_user', $prefix_old.'COURSE', $prefix_old.'dokeos_scorm');
$db_old = mysql_connect($sql_server_old,$sql_user_old,$sql_pass_old) or die(mysql_error());
// The system has not been designed to use special SQL modes that were introduced since MySQL 5 $db_old = mysql_connect($sql_server_old, $sql_user_old, $sql_pass_old) or die(mysql_error());
@mysql_query("set session sql_mode='';", $db_old); @mysql_query("set session sql_mode='';", $db_old); // Disabling special SQL modes (MySQL 5)
$field_details = array(0 => 'Field', 1 => 'Type', 2 => 'Null', 3 => 'Key', 4 => 'Default', 5 => 'Extra'); $field_details = array(0 => 'Field', 1 => 'Type', 2 => 'Null', 3 => 'Key', 4 => 'Default', 5 => 'Extra');
@ -49,29 +47,29 @@ $all_db_changes = array();
echo "<h1>Databases structure comparison script</h1>"; echo "<h1>Databases structure comparison script</h1>";
//iterate through databases given above (checking from the 'new' database side) // Iterate through databases given above (checking from the 'new' database side)
foreach($bases_new as $num_base=>$base) foreach ($bases_new as $num_base => $base) {
{
//init tables lists for this database //init tables lists for this database
$modif_tables = array(); $modif_tables = array();
$tables_db_new = array(); $tables_db_new = array();
$tables_db_old = array(); $tables_db_old = array();
$dump = array(); $dump = array();
//display current processed database // Display current processed database
echo "<h2>Now analysing differences between databases <em>$base</em> and <em>".$bases_old[$num_base]."</em></h2>"; echo "<h2>Now analysing differences between databases <em>$base</em> and <em>".$bases_old[$num_base]."</em></h2>";
//get a list of tables for this database // Get a list of tables for this database
$query_new = "SHOW TABLES FROM ".$bases_new[$num_base]; $query_new = "SHOW TABLES FROM ".$bases_new[$num_base];
$result_new = mysql_query($query_new, $db_new); $result_new = mysql_query($query_new, $db_new);
if($result_new) //if there are tables in this database if ($result_new) { //if there are tables in this database
{
$i=0; $i=0;
//as there are tables, process them one by one //as there are tables, process them one by one
while($row_new=mysql_fetch_row($result_new)) while ($row_new = mysql_fetch_row($result_new)) {
{
$dump[$i]['table_name'] = $row_new[0]; $dump[$i]['table_name'] = $row_new[0];
$dump[$i]['fields'] = array(); $dump[$i]['fields'] = array();
@ -81,8 +79,8 @@ foreach($bases_new as $num_base=>$base)
$j=0; $j=0;
//get the fields details (numbered fields) //get the fields details (numbered fields)
while($row_old=mysql_fetch_row($result_old)) while ($row_old = mysql_fetch_row($result_old)) {
{
$dump[$i]['fields'][$j][0] = $row_old[0]; $dump[$i]['fields'][$j][0] = $row_old[0];
$dump[$i]['fields'][$j][1] = $row_old[1]; $dump[$i]['fields'][$j][1] = $row_old[1];
$dump[$i]['fields'][$j][2] = $row_old[2]; $dump[$i]['fields'][$j][2] = $row_old[2];
@ -98,39 +96,40 @@ foreach($bases_new as $num_base=>$base)
$i++; $i++;
} }
foreach($dump as $table) foreach ($dump as $table) {
{
$query = "SHOW FIELDS FROM ".$bases_old[$num_base].".".$table['table_name']; $query = "SHOW FIELDS FROM ".$bases_old[$num_base].".".$table['table_name'];
$result = mysql_query($query,$db_old); $result = mysql_query($query,$db_old);
if(!$result) if (!$result) {
{
$modif_tables[]='**'.$table['table_name'].'**'; $modif_tables[]='**'.$table['table_name'].'**';
}
else } else {
{
$i = 0; $i = 0;
//check for removed, new or modified fields //check for removed, new or modified fields
$fields_old = array(); $fields_old = array();
$fields_new = array(); $fields_new = array();
//list the new fields in a enumeration array //list the new fields in a enumeration array
foreach($table['field_names'] as $dummy_key => $dummy_field) { foreach($table['field_names'] as $dummy_key => $dummy_field) {
$fields_new[] = $dummy_key; $fields_new[] = $dummy_key;
} }
//list the old fields in an enumeration array and check if their corresponding
//field in the new table is different (if any) //list the old fields in an enumeration array and check if their corresponding field in the new table is different (if any)
$modif_fields = array(); $modif_fields = array();
while ($row_old = mysql_fetch_row($result)) { while ($row_old = mysql_fetch_row($result)) {
$fields_old[] = $row_old[0]; $fields_old[] = $row_old[0];
$modif_field = ''; $modif_field = '';
if (isset($table['fields'][$table['field_names'][$row_old[0]]])) { if (isset($table['fields'][$table['field_names'][$row_old[0]]])) {
$field_infos=$table['fields'][$table['field_names'][$row_old[0]]]; $field_info = $table['fields'][$table['field_names'][$row_old[0]]];
foreach($row_old as $key=>$enreg) foreach ($row_old as $key => $enreg) {
{
//if the old field information of this kind doesn't match the new, record it //if the old field information of this kind doesn't match the new, record it
if($row_old[$key] != $field_infos[$key]) if ($row_old[$key] != $field_info[$key]) {
{
$modif_field .= '~+~'.$field_details[$key].'~+~,'; $modif_field .= '~+~'.$field_details[$key].'~+~,';
break; break;
} }
@ -141,14 +140,17 @@ foreach($bases_new as $num_base=>$base)
} }
} }
} }
$new_fields = array_diff($fields_new, $fields_old); $new_fields = array_diff($fields_new, $fields_old);
foreach ($new_fields as $dummy => $val) { foreach ($new_fields as $dummy => $val) {
$new_fields[$dummy] = '++'.$val.'++'; $new_fields[$dummy] = '++'.$val.'++';
} }
$old_fields = array_diff($fields_old, $fields_new); $old_fields = array_diff($fields_old, $fields_new);
foreach ($old_fields as $dummy => $val) { foreach ($old_fields as $dummy => $val) {
$old_fields[$dummy] = '--'.$val.'--'; $old_fields[$dummy] = '--'.$val.'--';
} }
if (count($old_fields) > 0 or count($modif_fields) > 0 or count($new_fields) > 0 ) { if (count($old_fields) > 0 or count($modif_fields) > 0 or count($new_fields) > 0 ) {
$modif_tables[] = array( $modif_tables[] = array(
'table' => $table['table_name'], 'table' => $table['table_name'],
@ -164,32 +166,29 @@ foreach($bases_new as $num_base=>$base)
$query = "SHOW TABLES FROM ".$bases_old[$num_base]; $query = "SHOW TABLES FROM ".$bases_old[$num_base];
$result = mysql_query($query, $db_old) or die(mysql_error()); $result = mysql_query($query, $db_old) or die(mysql_error());
while($row=mysql_fetch_row($result)) while ($row = mysql_fetch_row($result)) {
{
$tables_db_old[] = $row[0]; $tables_db_old[] = $row[0];
} }
$diff = array_diff($tables_db_old, $tables_db_new); $diff = array_diff($tables_db_old, $tables_db_new);
foreach($diff as $enreg) foreach ($diff as $enreg) {
{
$modif_tables[] = '---'.$enreg.'---'; $modif_tables[] = '---'.$enreg.'---';
} }
//$modif_tables = array_unique($modif_tables); //deprecated with the structure complexification //$modif_tables = array_unique($modif_tables); //deprecated with the structure complexification
} else { //this database was removed in the new version } else { //this database was removed in the new version
$query = "SHOW TABLES FROM ".$bases_old[$num_base]; $query = "SHOW TABLES FROM ".$bases_old[$num_base];
$result = mysql_query($query, $db_old) or die(mysql_error()); $result = mysql_query($query, $db_old) or die(mysql_error());
while($row=mysql_fetch_row($result)) while ($row = mysql_fetch_row($result)) {
{
$tables_db_old[] = $row[0]; $tables_db_old[] = $row[0];
} }
$diff = array_diff($tables_db_old, $tables_db_new); $diff = array_diff($tables_db_old, $tables_db_new);
foreach($diff as $enreg) foreach ($diff as $enreg) {
{
$modif_tables[] = '---'.$enreg.'---'; $modif_tables[] = '---'.$enreg.'---';
} }
@ -211,21 +210,26 @@ mysql_close($db_new);
mysql_close($db_old); mysql_close($db_old);
echo "<h2>Generating SQL</h2>"; echo "<h2>Generating SQL</h2>";
//going through all databases changes //going through all databases changes
foreach ($all_db_changes as $base => $changes) { foreach ($all_db_changes as $base => $changes) {
echo "<h3>SQL for DB $base</h3>"; echo "<h3>SQL for DB $base</h3>";
foreach ($changes as $table) { foreach ($changes as $table) {
if (is_array($table)) { if (is_array($table)) {
//we have a field-level difference //we have a field-level difference
$mytable = $table['table']; $mytable = $table['table'];
$myold = $table['old_fields']; $myold = $table['old_fields'];
$mychanged = $table['changed_fields']; $mychanged = $table['changed_fields'];
$mynew = $table['new_fields']; $mynew = $table['new_fields'];
foreach ($myold as $myname) { foreach ($myold as $myname) {
//column lost, display DROP command //column lost, display DROP command
$myname = str_replace('--', '', $myname); $myname = str_replace('--', '', $myname);
echo "ALTER TABLE ".$mytable." DROP ".$myname."<br />"; echo "ALTER TABLE ".$mytable." DROP ".$myname."<br />";
} }
foreach ($mychanged as $myname => $myprop) { foreach ($mychanged as $myname => $myprop) {
//field changed, display SET command //field changed, display SET command
$myprops = split(',', $myprop); $myprops = split(',', $myprop);
@ -236,12 +240,15 @@ foreach($all_db_changes as $base => $changes){
} }
echo "ALTER TABLE ".$mytable." CHANGE $myname $myname $myprops_string<br />"; echo "ALTER TABLE ".$mytable." CHANGE $myname $myname $myprops_string<br />";
} }
foreach ($mynew as $myname) { foreach ($mynew as $myname) {
//column created, display ADD command //column created, display ADD command
$myname = str_replace('++', '', $myname); $myname = str_replace('++', '', $myname);
echo "ALTER TABLE ".$mytable." ADD $myname...<br />"; echo "ALTER TABLE ".$mytable." ADD $myname...<br />";
} }
} else { } else {
//we have a table-level difference //we have a table-level difference
$open_tag = substr($table, 0, 2); $open_tag = substr($table, 0, 2);
switch ($open_tag) { switch ($open_tag) {
@ -262,4 +269,3 @@ foreach($all_db_changes as $base => $changes){
} }
} }
} }
?>

@ -244,7 +244,9 @@ if (!isset($_GET['running'])) {
$singleDbForm = 0; $singleDbForm = 0;
$encryptPassForm = 'md5'; $encryptPassForm = 'md5';
$session_lifetime = 360000; $session_lifetime = 360000;
} else { } else {
foreach($_POST as $key => $val) { foreach($_POST as $key => $val) {
$magic_quotes_gpc = ini_get('magic_quotes_gpc') ? true : false; $magic_quotes_gpc = ini_get('magic_quotes_gpc') ? true : false;
if (is_string($val)) { if (is_string($val)) {
@ -623,7 +625,9 @@ if ($_POST['step2']) {
} elseif ($_POST['step6']) { } elseif ($_POST['step6']) {
//STEP 6 : INSTALLATION PROCESS //STEP 6 : INSTALLATION PROCESS
if ($installType == 'update') { if ($installType == 'update') {
if (empty($my_old_version)) { $my_old_version = '1.8.6'; } //we guess if (empty($my_old_version)) { $my_old_version = '1.8.6'; } //we guess
$_configuration['main_database'] = $dbNameForm; $_configuration['main_database'] = $dbNameForm;
//$urlAppendPath = get_config_param('urlAppend'); //$urlAppendPath = get_config_param('urlAppend');
@ -674,7 +678,9 @@ if ($_POST['step2']) {
default: default:
break; break;
} }
} else { } else {
include 'install_db.inc.php'; include 'install_db.inc.php';
include 'install_files.inc.php'; include 'install_files.inc.php';
} }

@ -45,8 +45,7 @@ if (mysql_errno() > 0) {
exit(); exit();
} }
// The system has not been designed to use special SQL modes that were introduced since MySQL 5 @mysql_query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
@mysql_query("set session sql_mode='';");
// Initialization of the database encoding to be used. // Initialization of the database encoding to be used.
mysql_query("SET SESSION character_set_server='utf8';"); mysql_query("SET SESSION character_set_server='utf8';");

@ -38,7 +38,7 @@ function check_extension($extension_name, $return_success = 'Yes', $return_failu
if (extension_loaded($extension_name)) { if (extension_loaded($extension_name)) {
return '<strong><font color="green">'.$return_success.'</font></strong>'; return '<strong><font color="green">'.$return_success.'</font></strong>';
} else { } else {
if ($optional === true) { if ($optional) {
return '<strong><font color="#ff9900">'.$return_failure.'</font></strong>'; return '<strong><font color="#ff9900">'.$return_failure.'</font></strong>';
} else { } else {
return '<strong><font color="red">'.$return_failure.'</font></strong>'; return '<strong><font color="red">'.$return_failure.'</font></strong>';
@ -80,7 +80,7 @@ function check_writable($folder,$suggestion=false) {
if (is_writable('../'.$folder)) { if (is_writable('../'.$folder)) {
return '<strong><font color="green">'.get_lang('Writable').'</font></strong>'; return '<strong><font color="green">'.get_lang('Writable').'</font></strong>';
} else { } else {
if ($suggestion == true) { if ($suggestion) {
return '<strong><font color="#ff9900">'.get_lang('NotWritable').'</font></strong>'; return '<strong><font color="#ff9900">'.get_lang('NotWritable').'</font></strong>';
} else { } else {
return '<strong><font color="red">'.get_lang('NotWritable').'</font></strong>'; return '<strong><font color="red">'.get_lang('NotWritable').'</font></strong>';
@ -109,8 +109,7 @@ function file_to_array($filename) {
$fp = fopen($filename, 'rb'); $fp = fopen($filename, 'rb');
$buffer = fread($fp, filesize($filename)); $buffer = fread($fp, filesize($filename));
fclose($fp); fclose($fp);
$result = explode('<br />', nl2br($buffer)); return explode('<br />', nl2br($buffer));
return $result;
} }
/** /**
@ -124,51 +123,41 @@ function file_to_array($filename) {
* @return string the value of the parameter * @return string the value of the parameter
* @author Olivier Brouckaert * @author Olivier Brouckaert
*/ */
function get_config_param($param,$updatePath='') function get_config_param($param, $updatePath = '') {
{
global $configFile, $updateFromConfigFile; global $configFile, $updateFromConfigFile;
//look if we already have the queried param //look if we already have the queried param
if(is_array($configFile) && isset($configFile[$param])) if (is_array($configFile) && isset($configFile[$param])) {
{
return $configFile[$param]; return $configFile[$param];
} }
if(empty($updatePath) && !empty($_POST['updatePath'])) if (empty($updatePath) && !empty($_POST['updatePath'])) {
{
$updatePath = $_POST['updatePath']; $updatePath = $_POST['updatePath'];
} }
$updatePath = realpath($updatePath).'/'; $updatePath = realpath($updatePath).'/';
$updateFromInstalledVersionFile = ''; $updateFromInstalledVersionFile = '';
if(empty($updateFromConfigFile)) //if update from previous install was requested if (empty($updateFromConfigFile)) { //if update from previous install was requested
{
//try to recover old config file from dokeos 1.8.x //try to recover old config file from dokeos 1.8.x
if(file_exists($updatePath.'main/inc/conf/configuration.php')) if (file_exists($updatePath.'main/inc/conf/configuration.php')) {
{
$updateFromConfigFile='main/inc/conf/configuration.php'; $updateFromConfigFile='main/inc/conf/configuration.php';
} } elseif (file_exists($updatePath.'claroline/inc/conf/claro_main.conf.php')) {
elseif(file_exists($updatePath.'claroline/inc/conf/claro_main.conf.php'))
{
$updateFromConfigFile='claroline/inc/conf/claro_main.conf.php'; $updateFromConfigFile='claroline/inc/conf/claro_main.conf.php';
} } else { //give up recovering
//give up recovering
else
{
error_log('Could not find config file in '.$updatePath.' in get_config_param()',0); error_log('Could not find config file in '.$updatePath.' in get_config_param()',0);
return null; return null;
} }
} }
if(file_exists($updatePath.'main/inc/installedVersion.inc.php'))
{ if (file_exists($updatePath.'main/inc/installedVersion.inc.php')) {
$updateFromInstalledVersionFile = $updatePath.'main/inc/installedVersion.inc.php'; $updateFromInstalledVersionFile = $updatePath.'main/inc/installedVersion.inc.php';
}
//the param was not found in global vars, so look into the old config file } elseif (file_exists($updatePath.$updateFromConfigFile)) { //the param was not found in global vars, so look into the old config file
elseif(file_exists($updatePath.$updateFromConfigFile))
{
//make sure the installedVersion file is read first so it is overwritten //make sure the installedVersion file is read first so it is overwritten
//by the config file if the config file contains the version (from 1.8.4) //by the config file if the config file contains the version (from 1.8.4)
$temp2 = array(); $temp2 = array();
if(file_exists($updatePath.$updateFromInstalledVersionFile)) if (file_exists($updatePath.$updateFromInstalledVersionFile)) {
{
$temp2 = file_to_array($updatePath.$updateFromInstalledVersionFile); $temp2 = file_to_array($updatePath.$updateFromInstalledVersionFile);
} }
$configFile = array(); $configFile = array();
@ -177,43 +166,33 @@ function get_config_param($param,$updatePath='')
$val = ''; $val = '';
//parse the config file (TODO clarify why it has to be so complicated) //parse the config file (TODO clarify why it has to be so complicated)
foreach($temp as $enreg) foreach ($temp as $enreg) {
{ if (strstr($enreg, '=')) {
if(strstr($enreg,'='))
{
$enreg = explode('=', $enreg); $enreg = explode('=', $enreg);
$enreg[0] = trim($enreg[0]); $enreg[0] = trim($enreg[0]);
if($enreg[0][0] == '$') if ($enreg[0][0] == '$') {
{
list($enreg[1]) = explode(' //', $enreg[1]); list($enreg[1]) = explode(' //', $enreg[1]);
$enreg[0] = trim(str_replace('$', '', $enreg[0])); $enreg[0] = trim(str_replace('$', '', $enreg[0]));
$enreg[1] = str_replace('\"', '"', ereg_replace('(^"|"$)', '', substr(trim($enreg[1]), 0, -1))); $enreg[1] = str_replace('\"', '"', ereg_replace('(^"|"$)', '', substr(trim($enreg[1]), 0, -1)));
$enreg[1] = str_replace('\'', '"', ereg_replace('(^\'|\'$)', '', $enreg[1])); $enreg[1] = str_replace('\'', '"', ereg_replace('(^\'|\'$)', '', $enreg[1]));
if(strtolower($enreg[1]) == 'true') if (strtolower($enreg[1]) == 'true') {
{
$enreg[1] = 1; $enreg[1] = 1;
} }
if(strtolower($enreg[1]) == 'false') if (strtolower($enreg[1]) == 'false') {
{
$enreg[1] = 0; $enreg[1] = 0;
} } else {
else
{
$implode_string=' '; $implode_string=' ';
if(!strstr($enreg[1],'." ".') && strstr($enreg[1],'.$')) if (!strstr($enreg[1], '." ".') && strstr($enreg[1], '.$')) {
{
$enreg[1] = str_replace('.$', '." ".$', $enreg[1]); $enreg[1] = str_replace('.$', '." ".$', $enreg[1]);
$implode_string = ''; $implode_string = '';
} }
$tmp = explode('." ".', $enreg[1]); $tmp = explode('." ".', $enreg[1]);
foreach($tmp as $tmp_key=>$tmp_val) foreach ($tmp as $tmp_key => $tmp_val) {
{ if (eregi('^\$[a-z_][a-z0-9_]*$', $tmp_val)) {
if(eregi('^\$[a-z_][a-z0-9_]*$',$tmp_val))
{
$tmp[$tmp_key] = get_config_param(str_replace('$', '', $tmp_val)); $tmp[$tmp_key] = get_config_param(str_replace('$', '', $tmp_val));
} }
} }
@ -225,8 +204,7 @@ function get_config_param($param,$updatePath='')
$a = explode("'", $enreg[0]); $a = explode("'", $enreg[0]);
$key_tmp = $a[1]; $key_tmp = $a[1];
if($key_tmp== $param) if ($key_tmp == $param) {
{
$val = $enreg[1]; $val = $enreg[1];
} }
} }
@ -234,9 +212,8 @@ function get_config_param($param,$updatePath='')
} }
return $val; return $val;
}
else } else {
{
error_log('Config array could not be found in get_config_param()', 0); error_log('Config array could not be found in get_config_param()', 0);
return null; return null;
} }
@ -252,12 +229,12 @@ function get_config_param($param,$updatePath='')
* @return mixed The parameter value or null if not found * @return mixed The parameter value or null if not found
*/ */
function get_config_param_from_db($host, $login, $pass, $db_name, $param = '') { function get_config_param_from_db($host, $login, $pass, $db_name, $param = '') {
$mydb = mysql_connect($host, $login, $pass);
// The system has not been designed to use special SQL modes that were introduced since MySQL 5 $mydb = mysql_connect($host, $login, $pass);
@mysql_query("set session sql_mode='';"); @mysql_query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
$myconnect = mysql_select_db($db_name); $myconnect = mysql_select_db($db_name);
$sql = "SELECT * FROM settings_current WHERE variable = '$param'"; $sql = "SELECT * FROM settings_current WHERE variable = '$param'";
$res = mysql_query($sql); $res = mysql_query($sql);
if ($res === false) { if ($res === false) {
@ -273,6 +250,8 @@ function get_config_param_from_db($host, $login, $pass, $db_name, $param = '') {
} }
/** /**
* TODO: The main API is accessible here. Then we could use a function for this purpose from there?
*
* Return a list of language directories. * Return a list of language directories.
* @todo function does not belong here, move to code library, * @todo function does not belong here, move to code library,
* also see infocours.php which contains similar function * also see infocours.php which contains similar function
@ -309,7 +288,7 @@ function get_language_folder_list($dirname) {
*/ */
function display_language_selection_box() { function display_language_selection_box() {
//get language list //get language list
$dirname = '../lang/'; $dirname = '../lang/'; // TODO: Check api_get_path() and use it.
$language_list = get_language_folder_list($dirname); $language_list = get_language_folder_list($dirname);
sort($language_list); sort($language_list);
//Reduce the number of languages shown to only show those with higher than 90% translation in DLTT //Reduce the number of languages shown to only show those with higher than 90% translation in DLTT
@ -657,7 +636,7 @@ function display_requirements($installType, $badUpdatePath, $updatePath = '', $u
?> ?>
<p align="center"> <p align="center">
<button type="submit" name="step1" class="back" onclick="window.location='index.php';return false;" value="&lt; <?php echo get_lang('Previous'); ?>" ><?php echo get_lang('Previous'); ?></button> <button type="submit" name="step1" class="back" onclick="window.location='index.php';return false;" value="&lt; <?php echo get_lang('Previous'); ?>" ><?php echo get_lang('Previous'); ?></button>
<button type="submit" name="step2_install" class="add" value="<?php echo get_lang("NewInstallation"); ?>" <?php if($error) if($error)echo 'disabled="disabled"'; ?> ><?php echo get_lang('NewInstallation'); ?></button> <button type="submit" name="step2_install" class="add" value="<?php echo get_lang("NewInstallation"); ?>" <?php if ($error) echo 'disabled="disabled"'; ?> ><?php echo get_lang('NewInstallation'); ?></button>
<input type="hidden" name="is_executable" id="is_executable" value="-" /> <input type="hidden" name="is_executable" id="is_executable" value="-" />
<?php <?php
//real code //real code
@ -724,24 +703,19 @@ function display_license_agreement() {
function display_database_parameter($install_type, $parameter_name, $form_field_name, $parameter_value, $extra_notice, $display_when_update = true, $tr_attribute = '') { function display_database_parameter($install_type, $parameter_name, $form_field_name, $parameter_value, $extra_notice, $display_when_update = true, $tr_attribute = '') {
echo "<tr ".$tr_attribute.">\n"; echo "<tr ".$tr_attribute.">\n";
echo "<td>$parameter_name&nbsp;&nbsp;</td>\n"; echo "<td>$parameter_name&nbsp;&nbsp;</td>\n";
if ($install_type == INSTALL_TYPE_UPDATE && $display_when_update) { if ($install_type == INSTALL_TYPE_UPDATE && $display_when_update) {
echo '<td><input type="hidden" name="'.$form_field_name.'" id="'.$form_field_name.'" value="'.htmlentities($parameter_value).'" />'.$parameter_value."</td>\n";
} else {
if ($form_field_name == 'dbPassForm') {
$inputtype = 'password';
} else {
$inputtype = 'text';
}
//Slightly limit the length of the database prefix to avoid echo '<td><input type="hidden" name="'.$form_field_name.'" id="'.$form_field_name.'" value="'.api_htmlentities($parameter_value).'" />'.$parameter_value."</td>\n";
//having to cut down the databases names later on
if ($form_field_name == 'dbPrefixForm') {
$maxlength = '15';
} else { } else {
$maxlength = MAX_FORM_FIELD_LENGTH;
}
echo '<td><input type="'.$inputtype.'" size="'.DATABASE_FORM_FIELD_DISPLAY_LENGTH.'" maxlength="'.$maxlength.'" name="'.$form_field_name.'" id="'.$form_field_name.'" value="'.htmlentities($parameter_value).'" />'."</td>\n"; $inputtype = $form_field_name == 'dbPassForm' ? 'password' : 'text';
//Slightly limit the length of the database prefix to avoid having to cut down the databases names later on
$maxlength = $form_field_name == 'dbPrefixForm' ? '15' : MAX_FORM_FIELD_LENGTH;
echo '<td><input type="'.$inputtype.'" size="'.DATABASE_FORM_FIELD_DISPLAY_LENGTH.'" maxlength="'.$maxlength.'" name="'.$form_field_name.'" id="'.$form_field_name.'" value="'.api_htmlentities($parameter_value).'" />'."</td>\n";
echo "<td>$extra_notice</td>\n"; echo "<td>$extra_notice</td>\n";
} }
echo "</tr>\n"; echo "</tr>\n";
@ -753,8 +727,10 @@ function display_database_parameter($install_type, $parameter_name, $form_field_
* or multiple databases, tracking or not... * or multiple databases, tracking or not...
*/ */
function display_database_settings_form($installType, $dbHostForm, $dbUsernameForm, $dbPassForm, $dbPrefixForm, $enableTrackingForm, $singleDbForm, $dbNameForm, $dbStatsForm, $dbScormForm, $dbUserForm) { function display_database_settings_form($installType, $dbHostForm, $dbUsernameForm, $dbPassForm, $dbPrefixForm, $enableTrackingForm, $singleDbForm, $dbNameForm, $dbStatsForm, $dbScormForm, $dbUserForm) {
if ($installType == 'update') { if ($installType == 'update') {
global $_configuration, $update_from_version_6; global $_configuration, $update_from_version_6;
if (in_array($_POST['old_version'], $update_from_version_6)) { if (in_array($_POST['old_version'], $update_from_version_6)) {
$dbHostForm = get_config_param('dbHost'); $dbHostForm = get_config_param('dbHost');
$dbUsernameForm = get_config_param('dbLogin'); $dbUsernameForm = get_config_param('dbLogin');
@ -790,15 +766,13 @@ function display_database_settings_form($installType, $dbHostForm, $dbUsernameFo
} }
} }
if (empty($dbUserForm)) { if (empty($dbUserForm)) {
if ($singleDbForm) { $dbUserForm = $singleDbForm ? $dbNameForm : $dbPrefixForm.'chamilo_user';
$dbUserForm = $dbNameForm;
} else {
$dbUserForm = $dbPrefixForm.'chamilo_user';
}
} }
echo '<h2>' . display_step_sequence() .get_lang('DBSetting') . '</h2>'; echo '<h2>' . display_step_sequence() .get_lang('DBSetting') . '</h2>';
echo get_lang('DBSettingUpgradeIntro'); echo get_lang('DBSettingUpgradeIntro');
} else { } else {
if (empty($dbPrefixForm)) { //make sure there is a default value for db prefix if (empty($dbPrefixForm)) { //make sure there is a default value for db prefix
$dbPrefixForm = 'chamilo_'; $dbPrefixForm = 'chamilo_';
} }
@ -826,14 +800,18 @@ function display_database_settings_form($installType, $dbHostForm, $dbUsernameFo
</tr> </tr>
<?php <?php
//database user username //database user username
$example_login = get_lang('EG').' root'; $example_login = get_lang('EG').' root';
display_database_parameter($installType, get_lang('DBLogin'), 'dbUsernameForm', $dbUsernameForm, $example_login); display_database_parameter($installType, get_lang('DBLogin'), 'dbUsernameForm', $dbUsernameForm, $example_login);
//database user password //database user password
$example_password = get_lang('EG').' '.api_generate_password(); $example_password = get_lang('EG').' '.api_generate_password();
display_database_parameter($installType, get_lang('DBPassword'), 'dbPassForm', $dbPassForm, $example_password); display_database_parameter($installType, get_lang('DBPassword'), 'dbPassForm', $dbPassForm, $example_password);
//database prefix //database prefix
display_database_parameter($installType, get_lang('DbPrefixForm'), 'dbPrefixForm', $dbPrefixForm, get_lang('DbPrefixCom')); display_database_parameter($installType, get_lang('DbPrefixForm'), 'dbPrefixForm', $dbPrefixForm, get_lang('DbPrefixCom'));
//fields for the four standard Chamilo databases //fields for the four standard Chamilo databases
echo '<tr><td colspan="3"><a href="" onclick="javascript: show_hide_option();return false;" id="optionalparameters"><img style="vertical-align:middle;" src="../img/div_show.gif" alt="show-hide" /> '.get_lang('OptionalParameters', '').'</a></td></tr>'; echo '<tr><td colspan="3"><a href="" onclick="javascript: show_hide_option();return false;" id="optionalparameters"><img style="vertical-align:middle;" src="../img/div_show.gif" alt="show-hide" /> '.get_lang('OptionalParameters', '').'</a></td></tr>';
display_database_parameter($installType, get_lang('MainDB'), 'dbNameForm', $dbNameForm, '&nbsp;', null, 'id="optional_param1" style="display:none;"'); display_database_parameter($installType, get_lang('MainDB'), 'dbNameForm', $dbNameForm, '&nbsp;', null, 'id="optional_param1" style="display:none;"');
@ -842,6 +820,7 @@ function display_database_settings_form($installType, $dbHostForm, $dbUsernameFo
display_database_parameter($installType, get_lang('ScormDB'), 'dbScormForm', $dbScormForm, '&nbsp;', null, 'id="optional_param3" style="display:none;"'); display_database_parameter($installType, get_lang('ScormDB'), 'dbScormForm', $dbScormForm, '&nbsp;', null, 'id="optional_param3" style="display:none;"');
} }
display_database_parameter($installType, get_lang('UserDB'), 'dbUserForm', $dbUserForm, '&nbsp;', null, 'id="optional_param4" style="display:none;"'); display_database_parameter($installType, get_lang('UserDB'), 'dbUserForm', $dbUserForm, '&nbsp;', null, 'id="optional_param4" style="display:none;"');
?> ?>
<tr id="optional_param5" style="display:none;"> <tr id="optional_param5" style="display:none;">
<td><?php echo get_lang('EnableTracking'); ?> </td> <td><?php echo get_lang('EnableTracking'); ?> </td>
@ -947,14 +926,16 @@ function display_configuration_settings_form($installType, $urlForm, $languageFo
//First parameter: language //First parameter: language
echo "<tr>\n"; echo "<tr>\n";
echo '<td>'.get_lang('MainLang')."&nbsp;&nbsp;</td>\n"; echo '<td>'.get_lang('MainLang')."&nbsp;&nbsp;</td>\n";
if ($installType == 'update') { if ($installType == 'update') {
echo '<td><input type="hidden" name="languageForm" value="'.api_htmlentities($languageForm, ENT_QUOTES).'" />'.$languageForm."</td>\n"; echo '<td><input type="hidden" name="languageForm" value="'.api_htmlentities($languageForm, ENT_QUOTES).'" />'.$languageForm."</td>\n";
} else { // new installation } else { // new installation
echo '<td>'; echo '<td>';
$array_lang = array('asturian','english','italian','french','slovenian','spanish'); $array_lang = array('asturian', 'bulgarian', 'english', 'italian', 'french', 'slovenian', 'spanish');
////Only display Language have 90% + // TODO: Ivan: Is this policy actual? I am going to change it. ////Only display Language have 90% + // TODO: Ivan: Is this policy actual? I am going to change it.
echo "\t\t<select name=\"languageForm\">\n"; echo "\t\t<select name=\"languageForm\">\n";
@ -1151,15 +1132,11 @@ function test_db_connect($dbHostForm, $dbUsernameForm, $dbPassForm, $singleDbFor
} }
} elseif ($singleDbForm == 0) { } elseif ($singleDbForm == 0) {
$res = @mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm); $res = @mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm);
if ($res === false) {
return $res;
}
if ($res !== false) { if ($res !== false) {
// The system has not been designed to use special SQL modes that were introduced since MySQL 5 @mysql_query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
@mysql_query("set session sql_mode='';"); $multipleDbCheck = @mysql_query("CREATE DATABASE ".$dbPrefixForm."test_chamilo_connection");
$multipleDbCheck = @mysql_query("CREATE DATABASE ".$dbPrefixForm."test_dokeos_connection");
if ($multipleDbCheck !== false) { if ($multipleDbCheck !== false) {
$multipleDbCheck = @mysql_query("DROP DATABASE IF EXISTS ".$dbPrefixForm."test_dokeos_connection"); $multipleDbCheck = @mysql_query("DROP DATABASE IF EXISTS ".$dbPrefixForm."test_chamilo_connection");
if ($multipleDbCheck !== false) { if ($multipleDbCheck !== false) {
$dbConnect = 1; $dbConnect = 1;
} else { } else {

@ -33,8 +33,7 @@ require_once api_get_path(LIBRARY_PATH).'database.lib.php';
*/ */
/** /**
* We assume this function is called from install scripts that reside inside * We assume this function is called from install scripts that reside inside the install folder.
* the install folder.
*/ */
function set_file_folder_permissions() { function set_file_folder_permissions() {
@chmod('.', 0755); //set permissions on install dir @chmod('.', 0755); //set permissions on install dir
@ -72,6 +71,7 @@ function write_courses_htaccess_file($url_append) {
* @param string $path Path to the config file * @param string $path Path to the config file
*/ */
function write_dokeos_config_file($path) { function write_dokeos_config_file($path) {
global $dbHostForm; global $dbHostForm;
global $dbUsernameForm; global $dbUsernameForm;
global $dbPassForm; global $dbPassForm;
@ -92,11 +92,13 @@ function write_dokeos_config_file($path) {
global $session_lifetime; global $session_lifetime;
global $new_version; global $new_version;
global $new_version_stable; global $new_version_stable;
// TODO: api_get_path() to be tested here.
$seek = array('\\', '//'); $seek = array('\\', '//');
$destroy = array('/', '/'); $destroy = array('/', '/');
$rootSys = str_replace($seek, $destroy, realpath($pathForm).'/'); $rootSys = str_replace($seek, $destroy, realpath($pathForm).'/');
$file_path = dirname(__FILE__).'/'.DOKEOS_CONFIG_FILENAME; $file_path = dirname(__FILE__).'/'.DOKEOS_CONFIG_FILENAME;
$content = file_get_contents($file_path); $content = file_get_contents($file_path);
$config['{DATE_GENERATED}'] = date('r'); $config['{DATE_GENERATED}'] = date('r');
$config['{DATABASE_HOST}'] = $dbHostForm; $config['{DATABASE_HOST}'] = $dbHostForm;
@ -112,7 +114,7 @@ function write_dokeos_config_file($path) {
$config['{DATABASE_SCORM}'] = (($singleDbForm && empty($dbScormForm)) ? $dbNameForm : $dbScormForm); $config['{DATABASE_SCORM}'] = (($singleDbForm && empty($dbScormForm)) ? $dbNameForm : $dbScormForm);
$config['{DATABASE_PERSONAL}'] =(($singleDbForm && empty($dbUserForm)) ? $dbNameForm : $dbUserForm); $config['{DATABASE_PERSONAL}'] =(($singleDbForm && empty($dbUserForm)) ? $dbNameForm : $dbUserForm);
$config['{ROOT_WEB}'] = $urlForm; $config['{ROOT_WEB}'] = $urlForm;
$config['{ROOT_SYS}'] = str_replace('\\', '/', $rootSys); $config['{ROOT_SYS}'] = $rootSys;
$config['{URL_APPEND_PATH}'] = $urlAppendPath; $config['{URL_APPEND_PATH}'] = $urlAppendPath;
$config['{PLATFORM_LANGUAGE}'] = $languageForm; $config['{PLATFORM_LANGUAGE}'] = $languageForm;
$config['{SECURITY_KEY}'] = md5(uniqid(rand().time())); $config['{SECURITY_KEY}'] = md5(uniqid(rand().time()));
@ -121,6 +123,7 @@ function write_dokeos_config_file($path) {
$config['SESSION_LIFETIME'] = $session_lifetime; $config['SESSION_LIFETIME'] = $session_lifetime;
$config['{NEW_VERSION}'] = $new_version; $config['{NEW_VERSION}'] = $new_version;
$config['NEW_VERSION_STABLE'] = trueFalse($new_version_stable); $config['NEW_VERSION_STABLE'] = trueFalse($new_version_stable);
foreach ($config as $key => $value) { foreach ($config as $key => $value) {
$content = str_replace($key, $value, $content); $content = str_replace($key, $value, $content);
} }
@ -141,9 +144,9 @@ function write_dokeos_config_file($path) {
Please go back to step 5. Please go back to step 5.
<p><input type="submit" name="step5" value="&lt; Back" /></p> <p><input type="submit" name="step5" value="&lt; Back" /></p>
</td></tr></table></form></body></html>'; </td></tr></table></form></body></html>';
exit (); exit ();
} }
fwrite($fp, $content); fwrite($fp, $content);
fclose($fp); fclose($fp);
} }
@ -360,6 +363,7 @@ function get_sql_file_contents($file, $section, $print_errors = true) {
if ($print_errors) echo $error; if ($print_errors) echo $error;
return false; return false;
} }
//prepare the resulting array //prepare the resulting array
$section_contents = array(); $section_contents = array();
$record = false; $record = false;
@ -373,14 +377,14 @@ function get_sql_file_contents($file, $section, $print_errors = true) {
$record = true; $record = true;
} else { } else {
//we have another section's header. If we were recording, stop now and exit loop //we have another section's header. If we were recording, stop now and exit loop
if ($record == true) { if ($record) {
break; break;
} }
$record = false; $record = false;
} }
} }
} else { } else {
if ($record == true) { if ($record) {
if (!empty($line)) { if (!empty($line)) {
$section_contents[] = $line; $section_contents[] = $line;
} }
@ -391,6 +395,7 @@ function get_sql_file_contents($file, $section, $print_errors = true) {
return $section_contents; return $section_contents;
} }
// TODO: Maybe within the main API there is already a suitable function?
function my_directory_to_array($directory) { function my_directory_to_array($directory) {
$array_items = array(); $array_items = array();
if ($handle = opendir($directory)) { if ($handle = opendir($directory)) {

@ -37,11 +37,10 @@
*/ */
//load helper functions //load helper functions
require_once("install_upgrade.lib.php"); require_once 'install_upgrade.lib.php';
//remove memory and time limits as much as possible as this might be a long process... //remove memory and time limits as much as possible as this might be a long process...
if(function_exists('ini_set')) if (function_exists('ini_set')) {
{
ini_set('memory_limit', -1); ini_set('memory_limit', -1);
ini_set('max_execution_time', 0); ini_set('max_execution_time', 0);
} else { } else {
@ -55,11 +54,10 @@ if(function_exists('ini_set'))
*/ */
//check if we come from index.php or update_courses.php - otherwise display error msg //check if we come from index.php or update_courses.php - otherwise display error msg
if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) {
{
//check if the current Dokeos install is elligible for update //check if the current Dokeos install is elligible for update
if (empty ($updateFromConfigFile) || !file_exists($_POST['updatePath'].$updateFromConfigFile) || !in_array(get_config_param('clarolineVersion'), $update_from_version_6)) if (empty ($updateFromConfigFile) || !file_exists($_POST['updatePath'].$updateFromConfigFile) || !in_array(get_config_param('clarolineVersion'), $update_from_version_6)) {
{
echo '<strong>'.get_lang('Error').' !</strong> Dokeos '.implode('|', $updateFromVersion).' '.get_lang('HasNotBeenFound').'.<br /><br /> echo '<strong>'.get_lang('Error').' !</strong> Dokeos '.implode('|', $updateFromVersion).' '.get_lang('HasNotBeenFound').'.<br /><br />
'.get_lang('PleasGoBackToStep1').'. '.get_lang('PleasGoBackToStep1').'.
<p><button type="submit" class="back" name="step1" value="&lt; '.get_lang('Back').'">'.get_lang('Back').'</button></p> <p><button type="submit" class="back" name="step1" value="&lt; '.get_lang('Back').'">'.get_lang('Back').'</button></p>
@ -72,8 +70,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
//actually gets the param from //actually gets the param from
$_configuration['db_glue'] = get_config_param('dbGlu'); $_configuration['db_glue'] = get_config_param('dbGlu');
if ($singleDbForm) if ($singleDbForm) {
{
$_configuration['table_prefix'] = get_config_param('courseTablePrefix'); $_configuration['table_prefix'] = get_config_param('courseTablePrefix');
$_configuration['main_database'] = get_config_param('mainDbName'); $_configuration['main_database'] = get_config_param('mainDbName');
$_configuration['db_prefix'] = get_config_param('dbNamePrefix'); $_configuration['db_prefix'] = get_config_param('dbNamePrefix');
@ -81,20 +78,17 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
$dbScormForm = eregi_replace('[^a-z0-9_-]', '', $dbScormForm); $dbScormForm = eregi_replace('[^a-z0-9_-]', '', $dbScormForm);
if (!empty ($dbPrefixForm) && !ereg('^'.$dbPrefixForm, $dbScormForm)) if (!empty ($dbPrefixForm) && !ereg('^'.$dbPrefixForm, $dbScormForm)) {
{
$dbScormForm = $dbPrefixForm.$dbScormForm; $dbScormForm = $dbPrefixForm.$dbScormForm;
} }
if (empty ($dbScormForm) || $dbScormForm == 'mysql' || $dbScormForm == $dbPrefixForm) if (empty ($dbScormForm) || $dbScormForm == 'mysql' || $dbScormForm == $dbPrefixForm) {
{
$dbScormForm = $dbPrefixForm.'scorm'; $dbScormForm = $dbPrefixForm.'scorm';
} }
$res = @mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm); $res = @mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm);
//if error on connection to the database, show error and exit //if error on connection to the database, show error and exit
if ($res === false) if ($res === false) {
{
//$no = mysql_errno(); //$no = mysql_errno();
//$msg = mysql_error(); //$msg = mysql_error();
@ -111,8 +105,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
exit (); exit ();
} }
// The system has not been designed to use special SQL modes that were introduced since MySQL 5 @mysql_query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
@mysql_query("set session sql_mode='';");
$dblistres = mysql_list_dbs(); $dblistres = mysql_list_dbs();
$dblist = array(); $dblist = array();
@ -129,10 +122,10 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
// that we want to change the main databases as well... // that we want to change the main databases as well...
$only_test = false; $only_test = false;
$log = 0; $log = 0;
if (defined('DOKEOS_INSTALL'))
{ if (defined('DOKEOS_INSTALL')) {
if ($singleDbForm)
{ if ($singleDbForm) {
if (empty($dbStatsForm)) $dbStatsForm = $dbNameForm; if (empty($dbStatsForm)) $dbStatsForm = $dbNameForm;
if (empty($dbScormForm)) $dbScormForm = $dbNameForm; if (empty($dbScormForm)) $dbScormForm = $dbNameForm;
if (empty($dbUserForm)) $dbUserForm = $dbNameForm; if (empty($dbUserForm)) $dbUserForm = $dbNameForm;
@ -140,18 +133,16 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
/** /**
* Update the databases "pre" migration * Update the databases "pre" migration
*/ */
include ("../lang/english/create_course.inc.php"); include '../lang/english/create_course.inc.php';
if ($languageForm != 'english') if ($languageForm != 'english') {
{
//languageForm has been escaped in index.php //languageForm has been escaped in index.php
include ("../lang/$languageForm/create_course.inc.php"); include '../lang/'.$languageForm.'/create_course.inc.php';
} }
//get the main queries list (m_q_list) //get the main queries list (m_q_list)
$m_q_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql', 'main'); $m_q_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql', 'main');
if(count($m_q_list)>0) if (count($m_q_list) > 0) {
{
//now use the $m_q_list //now use the $m_q_list
/** /**
* We connect to the right DB first to make sure we can use the queries * We connect to the right DB first to make sure we can use the queries
@ -168,8 +159,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
error_log("mysql_query($dbNameForm,$query)", 0); error_log("mysql_query($dbNameForm,$query)", 0);
} else { } else {
$res = mysql_query($query); $res = mysql_query($query);
if($log) if ($log) {
{
error_log("In $dbNameForm, executed: $query", 0); error_log("In $dbNameForm, executed: $query", 0);
} }
} }
@ -179,8 +169,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
//get the stats queries list (s_q_list) //get the stats queries list (s_q_list)
$s_q_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql', 'stats'); $s_q_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql', 'stats');
if(count($s_q_list)>0) if (count($s_q_list) > 0) {
{
//now use the $s_q_list //now use the $s_q_list
/** /**
* We connect to the right DB first to make sure we can use the queries * We connect to the right DB first to make sure we can use the queries
@ -197,18 +186,17 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
error_log("mysql_query($dbStatsForm,$query)", 0); error_log("mysql_query($dbStatsForm,$query)", 0);
} else { } else {
$res = mysql_query($query); $res = mysql_query($query);
if($log) if ($log) {
{
error_log("In $dbStatsForm, executed: $query", 0); error_log("In $dbStatsForm, executed: $query", 0);
} }
} }
} }
} }
} }
//get the user queries list (u_q_list) //get the user queries list (u_q_list)
$u_q_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql', 'user'); $u_q_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql', 'user');
if(count($u_q_list)>0) if (count($u_q_list) > 0) {
{
//now use the $u_q_list //now use the $u_q_list
/** /**
* We connect to the right DB first to make sure we can use the queries * We connect to the right DB first to make sure we can use the queries
@ -247,14 +235,14 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
*/ */
$prefix = ''; $prefix = '';
if ($singleDbForm) if ($singleDbForm) {
{
$prefix = $_configuration['table_prefix']; $prefix = $_configuration['table_prefix'];
} }
//get the courses databases queries list (c_q_list) //get the courses databases queries list (c_q_list)
$c_q_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql', 'course'); $c_q_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql', 'course');
if(count($c_q_list)>0) if (count($c_q_list) > 0) {
{
//get the courses list //get the courses list
if (strlen($dbNameForm) > 40) { if (strlen($dbNameForm) > 40) {
error_log('Database name '.$dbNameForm.' is too long, skipping', 0); error_log('Database name '.$dbNameForm.' is too long, skipping', 0);
@ -264,42 +252,34 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
mysql_select_db($dbNameForm); mysql_select_db($dbNameForm);
$res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL"); $res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
if ($res === false) { die('Error while querying the courses list in update_db-1.6.x-1.8.0.inc.php'); } if ($res === false) { die('Error while querying the courses list in update_db-1.6.x-1.8.0.inc.php'); }
if(mysql_num_rows($res)>0) if (mysql_num_rows($res) > 0) {
{
$i = 0; $i = 0;
$list = array(); $list = array();
//while( ($i < MAX_COURSE_TRANSFER) && ($row = mysql_fetch_array($res))) //while( ($i < MAX_COURSE_TRANSFER) && ($row = mysql_fetch_array($res)))
while($row = mysql_fetch_array($res)) while($row = mysql_fetch_array($res)) {
{
$list[] = $row; $list[] = $row;
$i++; $i++;
} }
foreach($list as $row_course) foreach($list as $row_course) {
{
//now use the $c_q_list //now use the $c_q_list
/** /**
* We connect to the right DB first to make sure we can use the queries * We connect to the right DB first to make sure we can use the queries
* without a database name * without a database name
*/ */
if (!$singleDbForm) //otherwise just use the main one if (!$singleDbForm) { //otherwise just use the main one
{
mysql_select_db($row_course['db_name']); mysql_select_db($row_course['db_name']);
} }
foreach($c_q_list as $query) foreach($c_q_list as $query) {
{ if ($singleDbForm) { //otherwise just use the main one
if ($singleDbForm) //otherwise just use the main one
{
$query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/', "$1 $prefix{$row_course['db_name']}_$2$3", $query); $query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/', "$1 $prefix{$row_course['db_name']}_$2$3", $query);
} }
if($only_test) if ($only_test) {
{
error_log("mysql_query(".$row_course['db_name'].",$query)", 0); error_log("mysql_query(".$row_course['db_name'].",$query)", 0);
} else { } else {
$res = mysql_query($query); $res = mysql_query($query);
if($log) if ($log) {
{
error_log("In ".$row_course['db_name'].", executed: $query", 0); error_log("In ".$row_course['db_name'].", executed: $query", 0);
} }
} }
@ -313,8 +293,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
" WHERE cu.course_code = '".$row_course['code']."' " . " WHERE cu.course_code = '".$row_course['code']."' " .
" AND u.user_id = cu.user_id"; " AND u.user_id = cu.user_id";
$res_uc = mysql_query($sql_uc); $res_uc = mysql_query($sql_uc);
while($user_row = mysql_fetch_array($res_uc)) while($user_row = mysql_fetch_array($res_uc)) {
{
$users_list[$user_row['fn'].' '.$user_row['ln']] = $user_row['ui']; $users_list[$user_row['fn'].' '.$user_row['ln']] = $user_row['ui'];
} }
@ -326,8 +305,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
//update forum tables (migrate from bb_ tables to forum_ tables) //update forum tables (migrate from bb_ tables to forum_ tables)
//migrate categories //migrate categories
$prefix_course = $prefix; $prefix_course = $prefix;
if($singleDbForm) if ($singleDbForm) {
{
$prefix_course = $prefix.$row_course['db_name']."_"; $prefix_course = $prefix.$row_course['db_name']."_";
} }
@ -349,6 +327,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
$res = mysql_query($sql); $res = mysql_query($sql);
//error_log($sql,0); //error_log($sql,0);
} }
$sql_orig = "SELECT * FROM ".$prefix_course."bb_forums ORDER BY forum_last_post_id desc"; $sql_orig = "SELECT * FROM ".$prefix_course."bb_forums ORDER BY forum_last_post_id desc";
$res_orig = mysql_query($sql_orig); $res_orig = mysql_query($sql_orig);
$order = 1; $order = 1;
@ -375,19 +354,16 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
$res = mysql_query($sql); $res = mysql_query($sql);
//error_log($sql,0); //error_log($sql,0);
} }
$sql_orig = "SELECT * FROM ".$prefix_course."bb_topics"; $sql_orig = "SELECT * FROM ".$prefix_course."bb_topics";
$res_orig = mysql_query($sql_orig); $res_orig = mysql_query($sql_orig);
while ($row = mysql_fetch_array($res_orig)) { while ($row = mysql_fetch_array($res_orig)) {
$name = $row['prenom'].' '.$row['nom']; $name = $row['prenom'].' '.$row['nom'];
//check if user id is reusable //check if user id is reusable
if($row['topic_poster'] <= 1 ) if ($row['topic_poster'] <= 1) {
{ if (isset($users_list[$name])) {
if(isset($users_list[$name]))
{
$poster_id = $users_list[$name]; $poster_id = $users_list[$name];
} } else {
else
{
$poster_id = $row['topic_poster']; $poster_id = $row['topic_poster'];
} }
} }
@ -413,19 +389,16 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
$res = mysql_query($sql); $res = mysql_query($sql);
//error_log($sql,0); //error_log($sql,0);
} }
$sql_orig = "SELECT * FROM ".$prefix_course."bb_posts bp, ".$prefix_course."bb_posts_text bpt WHERE bp.post_id = bpt.post_id"; $sql_orig = "SELECT * FROM ".$prefix_course."bb_posts bp, ".$prefix_course."bb_posts_text bpt WHERE bp.post_id = bpt.post_id";
$res_orig = mysql_query($sql_orig); $res_orig = mysql_query($sql_orig);
while ($row = mysql_fetch_array($res_orig)) { while ($row = mysql_fetch_array($res_orig)) {
$name = $row['prenom'].' '.$row['nom']; $name = $row['prenom'].' '.$row['nom'];
//check if user id is reusable //check if user id is reusable
if($row['poster_id'] <= 0 ) if ($row['poster_id'] <= 0 ) {
{ if (isset($users_list[$name])) {
if(isset($users_list[$name]))
{
$poster_id = $users_list[$name]; $poster_id = $users_list[$name];
} } else {
else
{
$poster_id = $row['poster_id']; $poster_id = $row['poster_id'];
} }
} }
@ -466,15 +439,14 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
} }
} }
} }
//load the old-scorm to new-scorm migration script //load the old-scorm to new-scorm migration script
//TODO: deal with the fact that this should only act on MAX_COURSE_TRANSFER courses //TODO: deal with the fact that this should only act on MAX_COURSE_TRANSFER courses
if (!$only_test){ if (!$only_test){
include('update-db-scorm-1.6.x-1.8.0.inc.php'); include('update-db-scorm-1.6.x-1.8.0.inc.php');
} }
if (defined('DOKEOS_INSTALL')) if (defined('DOKEOS_INSTALL')) {
{ if ($singleDbForm) {
if ($singleDbForm)
{
if(empty($dbStatsForm)) $dbStatsForm = $dbNameForm; if(empty($dbStatsForm)) $dbStatsForm = $dbNameForm;
if(empty($dbScormForm)) $dbScormForm = $dbNameForm; if(empty($dbScormForm)) $dbScormForm = $dbNameForm;
if(empty($dbUserForm)) $dbUserForm = $dbNameForm; if(empty($dbUserForm)) $dbUserForm = $dbNameForm;
@ -482,8 +454,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
//deal with migrate-db-1.6.x-1.8.0-post.sql //deal with migrate-db-1.6.x-1.8.0-post.sql
//get the main queries list (m_q_list) //get the main queries list (m_q_list)
$m_q_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-post.sql', 'main'); $m_q_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-post.sql', 'main');
if(count($m_q_list)>0) if (count($m_q_list) > 0) {
{
//now use the $m_q_list //now use the $m_q_list
/** /**
* We connect to the right DB first to make sure we can use the queries * We connect to the right DB first to make sure we can use the queries
@ -500,8 +471,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
error_log("mysql_query($dbNameForm,$query)", 0); error_log("mysql_query($dbNameForm,$query)", 0);
} else { } else {
$res = mysql_query($query); $res = mysql_query($query);
if($log) if ($log) {
{
error_log("In $dbNameForm, executed: $query", 0); error_log("In $dbNameForm, executed: $query", 0);
} }
} }
@ -511,8 +481,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
//get the stats queries list (s_q_list) //get the stats queries list (s_q_list)
$s_q_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-post.sql', 'stats'); $s_q_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-post.sql', 'stats');
if(count($s_q_list)>0) if (count($s_q_list) > 0) {
{
//now use the $s_q_list //now use the $s_q_list
/** /**
* We connect to the right DB first to make sure we can use the queries * We connect to the right DB first to make sure we can use the queries
@ -529,18 +498,17 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
error_log("mysql_query($dbStatsForm,$query)", 0); error_log("mysql_query($dbStatsForm,$query)", 0);
} else { } else {
$res = mysql_query($query); $res = mysql_query($query);
if($log) if ($log) {
{
error_log("In $dbStatsForm, executed: $query", 0); error_log("In $dbStatsForm, executed: $query", 0);
} }
} }
} }
} }
} }
//get the user queries list (u_q_list) //get the user queries list (u_q_list)
$u_q_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-post.sql', 'user'); $u_q_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-post.sql', 'user');
if(count($u_q_list)>0) if (count($u_q_list) > 0) {
{
//now use the $u_q_list //now use the $u_q_list
/** /**
* We connect to the right DB first to make sure we can use the queries * We connect to the right DB first to make sure we can use the queries
@ -557,8 +525,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
error_log("mysql_query($dbUserForm,$query)", 0); error_log("mysql_query($dbUserForm,$query)", 0);
} else { } else {
$res = mysql_query($query); $res = mysql_query($query);
if($log) if ($log) {
{
error_log("In $dbUserForm, executed: $query", 0); error_log("In $dbUserForm, executed: $query", 0);
} }
} }
@ -567,10 +534,10 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
} }
//the SCORM database should need a drop in the post-migrate part. However, we will keep these tables a bit more, just in case... //the SCORM database should need a drop in the post-migrate part. However, we will keep these tables a bit more, just in case...
} }
//get the courses databases queries list (c_q_list) //get the courses databases queries list (c_q_list)
$c_q_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-post.sql', 'course'); $c_q_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-post.sql', 'course');
if(count($c_q_list)>0) if (count($c_q_list) > 0) {
{
//get the courses list //get the courses list
if (strlen($dbNameForm) > 40) { if (strlen($dbNameForm) > 40) {
error_log('Database name '.$dbNameForm.' is too long, skipping', 0); error_log('Database name '.$dbNameForm.' is too long, skipping', 0);
@ -580,43 +547,35 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
mysql_select_db($dbNameForm); mysql_select_db($dbNameForm);
$res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL"); $res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
if ($res === false) { die('Error while querying the courses list in update_db-1.6.x-1.8.0.inc.php'); } if ($res === false) { die('Error while querying the courses list in update_db-1.6.x-1.8.0.inc.php'); }
if(mysql_num_rows($res)>0) if (mysql_num_rows($res) > 0) {
{
$i = 0; $i = 0;
//while( ($i < MAX_COURSE_TRANSFER) && ($row = mysql_fetch_array($res))) //while( ($i < MAX_COURSE_TRANSFER) && ($row = mysql_fetch_array($res)))
while($row = mysql_fetch_array($res)) while ($row = mysql_fetch_array($res)) {
{
$list[] = $row; $list[] = $row;
$i++; $i++;
} }
foreach($list as $row) foreach ($list as $row) {
{
//now use the $c_q_list //now use the $c_q_list
/** /**
* We connect to the right DB first to make sure we can use the queries * We connect to the right DB first to make sure we can use the queries
* without a database name * without a database name
*/ */
$prefix_course = $prefix; $prefix_course = $prefix;
if($singleDbForm) if ($singleDbForm) {
{
$prefix_course = $prefix.$row['db_name']."_"; $prefix_course = $prefix.$row['db_name']."_";
} else { } else {
mysql_select_db($row['db_name']); mysql_select_db($row['db_name']);
} }
foreach($c_q_list as $query) foreach($c_q_list as $query) {
{ if ($singleDbForm) { //otherwise just use the main one
if ($singleDbForm) //otherwise just use the main one
{
$query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/',"$1 $prefix$2$3",$query); $query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/',"$1 $prefix$2$3",$query);
} }
if($only_test) if ($only_test) {
{
error_log("mysql_query(".$row['db_name'].",$query)", 0); error_log("mysql_query(".$row['db_name'].",$query)", 0);
} else { } else {
$res = mysql_query($query); $res = mysql_query($query);
if($log) if ($log) {
{
error_log("In ".$row['db_name'].", executed: $query", 0); error_log("In ".$row['db_name'].", executed: $query", 0);
} }
} }
@ -629,17 +588,13 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
// upgrade user categories sort // upgrade user categories sort
$table_user_categories = $dbUserForm.'.user_course_category'; $table_user_categories = $dbUserForm.'.user_course_category';
$sql = 'SELECT * FROM '.$table_user_categories.' ORDER BY user_id, title'; $sql = 'SELECT * FROM '.$table_user_categories.' ORDER BY user_id, title';
$rs = Database::query($sql); $rs = Database::query($sql);
$sort = 0; $sort = 0;
$old_user = 0; $old_user = 0;
while($cat = Database :: fetch_array($rs)) while ($cat = Database::fetch_array($rs)) {
{ if ($old_user != $cat['user_id']) {
if($old_user != $cat['user_id'])
{
$old_user = $cat['user_id']; $old_user = $cat['user_id'];
$sort = 0; $sort = 0;
} }
@ -650,10 +605,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
Database::query($sql); Database::query($sql);
} }
} else {
}
else
{
echo 'You are not allowed here !'; echo 'You are not allowed here !';
} }
?>

@ -111,8 +111,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
exit (); exit ();
} }
// The system has not been designed to use special SQL modes that were introduced since MySQL 5 @mysql_query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
@mysql_query("set session sql_mode='';");
$dblistres = mysql_list_dbs(); $dblistres = mysql_list_dbs();
$dblist = array(); $dblist = array();

@ -111,8 +111,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
exit (); exit ();
} }
// The system has not been designed to use special SQL modes that were introduced since MySQL 5 @mysql_query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
@mysql_query("set session sql_mode='';");
$dblistres = mysql_list_dbs(); $dblistres = mysql_list_dbs();
$dblist = array(); $dblist = array();

@ -111,8 +111,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
exit (); exit ();
} }
// The system has not been designed to use special SQL modes that were introduced since MySQL 5 @mysql_query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
@mysql_query("set session sql_mode='';");
$dblistres = mysql_list_dbs(); $dblistres = mysql_list_dbs();
$dblist = array(); $dblist = array();

@ -93,8 +93,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
exit (); exit ();
} }
// The system has not been designed to use special SQL modes that were introduced since MySQL 5 @mysql_query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
@mysql_query("set session sql_mode='';");
$dblistres = mysql_list_dbs(); $dblistres = mysql_list_dbs();
$dblist = array(); $dblist = array();

@ -93,8 +93,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
exit (); exit ();
} }
// The system has not been designed to use special SQL modes that were introduced since MySQL 5 @mysql_query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
@mysql_query("set session sql_mode='';");
$dblistres = mysql_list_dbs(); $dblistres = mysql_list_dbs();
$dblist = array(); $dblist = array();

@ -93,8 +93,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
exit (); exit ();
} }
// The system has not been designed to use special SQL modes that were introduced since MySQL 5 @mysql_query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
@mysql_query("set session sql_mode='';");
$dblistres = mysql_list_dbs(); $dblistres = mysql_list_dbs();
$dblist = array(); $dblist = array();

@ -93,8 +93,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
exit (); exit ();
} }
// The system has not been designed to use special SQL modes that were introduced since MySQL 5 @mysql_query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
@mysql_query("set session sql_mode='';");
$dblistres = mysql_list_dbs(); $dblistres = mysql_list_dbs();
$dblist = array(); $dblist = array();

@ -93,8 +93,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
exit (); exit ();
} }
// The system has not been designed to use special SQL modes that were introduced since MySQL 5 @mysql_query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
@mysql_query("set session sql_mode='';");
$dblistres = mysql_list_dbs(); $dblistres = mysql_list_dbs();
$dblist = array(); $dblist = array();

@ -8,15 +8,15 @@
/** /**
* Include mandatory libraries * Include mandatory libraries
*/ */
require_once('../inc/lib/main_api.lib.php'); require_once '../inc/lib/main_api.lib.php';
require_once('../inc/lib/database.lib.php'); require_once '../inc/lib/database.lib.php';
require_once('../inc/lib/document.lib.php'); require_once '../inc/lib/document.lib.php';
//require_once('../inc/lib/fileDisplay.lib.php'); //require_once '../inc/lib/fileDisplay.lib.php';
//require_once('../inc/lib/fileUpload.lib.php'); //replace_dangerous_char() //require_once '../inc/lib/fileUpload.lib.php'; //replace_dangerous_char()
require_once('../inc/lib/fileManage.lib.php'); //check_name_exists() require_once '../inc/lib/fileManage.lib.php'; //check_name_exists()
//include_once('../inc/lib/pclzip/pclzip.lib.php'); //include_once '../inc/lib/pclzip/pclzip.lib.php';
require_once('../newscorm/learnpath.class.php'); require_once '../newscorm/learnpath.class.php';
require_once('../newscorm/scorm.class.php'); require_once '../newscorm/scorm.class.php';
ini_set('max_execution_time', 0); ini_set('max_execution_time', 0);
@ -63,18 +63,17 @@ $courses_list = array();
$courses_id_list = array(); $courses_id_list = array();
$courses_id_full_table_prefix_list = array(); $courses_id_full_table_prefix_list = array();
$courses_dir_list = array(); $courses_dir_list = array();
mysql_select_db($dbNameForm); mysql_select_db($dbNameForm);
$sql = "SELECT * FROM course"; $sql = "SELECT * FROM course";
$res = Database::query($sql); $res = Database::query($sql);
while ($row = Database::fetch_array($res))
{ while ($row = Database::fetch_array($res)) {
$course_pref = $table_prefix; $course_pref = $table_prefix;
if($singleDbForm) if ($singleDbForm) {
{
$dbname = $_configuration['main_database'].'.'.$course_pref.$row['db_name'].'_'; $dbname = $_configuration['main_database'].'.'.$course_pref.$row['db_name'].'_';
} } else {
else
{
$dbname = $row['db_name'].'.'.$course_pref; $dbname = $row['db_name'].'.'.$course_pref;
} }
$courses_list[] = $row['db_name']; $courses_list[] = $row['db_name'];
@ -82,6 +81,7 @@ while ($row = Database::fetch_array($res))
$courses_id_full_table_prefix_list[$row['code']] = $dbname; $courses_id_full_table_prefix_list[$row['code']] = $dbname;
$courses_dir_list[$row['code']] = $row['directory']; $courses_dir_list[$row['code']] = $row['directory'];
} }
if ($loglevel > 0) { error_log("Tables created/deleted for all courses", 0); } if ($loglevel > 0) { error_log("Tables created/deleted for all courses", 0); }
/** /**
@ -90,13 +90,12 @@ if($loglevel>0){error_log("Tables created/deleted for all courses",0);}
*/ */
//MIGRATING LEARNPATHS //MIGRATING LEARNPATHS
//test only one course //test only one course
foreach($courses_id_full_table_prefix_list as $course_code => $db) foreach ($courses_id_full_table_prefix_list as $course_code => $db) {
{ if (strlen($courses_id_list[$course_code]) > 40) {
if(strlen($courses_id_list[$course_code])>40)
{
error_log('Database '.$courses_id_list[$course_code].' is too long, skipping', 0); error_log('Database '.$courses_id_list[$course_code].' is too long, skipping', 0);
continue; continue;
} }
$incoherences = 0; $incoherences = 0;
if ($loglevel > 0) { error_log("Now starting migration of learnpath tables from $db database...", 0); } if ($loglevel > 0) { error_log("Now starting migration of learnpath tables from $db database...", 0); }
$lp_doc = $db.TABLE_DOCUMENT; $lp_doc = $db.TABLE_DOCUMENT;
@ -122,7 +121,7 @@ foreach($courses_id_full_table_prefix_list as $course_code => $db)
$res_test = mysql_query($sql_test); $res_test = mysql_query($sql_test);
$sql_lp = "SELECT * FROM $lp_main"; $sql_lp = "SELECT * FROM $lp_main";
if ($loglevel > 1) { error_log("$sql_lp", 0); } if ($loglevel > 1) { error_log("$sql_lp", 0); }
$res_lp = mysql_query($sql_lp);//using mysql_query to avoid dying on failure $res_lp = mysql_query($sql_lp);
if (!$res_lp or !$res_test) { if (!$res_lp or !$res_test) {
if ($loglevel > 1) { if ($loglevel > 1) {
error_log("+++Problem querying DB $lp_main+++ skipping (".mysql_error().")", 0); error_log("+++Problem querying DB $lp_main+++ skipping (".mysql_error().")", 0);
@ -133,8 +132,7 @@ foreach($courses_id_full_table_prefix_list as $course_code => $db)
continue; continue;
} }
$dsp_ord = 1; $dsp_ord = 1;
while($row = Database::fetch_array($res_lp)) while ($row = Database::fetch_array($res_lp)) {
{
//echo "Treating lp id : ".$row['learnpath_id']."<br />\n"; //echo "Treating lp id : ".$row['learnpath_id']."<br />\n";
$ins_lp_sql = "INSERT INTO $my_new_lp (lp_type,name,description,display_order,content_maker) " . $ins_lp_sql = "INSERT INTO $my_new_lp (lp_type,name,description,display_order,content_maker) " .
"VALUES (1," . "VALUES (1," .
@ -195,14 +193,13 @@ foreach($courses_id_full_table_prefix_list as $course_code => $db)
$lp_chaps_list[$row['learnpath_id']][] = $in_id; $lp_chaps_list[$row['learnpath_id']][] = $in_id;
} }
//echo "<pre>parent_lps:".print_r($parent_lps,true)."</pre>\n"; //echo "<pre>parent_lps:".print_r($parent_lps,true)."</pre>\n";
//Now one loop to update the parent_chapter_ids //Now one loop to update the parent_chapter_ids
foreach ($parent_chaps as $old_chap => $old_parent_chap) { foreach ($parent_chaps as $old_chap => $old_parent_chap) {
if ($old_parent_chap != 0) { if ($old_parent_chap != 0) {
$new_chap = $lp_chap_items[$old_chap]; $new_chap = $lp_chap_items[$old_chap];
$new_parent = $lp_chap_items[$old_parent_chap]; $new_parent = $lp_chap_items[$old_parent_chap];
if(isset($new_chap) && $new_chap != '' if (isset($new_chap) && $new_chap != '' && isset($new_parent) && $new_parent != '') {
&& isset($new_parent) && $new_parent != '')
{
$sql_par_chap = "UPDATE $my_new_lp_item " . $sql_par_chap = "UPDATE $my_new_lp_item " .
"SET parent_item_id = $new_parent " . "SET parent_item_id = $new_parent " .
"WHERE id = $new_chap"; "WHERE id = $new_chap";
@ -211,6 +208,7 @@ foreach($courses_id_full_table_prefix_list as $course_code => $db)
} }
} }
unset($parent_chaps); unset($parent_chaps);
//Now one loop to set the next_item_id and the previous_item_id //Now one loop to set the next_item_id and the previous_item_id
foreach ($ordered_chaps as $parent_chap) { foreach ($ordered_chaps as $parent_chap) {
$last = 0; $last = 0;
@ -261,14 +259,14 @@ foreach($courses_id_full_table_prefix_list as $course_code => $db)
//'chapter' => 'dokeos_chapter', Chapters should all be in learnpath_chapter, no matter the nesting level //'chapter' => 'dokeos_chapter', Chapters should all be in learnpath_chapter, no matter the nesting level
); );
//MIGRATING LEARNPATH ITEMS //MIGRATING LEARNPATH ITEMS
$sql_lp_item = "ALTER TABLE $lp_item ADD INDEX ( chapter_id, display_order)"; $sql_lp_item = "ALTER TABLE $lp_item ADD INDEX ( chapter_id, display_order)";
$res_lp_item = Database::query($sql_lp_item); $res_lp_item = Database::query($sql_lp_item);
$sql_lp_item = "SELECT * FROM $lp_item ORDER BY chapter_id, display_order"; $sql_lp_item = "SELECT * FROM $lp_item ORDER BY chapter_id, display_order";
//echo "$sql_lp_item<br />\n"; //echo "$sql_lp_item<br />\n";
$res_lp_item = Database::query($sql_lp_item); $res_lp_item = Database::query($sql_lp_item);
while($row = Database::fetch_array($res_lp_item)) while ($row = Database::fetch_array($res_lp_item)) {
{
//echo "Treating chapter ".$row['chapter_id'].", item ".$row['id']."<br />\n"; //echo "Treating chapter ".$row['chapter_id'].", item ".$row['id']."<br />\n";
$type = $type_trans[$row['item_type']]; $type = $type_trans[$row['item_type']];
$ref = $row['item_id']; $ref = $row['item_id'];
@ -295,30 +293,23 @@ foreach($courses_id_full_table_prefix_list as $course_code => $db)
} }
} }
$my_parent_id = 0; $my_parent_id = 0;
if(isset($lp_chap_items[$row['chapter_id']])) if (isset($lp_chap_items[$row['chapter_id']])) {
{
$my_parent_id = $lp_chap_items[$row['chapter_id']]; $my_parent_id = $lp_chap_items[$row['chapter_id']];
} }
$title = ''; $title = '';
if(empty($row['title']) && $type == 'Document' && !empty($row['item_id'])) if (empty($row['title']) && $type == 'Document' && !empty($row['item_id'])) {
{
$my_sql_doctitle = "SELECT title FROM $lp_doc WHERE id = ".$row['item_id']; $my_sql_doctitle = "SELECT title FROM $lp_doc WHERE id = ".$row['item_id'];
$my_res_doctitle = Database::query($my_sql_doctitle); $my_res_doctitle = Database::query($my_sql_doctitle);
if($row_doctitle = Database::fetch_array($my_res_doctitle)) if ($row_doctitle = Database::fetch_array($my_res_doctitle)) {
{
$title = $row_doctitle['title']; $title = $row_doctitle['title'];
} } else {
else
{
$title = '-'; $title = '-';
} }
} } else {
else
{
$title = $row['title']; $title = $row['title'];
} }
if(isset($lp_ids[$parent_lps[$row['chapter_id']]])) if (isset($lp_ids[$parent_lps[$row['chapter_id']]])) {
{ //if there is a parent learnpath //if there is a parent learnpath
$ins_lp_sql = "INSERT INTO $my_new_lp_item (" . $ins_lp_sql = "INSERT INTO $my_new_lp_item (" .
"lp_id," . "lp_id," .
"item_type," . "item_type," .
@ -358,11 +349,9 @@ foreach($courses_id_full_table_prefix_list as $course_code => $db)
$order_item = array(); //this will contain a sequential list of item_id's, thus allowing to give a simple way to get next id... $order_item = array(); //this will contain a sequential list of item_id's, thus allowing to give a simple way to get next id...
$lp_id = 0; $lp_id = 0;
//echo "<pre>"; //echo "<pre>";
while($row = Database::fetch_array($order_res)) while ($row = Database::fetch_array($order_res)) {
{
//print_r($row); //print_r($row);
if($row['lp_id'] != $lp_id) if ($row['lp_id'] != $lp_id) {
{
//apply changes to the database and clean tool arrays //apply changes to the database and clean tool arrays
$last = 0; $last = 0;
foreach($order_item as $order_id => $item_id) { foreach($order_item as $order_id => $item_id) {
@ -414,10 +403,8 @@ foreach($courses_id_full_table_prefix_list as $course_code => $db)
$user_id = 0; $user_id = 0;
$learnpath_id = 0; $learnpath_id = 0;
$lp_view = 0; $lp_view = 0;
while($row = Database::fetch_array($res_lp_user)) while ($row = Database::fetch_array($res_lp_user)) {
{ if ($row['user_id']!=$user_id OR $row['learnpath_id']!=$learnpath_id) { //the user has changed or this is the first
if($row['user_id']!=$user_id OR $row['learnpath_id']!=$learnpath_id) //the user has changed or this is the first
{
//insert a new lp_view //insert a new lp_view
$last = 0; $last = 0;
if (!empty($lp_chaps_list[$row['learnpath_id']][0])) { if (!empty($lp_chaps_list[$row['learnpath_id']][0])) {
@ -544,11 +531,9 @@ foreach($courses_id_full_table_prefix_list as $course_code => $db)
$link = $row_tool['link']; $link = $row_tool['link'];
$matches = array(); $matches = array();
$pattern = '@scorm/showinframes\.php([^\s"\'&]*)(&|&amp;)file=([^\s"\'&]*)@'; $pattern = '@scorm/showinframes\.php([^\s"\'&]*)(&|&amp;)file=([^\s"\'&]*)@';
if(preg_match($pattern,$link,$matches)) if (preg_match($pattern, $link, $matches)) {
{
//echo "Found match for scorm link in $tbl_tool: $link<br />"; //echo "Found match for scorm link in $tbl_tool: $link<br />";
if(!empty($matches[3]) && (strtolower(substr($matches[3],-15))=='imsmanifest.xml') && !is_file(realpath(urldecode($matches[3]))) ) if (!empty($matches[3]) && (strtolower(substr($matches[3], -15)) == 'imsmanifest.xml') && !is_file(realpath(urldecode($matches[3])))) {
{
//echo "Removing link $link from tools<br />"; //echo "Removing link $link from tools<br />";
$sql_tool_upd = "DELETE FROM $tbl_tool WHERE id = ".$row_tool['id']; $sql_tool_upd = "DELETE FROM $tbl_tool WHERE id = ".$row_tool['id'];
error_log('New LP - Migration - Updating tool table (dead link): '.$sql_tool_upd, 0); error_log('New LP - Migration - Updating tool table (dead link): '.$sql_tool_upd, 0);
@ -596,12 +581,11 @@ foreach($courses_id_full_table_prefix_list as $course_code => $db)
} }
} }
if ($loglevel > 0) { error_log("Done!".$msg, 0); } if ($loglevel > 0) { error_log("Done!".$msg, 0); }
//flush(); //flush();
//ob_flush(); //ob_flush();
} }
unset($lp_ids); unset($lp_ids);
unset($lp_users); unset($lp_users);
unset($parent_chaps); unset($parent_chaps);
@ -654,11 +638,11 @@ while($course_row = Database::fetch_array($res_crs)){
//reinit the scormdocuments list //reinit the scormdocuments list
//$scormdocuments_lps = array(); //$scormdocuments_lps = array();
$db_name = $courses_id_full_table_prefix_list[$my_course_code]; $db_name = $courses_id_full_table_prefix_list[$my_course_code];
if(strlen($courses_id_list[$course_code])>40) if (strlen($courses_id_list[$course_code]) > 40) {
{
error_log('Database '.$courses_id_list[$course_code].' is too long, skipping', 0); error_log('Database '.$courses_id_list[$course_code].' is too long, skipping', 0);
continue; continue;
} }
//echo "Now processing database $db_name<br />"; //echo "Now processing database $db_name<br />";
$tblscodoc = $db_name.TABLE_SCORMDOC; $tblscodoc = $db_name.TABLE_SCORMDOC;
$sql_scodoc = "SELECT path FROM $tblscodoc WHERE path IS NOT NULL AND path != ''"; $sql_scodoc = "SELECT path FROM $tblscodoc WHERE path IS NOT NULL AND path != ''";
@ -728,22 +712,16 @@ while($course_row = Database::fetch_array($res_crs)){
//echo $intro."<br />\n"; //echo $intro."<br />\n";
$matches = array(); $matches = array();
$pattern = '@scorm/showinframes\.php([^\s"\']*)file=([^\s"\'&]*)@'; $pattern = '@scorm/showinframes\.php([^\s"\']*)file=([^\s"\'&]*)@';
if(preg_match_all($pattern,$intro,$matches,PREG_SET_ORDER)) if (preg_match_all($pattern, $intro, $matches, PREG_SET_ORDER)) {
{ if (count($matches) < 1) {
if(count($matches)<1)
{
//skip //skip
} } else {
else
{
//echo "Found matches in $tbl_intro<br />"; //echo "Found matches in $tbl_intro<br />";
foreach($matches as $match) foreach ($matches as $match) {
{
//echo "Found match ".print_r($match,true)."<br />"; //echo "Found match ".print_r($match,true)."<br />";
$mymatch = urldecode($match[2]); $mymatch = urldecode($match[2]);
$mymatch = str_replace($sys_course_path, $upd_course_path, $mymatch); $mymatch = str_replace($sys_course_path, $upd_course_path, $mymatch);
if(!empty($mymatch) && (strtolower(substr($mymatch,-15))=='imsmanifest.xml') && is_file(realpath(urldecode($mymatch))) ) if (!empty($mymatch) && (strtolower(substr($mymatch, -15)) == 'imsmanifest.xml') && is_file(realpath(urldecode($mymatch)))) {
{
//echo $mymatch." seems ok<br />"; //echo $mymatch." seems ok<br />";
//found a new scorm course in the old directory //found a new scorm course in the old directory
@ -751,8 +729,7 @@ while($course_row = Database::fetch_array($res_crs)){
//check if the file is in the current course path, otherwise just forget about it //check if the file is in the current course path, otherwise just forget about it
//as it would be too difficult to migrate //as it would be too difficult to migrate
//echo "Comparing $mymatch with $courses_dir<br />"; //echo "Comparing $mymatch with $courses_dir<br />";
if(strpos($mymatch,$courses_dir)!==false) if (strpos($mymatch, $courses_dir) !== false) {
{
//remove the course dir up to /scorm from this path //remove the course dir up to /scorm from this path
$entry = substr($mymatch, strlen($courses_dir)); $entry = substr($mymatch, strlen($courses_dir));
//remove the /imsmanifest.xml from the end of the path //remove the /imsmanifest.xml from the end of the path
@ -768,9 +745,7 @@ while($course_row = Database::fetch_array($res_crs)){
//echo "Recording $entry<br />"; //echo "Recording $entry<br />";
$scormdocuments_lps[] = $entry; $scormdocuments_lps[] = $entry;
} }
} } else {
else
{
//echo "Manifest does not exist in ".$courses_dir.$entry."/imsmanifest.xml<br />"; //echo "Manifest does not exist in ".$courses_dir.$entry."/imsmanifest.xml<br />";
} }
} }
@ -836,8 +811,7 @@ if($loglevel>0){error_log("---- Scorms array now contains ".$mycount." paths to
* Order by course to try and reuse the maximum data * Order by course to try and reuse the maximum data
*/ */
$i_count = 0; $i_count = 0;
foreach($scorms as $my_course_code => $paths_list ) foreach ($scorms as $my_course_code => $paths_list) {
{
$max_dsp_lp = 0; $max_dsp_lp = 0;
$course_lp_done = array(); $course_lp_done = array();
$db_name = $courses_id_full_table_prefix_list[$my_course_code]; $db_name = $courses_id_full_table_prefix_list[$my_course_code];
@ -906,8 +880,7 @@ foreach($scorms as $my_course_code => $paths_list )
$sql_items = "SELECT * FROM $scorm_item WHERE contentId = '".$my_content_id."' ORDER BY scoId"; $sql_items = "SELECT * FROM $scorm_item WHERE contentId = '".$my_content_id."' ORDER BY scoId";
//echo "$sql_items<br />\n"; //echo "$sql_items<br />\n";
$res_items = Database::query($sql_items); $res_items = Database::query($sql_items);
while($scormItem = Database::fetch_array($res_items)) while ($scormItem = Database::fetch_array($res_items)) {
{
$my_sco_id = $scormItem['scoId']; //the index for display??? (check that) $my_sco_id = $scormItem['scoId']; //the index for display??? (check that)
$my_identifier = $scormItem['scoIdentifier']; //the scorm item path/name $my_identifier = $scormItem['scoIdentifier']; //the scorm item path/name
$my_title = mysql_real_escape_string($scormItem['scoTitle']); $my_title = mysql_real_escape_string($scormItem['scoTitle']);
@ -973,8 +946,7 @@ foreach($scorms as $my_course_code => $paths_list )
} }
} }
} } else {
else{
//echo "Could not find $ims... Proceeding from database...(line ".__LINE__.")<br />"; //echo "Could not find $ims... Proceeding from database...(line ".__LINE__.")<br />";
if ($loglevel > 1) { error_log("This is a normal SCORM path", 0); } if ($loglevel > 1) { error_log("This is a normal SCORM path", 0); }
$scorm_lp_paths[$my_content_id]['path'] = $my_path; $scorm_lp_paths[$my_content_id]['path'] = $my_path;
@ -1033,7 +1005,7 @@ foreach($scorms as $my_course_code => $paths_list )
$manifest = $oScorm->parse_manifest($scorm_lp_paths[$my_content_id]['ims']); $manifest = $oScorm->parse_manifest($scorm_lp_paths[$my_content_id]['ims']);
//the title is already escaped in the method //the title is already escaped in the method
//$my_lp_title = api_convert_encoding($oScorm->get_title(),'ISO-8859-1',$oScorm->manifest_encoding); //$my_lp_title = api_convert_encoding($oScorm->get_title(),'ISO-8859-1',$oScorm->manifest_encoding);
$my_lp_title = api_convert_encoding($oScorm->get_title(),'ISO-8859-1','UTF-8'); $my_lp_title = api_convert_encoding($oScorm->get_title(), 'ISO-8859-1', 'UTF-8'); // TODO: This "magic" conversion to be checked.
if (!empty($my_lp_title)) { if (!empty($my_lp_title)) {
$my_new_lp = $db_name.$new_lp; $my_new_lp = $db_name.$new_lp;
$my_sql = "UPDATE $my_new_lp " . $my_sql = "UPDATE $my_new_lp " .
@ -1053,8 +1025,7 @@ foreach($scorms as $my_course_code => $paths_list )
$sql_items = "SELECT * FROM $scorm_item WHERE contentId = '".$my_content_id."' ORDER BY scoId"; $sql_items = "SELECT * FROM $scorm_item WHERE contentId = '".$my_content_id."' ORDER BY scoId";
//echo "$sql_items<br />\n"; //echo "$sql_items<br />\n";
$res_items = Database::query($sql_items); $res_items = Database::query($sql_items);
while($scormItem = Database::fetch_array($res_items)) while ($scormItem = Database::fetch_array($res_items)) {
{
$my_sco_id = $scormItem['scoId']; //the index for display??? (check that) $my_sco_id = $scormItem['scoId']; //the index for display??? (check that)
$my_identifier = $scormItem['scoIdentifier']; //the scorm item path/name $my_identifier = $scormItem['scoIdentifier']; //the scorm item path/name
$my_title = mysql_real_escape_string($scormItem['scoTitle']); $my_title = mysql_real_escape_string($scormItem['scoTitle']);
@ -1142,8 +1113,7 @@ foreach($scorms as $my_course_code => $paths_list )
} }
} }
//UPDATE THE LP_VIEW progress //UPDATE THE LP_VIEW progress
if(!empty($view_insert_id)) if (!empty($view_insert_id)) {
{
$sql = "SELECT count(distinct(lp_item_id)) FROM $my_new_lp_item_view WHERE lp_view_id = ".$view_insert_id." AND status IN ('passed','completed','succeeded','browsed','failed')"; $sql = "SELECT count(distinct(lp_item_id)) FROM $my_new_lp_item_view WHERE lp_view_id = ".$view_insert_id." AND status IN ('passed','completed','succeeded','browsed','failed')";
$myres = Database::query($sql); $myres = Database::query($sql);
$myrow = Database::fetch_array($myres); $myrow = Database::fetch_array($myres);
@ -1159,7 +1129,6 @@ foreach($scorms as $my_course_code => $paths_list )
$myres = Database::query($sql); $myres = Database::query($sql);
} }
/* /*
* Set all information that might be more correct coming from imsmanifest * Set all information that might be more correct coming from imsmanifest
*/ */
@ -1174,8 +1143,7 @@ foreach($scorms as $my_course_code => $paths_list )
// echo "Error selecting lp: $sel_sql - ".mysql_error()."<br />\n"; // echo "Error selecting lp: $sel_sql - ".mysql_error()."<br />\n";
//} //}
$lp_details = array(); $lp_details = array();
//while($row = Database::fetch_array($res)) //while($row = Database::fetch_array($res)) {
//{
$ordered_list = array(); $ordered_list = array();
$mylist = array(); $mylist = array();
foreach ($oScorm->organizations as $org) { foreach ($oScorm->organizations as $org) {
@ -1191,8 +1159,7 @@ foreach($scorms as $my_course_code => $paths_list )
$stock = array(0); $stock = array(0);
$level = 0; $level = 0;
$parent_id = 0; $parent_id = 0;
foreach($ordered_list as $index => $subarray) foreach ($ordered_list as $index => $subarray) {
{
//$subarray is an array representing one item and that contains info like //$subarray is an array representing one item and that contains info like
//identifier, level, rel_order, prerequisites, title, masteryscore, etc. //identifier, level, rel_order, prerequisites, title, masteryscore, etc.
//echo "<pre>Lookin for ".$subarray['identifier']." ".print_r($lp_item_refs,true)."</pre>\n"; //echo "<pre>Lookin for ".$subarray['identifier']." ".print_r($lp_item_refs,true)."</pre>\n";
@ -1318,4 +1285,3 @@ fclose($fh_revert);
fclose($fh_res); fclose($fh_res);
if ($loglevel > 0) { error_log("All done!", 0); } if ($loglevel > 0) { error_log("All done!", 0); }
//echo "</body></html>"; //echo "</body></html>";
?>

@ -41,10 +41,10 @@
============================================================================== ==============================================================================
*/ */
require_once("../inc/lib/main_api.lib.php"); require_once '../inc/lib/main_api.lib.php';
require_once("../inc/lib/fileUpload.lib.php"); require_once '../inc/lib/fileUpload.lib.php';
require_once('../inc/lib/database.lib.php'); require_once '../inc/lib/database.lib.php';
require_once('install_upgrade.lib.php'); require_once 'install_upgrade.lib.php';
/* /*
============================================================================== ==============================================================================
@ -53,9 +53,10 @@ require_once('install_upgrade.lib.php');
*/ */
function insert_db($db_name, $folder_name, $text) { function insert_db($db_name, $folder_name, $text) {
// TODO: The (global?) variable $_course has not been declared/initialized.
$_course['dbName'] = $db_name; $_course['dbName'] = $db_name;
$doc_id = add_document_180($_course, '/'.$folder_name, 'folder', 0, ucfirst($text)); $doc_id = add_document_180($_course, '/'.$folder_name, 'folder', 0, api_ucfirst($text));
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', 1); api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', 1);
} }
@ -66,8 +67,8 @@ function insert_db($db_name, $folder_name, $text){
============================================================================== ==============================================================================
*/ */
if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) {
{
$sys_course_path = $pathForm.'courses/'; $sys_course_path = $pathForm.'courses/';
//$tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE); //$tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
mysql_select_db($dbNameForm); mysql_select_db($dbNameForm);
@ -78,7 +79,9 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
$perm = api_get_setting('permissions_for_new_directories'); $perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm) ? $perm : '0770'); $perm = octdec(!empty($perm) ? $perm : '0770');
$old_umask = umask(0);
//$old_umask = umask(0); // This function is not thread-safe.
while ($courses_directories = mysql_fetch_array($result)) { while ($courses_directories = mysql_fetch_array($result)) {
$currentCourseRepositorySys = $sys_course_path.$courses_directories["directory"]."/"; $currentCourseRepositorySys = $sys_course_path.$courses_directories["directory"]."/";
@ -101,21 +104,25 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
mkdir($currentCourseRepositorySys."document/audio", $perm); mkdir($currentCourseRepositorySys."document/audio", $perm);
insert_db($db_name, "audio", get_lang('Audio')); insert_db($db_name, "audio", get_lang('Audio'));
} }
//document > flash //document > flash
if (!is_dir($currentCourseRepositorySys."document/flash")) { if (!is_dir($currentCourseRepositorySys."document/flash")) {
mkdir($currentCourseRepositorySys."document/flash", $perm); mkdir($currentCourseRepositorySys."document/flash", $perm);
insert_db($db_name,"flash",get_lang('Flash')); insert_db($db_name,"flash",get_lang('Flash'));
} }
//document > images //document > images
if (!is_dir($currentCourseRepositorySys."document/images")) { if (!is_dir($currentCourseRepositorySys."document/images")) {
mkdir($currentCourseRepositorySys."document/images", $perm); mkdir($currentCourseRepositorySys."document/images", $perm);
insert_db($db_name,"images",get_lang('Images')); insert_db($db_name,"images",get_lang('Images'));
} }
//document > video //document > video
if (!is_dir($currentCourseRepositorySys."document/video")) { if (!is_dir($currentCourseRepositorySys."document/video")) {
mkdir($currentCourseRepositorySys."document/video", $perm); mkdir($currentCourseRepositorySys."document/video", $perm);
insert_db($db_name,"video",get_lang('Video')); insert_db($db_name,"video",get_lang('Video'));
} }
//document > video > flv //document > video > flv
if (!is_dir($currentCourseRepositorySys."document/video/flv")) { if (!is_dir($currentCourseRepositorySys."document/video/flv")) {
mkdir($currentCourseRepositorySys."document/video/flv", $perm); mkdir($currentCourseRepositorySys."document/video/flv", $perm);
@ -133,10 +140,12 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
if (!is_dir($currentCourseRepositorySys."upload/blog")) { if (!is_dir($currentCourseRepositorySys."upload/blog")) {
mkdir($currentCourseRepositorySys."upload/blog", $perm); mkdir($currentCourseRepositorySys."upload/blog", $perm);
} }
//upload > forum //upload > forum
if (!is_dir($currentCourseRepositorySys."upload/forum")) { if (!is_dir($currentCourseRepositorySys."upload/forum")) {
mkdir($currentCourseRepositorySys."upload/forum", $perm); mkdir($currentCourseRepositorySys."upload/forum", $perm);
} }
//upload > test //upload > test
if (!is_dir($currentCourseRepositorySys."upload/test")) { if (!is_dir($currentCourseRepositorySys."upload/test")) {
mkdir($currentCourseRepositorySys."upload/test", $perm); mkdir($currentCourseRepositorySys."upload/test", $perm);
@ -150,8 +159,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
'?>'; '?>';
unlink($currentCourseRepositorySys.'index.php'); unlink($currentCourseRepositorySys.'index.php');
$fp = @ fopen($currentCourseRepositorySys.'index.php', 'w'); $fp = @ fopen($currentCourseRepositorySys.'index.php', 'w');
if ($fp) if ($fp) {
{
error_log('Writing redirection file in '.$currentCourseRepositorySys.'index.php', 0); error_log('Writing redirection file in '.$currentCourseRepositorySys.'index.php', 0);
fwrite($fp, $content); fwrite($fp, $content);
fclose($fp); fclose($fp);
@ -160,7 +168,8 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
} }
} }
umask($old_umask); //umask($old_umask); // This function is not thread-safe.
// Write the Dokeos config file // Write the Dokeos config file
write_dokeos_config_file('../inc/conf/configuration.php'); write_dokeos_config_file('../inc/conf/configuration.php');
// Write a distribution file with the config as a backup for the admin // Write a distribution file with the config as a backup for the admin
@ -184,14 +193,13 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
rename($updatePath.'claroline/upload/video', $pathForm.'main/upload/video'); rename($updatePath.'claroline/upload/video', $pathForm.'main/upload/video');
/* /*
if (defined('DOKEOS_INSTALL')) if (defined('DOKEOS_INSTALL')) {
{
//nothing to do this time //nothing to do this time
} }
*/ */
}
else } else {
{
echo 'You are not allowed here !'; echo 'You are not allowed here !';
} }
?>

@ -36,53 +36,44 @@
* @package dokeos.install * @package dokeos.install
============================================================================== ==============================================================================
*/ */
require_once("../inc/lib/main_api.lib.php"); require_once '../inc/lib/main_api.lib.php';
require_once("../inc/lib/fileUpload.lib.php"); require_once '../inc/lib/fileUpload.lib.php';
require_once('../inc/lib/database.lib.php'); require_once '../inc/lib/database.lib.php';
if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) {
if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
{
// Edit the Dokeos config file // Edit the Dokeos config file
$file = file('../inc/conf/configuration.php'); $file = file('../inc/conf/configuration.php');
$fh = fopen('../inc/conf/configuration.php', 'w'); $fh = fopen('../inc/conf/configuration.php', 'w');
$found_version = false; $found_version = false;
$found_stable = false; $found_stable = false;
foreach($file as $line) foreach ($file as $line) {
{
$ignore = false; $ignore = false;
if(stristr($line,'$_configuration[\'dokeos_version\']')) if(stristr($line, '$_configuration[\'dokeos_version\']')) {
{
$found_version = true; $found_version = true;
$line = '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n"; $line = '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n";
} } elseif(stristr($line, '$_configuration[\'dokeos_stable\']')) {
elseif(stristr($line,'$_configuration[\'dokeos_stable\']'))
{
$found_stable = true; $found_stable = true;
$line = '$_configuration[\'dokeos_stable\'] = '.($new_version_stable ? 'true' : 'false').';'."\r\n"; $line = '$_configuration[\'dokeos_stable\'] = '.($new_version_stable ? 'true' : 'false').';'."\r\n";
} } elseif (stristr($line, '?>')) {
elseif(stristr($line,'?>'))
{
//ignore the line //ignore the line
$ignore = true; $ignore = true;
} }
if(!$ignore) if (!$ignore) {
{
fwrite($fh, $line); fwrite($fh, $line);
} }
} }
if(!$found_version) if (!$found_version) {
{
fwrite($fh, '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n"); fwrite($fh, '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n");
} }
if(!$found_stable) if (!$found_stable) {
{
fwrite($fh, '$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n"); fwrite($fh, '$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n");
} }
fwrite($fh, '?>'); fwrite($fh, '?>');
fclose($fh); fclose($fh);
}
else } else {
{
echo 'You are not allowed here !'; echo 'You are not allowed here !';
} }
?>

@ -15,53 +15,44 @@
* @package dokeos.install * @package dokeos.install
============================================================================== ==============================================================================
*/ */
require_once("../inc/lib/main_api.lib.php"); require_once '../inc/lib/main_api.lib.php';
require_once("../inc/lib/fileUpload.lib.php"); require_once '../inc/lib/fileUpload.lib.php';
require_once('../inc/lib/database.lib.php'); require_once '../inc/lib/database.lib.php';
if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) {
if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
{
// Edit the Dokeos config file // Edit the Dokeos config file
$file = file('../inc/conf/configuration.php'); $file = file('../inc/conf/configuration.php');
$fh = fopen('../inc/conf/configuration.php', 'w'); $fh = fopen('../inc/conf/configuration.php', 'w');
$found_version = false; $found_version = false;
$found_stable = false; $found_stable = false;
foreach($file as $line) foreach ($file as $line) {
{
$ignore = false; $ignore = false;
if(stristr($line,'$_configuration[\'dokeos_version\']')) if (stristr($line, '$_configuration[\'dokeos_version\']')) {
{
$found_version = true; $found_version = true;
$line = '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n"; $line = '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n";
} } elseif (stristr($line, '$_configuration[\'dokeos_stable\']')) {
elseif(stristr($line,'$_configuration[\'dokeos_stable\']'))
{
$found_stable = true; $found_stable = true;
$line = '$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n"; $line = '$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n";
} } elseif(stristr($line, '?>')) {
elseif(stristr($line,'?>'))
{
//ignore the line //ignore the line
$ignore = true; $ignore = true;
} }
if(!$ignore) if (!$ignore) {
{
fwrite($fh, $line); fwrite($fh, $line);
} }
} }
if(!$found_version) if (!$found_version) {
{
fwrite($fh, '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n"); fwrite($fh, '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n");
} }
if(!$found_stable) if (!$found_stable) {
{
fwrite($fh, '$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n"); fwrite($fh, '$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n");
} }
fwrite($fh, '?>'); fwrite($fh, '?>');
fclose($fh); fclose($fh);
}
else } else {
{
echo 'You are not allowed here !'; echo 'You are not allowed here !';
} }
?>

@ -15,50 +15,39 @@
* @package dokeos.install * @package dokeos.install
============================================================================== ==============================================================================
*/ */
require_once("../inc/lib/main_api.lib.php"); require_once '../inc/lib/main_api.lib.php';
require_once("../inc/lib/fileUpload.lib.php"); require_once '../inc/lib/fileUpload.lib.php';
require_once('../inc/lib/database.lib.php'); require_once '../inc/lib/database.lib.php';
if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) {
if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
{
// Edit the Dokeos config file // Edit the Dokeos config file
$file = file('../inc/conf/configuration.php'); $file = file('../inc/conf/configuration.php');
$fh = fopen('../inc/conf/configuration.php', 'w'); $fh = fopen('../inc/conf/configuration.php', 'w');
$found_version = false; $found_version = false;
$found_stable = false; $found_stable = false;
foreach($file as $line) foreach ($file as $line) {
{
$ignore = false; $ignore = false;
if(stristr($line,'$_configuration[\'dokeos_version\']')) if (stristr($line, '$_configuration[\'dokeos_version\']')) {
{
$found_version = true; $found_version = true;
$line = '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n"; $line = '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n";
} } elseif(stristr($line, '$_configuration[\'dokeos_stable\']')) {
elseif(stristr($line,'$_configuration[\'dokeos_stable\']'))
{
$found_stable = true; $found_stable = true;
$line = '$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n"; $line = '$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n";
} } elseif(stristr($line,'$userPasswordCrypted')) {
elseif(stristr($line,'$userPasswordCrypted'))
{
$line = '$userPasswordCrypted = \''.($userPasswordCrypted).'\';'."\r\n"; $line = '$userPasswordCrypted = \''.($userPasswordCrypted).'\';'."\r\n";
} } elseif(stristr($line, '?>')) {
elseif(stristr($line,'?>'))
{
//ignore the line //ignore the line
$ignore = true; $ignore = true;
} }
if(!$ignore) if (!$ignore) {
{
fwrite($fh, $line); fwrite($fh, $line);
} }
} }
if(!$found_version) if (!$found_version) {
{
fwrite($fh, '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n"); fwrite($fh, '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n");
} }
if(!$found_stable) if (!$found_stable) {
{
fwrite($fh, '$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n"); fwrite($fh, '$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n");
} }
fwrite($fh, '?>'); fwrite($fh, '?>');
@ -77,11 +66,11 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
$perm = api_get_setting('permissions_for_new_directories'); $perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm) ? $perm : '0770'); $perm = octdec(!empty($perm) ? $perm : '0770');
$old_umask = umask(0);
//$old_umask = umask(0); // This function is not thread-safe.
while($courses_directories = mysql_fetch_array($result)) {
while($courses_directories=mysql_fetch_array($result))
{
$currentCourseRepositorySys = $sys_course_path.$courses_directories['directory'].'/'; $currentCourseRepositorySys = $sys_course_path.$courses_directories['directory'].'/';
$db_name = $courses_directories['db_name']; $db_name = $courses_directories['db_name'];

@ -15,59 +15,48 @@
* @package dokeos.install * @package dokeos.install
============================================================================== ==============================================================================
*/ */
require_once("../inc/lib/main_api.lib.php"); require_once '../inc/lib/main_api.lib.php';
require_once("../inc/lib/fileUpload.lib.php"); require_once '../inc/lib/fileUpload.lib.php';
require_once('../inc/lib/database.lib.php'); require_once '../inc/lib/database.lib.php';
if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) {
if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
{
// Edit the Dokeos config file // Edit the Dokeos config file
$file = file('../inc/conf/configuration.php'); $file = file('../inc/conf/configuration.php');
$fh = fopen('../inc/conf/configuration.php', 'w'); $fh = fopen('../inc/conf/configuration.php', 'w');
$found_version = false; $found_version = false;
$found_stable = false; $found_stable = false;
foreach($file as $line) foreach ($file as $line) {
{
$ignore = false; $ignore = false;
if(stristr($line,'$_configuration[\'dokeos_version\']')) if(stristr($line, '$_configuration[\'dokeos_version\']')) {
{
$found_version = true; $found_version = true;
$line = '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n"; $line = '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n";
} } elseif(stristr($line, '$_configuration[\'dokeos_stable\']')) {
elseif(stristr($line,'$_configuration[\'dokeos_stable\']'))
{
$found_stable = true; $found_stable = true;
$line = '$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n"; $line = '$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n";
} } elseif(stristr($line, '$userPasswordCrypted')) {
elseif(stristr($line,'$userPasswordCrypted'))
{
$line = '$userPasswordCrypted = \''.($userPasswordCrypted).'\';'."\r\n"; $line = '$userPasswordCrypted = \''.($userPasswordCrypted).'\';'."\r\n";
} } elseif(stristr($line, '?>')) {
elseif(stristr($line,'?>'))
{
//ignore the line //ignore the line
$ignore = true; $ignore = true;
} }
if(!$ignore) if (!$ignore) {
{
fwrite($fh, $line); fwrite($fh, $line);
} }
} }
if(!$found_version) if (!$found_version) {
{
fwrite($fh, '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n"); fwrite($fh, '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n");
} }
if(!$found_stable) if (!$found_stable) {
{
fwrite($fh, '$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n"); fwrite($fh, '$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n");
} }
fwrite($fh, '?>'); fwrite($fh, '?>');
fclose($fh); fclose($fh);
$perm = api_get_setting('permissions_for_new_directories'); $perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm) ? $perm : '0770'); $perm = octdec(!empty($perm) ? $perm : '0770');
$old_umask = umask(0);
//$old_umask = umask(0); // This function is not thread-safe.
////create a specific directory for global thumbails ////create a specific directory for global thumbails
//home > default_platform_document > template_thumb //home > default_platform_document > template_thumb
@ -75,9 +64,8 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
mkdir($pathForm.'home/default_platform_document/template_thumb', $perm); mkdir($pathForm.'home/default_platform_document/template_thumb', $perm);
} }
} } else {
else
{
echo 'You are not allowed here !'; echo 'You are not allowed here !';
} }
?>

@ -9,50 +9,38 @@
* @package dokeos.install * @package dokeos.install
============================================================================== ==============================================================================
*/ */
require_once("../inc/lib/main_api.lib.php"); require_once '../inc/lib/main_api.lib.php';
require_once("../inc/lib/fileUpload.lib.php"); require_once '../inc/lib/fileUpload.lib.php';
require_once('../inc/lib/database.lib.php'); require_once '../inc/lib/database.lib.php';
if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) {
{
// Edit the Dokeos config file // Edit the Dokeos config file
$file = file('../inc/conf/configuration.php'); $file = file('../inc/conf/configuration.php');
$fh = fopen('../inc/conf/configuration.php', 'w'); $fh = fopen('../inc/conf/configuration.php', 'w');
$found_version = false; $found_version = false;
$found_stable = false; $found_stable = false;
foreach($file as $line) foreach ($file as $line) {
{
$ignore = false; $ignore = false;
if(stristr($line,'$_configuration[\'dokeos_version\']')) if (stristr($line, '$_configuration[\'dokeos_version\']')) {
{
$found_version = true; $found_version = true;
$line = '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n"; $line = '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n";
} } elseif(stristr($line, '$_configuration[\'dokeos_stable\']')) {
elseif(stristr($line,'$_configuration[\'dokeos_stable\']'))
{
$found_stable = true; $found_stable = true;
$line = '$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n"; $line = '$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n";
} } elseif(stristr($line,'$userPasswordCrypted')) {
elseif(stristr($line,'$userPasswordCrypted'))
{
$line = '$userPasswordCrypted = \''.($userPasswordCrypted).'\';'."\r\n"; $line = '$userPasswordCrypted = \''.($userPasswordCrypted).'\';'."\r\n";
} } elseif(stristr($line, '?>')) {
elseif(stristr($line,'?>'))
{
//ignore the line //ignore the line
$ignore = true; $ignore = true;
} }
if(!$ignore) if (!$ignore) {
{
fwrite($fh, $line); fwrite($fh, $line);
} }
} }
if(!$found_version) if (!$found_version) {
{
fwrite($fh, '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n"); fwrite($fh, '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n");
} }
if(!$found_stable) if (!$found_stable) {
{
fwrite($fh, '$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n"); fwrite($fh, '$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n");
} }
fwrite($fh, '?>'); fwrite($fh, '?>');
@ -61,7 +49,8 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
$sys_course_path = $pathForm.'courses/'; $sys_course_path = $pathForm.'courses/';
$perm = api_get_setting('permissions_for_new_directories'); $perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm) ? $perm : '0770'); $perm = octdec(!empty($perm) ? $perm : '0770');
$old_umask = umask(0);
//$old_umask = umask(0); // This function is not thread-safe.
$link = mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm); $link = mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm);
mysql_select_db($dbNameForm, $link); mysql_select_db($dbNameForm, $link);
@ -89,9 +78,8 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
mkdir($pathForm.'home/default_platform_document/template_thumb', $perm); mkdir($pathForm.'home/default_platform_document/template_thumb', $perm);
} }
} } else {
else
{
echo 'You are not allowed here !'; echo 'You are not allowed here !';
} }
?>

@ -1,24 +1,24 @@
<?php <?php
/* See license terms in /dokeos_license.txt */ /* See license terms in /chamilo_license.txt */
/** /**
============================================================================== ==============================================================================
* Updates the Dokeos files from version 1.8.6.2 to version 1.8.7 * Updates the Chamilo files from version 1.8.6.2 to version 1.8.7
* This script operates only in the case of an update, and only to change the * This script operates only in the case of an update, and only to change the
* active version number (and other things that might need a change) in the * active version number (and other things that might need a change) in the
* current configuration file. * current configuration file.
* @package dokeos.install * @package chamilo.install
============================================================================== ==============================================================================
*/ */
require_once("../inc/lib/main_api.lib.php"); require_once '../inc/lib/main_api.lib.php';
require_once("../inc/lib/fileUpload.lib.php"); require_once '../inc/lib/fileUpload.lib.php';
require_once('../inc/lib/database.lib.php'); require_once '../inc/lib/database.lib.php';
if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) {
{
// Start coding here...
} else {
}
else
{
echo 'You are not allowed here !'; echo 'You are not allowed here !';
} }
?>

@ -1,5 +1,8 @@
<?php //$id: $ <?php //$id: $
/* For licensing terms, see /dokeos_license.txt */ /* For licensing terms, see /dokeos_license.txt */
// TODO: Ivan, 13-FEB-2010: Is this file really needed?
/** /**
============================================================================== ==============================================================================
* GOAL: Updates courses separately * GOAL: Updates courses separately
@ -53,36 +56,27 @@ $update_from_version=array('1.5','1.5.4','1.5.5');
$updateFromConfigFile = ''; // leave empty $updateFromConfigFile = ''; // leave empty
$badUpdatePath = false; $badUpdatePath = false;
if($_POST['step2']) if ($_POST['step2']) {
{
if(empty($_POST['updatePath'])) if (empty($_POST['updatePath'])) {
{
$_POST['step1'] = 1; $_POST['step1'] = 1;
}
else } else {
{
if($_POST['updatePath'][strlen($_POST['updatePath'])-1] != '/') if ($_POST['updatePath'][strlen($_POST['updatePath'])-1] != '/') {
{
$_POST['updatePath'] .= '/'; $_POST['updatePath'] .= '/';
} }
if(!file_exists($_POST['updatePath'])) if (!file_exists($_POST['updatePath'])) {
{
$badUpdatePath = true; $badUpdatePath = true;
$_POST['step2'] = 0; $_POST['step2'] = 0;
} } elseif (!in_array(get_config_param('clarolineVersion'), $update_from_version)) {
elseif(!in_array(get_config_param('clarolineVersion'),$update_from_version))
{
$badUpdatePath = true; $badUpdatePath = true;
$_POST['step2'] = 0; $_POST['step2'] = 0;
} } else {
else
{
$urlAppendPath = str_replace('/main/install/update_courses.php', '', api_get_self()); $urlAppendPath = str_replace('/main/install/update_courses.php', '', api_get_self());
$urlForm='http://'.$_SERVER['HTTP_HOST'].$urlAppendPath.'/'; $urlForm = 'http://'.$_SERVER['HTTP_HOST'].$urlAppendPath.'/'; // What about https? See api_get_path().
$singleDbForm = get_config_param('singleDbEnabled'); $singleDbForm = get_config_param('singleDbEnabled');
$dbNameForm = get_config_param('mainDbName'); $dbNameForm = get_config_param('mainDbName');
$dbHostForm = get_config_param('dbHost'); $dbHostForm = get_config_param('dbHost');
@ -90,19 +84,20 @@ if($_POST['step2'])
$dbPassForm = get_config_param('dbPass'); $dbPassForm = get_config_param('dbPass');
} }
} }
}
elseif($_POST['step1']) } elseif ($_POST['step1']) {
{
$_POST['updatePath'] = ''; $_POST['updatePath'] = '';
} }
?> ?>
<html> <html>
<head> <head>
<?php /* There is no metadata about current language and encoding. */ ?>
<title>-- Dokeos course update -- version <?php echo $dokeos_version; ?></title> <title>-- Dokeos course update -- version <?php echo $dokeos_version; ?></title>
<link rel="stylesheet" href="../css/chamilo/default.css" type="text/css"> <link rel="stylesheet" href="../css/chamilo/default.css" type="text/css">
</head> </head>
<body bgcolor="white" dir="<?php echo $text_dir ?>"> <body bgcolor="white" dir="<?php echo $text_dir; ?>">
<form method="post" action="<?php echo api_get_self(); ?>"> <form method="post" action="<?php echo api_get_self(); ?>">
<table cellpadding="6" cellspacing="0" border="0" width="650" bgcolor="#E6E6E6" align="center"> <table cellpadding="6" cellspacing="0" border="0" width="650" bgcolor="#E6E6E6" align="center">
@ -129,8 +124,8 @@ elseif($_POST['step1'])
============================================================================== ==============================================================================
*/ */
if($_POST['step2']) if ($_POST['step2']) {
{
include('update_db.inc.php'); include('update_db.inc.php');
include('update_files.inc.php'); include('update_files.inc.php');
?> ?>
@ -162,8 +157,7 @@ if($_POST['step2'])
============================================================================== ==============================================================================
*/ */
else else {
{
?> ?>
<h2>Step 1 of 2 &ndash; Configuration</h2> <h2>Step 1 of 2 &ndash; Configuration</h2>
@ -172,8 +166,7 @@ else
<strong>Notice:</strong> Please run this update script only if you've just updated (incompletely) Dokeos <?php echo implode('&nbsp;|&nbsp;',$update_from_version); ?> to Dokeos <?php echo $dokeos_version; ?>! <strong>Notice:</strong> Please run this update script only if you've just updated (incompletely) Dokeos <?php echo implode('&nbsp;|&nbsp;',$update_from_version); ?> to Dokeos <?php echo $dokeos_version; ?>!
<br /><br /> <br /><br />
<?php <?php
if($badUpdatePath) if ($badUpdatePath) {
{
?> ?>
<br /><br /> <br /><br />
<div style="background-color:white; color:red; text-align:center; font-weight:bold;"> <div style="background-color:white; color:red; text-align:center; font-weight:bold;">
@ -181,9 +174,7 @@ else
Dokeos <?php echo implode('|',$update_from_version); ?> has not been found in that directory. Dokeos <?php echo implode('|',$update_from_version); ?> has not been found in that directory.
</div> </div>
<?php <?php
} } else {
else
{
echo '<br />'; echo '<br />';
} }
?> ?>

@ -102,8 +102,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
exit (); exit ();
} }
// The system has not been designed to use special SQL modes that were introduced since MySQL 5 @mysql_query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
@mysql_query("set session sql_mode='';");
/* /*
----------------------------------------------------------- -----------------------------------------------------------

@ -1,4 +1,7 @@
<?php <?php
// TODO: Ivan, 13-FEB-2010: Is this file really needed?
/* /*
============================================================================== ==============================================================================
Dokeos - elearning and course management software Dokeos - elearning and course management software
@ -76,60 +79,48 @@ function fill_document_table($dir)
$documentPath = $newPath.'courses/'.$course.'/document'; $documentPath = $newPath.'courses/'.$course.'/document';
if (!@ $opendir = opendir($dir)) if (!@ $opendir = opendir($dir)) {
{
return false; return false;
} }
while ($readdir = readdir($opendir)) while ($readdir = readdir($opendir)) {
{
if ($readdir != '..' && $readdir != '.' && $readdir != '.htaccess') if ($readdir != '..' && $readdir != '.' && $readdir != '.htaccess') {
{
$path = str_replace($documentPath, '', $dir.'/'.$readdir); $path = str_replace($documentPath, '', $dir.'/'.$readdir);
$file_date = date("Y-m-d H:i:s", filemtime($dir.'/'.$readdir)); $file_date = date("Y-m-d H:i:s", filemtime($dir.'/'.$readdir));
if (is_file($dir.'/'.$readdir)) if (is_file($dir.'/'.$readdir)) {
{
$file_size = filesize($dir.'/'.$readdir); $file_size = filesize($dir.'/'.$readdir);
$result = mysql_query("SELECT id,visibility FROM `$mysql_base_course".$_configuration['db_glue']."document` WHERE path='".addslashes($path)."' LIMIT 0,1"); $result = mysql_query("SELECT id,visibility FROM `$mysql_base_course".$_configuration['db_glue']."document` WHERE path='".addslashes($path)."' LIMIT 0,1");
if (list ($id, $visibility) = mysql_fetch_row($result)) if (list ($id, $visibility) = mysql_fetch_row($result)) {
{
mysql_query("UPDATE `$mysql_base_course".$_configuration['db_glue']."document` SET filetype='file',title='".addslashes($readdir)."',size='$file_size' WHERE id='$id' AND path='".addslashes($path)."'"); mysql_query("UPDATE `$mysql_base_course".$_configuration['db_glue']."document` SET filetype='file',title='".addslashes($readdir)."',size='$file_size' WHERE id='$id' AND path='".addslashes($path)."'");
} } else {
else
{
mysql_query("INSERT INTO `$mysql_base_course".$_configuration['db_glue']."document`(path,filetype,title,size) VALUES('".addslashes($path)."','file','".addslashes($readdir)."','$file_size')"); mysql_query("INSERT INTO `$mysql_base_course".$_configuration['db_glue']."document`(path,filetype,title,size) VALUES('".addslashes($path)."','file','".addslashes($readdir)."','$file_size')");
$id = mysql_insert_id(); $id = mysql_insert_id();
} }
$visibility = ($visibility == 'v') ? 1 : 0; $visibility = ($visibility == 'v') ? 1 : 0;
mysql_query("INSERT INTO `$mysql_base_course".$_configuration['db_glue']."item_property`(tool,ref,visibility,lastedit_type,to_group_id,insert_date,lastedit_date) VALUES('document','$id','$visibility','DocumentAdded','0','".$file_date."','".$file_date."')"); mysql_query("INSERT INTO `$mysql_base_course".$_configuration['db_glue']."item_property`(tool,ref,visibility,lastedit_type,to_group_id,insert_date,lastedit_date) VALUES('document','$id','$visibility','DocumentAdded','0','".$file_date."','".$file_date."')");
}
elseif (is_dir($dir.'/'.$readdir)) } elseif (is_dir($dir.'/'.$readdir)) {
{
$result = mysql_query("SELECT id,visibility FROM `$mysql_base_course".$_configuration['db_glue']."document` WHERE path='".addslashes($path)."' LIMIT 0,1"); $result = mysql_query("SELECT id,visibility FROM `$mysql_base_course".$_configuration['db_glue']."document` WHERE path='".addslashes($path)."' LIMIT 0,1");
if (list ($id, $visibility) = mysql_fetch_row($result)) if (list ($id, $visibility) = mysql_fetch_row($result)) {
{
mysql_query("UPDATE `$mysql_base_course".$_configuration['db_glue']."document` SET filetype='folder',title='".addslashes($readdir)."' WHERE id='$id' AND path='".addslashes($path)."'"); mysql_query("UPDATE `$mysql_base_course".$_configuration['db_glue']."document` SET filetype='folder',title='".addslashes($readdir)."' WHERE id='$id' AND path='".addslashes($path)."'");
} } else {
else
{
mysql_query("INSERT INTO `$mysql_base_course".$_configuration['db_glue']."document`(path,filetype,title) VALUES('".addslashes($path)."','folder','".addslashes($readdir)."')"); mysql_query("INSERT INTO `$mysql_base_course".$_configuration['db_glue']."document`(path,filetype,title) VALUES('".addslashes($path)."','folder','".addslashes($readdir)."')");
$id = mysql_insert_id(); $id = mysql_insert_id();
} }
$visibility = ($visibility == 'v') ? 1 : 0; $visibility = ($visibility == 'v') ? 1 : 0;
mysql_query("INSERT INTO `$mysql_base_course".$_configuration['db_glue']."item_property`(tool,ref,visibility, lastedit_type, to_group_id,insert_date,lastedit_date) VALUES('document','$id','$visibility','FolderCreated','0','".$file_date."','".$file_date."')"); mysql_query("INSERT INTO `$mysql_base_course".$_configuration['db_glue']."item_property`(tool,ref,visibility, lastedit_type, to_group_id,insert_date,lastedit_date) VALUES('document','$id','$visibility','FolderCreated','0','".$file_date."','".$file_date."')");
if (!fill_document_table($dir.'/'.$readdir)) if (!fill_document_table($dir.'/'.$readdir)) {
{
return false; return false;
} }
} }
@ -147,33 +138,26 @@ function fill_document_table($dir)
============================================================================== ==============================================================================
*/ */
if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) {
{
$newPath = str_replace('\\', '/', realpath('../..')).'/'; $newPath = str_replace('\\', '/', realpath('../..')).'/';
$oldPath = $_POST['updatePath']; $oldPath = $_POST['updatePath'];
$perm = api_get_setting('permissions_for_new_directories'); $perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm) ? $perm : '0770'); $perm = octdec(!empty($perm) ? $perm : '0770');
foreach ($coursePath as $key => $course) foreach ($coursePath as $key => $course) {
{
$mysql_base_course = $courseDB[$key]; $mysql_base_course = $courseDB[$key];
@ unlink($oldPath.$course.'/document/.htaccess'); @ unlink($oldPath.$course.'/document/.htaccess');
@ unlink($oldPath.$course.'/group/index.php'); @ unlink($oldPath.$course.'/group/index.php');
if ($fp = @ fopen($oldPath.$course.'/group/index.php', 'w')) if ($fp = @ fopen($oldPath.$course.'/group/index.php', 'w')) {
{
fputs($fp, '<html></html>'); fputs($fp, '<html></html>');
fclose($fp); fclose($fp);
} }
@ unlink($oldPath.$course.'/index.php'); @ unlink($oldPath.$course.'/index.php');
if ($fp = @ fopen($oldPath.$course.'/index.php', 'w')) if ($fp = @ fopen($oldPath.$course.'/index.php', 'w')) {
{
fputs($fp, '<?php fputs($fp, '<?php
$cidReq = "'.$key.'"; $cidReq = "'.$key.'";
$dbname = "'.str_replace($dbPrefixForm, '', $mysql_base_course).'"; $dbname = "'.str_replace($dbPrefixForm, '', $mysql_base_course).'";
@ -186,25 +170,19 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
@ mkdir($oldPath.$course.'/temp', $perm); @ mkdir($oldPath.$course.'/temp', $perm);
@ chmod($oldPath.$course.'/temp', $perm); @ chmod($oldPath.$course.'/temp', $perm);
@ rename($oldPath.$course, $newPath.'courses/'.$course); @ rename($oldPath.$course, $newPath.'courses/'.$course);
// Move group documents to document folder of the course // Move group documents to document folder of the course
$group_dir = $newPath.'courses/'.$course.'/group'; $group_dir = $newPath.'courses/'.$course.'/group';
if ($dir = @ opendir($group_dir)) if ($dir = @ opendir($group_dir)) {
{ while (($entry = readdir($dir)) !== false) {
while (($entry = readdir($dir)) !== false) if ($entry != '.' && $entry != '..' && is_dir($group_dir.'/'.$entry)) {
{
if ($entry != '.' && $entry != '..' && is_dir($group_dir.'/'.$entry))
{
$from_dir = $group_dir.'/'.$entry; $from_dir = $group_dir.'/'.$entry;
$to_dir = $newPath.'courses/'.$course.'/document/'.$entry; $to_dir = $newPath.'courses/'.$course.'/document/'.$entry;
@ rename($from_dir, $to_dir); @ rename($from_dir, $to_dir);
} }
} }
closedir($dir); closedir($dir);
} }
@ -216,25 +194,28 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
$sql = "SELECT d.id AS doc_id, g.id AS group_id FROM `$mysql_base_course".$_configuration['db_glue']."group_info` g,`$mysql_base_course".$_configuration['db_glue']."document` d WHERE path LIKE CONCAT(g.secret_directory,'%')"; $sql = "SELECT d.id AS doc_id, g.id AS group_id FROM `$mysql_base_course".$_configuration['db_glue']."group_info` g,`$mysql_base_course".$_configuration['db_glue']."document` d WHERE path LIKE CONCAT(g.secret_directory,'%')";
$res = mysql_query($sql); $res = mysql_query($sql);
while ($group_doc = mysql_fetch_object($res)) while ($group_doc = mysql_fetch_object($res)) {
{
$sql = "UPDATE `$mysql_base_course".$_configuration['db_glue']."item_property` SET to_group_id = '".$group_doc->group_id."', visibility = '1' WHERE ref = '".$group_doc->doc_id."' AND tool = '".TOOL_DOCUMENT."'"; $sql = "UPDATE `$mysql_base_course".$_configuration['db_glue']."item_property` SET to_group_id = '".$group_doc->group_id."', visibility = '1' WHERE ref = '".$group_doc->doc_id."' AND tool = '".TOOL_DOCUMENT."'";
mysql_query($sql); mysql_query($sql);
} }
} }
if (defined('DOKEOS_INSTALL')) if (defined('DOKEOS_INSTALL')) {
{
// Write the Dokeos config file // Write the Dokeos config file
write_dokeos_config_file($newPath.'main/inc/conf/configuration.php'); write_dokeos_config_file($newPath.'main/inc/conf/configuration.php');
// Write a distribution file with the config as a backup for the admin // Write a distribution file with the config as a backup for the admin
write_dokeos_config_file($newPath.'main/inc/conf/configuration.dist.php'); write_dokeos_config_file($newPath.'main/inc/conf/configuration.dist.php');
// Write a .htaccess file in the course repository // Write a .htaccess file in the course repository
write_courses_htaccess_file($urlAppendPath); write_courses_htaccess_file($urlAppendPath);
require_once ('../inc/lib/fileManage.lib.php'); require_once ('../inc/lib/fileManage.lib.php');
// First remove the upload/users directory in the new installation // First remove the upload/users directory in the new installation
removeDir($newPath.'main/upload/users'); removeDir($newPath.'main/upload/users');
// Move the old user images to the new installation // Move the old user images to the new installation
@ rename($oldPath.'main/img/users', $newPath.'main/upload/users'); @ rename($oldPath.'main/img/users', $newPath.'main/upload/users');
@ -243,9 +224,6 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
unlink($oldPath.'main/inc/conf/configuration.php'); unlink($oldPath.'main/inc/conf/configuration.php');
} }
} }
} } else {
else
{
echo 'You are not allowed here !'; echo 'You are not allowed here !';
} }
?>

@ -1,4 +1,7 @@
<?php // $Id: upgrade.php 22577 2009-08-03 04:31:24Z yannoo $ <?php // $Id: upgrade.php 22577 2009-08-03 04:31:24Z yannoo $
// TODO: Ivan, 13-FEB-2010: Is this file needed? It looks like unfinished business.
/* For licensing terms, see /dokeos_license.txt */ /* For licensing terms, see /dokeos_license.txt */
/** /**
============================================================================== ==============================================================================
@ -43,19 +46,21 @@
*/ */
session_start(); session_start();
// TODO: It is not a good idea to refer to external PEAR packages due to version/customizations related problems.
ini_set('include_path', ini_get('include_path').PATH_SEPARATOR.'../inc/lib/pear'); ini_set('include_path', ini_get('include_path').PATH_SEPARATOR.'../inc/lib/pear');
//echo ini_get('include_path'); //DEBUG //echo ini_get('include_path'); //DEBUG
require_once 'HTML/QuickForm/Controller.php'; require_once 'HTML/QuickForm/Controller.php';
require_once 'HTML/QuickForm/Rule.php'; require_once 'HTML/QuickForm/Rule.php';
require_once 'HTML/QuickForm/Action/Display.php'; require_once 'HTML/QuickForm/Action/Display.php';
//
require('../inc/installedVersion.inc.php'); require '../inc/installedVersion.inc.php';
require('../inc/lib/main_api.lib.php'); require '../inc/lib/main_api.lib.php';
require('../lang/english/trad4all.inc.php'); require '../lang/english/trad4all.inc.php';
require('../lang/english/install.inc.php'); require '../lang/english/install.inc.php';
require_once('install_upgrade.lib.php'); require_once 'install_upgrade.lib.php';
require_once('upgrade_lib.php'); require_once 'upgrade_lib.php';
define('DOKEOS_INSTALL', 1); define('DOKEOS_INSTALL', 1);
define('MAX_COURSE_TRANSFER', 100); define('MAX_COURSE_TRANSFER', 100);
@ -63,23 +68,21 @@ define('INSTALL_TYPE_UPDATE', 'update');
define('FORM_FIELD_DISPLAY_LENGTH', 40); define('FORM_FIELD_DISPLAY_LENGTH', 40);
define('DATABASE_FORM_FIELD_DISPLAY_LENGTH', 25); define('DATABASE_FORM_FIELD_DISPLAY_LENGTH', 25);
define('MAX_FORM_FIELD_LENGTH', 50); define('MAX_FORM_FIELD_LENGTH', 50);
define('DEFAULT_LANGUAGE', 'english'); define('DEFAULT_LANGUAGE', 'english'); //TODO: What is the purpose of this constant?
//error_reporting(E_COMPILE_ERROR | E_ERROR | E_CORE_ERROR); //error_reporting(E_COMPILE_ERROR | E_ERROR | E_CORE_ERROR);
error_reporting(E_ALL); error_reporting(E_ALL);
@set_time_limit(0); @set_time_limit(0);
if(function_exists('ini_set')) if (function_exists('ini_set')) {
{
ini_set('memory_limit', -1); ini_set('memory_limit', -1);
ini_set('max_execution_time', 0); ini_set('max_execution_time', 0);
} }
$update_from_version = array('1.6', '1.6.1', '1.6.2', '1.6.3', '1.6.4', '1.6.5', '1.8.0', '1.8.1', '1.8.2'); $update_from_version = array('1.6', '1.6.1', '1.6.2', '1.6.3', '1.6.4', '1.6.5', '1.8.0', '1.8.1', '1.8.2');
$update_from_16_version = array('1.6', '1.6.1', '1.6.2', '1.6.3', '1.6.4', '1.6.5'); $update_from_16_version = array('1.6', '1.6.1', '1.6.2', '1.6.3', '1.6.4', '1.6.5');
$update_from_18_version = array('1.8.0','1.8.1','1.8.2'); $update_from_18_version = array('1.8.0', '1.8.1', '1.8.2'); // TODO: ...
/* /*
============================================================================== ==============================================================================
@ -91,18 +94,17 @@ $update_from_18_version = array('1.8.0','1.8.1','1.8.2');
* Page in the install wizard to select the language which will be used during * Page in the install wizard to select the language which will be used during
* the installation process. * the installation process.
*/ */
class Page_Language extends HTML_QuickForm_Page class Page_Language extends HTML_QuickForm_Page {
{
function get_title() function get_title() {
{
return get_lang('WelcomeToDokeosInstaller'); return get_lang('WelcomeToDokeosInstaller');
} }
function get_info()
{ function get_info() {
return 'Please select the language you\'d like to use while installing:'; return 'Please select the language you\'d like to use while installing:';
} }
function buildForm()
{ function buildForm() {
$this->_formBuilt = true; $this->_formBuilt = true;
$this->addElement('select', 'install_language', get_lang('InstallationLanguage'), get_language_folder_list()); $this->addElement('select', 'install_language', get_lang('InstallationLanguage'), get_language_folder_list());
$buttons[0] = & HTML_QuickForm :: createElement('submit', $this->getButtonName('next'), get_lang('Next').' >>'); $buttons[0] = & HTML_QuickForm :: createElement('submit', $this->getButtonName('next'), get_lang('Next').' >>');
@ -117,8 +119,8 @@ class Page_Language extends HTML_QuickForm_Page
* - necessary and optional extensions * - necessary and optional extensions
* - folders which have to be writable * - folders which have to be writable
*/ */
class Page_Requirements extends HTML_QuickForm_Page class Page_Requirements extends HTML_QuickForm_Page {
{
/** /**
* this function checks if a php extension exists or not * this function checks if a php extension exists or not
* *
@ -126,55 +128,45 @@ class Page_Requirements extends HTML_QuickForm_Page
* @param boolean $echoWhenOk true => show ok when the extension exists * @param boolean $echoWhenOk true => show ok when the extension exists
* @author Christophe Gesché * @author Christophe Gesché
*/ */
function check_extension($extentionName) function check_extension($extentionName) {
{ if (extension_loaded($extentionName)) {
if (extension_loaded($extentionName))
{
return '<li>'.$extentionName.' - ok</li>'; return '<li>'.$extentionName.' - ok</li>';
} } else {
else
{
return '<li><strong>'.$extentionName.'</strong> <font color="red">is missing (Dokeos can work without)</font> (<a href="http://www.php.net/'.$extentionName.'" target="_blank">'.$extentionName.'</a>)</li>'; return '<li><strong>'.$extentionName.'</strong> <font color="red">is missing (Dokeos can work without)</font> (<a href="http://www.php.net/'.$extentionName.'" target="_blank">'.$extentionName.'</a>)</li>';
} }
} }
function get_not_writable_folders()
{ function get_not_writable_folders() {
$writable_folders = array('../inc/conf', '../upload', '../../archive', '../../courses', '../../home'); $writable_folders = array('../inc/conf', '../upload', '../../archive', '../../courses', '../../home');
$not_writable = array(); $not_writable = array();
$perm = api_get_setting('permissions_for_new_directories'); $perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm) ? $perm : '0770'); $perm = octdec(!empty($perm) ? $perm : '0770');
foreach ($writable_folders as $index => $folder) foreach ($writable_folders as $index => $folder) {
{ if (!is_writable($folder) && !@ chmod($folder, $perm)) {
if (!is_writable($folder) && !@ chmod($folder, $perm))
{
$not_writable[] = $folder; $not_writable[] = $folder;
} }
} }
return $not_writable; return $not_writable;
} }
function get_title()
{ function get_title() {
return get_lang("Requirements"); return get_lang("Requirements");
} }
function get_info()
{ function get_info() {
$not_writable = $this->get_not_writable_folders(); $not_writable = $this->get_not_writable_folders();
if (count($not_writable) > 0) if (count($not_writable) > 0) {
{
$info[] = '<div style="margin:20px;padding:10px;width: 50%;color:#FF6600;border:2px solid #FF6600;">'; $info[] = '<div style="margin:20px;padding:10px;width: 50%;color:#FF6600;border:2px solid #FF6600;">';
$info[] = 'Some files or folders don\'t have writing permission. To be able to install Dokeos you should first change their permissions (using CHMOD). Please read the <a href="../../installation_guide.html" target="blank">installation guide</a>.'; $info[] = 'Some files or folders don\'t have writing permission. To be able to install Dokeos you should first change their permissions (using CHMOD). Please read the <a href="../../installation_guide.html" target="blank">installation guide</a>.';
$info[] = '<ul>'; $info[] = '<ul>';
foreach ($not_writable as $index => $folder) foreach ($not_writable as $index => $folder) {
{
$info[] = '<li>'.$folder.'</li>'; $info[] = '<li>'.$folder.'</li>';
} }
$info[] = '</ul>'; $info[] = '</ul>';
$info[] = '</div>'; $info[] = '</div>';
$this->disableNext = true; $this->disableNext = true;
} } elseif (file_exists('../inc/conf/claro_main.conf.php')) {
elseif (file_exists('../inc/conf/claro_main.conf.php'))
{
$info[] = '<div style="margin:20px;padding:10px;width: 50%;color:#FF6600;border:2px solid #FF6600;text-align:center;">'; $info[] = '<div style="margin:20px;padding:10px;width: 50%;color:#FF6600;border:2px solid #FF6600;text-align:center;">';
$info[] = get_lang("WarningExistingDokeosInstallationDetected"); $info[] = get_lang("WarningExistingDokeosInstallationDetected");
$info[] = '</div>'; $info[] = '</div>';
@ -197,8 +189,8 @@ class Page_Requirements extends HTML_QuickForm_Page
$info[] = get_lang('MoreDetails').", <a href=\"../../installation_guide.html\" target=\"blank\">read the installation guide</a>."; $info[] = get_lang('MoreDetails').", <a href=\"../../installation_guide.html\" target=\"blank\">read the installation guide</a>.";
return implode("\n",$info); return implode("\n",$info);
} }
function buildForm()
{ function buildForm() {
global $updateFromVersion; global $updateFromVersion;
$this->_formBuilt = true; $this->_formBuilt = true;
$this->addElement('radio', 'installation_type', get_lang('InstallType'), get_lang('NewInstall'), 'new'); $this->addElement('radio', 'installation_type', get_lang('InstallType'), get_lang('NewInstall'), 'new');
@ -207,8 +199,7 @@ class Page_Requirements extends HTML_QuickForm_Page
$prevnext[] = & $this->createElement('submit', $this->getButtonName('back'), '<< '.get_lang('Previous')); $prevnext[] = & $this->createElement('submit', $this->getButtonName('back'), '<< '.get_lang('Previous'));
$prevnext[] = & $this->createElement('submit', $this->getButtonName('next'), get_lang('Next').' >>'); $prevnext[] = & $this->createElement('submit', $this->getButtonName('next'), get_lang('Next').' >>');
$not_writable = $this->get_not_writable_folders(); $not_writable = $this->get_not_writable_folders();
if (count($not_writable) > 0) if (count($not_writable) > 0) {
{
$el = $prevnext[1]; $el = $prevnext[1];
$el->updateAttributes('disabled="disabled"'); $el->updateAttributes('disabled="disabled"');
} }
@ -220,18 +211,17 @@ class Page_Requirements extends HTML_QuickForm_Page
/** /**
* Page in the install wizard to select the location of the old Dokeos installation. * Page in the install wizard to select the location of the old Dokeos installation.
*/ */
class Page_LocationOldVersion extends HTML_QuickForm_Page class Page_LocationOldVersion extends HTML_QuickForm_Page {
{
function get_title() function get_title() {
{
return 'Old version root path'; return 'Old version root path';
} }
function get_info()
{ function get_info() {
return 'Give location of your old Dokeos installation '; return 'Give location of your old Dokeos installation ';
} }
function buildForm()
{ function buildForm() {
$this->_formBuilt = true; $this->_formBuilt = true;
$this->addElement('text', 'old_version_path', 'Old version root path'); $this->addElement('text', 'old_version_path', 'Old version root path');
$this->applyFilter('old_version_path', 'trim'); $this->applyFilter('old_version_path', 'trim');
@ -248,18 +238,16 @@ class Page_LocationOldVersion extends HTML_QuickForm_Page
* Class for license page * Class for license page
* Displays the GNU GPL license that has to be accepted to install Dokeos. * Displays the GNU GPL license that has to be accepted to install Dokeos.
*/ */
class Page_License extends HTML_QuickForm_Page class Page_License extends HTML_QuickForm_Page {
{ function get_title() {
function get_title()
{
return get_lang('Licence'); return get_lang('Licence');
} }
function get_info()
{ function get_info() {
return get_lang('DokeosLicenseInfo'); return get_lang('DokeosLicenseInfo');
} }
function buildForm()
{ function buildForm() {
$this->_formBuilt = true; $this->_formBuilt = true;
$this->addElement('textarea', 'license', get_lang('Licence'), array ('cols' => 80, 'rows' => 20, 'disabled' => 'disabled', 'style'=>'background-color: white;')); $this->addElement('textarea', 'license', get_lang('Licence'), array ('cols' => 80, 'rows' => 20, 'disabled' => 'disabled', 'style'=>'background-color: white;'));
$this->addElement('checkbox','license_accept','',get_lang('IAccept')); $this->addElement('checkbox','license_accept','',get_lang('IAccept'));
@ -277,18 +265,17 @@ class Page_License extends HTML_QuickForm_Page
* regarding the databases - login and password, names, prefixes, single * regarding the databases - login and password, names, prefixes, single
* or multiple databases, tracking or not... * or multiple databases, tracking or not...
*/ */
class Page_DatabaseSettings extends HTML_QuickForm_Page class Page_DatabaseSettings extends HTML_QuickForm_Page {
{
function get_title() function get_title() {
{
return get_lang('DBSetting'); return get_lang('DBSetting');
} }
function get_info()
{ function get_info() {
return get_lang('DBSettingIntro'); return get_lang('DBSettingIntro');
} }
function buildForm()
{ function buildForm() {
$this->_formBuilt = true; $this->_formBuilt = true;
$this->addElement('text', 'database_host', get_lang("DBHost"), array ('size' => '40')); $this->addElement('text', 'database_host', get_lang("DBHost"), array ('size' => '40'));
$this->addRule('database_host', 'ThisFieldIsRequired', 'required'); $this->addRule('database_host', 'ThisFieldIsRequired', 'required');
@ -327,15 +314,14 @@ class Page_DatabaseSettings extends HTML_QuickForm_Page
$this->setDefaultAction('next'); $this->setDefaultAction('next');
} }
} }
class ValidateDatabaseConnection extends HTML_QuickForm_Rule
{ class ValidateDatabaseConnection extends HTML_QuickForm_Rule {
public function validate($parameters)
{ public function validate($parameters) {
$db_host = $parameters[0]; $db_host = $parameters[0];
$db_user = $parameters[1]; $db_user = $parameters[1];
$db_password = $parameters[2]; $db_password = $parameters[2];
if(mysql_connect($db_host,$db_user,$db_password)) if (mysql_connect($db_host, $db_user, $db_password)) {
{
return true; return true;
} }
return false; return false;
@ -346,18 +332,17 @@ class ValidateDatabaseConnection extends HTML_QuickForm_Rule
* Page in the install wizard in which some config settings are asked to the * Page in the install wizard in which some config settings are asked to the
* user. * user.
*/ */
class Page_ConfigSettings extends HTML_QuickForm_Page class Page_ConfigSettings extends HTML_QuickForm_Page {
{
function get_title() function get_title() {
{
return get_lang('CfgSetting'); return get_lang('CfgSetting');
} }
function get_info()
{ function get_info() {
return get_lang('ConfigSettingsInfo'); return get_lang('ConfigSettingsInfo');
} }
function buildForm()
{ function buildForm() {
$this->_formBuilt = true; $this->_formBuilt = true;
$languages = array (); $languages = array ();
$languages['dutch'] = 'dutch'; $languages['dutch'] = 'dutch';
@ -402,21 +387,19 @@ class Page_ConfigSettings extends HTML_QuickForm_Page
* Page in the install wizard in which a final overview of all settings is * Page in the install wizard in which a final overview of all settings is
* displayed. * displayed.
*/ */
class Page_ConfirmSettings extends HTML_QuickForm_Page class Page_ConfirmSettings extends HTML_QuickForm_Page {
{
function get_title() function get_title() {
{
return get_lang('LastCheck'); return get_lang('LastCheck');
} }
function get_info()
{ function get_info() {
return 'Here are the values you entered return 'Here are the values you entered
<br /> <br />
<strong>Print this page to remember your password and other settings</strong>'; <strong>Print this page to remember your password and other settings</strong>';
} }
function buildForm()
{ function buildForm() {
$wizard = $this->controller; $wizard = $this->controller;
$values = $wizard->exportValues(); $values = $wizard->exportValues();
$this->addElement('static', 'confirm_platform_language', get_lang("MainLang"), $values['platform_language']); $this->addElement('static', 'confirm_platform_language', get_lang("MainLang"), $values['platform_language']);
@ -441,14 +424,13 @@ class Page_ConfirmSettings extends HTML_QuickForm_Page
/** /**
* Class to render a page in the install wizard. * Class to render a page in the install wizard.
*/ */
class ActionDisplay extends HTML_QuickForm_Action_Display class ActionDisplay extends HTML_QuickForm_Action_Display {
{
/** /**
* Displays the HTML-code of a page in the wizard * Displays the HTML-code of a page in the wizard
* @param HTML_Quickform_Page $page The page to display. * @param HTML_Quickform_Page $page The page to display.
*/ */
function _renderForm(& $current_page) function _renderForm(& $current_page) {
{
global $charset; global $charset;
global $dokeos_version, $installType, $updateFromVersion; global $dokeos_version, $installType, $updateFromVersion;
@ -481,16 +463,12 @@ class ActionDisplay extends HTML_QuickForm_Action_Display
$current_page_number = 0; $current_page_number = 0;
$page_number = 0; $page_number = 0;
echo '<ol>'; echo '<ol>';
foreach($all_pages as $index => $page) foreach($all_pages as $index => $page) {
{
$page_number++; $page_number++;
if($page->get_title() == $current_page->get_title()) if ($page->get_title() == $current_page->get_title()) {
{
$current_page_number = $page_number; $current_page_number = $page_number;
echo '<li style="font-weight: bold;">'.$page->get_title().'</li>'; echo '<li style="font-weight: bold;">'.$page->get_title().'</li>';
} } else {
else
{
echo '<li>'.$page->get_title().'</li>'; echo '<li>'.$page->get_title().'</li>';
} }
} }
@ -519,10 +497,10 @@ class ActionDisplay extends HTML_QuickForm_Action_Display
* Here happens the actual installation action after collecting * Here happens the actual installation action after collecting
* all the required data. * all the required data.
*/ */
class ActionProcess extends HTML_QuickForm_Action class ActionProcess extends HTML_QuickForm_Action {
{
function perform(& $page, $actionName) function perform(& $page, $actionName) {
{
global $charset; global $charset;
global $dokeos_version, $installType, $updateFromVersion; global $dokeos_version, $installType, $updateFromVersion;
@ -584,8 +562,7 @@ class ActionProcess extends HTML_QuickForm_Action
============================================================================== ==============================================================================
*/ */
function display_upgrade_header($text_dir, $dokeos_version, $install_type, $update_from_version) function display_upgrade_header($text_dir, $dokeos_version, $install_type, $update_from_version) {
{
?> ?>
<!DOCTYPE html <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
@ -614,22 +591,20 @@ function display_upgrade_header($text_dir, $dokeos_version, $install_type, $upda
} }
/** /**
* TODO: Copy/paste again. Find an existing function for this job.
* Return a list of language directories. * Return a list of language directories.
* @todo function does not belong here, move to code library, * @todo function does not belong here, move to code library,
* also see infocours.php which contains similar function * also see infocours.php which contains similar function
*/ */
function get_language_folder_list() function get_language_folder_list() {
{
$dirname = dirname(__FILE__).'/../lang'; $dirname = dirname(__FILE__).'/../lang';
if ($dirname[strlen($dirname) - 1] != '/') if ($dirname[strlen($dirname) - 1] != '/')
$dirname .= '/'; $dirname .= '/';
$handle = opendir($dirname); $handle = opendir($dirname);
while ($entries = readdir($handle)) while ($entries = readdir($handle)) {
{
if ($entries == '.' || $entries == '..' || $entries == '.svn') if ($entries == '.' || $entries == '..' || $entries == '.svn')
continue; continue;
if (is_dir($dirname.$entries)) if (is_dir($dirname.$entries)) {
{
$language_list[$entries] = api_ucfirst($entries); $language_list[$entries] = api_ucfirst($entries);
} }
} }
@ -638,9 +613,7 @@ function get_language_folder_list()
return $language_list; return $language_list;
} }
function display_installation_overview() {
function display_installation_overview()
{
echo '<div id="installation_steps">'; echo '<div id="installation_steps">';
echo '<img src="../img/bluelogo.gif" hspace="10" vspace="10" alt="Dokeos logo" />'; echo '<img src="../img/bluelogo.gif" hspace="10" vspace="10" alt="Dokeos logo" />';
echo '<ol>'; echo '<ol>';
@ -659,39 +632,31 @@ function display_installation_overview()
* This function prints class=active_step $current_step=$param * This function prints class=active_step $current_step=$param
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
*/ */
function step_active($this_step) function step_active($this_step) {
{
global $current_active_step; global $current_active_step;
if ($current_active_step == $this_step) if ($current_active_step == $this_step) {
{
return ' class="current_step" '; return ' class="current_step" ';
} }
} }
// Rule to check update path // Rule to check update path
function check_update_path($path) function check_update_path($path) {
{
global $update_from_version; global $update_from_version;
// Make sure path has a trailing / // Make sure path has a trailing /
$path = substr($path, -1) != '/' ? $path.'/' : $path; $path = substr($path, -1) != '/' ? $path.'/' : $path;
// Check the path // Check the path
if (file_exists($path)) if (file_exists($path)) {
{
//search for 1.6.x installation //search for 1.6.x installation
$version = get_installed_version($path, 'platformVersion'); $version = get_installed_version($path, 'platformVersion');
//search for 1.8.x installation //search for 1.8.x installation
//if (! isset($version) || $version == '') //if (! isset($version) || $version == '') {
//{
// $version = get_installed_version($path, 'dokeos_version'); // $version = get_installed_version($path, 'dokeos_version');
//} //}
if (in_array($version, $update_from_version)) if (in_array($version, $update_from_version)) {
{
return true; return true;
} } else {
else
{
return false; return false;
} }
} }
@ -703,16 +668,13 @@ function check_update_path($path)
* the older installation to upgrade by checking the * the older installation to upgrade by checking the
* claroline/inc/installedVersion.inc.php file. * claroline/inc/installedVersion.inc.php file.
*/ */
function get_installed_version($old_installation_path, $parameter) function get_installed_version($old_installation_path, $parameter) {
{ if (file_exists($old_installation_path.'claroline/inc/installedVersion.inc.php')) {
if( file_exists($old_installation_path.'claroline/inc/installedVersion.inc.php') )
{
$version_info_file = 'claroline/inc/installedVersion.inc.php'; $version_info_file = 'claroline/inc/installedVersion.inc.php';
} }
// with include_once inside a function, variables aren't remembered for later use // with include_once inside a function, variables aren't remembered for later use
include($old_installation_path.$version_info_file); include($old_installation_path.$version_info_file);
if (isset($$parameter)) if (isset($$parameter)) {
{
return $$parameter; return $$parameter;
} }
} }
@ -734,77 +696,56 @@ function get_installed_version($old_installation_path, $parameter)
* @return string the value of the parameter * @return string the value of the parameter
* @author Olivier Brouckaert * @author Olivier Brouckaert
*/ */
function get_config_param($param,$path) function get_config_param($param, $path) {
{
global $configFile, $updateFromConfigFile; global $configFile, $updateFromConfigFile;
if (empty ($updateFromConfigFile)) if (empty($updateFromConfigFile)) {
{ if (file_exists($path.'claroline/include/config.inc.php')) {
if (file_exists($path.'claroline/include/config.inc.php'))
{
$updateFromConfigFile = 'claroline/include/config.inc.php'; $updateFromConfigFile = 'claroline/include/config.inc.php';
} } elseif (file_exists($path.'claroline/inc/conf/claro_main.conf.php')) {
elseif (file_exists($path.'claroline/inc/conf/claro_main.conf.php'))
{
$updateFromConfigFile = 'claroline/inc/conf/claro_main.conf.php'; $updateFromConfigFile = 'claroline/inc/conf/claro_main.conf.php';
} } else {
else
{
return; return;
} }
} }
//echo "reading from file $path$updateFromConfigFile, which exists..."; //echo "reading from file $path$updateFromConfigFile, which exists...";
if (is_array($configFile) && isset ($configFile[$param])) if (is_array($configFile) && isset($configFile[$param])) {
{
return $configFile[$param]; return $configFile[$param];
} } elseif (file_exists($path.$updateFromConfigFile)) {
elseif (file_exists($path.$updateFromConfigFile))
{
$configFile = array(); $configFile = array();
$temp = file($path.$updateFromConfigFile); $temp = file($path.$updateFromConfigFile);
$val = ''; $val = '';
foreach ($temp as $enreg) {
foreach ($temp as $enreg) if (strstr($enreg, '=')) {
{
if (strstr($enreg, '='))
{
$enreg = explode('=', $enreg); $enreg = explode('=', $enreg);
if ($enreg[0][0] == '$') if ($enreg[0][0] == '$') {
{
list ($enreg[1]) = explode(' //', $enreg[1]); list ($enreg[1]) = explode(' //', $enreg[1]);
$enreg[0] = trim(str_replace('$', '', $enreg[0])); $enreg[0] = trim(str_replace('$', '', $enreg[0]));
$enreg[1] = str_replace('\"', '"', ereg_replace('(^"|"$)', '', substr(trim($enreg[1]), 0, -1))); $enreg[1] = str_replace('\"', '"', ereg_replace('(^"|"$)', '', substr(trim($enreg[1]), 0, -1)));
if (strtolower($enreg[1]) == 'true') if (strtolower($enreg[1]) == 'true') {
{
$enreg[1] = 1; $enreg[1] = 1;
} }
if (strtolower($enreg[1]) == 'false') if (strtolower($enreg[1]) == 'false') {
{
$enreg[1] = 0; $enreg[1] = 0;
} } else {
else
{
$implode_string = ' '; $implode_string = ' ';
if (!strstr($enreg[1], '." ".') && strstr($enreg[1], '.$')) if (!strstr($enreg[1], '." ".') && strstr($enreg[1], '.$')) {
{
$enreg[1] = str_replace('.$', '." ".$', $enreg[1]); $enreg[1] = str_replace('.$', '." ".$', $enreg[1]);
$implode_string = ''; $implode_string = '';
} }
$tmp = explode('." ".', $enreg[1]); $tmp = explode('." ".', $enreg[1]);
foreach ($tmp as $tmp_key => $tmp_val) foreach ($tmp as $tmp_key => $tmp_val) {
{ if (eregi('^\$[a-z_][a-z0-9_]*$', $tmp_val)) {
if (eregi('^\$[a-z_][a-z0-9_]*$', $tmp_val))
{
$tmp[$tmp_key] = get_config_param(str_replace('$', '', $tmp_val), $path); $tmp[$tmp_key] = get_config_param(str_replace('$', '', $tmp_val), $path);
} }
} }
@ -814,8 +755,7 @@ function get_config_param($param,$path)
$configFile[$enreg[0]] = $enreg[1]; $configFile[$enreg[0]] = $enreg[1];
if ($enreg[0] == $param) if ($enreg[0] == $param) {
{
$val = $enreg[1]; $val = $enreg[1];
} }
} }
@ -845,8 +785,8 @@ $wizard = & new HTML_QuickForm_Controller('regWizard', true);
//$wizard->addPage(new Page_Requirements('page_requirements')); //$wizard->addPage(new Page_Requirements('page_requirements'));
$wizard->addPage(new Page_LocationOldVersion('page_location_old_version')); $wizard->addPage(new Page_LocationOldVersion('page_location_old_version'));
$values = $wizard->exportValues(); $values = $wizard->exportValues();
if( isset($values['old_version_path']) && $values['old_version_path'] != '/var/www/html/old_version/' )
{ if (isset($values['old_version_path']) && $values['old_version_path'] != '/var/www/html/old_version/') {
$path = $values['old_version_path']; $path = $values['old_version_path'];
$defaults['platform_language'] = get_config_param('platformLanguage',$path); $defaults['platform_language'] = get_config_param('platformLanguage',$path);
$defaults['platform_url'] = 'http://'.$_SERVER['HTTP_HOST'].$urlAppendPath.'/'; $defaults['platform_url'] = 'http://'.$_SERVER['HTTP_HOST'].$urlAppendPath.'/';
@ -883,9 +823,7 @@ if( isset($values['old_version_path']) && $values['old_version_path'] != '/var/w
} }
//$defaults['encrypt_password'] = get_config_param('userPasswordCrypted',$path); //$defaults['encrypt_password'] = get_config_param('userPasswordCrypted',$path);
$defaults['self_reg'] = get_config_param('allowSelfReg',$path); $defaults['self_reg'] = get_config_param('allowSelfReg',$path);
} } else {
else
{
//old version path not correct yet //old version path not correct yet
} }
@ -909,10 +847,10 @@ $wizard->addAction('display', new ActionDisplay());
// Set the installation language // Set the installation language
$install_language = $wizard->exportValue('page_language', 'install_language'); $install_language = $wizard->exportValue('page_language', 'install_language');
require_once ('../lang/english/trad4all.inc.php'); require_once '../lang/english/trad4all.inc.php';
require_once ('../lang/english/install.inc.php'); require_once '../lang/english/install.inc.php';
include_once ("../lang/$install_language/trad4all.inc.php"); include_once '../lang/'.$install_language.'/trad4all.inc.php';
include_once ("../lang/$install_language/install.inc.php"); include_once '../lang/'.$install_language.'/install.inc.php';
// Set default platform language to the selected install language // Set default platform language to the selected install language
$defaults['platform_language'] = $install_language; $defaults['platform_language'] = $install_language;
@ -923,11 +861,9 @@ $wizard->run();
// Set the installation language // Set the installation language
$install_language = $wizard->exportValue('page_language', 'install_language'); $install_language = $wizard->exportValue('page_language', 'install_language');
require_once ('../lang/english/trad4all.inc.php'); require_once '../lang/english/trad4all.inc.php';
require_once ('../lang/english/install.inc.php'); require_once '../lang/english/install.inc.php';
include_once ("../lang/$install_language/trad4all.inc.php"); include_once '../lang/'.$install_language.'/trad4all.inc.php');
include_once ("../lang/$install_language/install.inc.php"); include_once '../lang/'.$install_language.'/install.inc.php');
//$values = $wizard->exportValues(); //$values = $wizard->exportValues();
?>

@ -44,8 +44,8 @@
* - migrate-db-1.6.x-1.8.0-pre.sql * - migrate-db-1.6.x-1.8.0-pre.sql
* @todo remove code duplication in this function * @todo remove code duplication in this function
*/ */
function upgrade_16x_to_180($values) function upgrade_16x_to_180($values) {
{
$is_single_database = $values['database_single']; $is_single_database = $values['database_single'];
$main_database = $values['database_main_db']; $main_database = $values['database_main_db'];
$tracking_database = $values['database_tracking']; $tracking_database = $values['database_tracking'];
@ -59,11 +59,9 @@ function upgrade_16x_to_180($values)
//MAIN database section //MAIN database section
//Get the list of queries to upgrade the main database //Get the list of queries to upgrade the main database
$main_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql', 'main'); $main_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql', 'main');
if(count($main_query_list) > 0) if (count($main_query_list) > 0) {
{
mysql_select_db($main_database); mysql_select_db($main_database);
foreach($main_query_list as $this_query) foreach ($main_query_list as $this_query) {
{
mysql_query($this_query); mysql_query($this_query);
} }
} }
@ -71,11 +69,9 @@ function upgrade_16x_to_180($values)
//TRACKING database section //TRACKING database section
//Get the list of queries to upgrade the statistics/tracking database //Get the list of queries to upgrade the statistics/tracking database
$tracking_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql', 'stats'); $tracking_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql', 'stats');
if(count($tracking_query_list) > 0) if (count($tracking_query_list) > 0) {
{
mysql_select_db($tracking_database); mysql_select_db($tracking_database);
foreach($tracking_query_list as $this_query) foreach ($tracking_query_list as $this_query) {
{
mysql_query($this_query); mysql_query($this_query);
} }
} }
@ -83,11 +79,9 @@ function upgrade_16x_to_180($values)
//USER database section //USER database section
//Get the list of queries to upgrade the user database //Get the list of queries to upgrade the user database
$user_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql', 'user'); $user_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql', 'user');
if(count($user_query_list) > 0) if (count($user_query_list) > 0) {
{
mysql_select_db($user_database); mysql_select_db($user_database);
foreach($user_query_list as $this_query) foreach ($user_query_list as $this_query) {
{
mysql_query($this_query); mysql_query($this_query);
} }
} }
@ -98,14 +92,12 @@ function upgrade_16x_to_180($values)
*/ */
$prefix = ''; $prefix = '';
global $singleDbForm, $_configuration; global $singleDbForm, $_configuration;
if ($singleDbForm) if ($singleDbForm) {
{
$prefix = $_configuration['table_prefix']; $prefix = $_configuration['table_prefix'];
} }
//get the course databases queries list (c_q_list) //get the course databases queries list (c_q_list)
$course_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql', 'course'); $course_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql', 'course');
if(count($course_query_list) > 0) if (count($course_query_list) > 0) {
{
//upgrade course databases //upgrade course databases
} }
@ -120,63 +112,50 @@ function upgrade_16x_to_180($values)
UPGRADES TO GENERAL DATABASES after course upgrades UPGRADES TO GENERAL DATABASES after course upgrades
*/ */
$main_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-post.sql', 'main'); $main_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-post.sql', 'main');
if(count($main_query_list) > 0) if (count($main_query_list) > 0) {
{
mysql_select_db($main_database); mysql_select_db($main_database);
foreach($main_query_list as $this_query) foreach ($main_query_list as $this_query) {
{
mysql_query($this_query); mysql_query($this_query);
} }
} }
$tracking_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-post.sql', 'stats'); $tracking_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-post.sql', 'stats');
$tracking_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql', 'stats'); $tracking_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql', 'stats');
if(count($tracking_query_list) > 0) if (count($tracking_query_list) > 0) {
{
mysql_select_db($tracking_database); mysql_select_db($tracking_database);
foreach($tracking_query_list as $this_query) foreach ($tracking_query_list as $this_query) {
{
mysql_query($this_query); mysql_query($this_query);
} }
} }
$user_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-post.sql', 'user'); $user_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-post.sql', 'user');
if(count($user_query_list) > 0) if (count($user_query_list) > 0) {
{
mysql_select_db($user_database); mysql_select_db($user_database);
foreach($user_query_list as $this_query) foreach ($user_query_list as $this_query) {
{
mysql_query($this_query); mysql_query($this_query);
} }
} }
$prefix = ''; $prefix = '';
if ($singleDbForm) if ($singleDbForm) {
{
$prefix = $_configuration['table_prefix']; $prefix = $_configuration['table_prefix'];
} }
//get the course databases queries list (c_q_list) //get the course databases queries list (c_q_list)
$course_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql', 'course'); $course_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql', 'course');
if(count($course_query_list) > 0) if (count($course_query_list) > 0) {
{
//upgrade course databases //upgrade course databases
mysql_select_db($main_database); mysql_select_db($main_database);
$sql_result = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL"); $sql_result = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
if(mysql_num_rows($sql_result) > 0) if (mysql_num_rows($sql_result) > 0) {
{ while ($row = mysql_fetch_array($sql_result)) {
while($row = mysql_fetch_array($sql_result))
{
$course_list[] = $row; $course_list[] = $row;
} }
//for each course in the course list... //for each course in the course list...
foreach($course_list as $this_course) foreach ($course_list as $this_course) {
{
mysql_select_db($this_course['db_name']); mysql_select_db($this_course['db_name']);
//... execute the list of course update queries //... execute the list of course update queries
foreach($course_query_list as $this_query) foreach ($course_query_list as $this_query) {
{ if ($is_single_database) { //otherwise just use the main one
if ($is_single_database) //otherwise just use the main one
{
$query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/', "$1 $prefix$2$3", $query); $query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/', "$1 $prefix$2$3", $query);
} }
mysql_query($this_query); mysql_query($this_query);
@ -193,14 +172,10 @@ function upgrade_16x_to_180($values)
* - update-db-1.8.0-1.8.2.inc.php * - update-db-1.8.0-1.8.2.inc.php
* - migrate-db-1.8.0-1.8.2-pre.sql * - migrate-db-1.8.0-1.8.2-pre.sql
*/ */
function upgrade_180_to_182($values) function upgrade_180_to_182($values) {
{
} }
function upgrade_182_to_183($values) function upgrade_182_to_183($values) {
{
//no database/file structure changes needed? //no database/file structure changes needed?
} }
?>
Loading…
Cancel
Save