Index: openacs-4/packages/attachments/www/download/index.vuh =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/attachments/www/download/index.vuh,v diff -u -N -r1.3.2.1 -r1.3.2.2 --- openacs-4/packages/attachments/www/download/index.vuh 11 Jul 2019 16:01:34 -0000 1.3.2.1 +++ openacs-4/packages/attachments/www/download/index.vuh 11 Jul 2019 16:38:53 -0000 1.3.2.2 @@ -11,22 +11,46 @@ object_id:naturalnum,notnull attachment_id:naturalnum,notnull } - +# # Permission check +# permission::require_permission -object_id $object_id -privilege read - - - -# Get the live version -# (and check that this is the right attachment while we're at it) -set version_id [db_string select_version_id {} -default {}] - +# +# Double check if this is the right attachment, and get the live revision if the +# object is a 'content_item' or subtype +# +set object_type [acs_object_type $attachment_id] +if {$object_type eq ""} { + # + # No object type + # + set version_id "" +} elseif {[content::item::is_subclass \ + -object_type $object_type \ + -supertype "content_item"]} { + # + # Content item, or subtype + # + set version_id [db_string select_version_id {} -default {}] +} elseif {[content::item::is_subclass \ + -object_type $object_type \ + -supertype "content_revision"]} { + # + # Content revision, or subtype + # + set version_id [db_string select_version_id_revision {} -default {}] +} +# +# Last check +# if {$version_id eq ""} { - ad_return_complaint 1 "bad attachment" + ad_return_complaint 1 [_ attachments.lt_No_such_attachment_fo] ad_script_abort return } - +# +# Good to go +# cr_write_content -revision_id $version_id # Local variables: