Index: openacs-4/contrib/packages/bcms/tcl/bcms-revision-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/bcms/tcl/bcms-revision-procs.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/contrib/packages/bcms/tcl/bcms-revision-procs.tcl 22 Sep 2003 07:32:52 -0000 1.4 +++ openacs-4/contrib/packages/bcms/tcl/bcms-revision-procs.tcl 4 Oct 2003 08:53:05 -0000 1.5 @@ -6,13 +6,13 @@ @creation-date 06 Oct 2002 @cvs-id $Id$ -TODO: refactor the creation_user_id "" to something ad_conn TODO: add back the lob support } namespace eval bcms::revision {} +# TODO merge with upload_file_revision ad_proc -public bcms::revision::add_revision { {-item_id:required} {-title:required} @@ -22,13 +22,39 @@ {-content ""} {-creation_user_id} {-creation_ip} + {-additional_properties} } { - Adds a new revision to a content item stored in the cr_revision.content column. - Normally you will use your own proc patterned after this proc + Adds a new revision, you pass additional properties/columns for your custom + content type + + @param item_id item_id of this revision is adding to + @param title title of the revision + @param content_type content_type of the item, if not passed it will determine the content_type + @param mime_type mime type of this revision + @param description description of the revision + @param content content of the revision + @param creation_user_id user_id creating this item + @param creation_user_ip ip address which this item is created + @param additional_properites a list of additional properties / columns to insert format: {property value ... property value} + + @returns revision_id of newly created revision } { if {![info exists creation_user_id]} { set creation_user_id [ad_conn user_id] } if {![info exists creation_ip]} { set creation_ip [ad_conn peeraddr] } + # create the additional properties + set addtnl_properties "" + set addtnl_values "" + set addtnl_properties_list {} + set addtnl_values_list {} + foreach {property value} $additional_properties { + lappend addtnl_properties_list $property + lappend addtnl_values_list :__$property + set __$property $value + } + set addtnl_properties ",[join $addtnl_properties_list ","]" + set addtnl_values ",[join $addtnl_values_list ","]" + if ![info exists content_type] { set content_type [bcms::item::get_content_type -item_id $item_id] } @@ -39,32 +65,41 @@ db_dml insert_revision "SQL" } - ns_log notice "bcms::revision::revision_create_in_text created new revision $revision_id" + ns_log notice "bcms::revision::add_revision created new revision $revision_id" return $revision_id } ad_proc -public bcms::revision::upload_file_revision { {-item_id:required} - {-revision_id} - {-title ""} + {-title:required} {-content_type} {-description ""} {-upload_tmpfile:required} {-upload_filename:required} {-mime_type "application/octet-stream"} - {-creation_user_id ""} - {-creation_ip ""} + {-creation_user_id} + {-creation_ip} + {-additional_properties} } { Adds a new revision to a content item stored in file system at acs_root/content-repository-content-files. - Normally you will use your own proc patterned after this proc - TODO: think about merging this with edit_revision since - now its also used for editing - also lets just accept the upload_file and get the tmpfile and mimetype - inside the proc + @param item_id item_id of this revision is adding to + @param title title of the revision + @param content_type content_type of the item, if not passed it will determine the content_type + @param mime_type mime type of this revision + @param description description of the revision + @param upload_tmpfile + @param upload_filename + @param creation_user_id user_id creating this item + @param creation_user_ip ip address which this item is created + @param additional_properites a list of additional properties / columns to insert format: {property value ... property value} + } { + if {![info exists creation_user_id]} { set creation_user_id [ad_conn user_id] } + if {![info exists creation_ip]} { set creation_ip [ad_conn peeraddr] } + if ![info exists content_type] { set content_type [bcms::item::get_content_type -item_id $item_id] } @@ -79,6 +114,19 @@ db_dml new_mime_type "SQL" } + # create the additional properties + set addtnl_properties "" + set addtnl_values "" + set addtnl_properties_list {} + set addtnl_values_list {} + foreach {property value} $additional_properties { + lappend addtnl_properties_list $property + lappend addtnl_values_list :__$property + set __$property $value + } + set addtnl_properties ",[join $addtnl_properties_list ","]" + set addtnl_values ",[join $addtnl_values_list ","]" + db_transaction { # if we are editing a existing revision then lets get the next object_id if ![info exists revision_id] { @@ -94,8 +142,7 @@ # since we are using the file system we will set content to the filename in the fs set content $tmp_filename - if $insert_revision_p { - # we do not need to reinsert an existing revision + if {$insert_revision_p} { db_dml insert_revision "SQL" } db_dml update_file_size "SQL"