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 -N -r1.24.2.2 -r1.24.2.3 --- openacs-4/packages/acs-content-repository/tcl/content-item-procs.tcl 5 Jan 2016 15:28:43 -0000 1.24.2.2 +++ openacs-4/packages/acs-content-repository/tcl/content-item-procs.tcl 27 Oct 2016 18:02:00 -0000 1.24.2.3 @@ -75,14 +75,18 @@ if {$creation_user eq ""} { set creation_user [ad_conn user_id] } - if {$creation_ip eq ""} { set creation_ip [ad_conn peeraddr] } if {$package_id eq ""} { set package_id [ad_conn package_id] } + set mime_type [cr_check_mime_type \ + -filename $name \ + -mime_type $mime_type \ + -file $tmp_filename] + set var_list [list] lappend var_list \ [list name $name] \ @@ -102,53 +106,53 @@ [list is_live $is_live ] \ [list storage_type $storage_type] - # we don't pass title, text, or data to content_item__new - # because the magic revision creation of the pl/sql proc does - # not create a proper subtype of content revision, also it - # can't set attributes of an extended type + # we don't pass title, text, or data to content_item__new because + # the magic revision creation of the pl/sql proc does not create a + # proper subtype of content revision, also it can't set attributes + # of an extended type - # the content type is not the object type of the cr_item so we pass in - # the cr_item subtype here and content_type as part of + # the content type is not the object type of the cr_item so we + # pass in the cr_item subtype here and content_type as part of # var_list db_transaction { # An explict lock was necessary for PostgreSQL between 8.0 and - # 8.2; left the following statement here for documentary purposes + # 8.2; left the following statement here for documentary + # purposes # # db_dml lock_objects "LOCK TABLE acs_objects IN SHARE ROW EXCLUSIVE MODE" - set item_id [package_exec_plsql \ - -var_list $var_list \ - content_item new] - # if we have attributes we pass in everything - # and create a revision with all subtype attributes that were - # passed in + set item_id [package_exec_plsql \ + -var_list $var_list \ + content_item new] + # if we have attributes we pass in everything and create a + # revision with all subtype attributes that were passed in - # since we can't rely on content_item__new to create a revision - # we have to pass is_live to content::revision::new and - # set the live revision there - if {([info exists title] && $title ne "") + # since we can't rely on content_item__new to create a + # revision we have to pass is_live to content::revision::new + # and set the live revision there + if {([info exists title] && $title ne "") || ([info exists text] && $text ne "") - || ([info exists data] && $data ne "") - || ([info exists tmp_filename] && $tmp_filename ne "") - || [llength $attributes] - } { - content::revision::new \ - -item_id $item_id \ - -title $title \ - -description $description \ - -content $text \ - -mime_type $mime_type \ - -content_type $content_type \ - -is_live $is_live \ - -package_id $package_id \ - -creation_user $creation_user \ - -creation_ip $creation_ip \ - -creation_date $creation_date \ - -nls_language $nls_language \ - -tmp_filename $tmp_filename \ - -attributes $attributes + || ([info exists data] && $data ne "") + || ([info exists tmp_filename] && $tmp_filename ne "") + || [llength $attributes] + } { + content::revision::new \ + -item_id $item_id \ + -title $title \ + -description $description \ + -content $text \ + -mime_type $mime_type \ + -content_type $content_type \ + -is_live $is_live \ + -package_id $package_id \ + -creation_user $creation_user \ + -creation_ip $creation_ip \ + -creation_date $creation_date \ + -nls_language $nls_language \ + -tmp_filename $tmp_filename \ + -attributes $attributes + } } - } return $item_id }