Index: openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-procs-oracle.xql,v diff -u -r1.1.1.1 -r1.1.1.1.8.1 --- openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-procs-oracle.xql 17 Feb 2003 20:56:15 -0000 1.1.1.1 +++ openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-procs-oracle.xql 30 Aug 2004 16:44:53 -0000 1.1.1.1.8.1 @@ -11,7 +11,7 @@ where exists (select name from cr_items where parent_id = :parent_folder_id - and name = :title) + and name = :encoded_filename) @@ -22,7 +22,7 @@ begin :1 := file_storage.new_file ( item_id => :file_id, - title => :title, + title => :encoded_filename, folder_id => :parent_folder_id, creation_user => :user_id, creation_ip => :creation_ip, @@ -39,7 +39,7 @@ begin :1 := file_storage.new_version ( - filename => :filename, + filename => :title, description => :description, mime_type => :mime_type, item_id => :file_id, Index: openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-procs-postgresql.xql,v diff -u -r1.5 -r1.5.6.1 --- openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-procs-postgresql.xql 6 Nov 2003 13:01:41 -0000 1.5 +++ openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-procs-postgresql.xql 30 Aug 2004 16:44:54 -0000 1.5.6.1 @@ -10,7 +10,7 @@ where exists (select name from cr_items where parent_id = :parent_folder_id - and name = :title) + and name = :encoded_filename) @@ -20,7 +20,7 @@ select file_storage__new_file ( - :title, + :encoded_filename, :parent_folder_id, :user_id, :creation_ip, @@ -36,7 +36,7 @@ select file_storage__new_version ( - :filename, + :title, :description, :mime_type, :file_id, Index: openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-procs.tcl,v diff -u -r1.3.6.1 -r1.3.6.2 --- openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-procs.tcl 6 Aug 2004 19:58:56 -0000 1.3.6.1 +++ openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-procs.tcl 30 Aug 2004 16:44:54 -0000 1.3.6.2 @@ -102,10 +102,25 @@ set homework_user_id $user_id } - set title [encode_name -user_id $homework_user_id $title] + set encoded_filename [encode_name -user_id $homework_user_id $filename] if { [db_0or1row check_duplicate {}]} { - return -code error "[_ dotlrn-homework.lt_file_named]" + + # AG: Make a reasonable attempt at avoiding collisions by + # converting a duplicate filename foo.txt to foo-2.txt, + # foo-3.txt and so on. + set success_p 0 + set saved_filename $encoded_filename + for {set i 2} {$i < 11} {incr i} { + set encoded_filename "[file rootname $saved_filename]-${i}[file extension $saved_filename]" + if { ![db_0or1row check_duplicate {}]} { + set success_p 1 + break + } + } + if { !$success_p } { + return -code error "[_ dotlrn-homework.lt_file_named]" + } } db_exec_plsql new_lob_file {} @@ -145,8 +160,15 @@ } - } + } else { + # When updating we simply query for the title of the live + # revision. The title is used by the new_version query + # below. + set title [db_string live_version_title {}] + + } + # Grab key for new revision set revision_id [db_exec_plsql new_version {}] Index: openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-procs.xql,v diff -u -r1.1.1.1 -r1.1.1.1.8.1 --- openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-procs.xql 17 Feb 2003 20:56:16 -0000 1.1.1.1 +++ openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-procs.xql 30 Aug 2004 16:44:54 -0000 1.1.1.1.8.1 @@ -18,6 +18,17 @@ + + + + select r.title + from cr_revisions r, cr_items i + where i.item_id = :file_id + and i.content_type = 'file_storage_object' + and r.revision_id = i.live_revision + + + Index: openacs-4/packages/dotlrn-homework/www/file-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/file-delete.tcl,v diff -u -r1.2.2.1 -r1.2.2.1.4.1 --- openacs-4/packages/dotlrn-homework/www/file-delete.tcl 26 Nov 2003 11:34:09 -0000 1.2.2.1 +++ openacs-4/packages/dotlrn-homework/www/file-delete.tcl 30 Aug 2004 16:44:55 -0000 1.2.2.1.4.1 @@ -61,10 +61,7 @@ } else { # they need to confirm that they really want to delete the file - db_1row file_name " - select name as title - from cr_items - where item_id = :file_id" + db_1row file_name {} set title [dotlrn_homework::decode_name $title] Index: openacs-4/packages/dotlrn-homework/www/file-move-2-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/file-move-2-oracle.xql,v diff -u -r1.1.1.1 -r1.1.1.1.10.1 --- openacs-4/packages/dotlrn-homework/www/file-move-2-oracle.xql 17 Feb 2003 20:56:16 -0000 1.1.1.1 +++ openacs-4/packages/dotlrn-homework/www/file-move-2-oracle.xql 30 Aug 2004 16:44:55 -0000 1.1.1.1.10.1 @@ -9,7 +9,9 @@ begin file_storage.move_file ( file_id => :file_id, - target_folder_id => :parent_id + target_folder_id => :parent_id, + creation_user => :creation_user, + creation_ip => :creation_ip ); end; @@ -22,7 +24,9 @@ begin file_storage.move_file ( file_id => :correction_file_id, - target_folder_id => :parent_id + target_folder_id => :parent_id, + creation_user => :creation_user, + creation_ip => :creation_ip ); end; Index: openacs-4/packages/dotlrn-homework/www/file-move-2-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/file-move-2-postgresql.xql,v diff -u -r1.2 -r1.2.6.1 --- openacs-4/packages/dotlrn-homework/www/file-move-2-postgresql.xql 29 Jun 2003 18:47:37 -0000 1.2 +++ openacs-4/packages/dotlrn-homework/www/file-move-2-postgresql.xql 30 Aug 2004 16:44:55 -0000 1.2.6.1 @@ -8,7 +8,9 @@ select file_storage__move_file ( :file_id, - :parent_id + :parent_id, + :creation_user, + :creation_ip ); @@ -19,7 +21,9 @@ select file_storage__move_file ( :correction_file_id, - :parent_id + :parent_id, + :creation_user, + :creation_ip ); Index: openacs-4/packages/dotlrn-homework/www/file-move-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/file-move-2.tcl,v diff -u -r1.2 -r1.2.6.1 --- openacs-4/packages/dotlrn-homework/www/file-move-2.tcl 30 Oct 2003 12:21:44 -0000 1.2 +++ openacs-4/packages/dotlrn-homework/www/file-move-2.tcl 30 Aug 2004 16:44:55 -0000 1.2.6.1 @@ -26,6 +26,9 @@ ad_require_permission $file_id write ad_require_permission $parent_id write +set creation_user [ad_conn user_id] +set creation_ip [ns_conn peeraddr] + db_transaction { set correction_file_id [db_string correction_file_id {} -default ""] Index: openacs-4/packages/dotlrn-homework/www/file-move.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/file-move.adp,v diff -u -r1.2 -r1.2.6.1 --- openacs-4/packages/dotlrn-homework/www/file-move.adp 30 Oct 2003 12:21:44 -0000 1.2 +++ openacs-4/packages/dotlrn-homework/www/file-move.adp 30 Aug 2004 16:44:55 -0000 1.2.6.1 @@ -7,7 +7,7 @@
- +

Index: openacs-4/packages/dotlrn-homework/www/file-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/file-oracle.xql,v diff -u -r1.1.1.1.6.1 -r1.1.1.1.6.1.4.1 --- openacs-4/packages/dotlrn-homework/www/file-oracle.xql 3 Apr 2004 02:22:29 -0000 1.1.1.1.6.1 +++ openacs-4/packages/dotlrn-homework/www/file-oracle.xql 30 Aug 2004 16:44:55 -0000 1.1.1.1.6.1.4.1 @@ -7,6 +7,7 @@ select person.name(o.creation_user) as owner, i.name, + r.title, acs_permission.permission_p(:file_id, :user_id, 'write') as write_file_p, acs_permission.permission_p(:file_id, :user_id, 'delete') as delete_p, decode(cir.item_id, null, 'f', 't') as correction_file_p @@ -15,13 +16,15 @@ and i.item_id = o.object_id and r.revision_id = i.live_revision and cir.related_object_id(+) = i.item_id + - select r.title, + select i.name as version_name, + r.title, r.revision_id as version_id, person.name(o.creation_user) as author, r.mime_type as type, Index: openacs-4/packages/dotlrn-homework/www/file-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/file-postgresql.xql,v diff -u -r1.1.1.1.4.1 -r1.1.1.1.4.1.4.1 --- openacs-4/packages/dotlrn-homework/www/file-postgresql.xql 3 Apr 2004 02:22:29 -0000 1.1.1.1.4.1 +++ openacs-4/packages/dotlrn-homework/www/file-postgresql.xql 30 Aug 2004 16:44:55 -0000 1.1.1.1.4.1.4.1 @@ -11,18 +11,21 @@ r.title, acs_permission__permission_p(:file_id,:user_id,'write') as write_file_p, acs_permission__permission_p(:file_id,:user_id,'delete') as delete_p, - i.item_id as correction_file_p - from acs_objects o, cr_revisions r, cr_items i + case when cir.item_id is null then 'f' else 't' end as correction_file_p + from acs_objects o + join cr_items i on (i.item_id = o.object_id) + join cr_revisions r on (r.revision_id = i.live_revision) + left join cr_item_rels cir on + (cir.item_id = o.object_id and cir.relation_tag = 'homework_correction') where o.object_id = :file_id - and i.item_id = o.object_id - and r.revision_id = i.live_revision - select r.title, + select i.name as version_name, + r.title, r.revision_id as version_id, person__name(o.creation_user) as author, r.mime_type as type, Index: openacs-4/packages/dotlrn-homework/www/file.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/file.adp,v diff -u -r1.2.2.3 -r1.2.2.3.4.1 --- openacs-4/packages/dotlrn-homework/www/file.adp 7 Apr 2004 18:33:18 -0000 1.2.2.3 +++ openacs-4/packages/dotlrn-homework/www/file.adp 30 Aug 2004 16:44:55 -0000 1.2.2.3.4.1 @@ -1,5 +1,5 @@ -@name@ +@name@/@title@ @context_bar@

@@ -44,7 +44,7 @@ - @version.title@ + @version.version_name@ @version.author@ @version.content_size@ Index: openacs-4/packages/dotlrn-homework/www/file.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/file.tcl,v diff -u -r1.2.2.2 -r1.2.2.2.4.1 --- openacs-4/packages/dotlrn-homework/www/file.tcl 3 Apr 2004 00:22:06 -0000 1.2.2.2 +++ openacs-4/packages/dotlrn-homework/www/file.tcl 30 Aug 2004 16:44:55 -0000 1.2.2.2.4.1 @@ -45,6 +45,7 @@ db_1row file_info {} set name [dotlrn_homework::decode_name $name] + set version_add_url "version-add?[export_vars {return_url folder_id file_id name}]" set move_url "file-move?[export_vars {file_id name}]" @@ -62,7 +63,9 @@ set action_exists_p 0 db_multirow -extend {download_url} version version_info {} { - set download_url "${file_storage_url}/download/$title?[export_vars {version_id}]" + set version_name [dotlrn_homework::decode_name $version_name] + + set download_url "${file_storage_url}/download/[ns_urlencode $version_name]?[export_vars {version_id}]" if { [string is true $delete_p] } { set action_exists_p 1 } Index: openacs-4/packages/dotlrn-homework/www/folder-chunk-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/folder-chunk-oracle.xql,v diff -u -r1.2.2.1.4.4 -r1.2.2.1.4.5 --- openacs-4/packages/dotlrn-homework/www/folder-chunk-oracle.xql 30 Aug 2004 15:08:52 -0000 1.2.2.1.4.4 +++ openacs-4/packages/dotlrn-homework/www/folder-chunk-oracle.xql 30 Aug 2004 16:44:55 -0000 1.2.2.1.4.5 @@ -12,30 +12,29 @@ fs_tree.content_type, r.content_length, r.title, fs_tree.parent_id as folder_id, - content_item.get_path(o.object_id) as item_path, lpad(' ',(the_level - 1), ' ') as spaces, rels.related_object_id as homework_file_id, - c.first_names || ' ' || c.last_name as file_owner_name, + p.first_names || ' ' || p.last_name as file_owner_name, o.creation_user - from cr_item_rels rels, acs_objects o, cr_revisions r, cr_folders f, acs_users_all c, + from cr_item_rels rels, acs_objects o, cr_revisions r, cr_folders f, persons p, (select cr_items.*, level as the_level from cr_items where level >= :min_level and level <= :max_level start with item_id in ([join $list_of_folder_ids ", "]) connect by parent_id = prior item_id) fs_tree where o.object_id = fs_tree.item_id - and c.user_id(+) = o.creation_user and f.folder_id(+) = fs_tree.item_id - $qualify_by_owner - and r.item_id(+) = fs_tree.item_id + and p.person_id(+) = o.creation_user and r.revision_id(+) = fs_tree.live_revision + and r.item_id(+) = fs_tree.item_id and rels.item_id(+) = o.object_id and rels.relation_tag(+) = 'homework_correction' and not exists (select 1 from cr_item_rels where related_object_id = o.object_id and relation_tag = 'homework_correction') - order by item_path + $qualify_by_owner + order by content_item.get_path(fs_tree.item_id) Index: openacs-4/packages/dotlrn-homework/www/folder-chunk-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/folder-chunk-postgresql.xql,v diff -u -r1.2.2.2 -r1.2.2.2.4.1 --- openacs-4/packages/dotlrn-homework/www/folder-chunk-postgresql.xql 13 Apr 2004 18:46:41 -0000 1.2.2.2 +++ openacs-4/packages/dotlrn-homework/www/folder-chunk-postgresql.xql 30 Aug 2004 16:44:55 -0000 1.2.2.2.4.1 @@ -22,8 +22,8 @@ where cr_items2.item_id in ([join $list_of_folder_ids ", "]) and cr_items.tree_sortkey between cr_items2.tree_sortkey and tree_right(cr_items2.tree_sortkey) - and tree_level(cr_items.tree_sortkey) > :min_level - and tree_level(cr_items.tree_sortkey) <= :max_level + 1) fs_tree + and tree_level(cr_items.tree_sortkey) >= :min_level + 2 + and tree_level(cr_items.tree_sortkey) <= :max_level + 2) fs_tree join acs_objects o on (o.object_id = fs_tree.item_id) left join cr_folders f on (f.folder_id = fs_tree.item_id) left join persons p on (p.person_id = o.creation_user) Index: openacs-4/packages/dotlrn-homework/www/folder-chunk.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/folder-chunk.adp,v diff -u -r1.3.2.1 -r1.3.2.1.4.1 --- openacs-4/packages/dotlrn-homework/www/folder-chunk.adp 3 Apr 2004 00:22:06 -0000 1.3.2.1 +++ openacs-4/packages/dotlrn-homework/www/folder-chunk.adp 30 Aug 2004 16:44:55 -0000 1.3.2.1.4.1 @@ -55,7 +55,7 @@ @folders.spaces;noquote@ - @folders.pretty_name@ + @folders.name@
@folders.title@ @folders.file_owner_name@ Index: openacs-4/packages/dotlrn-homework/www/folder-chunk.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/folder-chunk.tcl,v diff -u -r1.2.2.2 -r1.2.2.2.4.1 --- openacs-4/packages/dotlrn-homework/www/folder-chunk.tcl 13 Apr 2004 18:46:23 -0000 1.2.2.2 +++ openacs-4/packages/dotlrn-homework/www/folder-chunk.tcl 30 Aug 2004 16:44:55 -0000 1.2.2.2.4.1 @@ -76,23 +76,22 @@ set show_users_p 1 } - # Strip off the user_id - set pretty_name [dotlrn_homework::decode_name $name] + # Strip off the user_id + set name [dotlrn_homework::decode_name $name] - # If the user can read the file the user can read the file's details set view_details_url "${url}file?[export_vars {folder_id {file_id $object_id}}]" # And download the latest revision set file_storage_url [dotlrn_homework::get_file_storage_url] - set download_url "${file_storage_url}/download/$title?[export_vars {version_id}]" + set download_url "${file_storage_url}/download/[ns_urlencode $name]?[export_vars {version_id}]" # Admin and students can read correction files but only an admin can add one ... if { ![string equal $homework_file_id ""] } { set view_correction_details_url "${url}file?[export_vars {folder_id {file_id $homework_file_id} {show_all_versions_p "t"}}]" } elseif { $admin_p } { set upload_correction_url \ - "${url}file-add?[export_vars {folder_id return_url {name "$pretty_name - [_ dotlrn-homework.Comments]"} {homework_file_id $object_id}}]" + "${url}file-add?[export_vars {folder_id return_url {name "$title - [_ dotlrn-homework.Comments]"} {homework_file_id $object_id}}]" } } } Index: openacs-4/packages/dotlrn-homework/www/version-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/version-delete.tcl,v diff -u -r1.2.2.1 -r1.2.2.1.4.1 --- openacs-4/packages/dotlrn-homework/www/version-delete.tcl 26 Nov 2003 11:34:09 -0000 1.2.2.1 +++ openacs-4/packages/dotlrn-homework/www/version-delete.tcl 30 Aug 2004 16:44:55 -0000 1.2.2.1.4.1 @@ -70,11 +70,7 @@ } else { # they still need to confirm - db_1row version_name " - select i.name as title,r.title as version_name - from cr_items i,cr_revisions r - where i.item_id = r.item_id - and revision_id = :version_id" + db_1row version_name {} set title [dotlrn_homework::decode_name $title]