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.8 -r1.9
--- openacs-4/packages/acs-templating/www/scripts/xinha/attach-file.tcl	9 Oct 2006 19:29:51 -0000	1.8
+++ openacs-4/packages/acs-templating/www/scripts/xinha/attach-file.tcl	20 Oct 2006 17:47:57 -0000	1.9
@@ -13,11 +13,18 @@
 
 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
-
+set write_p [permission::permission_p \
+		 -party_id $user_id \
+		 -object_id $parent_id \
+		 -privilege "write"]
+if {!$write_p} {
+    # item might not exist!
+    set write_p [permission::permission_p \
+		     -party_id $user_id \
+		     -object_id [ad_conn package_id] \
+		     -privilege "write"]
+}
+if {$write_p} {
     # set recent files
     set recent_files_options [list]
     db_multirow -extend {mime_icon} -unclobber recent_files recent_files \