Index: openacs-4/packages/acs-content-repository/tcl/item-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/Attic/item-procs.tcl,v diff -u -N -r1.5.2.4 -r1.5.2.5 --- openacs-4/packages/acs-content-repository/tcl/item-procs.tcl 23 Mar 2003 02:01:41 -0000 1.5.2.4 +++ openacs-4/packages/acs-content-repository/tcl/item-procs.tcl 26 May 2003 21:38:27 -0000 1.5.2.5 @@ -264,6 +264,17 @@ return $file_url } +ad_proc -public item::get_type { item_id } { + Returns the content type of the specified item, or empty string + if the item_id is invalid +} { + if { [db_0or1row get_content_type ""] } { + return $content_type + } else { + return "" + } +} + ad_proc item::copy { -item_id:required -target_folder_id:required Index: openacs-4/packages/acs-content-repository/tcl/item-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/Attic/item-procs.xql,v diff -u -N -r1.2 -r1.2.2.1 --- openacs-4/packages/acs-content-repository/tcl/item-procs.xql 13 Aug 2002 04:21:33 -0000 1.2 +++ openacs-4/packages/acs-content-repository/tcl/item-procs.xql 26 May 2003 21:38:27 -0000 1.2.2.1 @@ -1,6 +1,13 @@ + + + select content_type from cr_items + where item_id = :item_id + + + Index: openacs-4/packages/attachments/tcl/attachments-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/attachments/tcl/Attic/attachments-procs-oracle.xql,v diff -u -N -r1.2 -r1.2.2.1 --- openacs-4/packages/attachments/tcl/attachments-procs-oracle.xql 30 Aug 2002 14:44:08 -0000 1.2 +++ openacs-4/packages/attachments/tcl/attachments-procs-oracle.xql 26 May 2003 21:38:58 -0000 1.2.2.1 @@ -4,11 +4,12 @@ - select item_id, - acs_object.name(item_id) - from attachments + select a.item_id, + e.label + from attachments a, cr_extlinks e where object_id = :object_id - and approved_p = 't' + and a.item_id = e.extlink_id + and a.approved_p = 't' Index: openacs-4/packages/attachments/www/go-to-attachment.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/attachments/www/go-to-attachment.tcl,v diff -u -N -r1.2.2.2 -r1.2.2.3 --- openacs-4/packages/attachments/www/go-to-attachment.tcl 20 Mar 2003 22:12:18 -0000 1.2.2.2 +++ openacs-4/packages/attachments/www/go-to-attachment.tcl 26 May 2003 21:39:13 -0000 1.2.2.3 @@ -12,12 +12,13 @@ permission::require_permission -object_id $object_id -privilege read # Get information about attachment -if {![db_0or1row select_attachment_data {}]} { - ad_return_complaint "No such attachment for this object" +set content_type [item::get_type $attachment_id] +if { [string length $content_type] == 0 } { + ad_return_complaint 1 "No such attachment for this object" return } -switch $object_type { +switch $content_type { content_extlink { ad_returnredirect [db_string select_url {}] ad_script_abort @@ -32,7 +33,7 @@ } default { - ad_return_complaint "don't know how to deal with this attachment type" + ad_return_complaint 1 "don't know how to deal with this attachment type" return } } Index: openacs-4/packages/attachments/www/go-to-attachment.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/attachments/www/go-to-attachment.xql,v diff -u -N -r1.1.2.2 -r1.1.2.3 --- openacs-4/packages/attachments/www/go-to-attachment.xql 20 Mar 2003 22:12:18 -0000 1.1.2.2 +++ openacs-4/packages/attachments/www/go-to-attachment.xql 26 May 2003 21:39:13 -0000 1.1.2.3 @@ -1,17 +1,6 @@ - - - select object_type - from attachments, acs_objects - where - attachments.object_id = :object_id and - attachments.item_id = :attachment_id and - attachments.item_id = acs_objects.object_id - - - select url Index: openacs-4/packages/attachments/www/simple-add-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/attachments/www/simple-add-2.tcl,v diff -u -N -r1.1.2.1 -r1.1.2.2 --- openacs-4/packages/attachments/www/simple-add-2.tcl 20 Mar 2003 22:12:18 -0000 1.1.2.1 +++ openacs-4/packages/attachments/www/simple-add-2.tcl 26 May 2003 21:39:13 -0000 1.1.2.2 @@ -24,11 +24,13 @@ ad_require_permission $folder_id write db_transaction { - - # Create and attach the URL - attachments::attach -object_id $object_id \ - -attachment_id [content_simple::new -url $url -label $title -description $description -parent_id $folder_id] + # Create the URL (for now) + set url_id [content_extlink::new -url $url -label $title -description $description -parent_id $folder_id] + + # Attach the URL + attachments::attach -object_id $object_id -attachment_id $url_id + } ad_returnredirect "$return_url"