Index: openacs-4/packages/attachments/www/attach.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/attachments/www/attach.tcl,v diff -u -r1.7.2.1 -r1.7.2.2 --- openacs-4/packages/attachments/www/attach.tcl 21 Jun 2004 20:10:10 -0000 1.7.2.1 +++ openacs-4/packages/attachments/www/attach.tcl 2 Aug 2004 16:55:37 -0000 1.7.2.2 @@ -17,8 +17,6 @@ # We require the write permission on an object permission::require_permission -object_id $object_id -privilege write -set write_permission_p \ - [permission::permission_p -object_id $folder_id -privilege write] # Give the object a nasty name if it doesn't have a pretty name if {[empty_string_p $pretty_object_name]} { @@ -37,6 +35,9 @@ ad_script_abort } +set write_permission_p \ + [permission::permission_p -object_id $folder_id -privilege write] + # Check permission permission::require_permission -object_id $folder_id -privilege read Index: openacs-4/packages/attachments/www/file-add-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/attachments/www/file-add-2.tcl,v diff -u -r1.4 -r1.4.4.1 --- openacs-4/packages/attachments/www/file-add-2.tcl 17 May 2003 10:13:01 -0000 1.4 +++ openacs-4/packages/attachments/www/file-add-2.tcl 2 Aug 2004 16:55:37 -0000 1.4.4.1 @@ -45,104 +45,34 @@ # Get the ip set creation_ip [ad_conn peeraddr] -set mime_type [cr_filename_to_mime_type -create $upload_file] +set root_folder [attachments::get_root_folder] +set fs_package_id [db_string get_fs_package_id "select package_id from fs_root_folders where folder_id=:root_folder"] -# Get the storage type -set indb_p [ad_parameter "StoreFilesInDatabaseP" -package_id [ad_conn package_id]] - -db_transaction { - - # create the new item - if {$indb_p} { - - set file_id [db_exec_plsql new_lob_file " - begin - :1 := file_storage.new_file ( - title => :title, - folder_id => :folder_id, - creation_user => :user_id, - creation_ip => :creation_ip, - indb_p => 't' - ); - - end;"] - - set version_id [db_exec_plsql new_version " - begin - :1 := file_storage.new_version ( - filename => :filename, - description => :description, - mime_type => :mime_type, - item_id => :file_id, - creation_user => :user_id, - creation_ip => :creation_ip - ); - end;"] - - db_dml lob_content " - update cr_revisions - set content = empty_lob() - where revision_id = :version_id - returning content into :1" -blob_files [list ${upload_file.tmpfile}] - - - # Unfortunately, we can only calculate the file size after the lob is uploaded - db_dml lob_size " - update cr_revisions - set content_length = dbms_lob.getlength(content) - where revision_id = :version_id" - - } else { - - set file_id [db_exec_plsql new_fs_file " - begin - :1 := file_storage.new_file ( - title => :title, - folder_id => :folder_id, - creation_user => :user_id, - creation_ip => :creation_ip, - indb_p => 'f' - ); - end;"] - - - set version_id [db_exec_plsql new_version " - begin - - :1 := file_storage.new_version ( - filename => :filename, - description => :description, - mime_type => :mime_type, - item_id => :file_id, - creation_user => :user_id, - creation_ip => :creation_ip - ); - - end;"] - - set tmp_filename [cr_create_content_file $file_id $version_id ${upload_file.tmpfile}] - set tmp_size [cr_file_size $tmp_filename] - - db_dml fs_content_size " - update cr_revisions - set content = '$tmp_filename', - content_length = $tmp_size - where revision_id = :version_id" - - } - +#db_transaction { + set file_id [db_nextval "acs_object_id_seq"] + fs::add_file \ + -name $upload_file \ + -item_id $file_id \ + -parent_id $folder_id \ + -tmp_filename ${upload_file.tmpfile}\ + -creation_user $user_id \ + -creation_ip $creation_ip \ + -title $title \ + -description $description \ + -package_id $fs_package_id + # attach the file_id attachments::attach -object_id $object_id -attachment_id $file_id -} on_error { +#} on_error { # most likely a duplicate name or a double click - set folder_url index?folder_id?$folder_id - ad_return_complaint 1 "[_ attachments.lt_You_probably_clicked_]" +# set folder_url index?folder_id?$folder_id +# ad_return_complaint 1 "[_ attachments.lt_You_probably_clicked_]" - ad_script_abort -} +# ad_script_abort +#} ad_returnredirect $return_url