Index: openacs-4/packages/file-storage/tcl/test/file-storage-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/tcl/test/file-storage-procs.tcl,v diff -u -r1.10.2.7 -r1.10.2.8 --- openacs-4/packages/file-storage/tcl/test/file-storage-procs.tcl 31 Mar 2021 09:15:51 -0000 1.10.2.7 +++ openacs-4/packages/file-storage/tcl/test/file-storage-procs.tcl 31 Mar 2021 11:30:23 -0000 1.10.2.8 @@ -361,6 +361,29 @@ file_storage::test::call_fs_page file_storage::test::create_new_folder file_storage::test::add_file_to_folder + file_storage::test::delete_file + + aa_get_first_url + acs::test::find_link + acs::test::follow_link + acs::test::form_reply + acs::test::get_url_from_location + ad_sanitize_filename + content::item::get_id_by_name + fs::add_file + fs::add_version + fs::delete_file + fs::do_notifications + fs::get_folder_contents_count + fs::get_folder_package_and_root + fs::get_item_id + fs::get_object_name + fs::get_parent + fs::get_root_folder + fs::max_upload_size + fs::new_folder + fs_context_bar_list + fs_get_root_folder } \ fs_add_file_to_folder { Index: openacs-4/packages/file-storage/tcl/test/webtest-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/tcl/test/webtest-procs.tcl,v diff -u -r1.1.2.7 -r1.1.2.8 --- openacs-4/packages/file-storage/tcl/test/webtest-procs.tcl 30 Mar 2021 11:19:39 -0000 1.1.2.7 +++ openacs-4/packages/file-storage/tcl/test/webtest-procs.tcl 31 Mar 2021 11:30:23 -0000 1.1.2.8 @@ -104,10 +104,10 @@ -last_request $d \ -form $form \ -update [subst { - upload_file $file_name - upload_file.tmpfile $file_name - title $file_name - description $file_description + upload_file {$file_name} + upload_file.tmpfile {$file_name} + title {$file_name} + description {$file_description} }]] acs::test::reply_has_status_code $d 302 set location [::acs::test::get_url_from_location $d] @@ -141,8 +141,18 @@ aa_log "Download link $href" regsub -all /file-add $href /delete href - set d [acs::test::http -last_request $last_request $href] - + regsub -all file_id= $href object_id= href + aa_log "Delete link $href" + set d [acs::test::http -last_request $last_request? $href] + acs::test::reply_has_status_code $d 200 + # + # Get confirm form + # + set form [acs::test::get_form [dict get $d body] {//form[@id='delete_confirm']}] + aa_true "delete confirm form was returned" {[llength $form] > 2} + set d [::acs::test::form_reply -last_request $d -form $form] + acs::test::reply_has_status_code $d 302 + return $d } @@ -160,7 +170,12 @@ set form [acs::test::get_form [dict get $d body] {//form[@id='folder-delete']}] aa_true "delete form was returned" {[llength $form] > 2} - set d [::acs::test::form_reply -last_request $d -form $form] + set d [::acs::test::form_reply -last_request $d -form $form \ + -update [subst { + formbutton:ok "OK" + __refreshing_p 0 + }]] + acs::test::reply_has_status_code $d 302 return $d } Index: openacs-4/packages/file-storage/www/delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/delete.tcl,v diff -u -r1.10.2.1 -r1.10.2.2 --- openacs-4/packages/file-storage/www/delete.tcl 15 Mar 2019 09:43:08 -0000 1.10.2.1 +++ openacs-4/packages/file-storage/www/delete.tcl 31 Mar 2021 11:30:23 -0000 1.10.2.2 @@ -6,7 +6,6 @@ {return_url:localurl ""} } - set user_id [ad_conn user_id] template::list::create \ @@ -15,12 +14,12 @@ -key fs_object_id \ -no_data "No items selected" \ -elements { - name { - label "\#file-storage.Name\#" - } - delete_message { - label "" - } + name { + label "\#file-storage.Name\#" + } + delete_message { + label "" + } } set allowed_count 0 @@ -32,24 +31,28 @@ ad_script_abort } -set object_id_list [join $object_id "','"] +set F [db_list_of_lists . [subst { + select fs.object_id as fs_object_id, fs.type, fs.name, fs.parent_id, + acs_permission.permission_p(fs.object_id, :user_id, 'delete') as delete_p + from fs_objects fs + where fs.object_id in ([ns_dbquotelist $object_id]) +}]] db_multirow -extend {delete_message} delete_list get_to_be_deleted [subst { select fs.object_id as fs_object_id, fs.type, fs.name, fs.parent_id, acs_permission.permission_p(fs.object_id, :user_id, 'delete') as delete_p from fs_objects fs - where fs.object_id in ('$object_id_list') + where fs.object_id in ([ns_dbquotelist $object_id]) }] { - if {$delete_p} { - set delete_message "" - incr allowed_count - } else { - set delete_message [_ file-storage.Not_Allowed] - incr not_allowed_count - } + if {$delete_p} { + set delete_message "" + incr allowed_count + } else { + set delete_message [_ file-storage.Not_Allowed] + incr not_allowed_count + } +} - } - set total_count [template::multirow size delete_list] set delete_inform [_ file-storage.lt_Do_you_want_to_delete] @@ -73,12 +76,12 @@ default { fs::delete_file \ -item_id $fs_object_id \ - -parent_id $parent_id + -parent_id $parent_id } } - } - } + } + } } ad_returnredirect $return_url ad_script_abort