$course) { $mysql_base_course = $courseDB[$key]; @ unlink($oldPath.$course.'/document/.htaccess'); @ unlink($oldPath.$course.'/group/index.php'); if ($fp = @ fopen($oldPath.$course.'/group/index.php', 'w')) { fputs($fp, ''); fclose($fp); } @ unlink($oldPath.$course.'/index.php'); if ($fp = @ fopen($oldPath.$course.'/index.php', 'w')) { fputs($fp, ''); fclose($fp); } @ mkdir($oldPath.$course.'/temp', $perm); @ chmod($oldPath.$course.'/temp', $perm); @ rename($oldPath.$course, $newPath.'courses/'.$course); // Move group documents to document folder of the course $group_dir = $newPath.'courses/'.$course.'/group'; if ($dir = @ opendir($group_dir)) { while (($entry = readdir($dir)) !== false) { if ($entry != '.' && $entry != '..' && is_dir($group_dir.'/'.$entry)) { $from_dir = $group_dir.'/'.$entry; $to_dir = $newPath.'courses/'.$course.'/document/'.$entry; @ rename($from_dir, $to_dir); } } closedir($dir); } fill_document_table($newPath.'courses/'.$course.'/document'); mysql_query("ALTER TABLE `$mysql_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); 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); } } if (defined('DOKEOS_INSTALL')) { // Write the Dokeos config file write_dokeos_config_file($newPath.'main/inc/conf/configuration.php'); // 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 a .htaccess file in the course repository write_courses_htaccess_file($urlAppendPath); require_once ('../inc/lib/fileManage.lib.php'); // First remove the upload/users directory in the new installation removeDir($newPath.'main/upload/users'); // Move the old user images to the new installation @ rename($oldPath.'main/img/users', $newPath.'main/upload/users'); if (!@ rename($oldPath.'main/inc/conf/configuration.php', $oldPath.'main/inc/conf/configuration.php.old')) { unlink($oldPath.'main/inc/conf/configuration.php'); } } } else { echo 'You are not allowed here !'; } ?>