|
|
|
@ -51,50 +51,60 @@ $files = array(); |
|
|
|
|
$course_id = api_get_course_int_id(); |
|
|
|
|
|
|
|
|
|
if (api_is_allowed_to_edit()) { |
|
|
|
|
//Search for all files that are not deleted => visibility != 2 |
|
|
|
|
$sql = "SELECT url, title, insert_user_id, insert_date FROM $tbl_student_publication AS work, $prop_table AS props |
|
|
|
|
WHERE props.c_id = $course_id AND |
|
|
|
|
work.c_id = $course_id AND |
|
|
|
|
props.tool='work' AND |
|
|
|
|
work.id=props.ref AND |
|
|
|
|
//Search for all files that are not deleted => visibility != 2 |
|
|
|
|
$sql = "SELECT url, title, description, insert_user_id, insert_date, contains_file |
|
|
|
|
FROM $tbl_student_publication AS work INNER JOIN $prop_table AS props |
|
|
|
|
ON (props.c_id = $course_id AND |
|
|
|
|
work.c_id = $course_id AND |
|
|
|
|
work.id = props.ref) |
|
|
|
|
WHERE props.tool='work' AND |
|
|
|
|
work.parent_id = $work_id AND |
|
|
|
|
work.filetype='file' AND |
|
|
|
|
props.visibility<>'2' |
|
|
|
|
AND url != ''"; |
|
|
|
|
$query = Database::query($sql); |
|
|
|
|
//add tem to the zip file |
|
|
|
|
while ($not_deleted_file = Database::fetch_assoc($query)) { |
|
|
|
|
if (file_exists($sys_course_path.$_course['path'].'/'.$not_deleted_file['url'])) { |
|
|
|
|
$user_info = api_get_user_info($not_deleted_file['insert_user_id']); |
|
|
|
|
$insert_date = api_get_local_time($not_deleted_file['insert_date']); |
|
|
|
|
$insert_date = str_replace(array(':','-', ' '), '_', $insert_date); |
|
|
|
|
$files[basename($not_deleted_file['url'])] = $insert_date.'_'.$user_info['username'].'_'.basename($not_deleted_file['title']); |
|
|
|
|
$zip_folder->add($sys_course_path.$_course['path'].'/'.$not_deleted_file['url'], PCLZIP_OPT_REMOVE_PATH, $sys_course_path.$_course['path'].'/work', PCLZIP_CB_PRE_ADD, 'my_pre_add_callback'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
work.filetype = 'file' AND |
|
|
|
|
props.visibility<>'2' "; |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
//for other users, we need to create a zipfile with only visible files and folders |
|
|
|
|
$sql = "SELECT url, title, insert_date FROM $tbl_student_publication AS work, $prop_table AS props |
|
|
|
|
WHERE props.c_id = $course_id AND work.c_id = $course_id AND |
|
|
|
|
$sql = "SELECT url, title, description, insert_user_id, insert_date, contains_file |
|
|
|
|
FROM $tbl_student_publication AS work INNER JOIN $prop_table AS props |
|
|
|
|
ON (props.c_id = $course_id AND |
|
|
|
|
work.c_id = $course_id AND |
|
|
|
|
work.id = props.ref) |
|
|
|
|
WHERE |
|
|
|
|
props.tool='work' AND |
|
|
|
|
work.accepted = 1 AND |
|
|
|
|
work.id=props.ref AND |
|
|
|
|
work.parent_id = $work_id AND |
|
|
|
|
work.filetype='file' AND |
|
|
|
|
props.visibility = '1' AND |
|
|
|
|
props.insert_user_id='".api_get_user_id()."' AND |
|
|
|
|
url != ''"; |
|
|
|
|
$query = Database::query($sql); |
|
|
|
|
//add tem to the zip file |
|
|
|
|
while ($not_deleted_file = Database::fetch_assoc($query)) { |
|
|
|
|
if (file_exists($sys_course_path.$_course['path'].'/'.$not_deleted_file['url'])) { |
|
|
|
|
$insert_date = api_get_local_time($not_deleted_file['insert_date']); |
|
|
|
|
$insert_date = str_replace(array(':','-', ' '), '_', $insert_date); |
|
|
|
|
$files[basename($not_deleted_file['url'])] = $insert_date.'_'.$not_deleted_file['title']; |
|
|
|
|
$zip_folder->add($sys_course_path.$_course['path'].'/'.$not_deleted_file['url'], PCLZIP_OPT_REMOVE_PATH, $sys_course_path.$_course['path'].'/work', PCLZIP_CB_PRE_ADD, 'my_pre_add_callback'); |
|
|
|
|
} |
|
|
|
|
props.visibility = '1' AND |
|
|
|
|
props.insert_user_id='".api_get_user_id()."' |
|
|
|
|
"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$query = Database::query($sql); |
|
|
|
|
|
|
|
|
|
//add tem to the zip file |
|
|
|
|
while ($not_deleted_file = Database::fetch_assoc($query)) { |
|
|
|
|
|
|
|
|
|
$user_info = api_get_user_info($not_deleted_file['insert_user_id']); |
|
|
|
|
$insert_date = api_get_local_time($not_deleted_file['insert_date']); |
|
|
|
|
$insert_date = str_replace(array(':','-', ' '), '_', $insert_date); |
|
|
|
|
$filename = $insert_date.'_'.$user_info['username'].'_'.basename($not_deleted_file['title']); |
|
|
|
|
|
|
|
|
|
if (file_exists($sys_course_path.$_course['path'].'/'.$not_deleted_file['url']) && !empty($not_deleted_file['url'])) { |
|
|
|
|
$files[basename($not_deleted_file['url'])] = $filename; |
|
|
|
|
$zip_folder->add($sys_course_path.$_course['path'].'/'.$not_deleted_file['url'], PCLZIP_OPT_REMOVE_PATH, $sys_course_path.$_course['path'].'/work', PCLZIP_CB_PRE_ADD, 'my_pre_add_callback'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//Convert texts in html files |
|
|
|
|
if ($not_deleted_file['contains_file'] == 0) { |
|
|
|
|
$filename = trim($filename).".html"; |
|
|
|
|
$work_temp = api_get_path(SYS_ARCHIVE_PATH).api_get_unique_id().'_'.$filename; |
|
|
|
|
file_put_contents($work_temp, $not_deleted_file['description']); |
|
|
|
|
$files[basename($work_temp)] = $filename; |
|
|
|
|
$zip_folder->add($work_temp, PCLZIP_OPT_REMOVE_PATH, api_get_path(SYS_ARCHIVE_PATH), PCLZIP_CB_PRE_ADD, 'my_pre_add_callback'); |
|
|
|
|
@unlink($work_temp); |
|
|
|
|
} |
|
|
|
|
}//end for other users |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!empty($files)) { |
|
|
|
|
//logging |
|
|
|
|