//echo "<pre>Replacing ".$row_i['intro_text']."\n by \n ".$intro."</pre><br/>\n";
$sql_upd = "update $tbl_intro set intro_text = '".mysql_real_escape_string($intro)."' WHERE id = 'course_homepage' AND intro_text = '".mysql_real_escape_string($row_i['intro_text'])."'";
$sql_upd = "update $tbl_intro set intro_text = '".Database::escape_string($intro)."' WHERE id = 'course_homepage' AND intro_text = '".Database::escape_string($row_i['intro_text'])."'";
//echo $sql_upd."<br/>\n";
fwrite($fh,"$sql_upd\n");
fwrite($fh_revert,"UPDATE $tbl_intro set intro_text = '".$row_i['intro_text']."' WHERE id = 'course_homepage' AND intro_text = '$intro';\n");
@ -618,7 +618,7 @@ $lp_course_code = array();
$scorm_lp_paths = array();
//avoid empty dokeosCourse fields as they potentially break the rest
mysql_select_db($dbNameForm);
Database::select_db($dbNameForm);
$course_main = TABLE_MAIN_COURSE;
$sql_crs = "SELECT * FROM $course_main WHERE target_course_code IS NULL";
//echo "<pre>Replacing ".$row_i['intro_text']."\n by \n ".$intro."</pre><br/>\n";
$sql_upd = "update $tbl_intro set intro_text = '".mysql_real_escape_string($intro)."' WHERE id = 'course_homepage' AND intro_text = '".mysql_real_escape_string($row_i['intro_text'])."'";
$sql_upd = "update $tbl_intro set intro_text = '".Database::escape_string($intro)."' WHERE id = 'course_homepage' AND intro_text = '".Database::escape_string($row_i['intro_text'])."'";
//echo $sql_upd."<br/>\n";
fwrite($fh, $sql_upd."\n");
fwrite($fh_revert, "UPDATE $tbl_intro set intro_text = '".$row_i['intro_text']."' WHERE id = 'course_homepage' AND intro_text = '$intro';\n");
@ -358,7 +359,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE'))
}
$coursePath[$course_code] = $directory;
$courseDB[$course_code] = $mysql_base_course;
$courseDB[$course_code] = $db_base_course;
include ("../lang/english/create_course.inc.php");
@ -372,11 +373,11 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE'))
// Set item-properties of dropbox files
/*
$sql = "SELECT * FROM `$mysql_base_course".$_configuration['db_glue']."dropbox_file` f, `".$_configuration['db_glue']."_base_course".$_configuration['db_glue']."dropbox_post` p WHERE f.id = p.file_id";
$res = mysql_query($sql);
while ($obj = mysql_fetch_object($res))
$sql = "SELECT * FROM `$db_base_course".$_configuration['db_glue']."dropbox_file` f, `".$_configuration['db_glue']."_base_course".$_configuration['db_glue']."dropbox_post` p WHERE f.id = p.file_id";
$res = Database::query($sql);
while ($obj = Database::fetch_object($res))
{
$sql = "INSERT INTO `$mysql_base_course".$_configuration['db_glue']."item_property` SET ";
$sql = "INSERT INTO `$db_base_course".$_configuration['db_glue']."item_property` SET ";
@ -94,31 +94,31 @@ function fill_document_table($dir)
$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 = Database::query("SELECT id,visibility FROM `$db_base_course".$_configuration['db_glue']."document` WHERE path='".addslashes($path)."' LIMIT 0,1");
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)."'");
if (list ($id, $visibility) = Database::fetch_row($result)) {
Database::query("UPDATE `$db_base_course".$_configuration['db_glue']."document` SET filetype='file',title='".addslashes($readdir)."',size='$file_size' WHERE id='$id' AND path='".addslashes($path)."'");
} else {
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();
Database::query("INSERT INTO `$db_base_course".$_configuration['db_glue']."document`(path,filetype,title,size) VALUES('".addslashes($path)."','file','".addslashes($readdir)."','$file_size')");
$id =Database::insert_id();
}
$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."')");
Database::query("INSERT INTO `$db_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)) {
$result = mysql_query("SELECT id,visibility FROM `$mysql_base_course".$_configuration['db_glue']."document` WHERE path='".addslashes($path)."' LIMIT 0,1");
$result = Database::query("SELECT id,visibility FROM `$db_base_course".$_configuration['db_glue']."document` WHERE path='".addslashes($path)."' LIMIT 0,1");
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)."'");
if (list ($id, $visibility) = Database::fetch_row($result)) {
Database::query("UPDATE `$db_base_course".$_configuration['db_glue']."document` SET filetype='folder',title='".addslashes($readdir)."' WHERE id='$id' AND path='".addslashes($path)."'");
} else {
mysql_query("INSERT INTO `$mysql_base_course".$_configuration['db_glue']."document`(path,filetype,title) VALUES('".addslashes($path)."','folder','".addslashes($readdir)."')");
$id = mysql_insert_id();
Database::query("INSERT INTO `$db_base_course".$_configuration['db_glue']."document`(path,filetype,title) VALUES('".addslashes($path)."','folder','".addslashes($readdir)."')");
$id = Database::insert_id();
}
$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."')");
Database::query("INSERT INTO `$db_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)) {
return false;
@ -146,7 +146,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
mysql_query("ALTER TABLE `$mysql_base_course".$_configuration['db_glue']."document` DROP `visibility`");
Database::query("ALTER TABLE `$db_base_course".$_configuration['db_glue']."document` DROP `visibility`");
// Update item_properties of group documents
$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);
$sql = "SELECT d.id AS doc_id, g.id AS group_id FROM `$db_base_course".$_configuration['db_glue']."group_info` g,`$db_base_course".$_configuration['db_glue']."document` d WHERE path LIKE CONCAT(g.secret_directory,'%')";
$res = Database::query($sql);
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."'";
mysql_query($sql);
while ($group_doc = Database::fetch_object($res)) {
$sql = "UPDATE `$db_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."'";