Fixing pclzip calls using /archive instead of courses/XXX/temp folder, also removing some useless code in dropbox and fixing/improving code that generates the zip, fixing the layout of the course copy, adding documentation, setting some functions to deprecated, changing icon of LP export to a CD common icon in all platorm
$querypath = ''; // To prevent ...path LIKE '//%'... in query
} else {
$querypath = $path;
}
$querypath = Database::escape_string($querypath);
// Search for all files that are not deleted => visibility != 2
$query = Database::query("SELECT path FROM $doc_table AS docs,$prop_table AS props WHERE props.tool='".TOOL_DOCUMENT."' AND docs.id=props.ref AND docs.path LIKE '".$querypath."/%' AND docs.filetype='file' AND props.visibility<>'2' AND props.to_group_id=".$to_group_id."");
$query = Database::query("SELECT path FROM $doc_table AS docs,$prop_table AS props
WHERE props.tool='".TOOL_DOCUMENT."' AND docs.id=props.ref AND docs.path LIKE '".$querypath."/%' AND docs.filetype='file' AND props.visibility<>'2' AND props.to_group_id=".$to_group_id."");
// Add tem to the zip file
while ($not_deleted_file = Database::fetch_assoc($query)) {
// For other users, we need to create a zipfile with only visible files and folders
else {
} else {
// For other users, we need to create a zipfile with only visible files and folders
if ($path == '/') {
$querypath = ''; // To prevent ...path LIKE '//%'... in query
} else {
@ -95,7 +74,9 @@ else {
// A big problem: Visible files that are in a hidden folder are included when we do a query for visiblity='v'
// So... I do it in a couple of steps:
// 1st: Get all files that are visible in the given path
$query = Database::query("SELECT path FROM $doc_table AS docs,$prop_table AS props WHERE props.tool='".TOOL_DOCUMENT."' AND docs.id=props.ref AND docs.path LIKE '".$querypath."/%' AND props.visibility='1' AND docs.filetype='file' AND props.to_group_id=".$to_group_id);
$querypath = Database::escape_string($querypath);
$query = Database::query("SELECT path FROM $doc_table AS docs,$prop_table AS props
WHERE props.tool='".TOOL_DOCUMENT."' AND docs.id=props.ref AND docs.path LIKE '".$querypath."/%' AND props.visibility='1' AND docs.filetype='file' AND props.to_group_id=".$to_group_id);
// Add them to an array
while ($all_visible_files = Database::fetch_assoc($query)) {
// 2nd: Get all folders that are invisible in the given path
$query2 = Database::query("SELECT path FROM $doc_table AS docs,$prop_table AS props WHERE props.tool='".TOOL_DOCUMENT."' AND docs.id=props.ref AND docs.path LIKE '".$querypath."/%' AND props.visibility<>'1' AND docs.filetype='folder'");
$query2 = Database::query("SELECT path FROM $doc_table AS docs,$prop_table AS props
WHERE props.tool='".TOOL_DOCUMENT."' AND docs.id=props.ref AND docs.path LIKE '".$querypath."/%' AND props.visibility<>'1' AND docs.filetype='folder'");
// If we get invisible folders, we have to filter out these results from all visible files we found
if (Database::num_rows($query2) > 0) {
// Add tem to an array
@ -128,26 +110,25 @@ else {
$files_for_zipfile = $all_visible_files_path;
}
// Add all files in our final array to the zipfile
//echo("path to remove from file ".$sys_course_path.$_course['path']."/document".$remove_dir.'<br>');
@ -1106,114 +1094,6 @@ function my_pre_add_callback($p_event, &$p_header) {
return 1;
}
/**
* This function is an alternative zip download. It was added because PCLZip causes problems on PHP5 when using PCLZIP_CB_PRE_ADD and a callback function to rename
* the files inside the zip file (dropbox scrambles the files to prevent
* @todo consider using a htaccess that denies direct access to the file but only allows the php file to access it. This would remove the scrambling requirement
* but it would require additional checks to see if the filename of the uploaded file is not used yet.
* @param $files is an associative array that contains the files that the user wants to download (check to see if the user is allowed to download these files already
* happened so the array is clean!!. The key is the filename on the filesystem. The value is an array that contains both the filename on the filesystem and
* the original filename (that will be used in the zip file)
* @todo when we copy the files there might be two files with the same name. We need a function that (recursively) checks this and changes the name
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* This functions exports the given path. This is the opener function, which is called first
* @deprecated this function is only called in the newscorm/scorm_admin.php which is deprecated
* @param integer The path id
* @return resource A zip file, containing a hopefully Scorm compliant course made from the LP. This might happen when we don't actually exit the function first :-)
*/
@ -1985,6 +1986,7 @@ function exportpath($learnpath_id) {
// 8. Put the files in the exportdir into a zip and force download.
//for other users, we need to create a zipfile with only visible files and folders
@ -94,7 +71,7 @@ if (api_is_allowed_to_edit()) {
}
//2nd: get all folders that are invisible in the given path
$query2 = Database::query("SELECT url FROM $tbl_student_publication AS work, $prop_table AS props
WHERE props.tool='work' AND work.id=props.ref AND work.url LIKE 'work".$querypath."/%' AND work.filetype='file' AND props.visibility<>'1' AND props.lastedit_user_id='".api_get_user_id()."'");
WHERE props.tool='work' AND work.id=props.ref AND work.url LIKE 'work".$querypath."/%' AND work.filetype='file' AND props.visibility<>'1' AND props.lastedit_user_id='".api_get_user_id()."'");
//if we get invisible folders, we have to filter out these results from all visible files we found
$sql = "SELECT work.id FROM $TBL_STUDENT_PUBLICATION AS work,$TBL_PROP_TABLE AS props WHERE props.tool='work' AND work.id=props.ref AND work.url LIKE 'work/".$path."%' AND work.filetype='file' AND props.visibility<>'2'";
} else {
$sql = "SELECT work.id FROM $TBL_STUDENT_PUBLICATION AS work,$TBL_PROP_TABLE AS props WHERE props.tool='work' AND work.id=props.ref AND work.url LIKE 'work/".$path."%' AND work.filetype='file' AND props.visibility<>'2' AND props.lastedit_user_id='".api_get_user_id()."'";
@ -415,30 +415,6 @@ class TestDropboxFunctions extends UnitTestCase {
}
*/
/**
* This function is an alternative zip download. It was added because PCLZip causes problems on PHP5 when using PCLZIP_CB_PRE_ADD and a callback function to rename
* the files inside the zip file (dropbox scrambles the files to prevent
* @todo consider using a htaccess that denies direct access to the file but only allows the php file to access it. This would remove the scrambling requirement
* but it would require additional checks to see if the filename of the uploaded file is not used yet.
* @param $files is an associative array that contains the files that the user wants to download (check to see if the user is allowed to download these files already
* happened so the array is clean!!. The key is the filename on the filesystem. The value is an array that contains both the filename on the filesystem and
* the original filename (that will be used in the zip file)
* @todo when we copy the files there might be two files with the same name. We need a function that (recursively) checks this and changes the name