Index: openacs-4/packages/file-storage/sql/postgresql/file-storage-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/sql/postgresql/file-storage-drop.sql,v diff -u -r1.8 -r1.8.2.1 --- openacs-4/packages/file-storage/sql/postgresql/file-storage-drop.sql 4 Apr 2002 03:01:06 -0000 1.8 +++ openacs-4/packages/file-storage/sql/postgresql/file-storage-drop.sql 16 Nov 2003 02:05:00 -0000 1.8.2.1 @@ -38,20 +38,28 @@ drop function inline_0(); \i file-storage-views-drop.sql; - -drop function fs_package_items_delete_trig(); drop trigger fs_package_items_delete_trig on fs_root_folders; +drop function fs_package_items_delete_trig(); -drop function fs_root_folder_delete_trig(); drop trigger fs_root_folder_delete_trig on fs_root_folders; +drop function fs_root_folder_delete_trig(); -drop table fs_root_folders; -select drop_package('file_storage'); - --- Remove subtype of content_revision so that site-wide-search --- can distinguish file-storage items in the search results select content_type__drop_type ( 'file_storage_object', -- content_type 'f', -- drop_children_p 'f' -- drop_table_p ); + +-- this content type is created incorrectly tying the file_storage_root_folders +-- table to file_storage_object +-- so we drop these directly + +drop view file_storage_root_foldersi; +drop view file_storage_root_foldersx; + +drop table fs_root_folders; + +select drop_package('file_storage'); + +-- Remove subtype of content_revision so that site-wide-search +-- can distinguish file-storage items in the search results Index: openacs-4/packages/file-storage/sql/postgresql/file-storage-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/sql/postgresql/file-storage-package-create.sql,v diff -u -r1.8.2.7 -r1.8.2.8 --- openacs-4/packages/file-storage/sql/postgresql/file-storage-package-create.sql 15 Nov 2003 18:47:25 -0000 1.8.2.7 +++ openacs-4/packages/file-storage/sql/postgresql/file-storage-package-create.sql 16 Nov 2003 02:05:00 -0000 1.8.2.8 @@ -454,7 +454,7 @@ select title into v_title from cr_revisions, cr_items where revision_id=live_revision - and item_id=get_title__item_id; + and cr_items.item_id=get_title__item_id; end if; end if; Index: openacs-4/packages/file-storage/tcl/file-storage-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/tcl/file-storage-procs-postgresql.xql,v diff -u -r1.29.2.6 -r1.29.2.7 --- openacs-4/packages/file-storage/tcl/file-storage-procs-postgresql.xql 9 Nov 2003 20:56:45 -0000 1.29.2.6 +++ openacs-4/packages/file-storage/tcl/file-storage-procs-postgresql.xql 16 Nov 2003 02:05:00 -0000 1.29.2.7 @@ -157,7 +157,7 @@ - + begin perform acs_object__update_last_modified Index: openacs-4/packages/file-storage/tcl/file-storage-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/tcl/file-storage-procs.tcl,v diff -u -r1.25.2.9 -r1.25.2.10 --- openacs-4/packages/file-storage/tcl/file-storage-procs.tcl 15 Nov 2003 18:47:25 -0000 1.25.2.9 +++ openacs-4/packages/file-storage/tcl/file-storage-procs.tcl 16 Nov 2003 02:05:00 -0000 1.25.2.10 @@ -620,14 +620,11 @@ if {[ad_parameter "StoreFilesInDatabaseP" -package_id $package_id]} { set indbp "t" - set storage_type "lob" } else { set indpb "f" - set storage_type "file" } set mime_type [cr_filename_to_mime_type -create $name] - set tmp_size [file size $tmp_filename] switch [cr_registered_type_for_mime_type $mime_type] { image { set content_type "image" @@ -646,25 +643,63 @@ } } - set revision_id [cr_import_content \ - -item_id $item_id \ - -storage_type $storage_type \ - -creation_user $creation_user \ - -creation_ip $creation_ip \ - -other_type "file_storage_object" \ - -title $title \ - -description $description \ - $parent_id \ - $tmp_filename \ - $tmp_size \ - $mime_type \ - $name] + + set revision_id [fs::add_version \ + -name $name \ + -parent_id $parent_id \ + -tmp_filename $tmp_filename \ + -package_id $package_id \ + -item_id $item_id \ + -creation_user $creation_user \ + -creation_ip $creation_ip \ + -title $title \ + -description $description + ] + } + return $revision_id +} + +ad_proc fs::add_version { + -name + -parent_id + -tmp_filename + -package_id + {-item_id ""} + {-creation_user ""} + {-creation_ip ""} + {-title ""} + {-description ""} + +} { + Create a new version of a file storage item + @returns revision_id +} { + + if {[ad_parameter "StoreFilesInDatabaseP" -package_id $package_id]} { + set storage_type "lob" + } else { + set storage_type "file" + } + + set mime_type [cr_filename_to_mime_type -create $name] + set tmp_size [file size $tmp_filename] + + set revision_id [cr_import_content \ + -item_id $item_id \ + -storage_type $storage_type \ + -creation_user $creation_user \ + -creation_ip $creation_ip \ + -other_type "file_storage_object" \ + -title $title \ + -description $description \ + $parent_id \ + $tmp_filename \ + $tmp_size \ + $mime_type \ + $name] db_dml set_live_revision "" db_exec_plsql update_last_modified "" - } on_error { - error $errmsg - } return $revision_id -} \ No newline at end of file +} Index: openacs-4/packages/file-storage/tcl/file-storage-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/tcl/file-storage-procs.xql,v diff -u -r1.10.2.5 -r1.10.2.6 --- openacs-4/packages/file-storage/tcl/file-storage-procs.xql 9 Nov 2003 20:56:45 -0000 1.10.2.5 +++ openacs-4/packages/file-storage/tcl/file-storage-procs.xql 16 Nov 2003 02:05:00 -0000 1.10.2.6 @@ -125,7 +125,7 @@ - + update cr_items set live_revision=:revision_id where item_id=:item_id Index: openacs-4/packages/file-storage/www/file-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/file-add.tcl,v diff -u -r1.3.2.3 -r1.3.2.4 --- openacs-4/packages/file-storage/www/file-add.tcl 15 Nov 2003 19:48:32 -0000 1.3.2.3 +++ openacs-4/packages/file-storage/www/file-add.tcl 16 Nov 2003 02:05:00 -0000 1.3.2.4 @@ -10,18 +10,17 @@ upload_file:trim,optional upload_file.tmpfile:tmpfile,optional {title ""} - {lock_title_p 0} + {lock_title_p 1} + } -properties { folder_id:onevalue context:onevalue title:onevalue lock_title_p:onevalue } -validate { file_id_or_folder_id { - if {[exists_and_not_null file_id]} { + if {[exists_and_not_null file_id] && ![exists_and_not_null folder_id]} { set folder_id [db_string get_folder_id "" -default ""] - } else { - set folder_id "" } if {![fs_folder_p $folder_id]} { ad_complain "The specified parent folder is not valid." @@ -37,11 +36,21 @@ } set user_id [ad_conn user_id] +set package_id [ad_conn package_id] +# check for write permission on the folder or item -# check for write permission on the folder +permission::require_permission \ + -object_id $folder_id \ + -party_id $user_id \ + -privilege "write" -ad_require_permission $folder_id write - +if {![ad_form_new_p -key file_id]} { + permission::require_permission \ + -object_id $file_id \ + -party_id $user_id \ + -privilege "write" + +} # set templating datasources set context [fs_context_bar_list -final "Add File" $folder_id] @@ -54,11 +63,27 @@ ad_form -html { enctype multipart/form-data } -export { folder_id } -form { file_id:key {upload_file:file {label "Upload File"} {html "size 30"}} - {title:text,optional {label "Title"} {html "size 30"}} +} + +if {$lock_title_p} { + ad_form -extend -form { + {title_display:text(inform) {label "Title"} } + {title:text(hidden) {value $title}} + } +} else { + ad_form -extend -form { + {title:text,optional {label "Title"} {html {size 30}} } + } +} + +ad_form -extend -form { {description:text(textarea),optional {label "Description"} {html "rows 5 cols 35"}} } -select_query_name {get_file} -new_data { + # upload a new file + # if the user choose upload from the folder view + # and the file with the same name already exists + # we create a new revision set name [template::util::file::get_property filename $upload_file] - set package_id [ad_conn package_id] set existing_item_id [fs::get_item_id -name $name -folder_id $folder_id] if {![empty_string_p $existing_item_id]} { # file with the same name already exists @@ -83,6 +108,21 @@ ad_returnredirect "." ad_script_abort +} -edit_data { + + fs::add_version \ + -name [template::util::file::get_property filename $upload_file] \ + -tmp_filename [template::util::file::get_property tmp_filename $upload_file] \ + -item_id $file_id \ + -parent_id $folder_id \ + -creation_user $user_id \ + -creation_ip [ad_conn peeraddr] \ + -title $title \ + -description $description \ + -package_id $package_id + + ad_returnredirect "." + ad_script_abort } ad_return_template \ No newline at end of file Index: openacs-4/packages/file-storage/www/file-add.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/file-add.xql,v diff -u -r1.1.2.1 -r1.1.2.2 --- openacs-4/packages/file-storage/www/file-add.xql 15 Nov 2003 19:48:32 -0000 1.1.2.1 +++ openacs-4/packages/file-storage/www/file-add.xql 16 Nov 2003 02:05:00 -0000 1.1.2.2 @@ -18,7 +18,7 @@ update cr_items set live_revision=:revision_id - where item_id=:item_id + where item_id=:file_id \ No newline at end of file Index: openacs-4/packages/file-storage/www/file-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/file-edit.tcl,v diff -u -r1.3 -r1.3.2.1 --- openacs-4/packages/file-storage/www/file-edit.tcl 5 Sep 2002 09:29:00 -0000 1.3 +++ openacs-4/packages/file-storage/www/file-edit.tcl 16 Nov 2003 02:05:00 -0000 1.3.2.1 @@ -23,6 +23,15 @@ ad_require_permission $file_id write +ad_form -form { + key:item_id + {title:text {label "Title"} {html {size 40}}} + {description:text(textarea) {label "Description"} {html {rows 10 cols 50}} } +} -select_query_name {file_info} -edit_data { + +} + +} db_1row file_info " select name as title from cr_items Index: openacs-4/packages/file-storage/www/folder-chunk.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/folder-chunk.adp,v diff -u -r1.10.2.9 -r1.10.2.10 --- openacs-4/packages/file-storage/www/folder-chunk.adp 28 Mar 2003 13:21:18 -0000 1.10.2.9 +++ openacs-4/packages/file-storage/www/folder-chunk.adp 16 Nov 2003 02:05:00 -0000 1.10.2.10 @@ -18,7 +18,8 @@ folder - @contents.name@ + @contents.name@ new   Index: openacs-4/packages/file-storage/www/version-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/Attic/version-add.tcl,v diff -u -r1.3 -r1.3.2.1 --- openacs-4/packages/file-storage/www/version-add.tcl 5 Sep 2002 09:29:00 -0000 1.3 +++ openacs-4/packages/file-storage/www/version-add.tcl 16 Nov 2003 02:05:00 -0000 1.3.2.1 @@ -24,12 +24,7 @@ # set templating datasources -db_1row file_name " -select title -from cr_revisions -where revision_id = (select live_revision - from cr_items - where item_id = :file_id)" +db_1row file_title "" set context [fs_context_bar_list -final "Upload New Version" $file_id]