Index: openacs-4/packages/acs-templating/www/scripts/xinha/attach-file.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/scripts/xinha/attach-file.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-templating/www/scripts/xinha/attach-file.tcl 18 Aug 2006 19:00:07 -0000 1.1 +++ openacs-4/packages/acs-templating/www/scripts/xinha/attach-file.tcl 30 Aug 2006 15:55:16 -0000 1.2 @@ -8,19 +8,16 @@ @cvs-id $Id$ } { {parent_id:integer} - {selector_type "image"} + {selector_type "file"} } -set f_url "" - set user_id [ad_conn user_id] # if user has write permission, create image upload form, if {[permission::permission_p -party_id $user_id -object_id $parent_id \ -privilege "write"]} { set write_p 1 - # FIXME DAVEB i18n for share_options set share_options [list [list "[_ acs-templating.Only_myself]" private] [list "[_ acs-templating.This_Group]" group] [list "[_ acs-templating.Anyone_on_this_system]" site] [list "[_ acs-templating.Anyone_on_the_internet]" public]] ad_form \ -name upload_form \ @@ -29,13 +26,16 @@ -html { enctype multipart/form-data } \ -form { item_id:key + {f_title:text,optional {html {size 50 id f_title} } } {upload_file:file(file) {html {size 30}} } - {share:text(radio),optional {label "[_ acs-templating.This_image_can_be_reused_by]"} {options $share_options} {help_text "[_ acs-templating.This_image_can_be_reused_help]"}} + {share:text(radio),optional {label "[_ acs-templating.This_file_can_be_reused_by]"} {options $share_options} {help_text "[_ acs-templating.This_file_can_be_reused_help]"}} {ok_btn:text(submit) {label "[_ acs-templating.HTMLArea_SelectUploadBtn]"} } } \ -on_request { set share site + set f_title "" + set f_href "" } \ -on_submit { # check file name @@ -64,18 +64,16 @@ if {$mime_type eq ""} { set mime_type [ns_guesstype $file_name] } - if {$selector_type eq "image" \ - && ![string match "image/*" $mime_type]} { - template::form::set_error upload_form upload_file \ - [_ acs-templating.HTMLArea_SelectImageUploadNoImage] - break - } + if {$f_title eq ""} { + element set_value upload_form f_title $file_name + } if {[string match "image/*" $mime_type]} { image::new \ -item_id $item_id \ -name ${item_id}_$file_name \ -parent_id $parent_id \ + -title $f_title \ -tmp_filename $upload_tmpfile \ -creation_user $user_id \ -creation_ip [ad_conn peeraddr] \ @@ -84,6 +82,7 @@ content::item::new \ -item_id $item_id \ -name ${item_id}_$file_name \ + -title $f_title \ -parent_id $parent_id \ -tmp_filename $upload_tmpfile \ -creation_user $user_id \ @@ -124,17 +123,18 @@ } } - if {$share eq "private"} { + if {$share eq "private" && [string match "image/*" $mime_type]} { # need a private URL that allows viewers of this # object to see the image # this isn't totally secure, because of course # you need to be able to see the image somehow # but we only allow read on the image if you can # see the parent object - set f_url "/image/$item_id/private/$file_name" + set f_href "/image/$item_id/private/$file_name" } else { - set f_url "/image/$item_id/$file_name" + set f_href "/o/$item_id/$file_name" } + } } else {