[svn r17901] Logic changes - Implemented file upload in works / assignments into students interface - see FS#3486

skala
Cristian Fasanando 16 years ago
parent 10904dcda2
commit 5aee6eba5c
  1. 7
      main/work/downloadfolder.inc.php
  2. 9
      main/work/work.lib.php

@ -66,6 +66,7 @@ if (is_allowed_to_edit()) {
$querypath=$path;
}
//search for all files that are not deleted => visibility != 2
$query = api_sql_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<>'2'",__FILE__,__LINE__);
//add tem to the zip file
while ($not_deleted_file = mysql_fetch_assoc($query)) { //var_dump($sys_course_path.$_course['path']."/".$not_deleted_file['url']);exit();
@ -84,21 +85,21 @@ else
//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 = api_sql_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' ",__FILE__,__LINE__);
$query = api_sql_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()."'",__FILE__,__LINE__);
//add them to an array
$all_visible_files_path = array();
while ($all_visible_files = mysql_fetch_assoc($query)) {
$all_visible_files_path[] = $all_visible_files['url'];
}
//2nd: get all folders that are invisible in the given path
$query2 = api_sql_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'",__FILE__,__LINE__);
$query2 = api_sql_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()."'",__FILE__,__LINE__);
//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 = mysql_fetch_assoc($query2)) {
//3rd: get all files that are in the found invisible folder (these are "invisible" too)
$query3 = api_sql_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".$invisible_folders['path']."/%' AND work.filetype='file' AND props.visibility='1'",__FILE__,__LINE__);
$query3 = api_sql_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".$invisible_folders['path']."/%' AND work.filetype='file' AND props.visibility='1' AND props.lastedit_user_id='".api_get_user_id()."'",__FILE__,__LINE__);
//add tem to an array
while ($files_in_invisible_folder = mysql_fetch_assoc($query3)) {
$files_in_invisible_folder_path[] = $files_in_invisible_folder['url'];

@ -570,7 +570,7 @@ function display_student_publications_list($work_dir,$sub_course_dir,$currentCou
}
$show_as_icon = get_work_id($mydir); //true or false
if ($show_as_icon && api_is_allowed_to_edit()) {
if ($show_as_icon) {
$row[] = '<a href="'.api_get_self().'?cidReq='.api_get_course_id().'&action=downloadfolder&path=/'.$mydir.'"><img src="../img/zip_save.gif" style="float:right;" alt="'.get_lang('Save').'" title="'.get_lang('Save').'" width="17" height="17"/></a><a href="'.api_get_self().'?'.api_get_cidreq().'&origin='.$origin.'&curdirpath='.$mydir.'"'.$class.'>'.$dir.'</a>'.$add_to_name.'<br>'.$cant_files.' '.$text_file.$dirtext;
} else {
$row[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&origin='.$origin.'&curdirpath='.$mydir.'"'.$class.'>'.$dir.'</a>'.$add_to_name.'<br>'.$cant_files.' '.$text_file.$dirtext;
@ -1256,7 +1256,12 @@ function to_javascript_work() {
*/
function get_work_id($path) {
$TBL_STUDENT_PUBLICATION = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
$sql = "SELECT id FROM $TBL_STUDENT_PUBLICATION WHERE url LIKE 'work/".$path."%'";
$TBL_PROP_TABLE = Database::get_course_table(TABLE_ITEM_PROPERTY);
if (is_allowed_to_edit()) {
$sql = "SELECT 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 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()."'";
}
$result = api_sql_query($sql, __FILE__, __LINE__);
$num_rows = Database::num_rows($result);

Loading…
Cancel
Save