@ -65,46 +65,19 @@ if (api_is_allowed_to_edit()) {
$querypath = $path;
}
$querypath = Database::escape_string($querypath);
//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 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()."'");
//add them to an array
$all_visible_files_path = array();
while ($all_visible_files = Database::fetch_assoc($query)) {
//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()."'");
//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
while ($invisible_folders = Database::fetch_assoc($query2)) {
//3rd: get all files that are in the found invisible folder (these are "invisible" too)
$query3 = 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".Database::escape_string($invisible_folders['path'])."/%' AND work.filetype='file' AND props.visibility='1' AND props.lastedit_user_id='".api_get_user_id()."'");
//add tem to an array
while ($files_in_invisible_folder = Database::fetch_assoc($query3)) {
$sql = "SELECT url, title 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 work.url LIKE 'work".$querypath."/%' AND work.filetype='file' AND
props.visibility = '1' AND props.lastedit_user_id='".api_get_user_id()."' ";
$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'])) {
@ -403,10 +402,7 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
( contains_file = 1 AND parent_id = $parent_id )
$contains_file_query
ORDER BY sent_date DESC";
} else {
} else {
if (!empty($_SESSION['toolgroup'])) {
$group_query = " WHERE c_id = $course_id AND post_group_id = '".intval($_SESSION['toolgroup'])."' "; // set to select only messages posted by the user's group
$subdirs_query = "AND parent_id = $parent_id";
@ -423,6 +419,7 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
$sql_select_directory .= " AND prop.c_id = $course_id AND work.c_id = $course_id AND work.url LIKE BINARY '".$mydir_temp."' AND work.filetype = 'folder' AND prop.tool='work' $condition_session";
$result = Database::query($sql_select_directory);
$row = Database::fetch_array($result);
@ -736,6 +734,7 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
}
}
}
$action = '';
$row = array();
$class = '';
@ -745,52 +744,28 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
$cant_files = 0;
$cant_dir = 0;
$course_id = api_get_course_int_id();
$course_id = api_get_course_int_id();
$session_id = api_get_session_id();
if (api_is_allowed_to_edit()) {
$sql_document = "SELECT count(*) FROM $work_table WHERE c_id = $course_id AND parent_id = ".$work_data['id']." AND active IN (0, 1) ";