Index: openacs-4/packages/acs-subsite/www/user/portrait/upload-2-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/user/portrait/Attic/upload-2-oracle.xql,v diff -u -r1.2.6.2 -r1.2.6.3 --- openacs-4/packages/acs-subsite/www/user/portrait/upload-2-oracle.xql 2 Jul 2004 11:40:55 -0000 1.2.6.2 +++ openacs-4/packages/acs-subsite/www/user/portrait/upload-2-oracle.xql 11 Aug 2004 00:25:47 -0000 1.2.6.3 @@ -2,18 +2,6 @@ oracle8.1.6 - - - - begin - :1 := content_item.new( - name => :name, - creation_ip => :creation_ip); - end; - - - - @@ -27,52 +15,4 @@ - - - - begin - :1 := content_revision.new( - title => :title, - description => :portrait_comment, - text => 'not_important', - mime_type => :guessed_file_type, - item_id => :item_id, - creation_user => :user_id, - creation_ip => :creation_ip, - content_length => :n_bytes - ); - - update cr_items - set live_revision = :1 - where item_id = :item_id; - end; - - - - - - - - update cr_revisions - set content = empty_blob() - where revision_id = :revision_id - returning content into :1 - - - - - - - - update cr_revisions - set description = :portrait_comment, - publish_date = sysdate, - mime_type = :guessed_file_type, - content_length = :n_bytes, - title = :title - where revision_id = :revision_id - - - - Index: openacs-4/packages/acs-subsite/www/user/portrait/upload-2-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/user/portrait/Attic/upload-2-postgresql.xql,v diff -u -r1.3.6.2 -r1.3.6.3 --- openacs-4/packages/acs-subsite/www/user/portrait/upload-2-postgresql.xql 2 Jul 2004 12:37:18 -0000 1.3.6.2 +++ openacs-4/packages/acs-subsite/www/user/portrait/upload-2-postgresql.xql 11 Aug 2004 00:25:47 -0000 1.3.6.3 @@ -5,28 +5,6 @@ - select content_item__new( - varchar :name, - null, - null, - null, - now(), - null, - null, - :creation_ip, - 'content_item', - 'content_revision', - null, - null, - 'text/plain', - null, - null - ) - - - - - @@ -44,62 +22,4 @@ - - - - - declare - v_revision_id integer; - begin - - v_revision_id := content_revision__new( - :title, - :portrait_comment, - now(), - :guessed_file_type, - null, - null, - :item_id, - null, - now(), - :user_id, - :creation_ip, - :n_bytes - ); - - update cr_items - set live_revision = v_revision_id - where item_id = :item_id; - - return v_revision_id; - - end; - - - - - - - - update cr_revisions - set lob = [set __lob_id [db_string get_lob_id "select empty_lob()"]] - where revision_id = :revision_id - - - - - - - - update cr_revisions - set description = :portrait_comment, - publish_date = now(), - mime_type = :guessed_file_type, - content_length = :n_bytes, - title = :title - where revision_id = :revision_id - - - - Index: openacs-4/packages/acs-subsite/www/user/portrait/upload-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/user/portrait/Attic/upload-2.tcl,v diff -u -r1.7.2.2 -r1.7.2.3 --- openacs-4/packages/acs-subsite/www/user/portrait/upload-2.tcl 19 Jul 2004 18:39:41 -0000 1.7.2.2 +++ openacs-4/packages/acs-subsite/www/user/portrait/upload-2.tcl 11 Aug 2004 00:25:47 -0000 1.7.2.3 @@ -44,6 +44,11 @@ # check to see if this is one of the favored MIME types, # e.g., image/gif or image/jpeg + + # DRB: the code actually depends on our having either gif or jpeg and this was true + # before I switched this routine to use cr_import_content (i.e. don't believe the + # generality implicit in the following if statement) + if { ![empty_string_p [ad_parameter AcceptablePortraitMIMETypes "user-info"]] && [lsearch [ad_parameter AcceptablePortraitMIMETypes "user-info"] $guessed_file_type] == -1 } { incr exception_count @@ -63,70 +68,44 @@ } } - if { $exception_count > 0 } { ad_return_complaint $exception_count $exception_text ad_script_abort } -set what_aolserver_told_us "" -if { $file_extension == "jpeg" || $file_extension == "jpg" } { - catch { set what_aolserver_told_us [ns_jpegsize $tmp_filename] } -} elseif { $file_extension == "gif" } { - catch { set what_aolserver_told_us [ns_gifsize $tmp_filename] } -} - -# the AOLserver jpegsize command has some bugs where the height comes -# through as 1 or 2 -if { ![empty_string_p $what_aolserver_told_us] - && [lindex $what_aolserver_told_us 0] > 10 - && [lindex $what_aolserver_told_us 1] > 10 } { - set original_width [lindex $what_aolserver_told_us 0] - set original_height [lindex $what_aolserver_told_us 1] -} else { - set original_width "" - set original_height "" -} - -## The portrait is ready. Let's now figure out how to insert into the system - -set creation_ip [ad_conn peeraddr] -set name "portrait-of-user-$user_id" - -# let's figure out if this person has a portrait yet - if { ![db_0or1row get_item_id {}]} { # The user doesn't have a portrait relation yet db_transaction { - set item_id [db_exec_plsql create_item {}] - set revision_id [db_exec_plsql create_revision {}] - set rel_id [db_exec_plsql create_rel {}] - db_dml update_photo {} -blob_files [list $tmp_filename] - db_dml upload_image_info {} - } -} else { - #already has a portrait, so all we have to do is to make a new revision for it + set var_list [list \ + [list content_type image] \ + [list creation_user $user_id] \ + [list creation_ip [ad_conn peeraddr]] \ + [list name portrait-of-user-$user_id]] + set item_id [package_instantiate_object -var_list $var_list content_item] - # Let's check if a current revision exists: - if {![db_0or1row get_revision_id {}] - || [empty_string_p $revision_id] - } { - # It's an insert rather than an update - db_transaction { - set revision_id [db_exec_plsql create_revision {}] - db_dml update_photo {} -blob_files [list $tmp_filename] - db_dml upload_image_info {} - } - } else { - # it's merely an update - db_transaction { - db_dml update_photo {} -blob_files [list $tmp_filename] - db_dml update_image_info {} - db_dml update_photo_info {} - } + # DRB: this is done via manual SQL because acs rel types are a bit messed + # up on the PostgreSQL side, which should be fixed someday. + + db_exec_plsql create_rel {} } } +set revision_id [cr_import_content \ + -image_only \ + -item_id $item_id \ + -storage_type lob \ + -creation_user [ad_conn user_id] \ + -creation_ip [ad_conn peeraddr] \ + [ad_conn package_id] \ + $tmp_filename \ + $n_bytes \ + $guessed_file_type \ + portrait-of-user-$user_id] + +cr_set_imported_content_live $guessed_file_type $revision_id + +} + if { [exists_and_not_null return_url] } { ad_returnredirect $return_url } else { Index: openacs-4/packages/acs-subsite/www/user/portrait/upload-2.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/user/portrait/Attic/upload-2.xql,v diff -u -r1.4 -r1.4.2.1 --- openacs-4/packages/acs-subsite/www/user/portrait/upload-2.xql 4 Mar 2004 14:52:48 -0000 1.4 +++ openacs-4/packages/acs-subsite/www/user/portrait/upload-2.xql 11 Aug 2004 00:25:47 -0000 1.4.2.1 @@ -12,35 +12,4 @@ - - - - insert into images - (image_id, width, height) - values - (:revision_id, :original_width, :original_height) - - - - - - - - select live_revision as revision_id - from cr_items - where item_id = :item_id - - - - - - - - update images - set width = :original_width, height = :original_height - where image_id = :revision_id - - - -