Index: openacs-4/packages/acs-content-repository/tcl/content-item-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/content-item-procs.tcl,v diff -u -r1.15 -r1.16 --- openacs-4/packages/acs-content-repository/tcl/content-item-procs.tcl 26 Jul 2006 20:52:48 -0000 1.15 +++ openacs-4/packages/acs-content-repository/tcl/content-item-procs.tcl 6 Aug 2006 19:43:05 -0000 1.16 @@ -125,6 +125,7 @@ if {[exists_and_not_null title] \ || [exists_and_not_null text] \ || [exists_and_not_null data] \ + || [exists_and_not_null tmp_filename] \ || [llength $attributes]} { content::revision::new \ -item_id $item_id \ Index: openacs-4/packages/acs-content-repository/tcl/image-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/image-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-content-repository/tcl/image-procs.tcl 6 Aug 2006 19:43:05 -0000 1.1 @@ -0,0 +1,81 @@ +# packages/acs-content-repository/tcl/image-procs.tcl + +ad_library { + + Procedures to handle image subtype + + @author Dave Bauer (dave@thedesignexperience.org) + @creation-date 2006-07-31 + @cvs-id $Id: image-procs.tcl,v 1.1 2006/08/06 19:43:05 daveb Exp $ +} + +namespace eval image:: {} + +ad_proc -public image::new { + {-name ""} + {-parent_id ""} + {-item_id ""} + {-locale ""} + {-creation_date ""} + {-creation_user ""} + {-context_id ""} + {-package_id ""} + {-creation_ip ""} + {-item_subtype "content_item"} + {-content_type "content_revision"} + {-title ""} + {-description ""} + {-mime_type ""} + {-relation_tag ""} + {-is_live ""} + {-storage_type "file"} + {-attributes ""} + {-tmp_filename ""} +} { + Create a new image object from a temporary file + + @author Dave Bauer (dave@thedesignexperience.org) + @creation-date 2006-07-31 + + @param item_id Item id of the content item for this image. The + item_id will be generated from the acs_object_id + sequence if not specified. + + @param parent_id Parent object for this image. Context_id will be + set to parent_id + + @param name Name of image item, must be unique per parent_id + + @param tmp_filename Filename in the filesystem, readable by + AOLserver user to create image from + + @return Item_id + + @error +} { + + return [content::item::new \ + -name $name \ + -parent_id $parent_id \ + -item_id $item_id \ + -locale $locale \ + -creation_date $creation_date \ + -creation_user $creation_user \ + -context_id $context_id \ + -package_id $package_id \ + -creation_ip $creation_ip \ + -item_subtype $item_subtype \ + -content_type "image" \ + -title $title \ + -description $description \ + -mime_type $mime_type \ + -relation_tag $relation_tag \ + -is_live $is_live \ + -storage_type "file" \ + -attributes $attributes \ + -tmp_filename $tmp_filename] +} + + + + Index: openacs-4/packages/acs-content-repository/tcl/test/content-image-test-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/test/content-image-test-procs.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-content-repository/tcl/test/content-image-test-procs.tcl 4 Jun 2006 00:45:23 -0000 1.2 +++ openacs-4/packages/acs-content-repository/tcl/test/content-image-test-procs.tcl 6 Aug 2006 19:43:05 -0000 1.3 @@ -61,3 +61,42 @@ content::folder::delete -folder_id $first_folder_id } } + +aa_register_case -cats {api smoke db} image_new { + +} { + aa_run_with_teardown \ + -rollback \ + -test_code \ + { + # create a cr_folder + set first_folder_id [db_nextval "acs_object_id_seq"] + set returned_first_folder_id [content::folder::new \ + -folder_id $first_folder_id \ + -name "test_folder_${first_folder_id}"] + aa_true "Folder created" [expr $first_folder_id == $returned_first_folder_id] + + content::folder::register_content_type \ + -folder_id $first_folder_id \ + -content_type "image" \ + + set tmp_filename "[acs_root_dir]/packages/acs-content-repository/tcl/test/test-image-1.jpg" + set image_item_id_orig [db_nextval "acs_object_id_seq"] + set image_name [ns_mktemp "XXXXXX"] + set image_item_id [image::new \ + -item_id $image_item_id_orig \ + -parent_id $first_folder_id \ + -name $image_name \ + -tmp_filename $tmp_filename] + + aa_true "Image Created" [expr {$image_item_id_orig eq $image_item_id}] + aa_true "Image CR Item Exists" \ + [expr \ + {$image_item_id eq \ + [content::item::get_id \ + -item_path $image_name \ + -root_folder_id $first_folder_id]}] + + } +} +