Index: openacs-4/packages/acs-content-repository/sql/oracle/content-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/oracle/content-create.sql,v diff -u -r1.12 -r1.13 --- openacs-4/packages/acs-content-repository/sql/oracle/content-create.sql 7 Nov 2001 22:55:49 -0000 1.12 +++ openacs-4/packages/acs-content-repository/sql/oracle/content-create.sql 15 Nov 2001 01:47:13 -0000 1.13 @@ -779,6 +779,8 @@ content_type => 'content_revision', mime_type => 'text/html'); content_type.register_mime_type( content_type => 'content_revision', mime_type => 'text/plain'); + content_type.register_mime_type( + content_type => 'content_revision', mime_type => 'text/richtext'); end; / show errors Index: openacs-4/packages/acs-content-repository/sql/oracle/content-image.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/oracle/content-image.sql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-content-repository/sql/oracle/content-image.sql 9 Oct 2001 04:31:24 -0000 1.3 +++ openacs-4/packages/acs-content-repository/sql/oracle/content-image.sql 15 Nov 2001 01:47:13 -0000 1.4 @@ -122,12 +122,33 @@ relation_tag in cr_child_rels.relation_tag%TYPE default null, is_live in char default 'f', publish_date in cr_revisions.publish_date%TYPE default sysdate, - path in varchar, + data in cr_revisions.content%TYPE default null, + filename in cr_revisions.filename%TYPE default null, height in images.height%TYPE default null, width in images.width%TYPE default null, - file_size in cr_revisions.content_length%TYPE default null + file_size in cr_revisions.content_length%TYPE default null, + storage_type in cr_items.storage_type%TYPE default 'file' ) return cr_items.item_id%TYPE; + function new_revision ( + item_id in acs_objects.object_id%TYPE default null, + revision_id in acs_objects.object_id%TYPE default null, + creation_date in acs_objects.creation_date%TYPE default sysdate, + creation_user in acs_objects.creation_user%TYPE default null, + creation_ip in acs_objects.creation_ip%TYPE default null, + title in cr_revisions.title%TYPE default null, + description in cr_revisions.description%TYPE default null, + mime_type in cr_revisions.mime_type%TYPE default null, + nls_language in cr_revisions.nls_language%TYPE default null, + is_live in char default 'f', + publish_date in cr_revisions.publish_date%TYPE default sysdate, + data in cr_revisions.content%TYPE default null, + filename in cr_revisions.filename%TYPE default null, + height in images.height%TYPE default null, + width in images.width%TYPE default null, + file_size in cr_revisions.content_length%TYPE default null + ) return cr_revisions.revision_id%TYPE; + --/** -- Deletes a single revision of image -- Schedules binary file for deletion. @@ -171,10 +192,12 @@ relation_tag in cr_child_rels.relation_tag%TYPE default null, is_live in char default 'f', publish_date in cr_revisions.publish_date%TYPE default sysdate, - path in varchar, + data in cr_revisions.content%TYPE default null, + filename in cr_revisions.filename%TYPE default null, height in images.height%TYPE default null, width in images.width%TYPE default null, - file_size in cr_revisions.content_length%TYPE default null + file_size in cr_revisions.content_length%TYPE default null, + storage_type in cr_items.storage_type%TYPE default 'file' ) return cr_items.item_id%TYPE is v_item_id cr_items.item_id%TYPE; @@ -187,23 +210,24 @@ parent_id => parent_id, relation_tag => relation_tag, content_type => content_type, - creation_date => sysdate, + creation_date => creation_date, creation_user => creation_user, creation_ip => creation_ip, locale => locale, context_id => context_id, - storage_type => 'file' + storage_type => storage_type ); v_revision_id := content_revision.new ( - title => title, + title => title, description => description, item_id => v_item_id, revision_id => revision_id, publish_date => publish_date, mime_type => mime_type, nls_language => nls_language, - text => path, + data => data, + filename => filename, creation_date => sysdate, creation_user => creation_user, creation_ip => creation_ip @@ -232,6 +256,66 @@ return v_item_id; end new; + function new_revision ( + item_id in acs_objects.object_id%TYPE default null, + revision_id in acs_objects.object_id%TYPE default null, + creation_date in acs_objects.creation_date%TYPE default sysdate, + creation_user in acs_objects.creation_user%TYPE default null, + creation_ip in acs_objects.creation_ip%TYPE default null, + title in cr_revisions.title%TYPE default null, + description in cr_revisions.description%TYPE default null, + mime_type in cr_revisions.mime_type%TYPE default null, + nls_language in cr_revisions.nls_language%TYPE default null, + is_live in char default 'f', + publish_date in cr_revisions.publish_date%TYPE default sysdate, + data in cr_revisions.content%TYPE default null, + filename in cr_revisions.filename%TYPE default null, + height in images.height%TYPE default null, + width in images.width%TYPE default null, + file_size in cr_revisions.content_length%TYPE default null + ) return cr_revisions.revision_id%TYPE + is + v_revision_id cr_revisions.revision_id%TYPE; + + begin + v_revision_id := content_revision.new ( + title => title, + description => description, + item_id => item_id, + revision_id => revision_id, + publish_date => publish_date, + mime_type => mime_type, + nls_language => nls_language, + data => data, + filename => filename, + creation_date => creation_date, + creation_user => creation_user, + creation_ip => creation_ip + ); + + insert into images + (image_id, height, width) + values + (v_revision_id, height, width); + + -- update revision with image file info + update cr_revisions + set content_length = file_size + where revision_id = v_revision_id; + + -- is_live => 't' not used as part of content_item.new + -- because content_item.new does not let developer specify revision_id, + -- revision_id is determined in advance + + if is_live = 't' then + content_item.set_live_revision ( + revision_id => v_revision_id + ); + end if; + + return v_revision_id; + end new_revision; + procedure delete_revision ( revision_id in cr_revisions.revision_id%TYPE ) Index: openacs-4/packages/acs-content-repository/sql/oracle/content-revision.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/oracle/content-revision.sql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-content-repository/sql/oracle/content-revision.sql 12 May 2001 05:09:48 -0000 1.3 +++ openacs-4/packages/acs-content-repository/sql/oracle/content-revision.sql 15 Nov 2001 01:47:13 -0000 1.4 @@ -24,7 +24,8 @@ revision_id in cr_revisions.revision_id%TYPE default null, creation_date in acs_objects.creation_date%TYPE default sysdate, creation_user in acs_objects.creation_user%TYPE default null, - creation_ip in acs_objects.creation_ip%TYPE default null + creation_ip in acs_objects.creation_ip%TYPE default null, + filename in cr_revisions.filename%TYPE default null ) return cr_revisions.revision_id%TYPE is @@ -46,10 +47,10 @@ insert into cr_revisions ( revision_id, title, description, mime_type, publish_date, - nls_language, content, item_id + nls_language, content, item_id, filename ) values ( v_revision_id, title, description, mime_type, publish_date, - nls_language, data, item_id + nls_language, data, item_id, filename ); return v_revision_id; Index: openacs-4/packages/acs-content-repository/sql/oracle/packages-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/oracle/packages-create.sql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-content-repository/sql/oracle/packages-create.sql 12 May 2001 05:09:48 -0000 1.3 +++ openacs-4/packages/acs-content-repository/sql/oracle/packages-create.sql 15 Nov 2001 01:47:13 -0000 1.4 @@ -836,7 +836,8 @@ default sysdate, creation_user in acs_objects.creation_user%TYPE default null, - creation_ip in acs_objects.creation_ip%TYPE default null + creation_ip in acs_objects.creation_ip%TYPE default null, + filename in cr_revisions.filename%TYPE default null ) return cr_revisions.revision_id%TYPE; function new ( Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql,v diff -u -r1.31 -r1.32 --- openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql 7 Nov 2001 22:55:49 -0000 1.31 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql 15 Nov 2001 01:47:13 -0000 1.32 @@ -1178,6 +1178,8 @@ ''text/html''); PERFORM content_type__register_mime_type(''content_revision'', ''text/plain''); + PERFORM content_type__register_mime_type(''content_revision'', + ''text/richtext''); v_id := content_folder__new ( ''pages'', Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-image-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-image-drop.sql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-content-repository/sql/postgresql/content-image-drop.sql 27 Sep 2001 22:48:16 -0000 1.2 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-image-drop.sql 15 Nov 2001 01:47:13 -0000 1.3 @@ -14,6 +14,11 @@ drop function image__new (varchar,integer,integer,integer,varchar,integer,varchar,integer,varchar,varchar,boolean,timestamp,varchar,integer,integer,integer); +drop function image__new_revision(integer, integer, varchar, varchar, timestamp, varchar, varchar, + integer, varchar, integer, integer); + +drop function image__new (varchar,integer,integer,integer,varchar,varchar,varchar,varchar,varchar,varchar,varchar, + varchar,timestamp,integer, integer); begin; select content_type__unregister_mime_type( Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-image.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-image.sql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-content-repository/sql/postgresql/content-image.sql 27 Sep 2001 22:48:16 -0000 1.3 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-image.sql 15 Nov 2001 01:47:13 -0000 1.4 @@ -104,6 +104,22 @@ Binary file stored in file-system */ +-- DRB: This code has some serious problem, IMO. It's impossible to derive a new +-- type from "image" and make use of it, for starters. Photo-album uses two +-- content types to store a photograph - pa_photo and image. pa_photo would, in +-- the world of real object-oriented languages, be derived from image and there's +-- really no reason not to do so in the OpenACS object type system. The current +-- style requires separate content_items and content_revisions for both the +-- pa_photo extended type and the image base type. They're only tied together +-- by the coincidence of both being the live revision at the same time. Delete +-- one or the other and guess what, that association's broken! + +-- This is not, to put it mildly, clean. Nor is it efficient to fill the RDBMS +-- with twice as many objects as you need... + +-- The Oracle version does allow a non-image type to be specified, as does my +-- alternative down below. This needs a little more straightening out. + create function image__new (varchar,integer,integer,integer,varchar,integer,varchar,varchar,varchar,varchar,boolean,timestamp,varchar,integer,integer,integer ) returns integer as ' declare @@ -196,6 +212,118 @@ return v_item_id; end; ' language 'plpgsql'; +-- DRB's version + +create function image__new (varchar,integer,integer,integer,varchar,integer,varchar,varchar,varchar,varchar,varchar, + varchar,timestamp,integer, integer) returns integer as ' + declare + p_name alias for $1; + p_parent_id alias for $2; -- default null + p_item_id alias for $3; -- default null + p_revision_id alias for $4; -- default null + p_mime_type alias for $5; -- default jpeg + p_creation_user alias for $6; -- default null + p_creation_ip alias for $7; -- default null + p_title alias for $8; -- default null + p_description alias for $9; -- default null + p_storage_type alias for $10; + p_content_type alias for $11; + p_nls_language alias for $12; + p_publish_date alias for $13; + p_height alias for $14; + p_width alias for $15; + + v_item_id cr_items.item_id%TYPE; + v_revision_id cr_revisions.revision_id%TYPE; + begin + + if content_item__is_subclass(p_content_type, ''image'') = ''f'' then + raise EXCEPTION ''-20000: image__new can only be called for an image type''; + end if; + + v_item_id := content_item__new ( + p_name, + p_parent_id, + p_item_id, + null, + current_timestamp, + p_creation_user, + p_parent_id, + p_creation_ip, + ''content_item'', + p_content_type, + null, + null, + null, + null, + null, + p_storage_type + ); + + -- We will let the caller fill in the LOB data or file path. + + v_revision_id := content_revision__new ( + p_title, + p_description, + p_publish_date, + p_mime_type, + p_nls_language, + null, + v_item_id, + p_revision_id, + current_timestamp, + p_creation_user, + p_creation_ip + ); + + insert into images + (image_id, height, width) + values + (v_revision_id, p_height, p_width); + + return v_item_id; +end; ' language 'plpgsql'; + +create function image__new_revision(integer, integer, varchar, varchar, timestamp, varchar, varchar, + integer, varchar, integer, integer) returns integer as ' +declare + p_item_id alias for $1; + p_revision_id alias for $2; + p_title alias for $3; + p_description alias for $4; + p_publish_date alias for $5; + p_mime_type alias for $6; + p_nls_language alias for $7; + p_creation_user alias for $8; + p_creation_ip alias for $9; + p_height alias for $10; + p_width alias for $11; + +begin + -- We will let the caller fill in the LOB data or file path. + + v_revision_id := content_revision__new ( + p_title, + p_description, + p_publish_date, + p_mime_type, + p_nls_language, + null, + p_item_id, + p_revision_id, + current_timestamp, + p_creation_user, + p_creation_ip + ); + + insert into images + (image_id, height, width) + values + (v_revision_id, p_height, p_width); + + return v_revision_id; +end;' language 'plpgsql'; + create function image__delete (integer) returns integer as ' declare @@ -220,4 +348,3 @@ PERFORM content_item__delete (v_item_id); return 1; end; ' language 'plpgsql'; - Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-item.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-item.sql,v diff -u -r1.32 -r1.33 --- openacs-4/packages/acs-content-repository/sql/postgresql/content-item.sql 23 Oct 2001 19:41:02 -0000 1.32 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-item.sql 15 Nov 2001 01:47:13 -0000 1.33 @@ -120,7 +120,7 @@ content_folder__is_registered( v_parent_id, new__content_type, ''f'') = ''f'' then - raise EXCEPTION ''-20000: This item\\\'s content type % is not registered to this folder %'', new__content_type, v_parent_id; + raise EXCEPTION ''-20000: This items content type % is not registered to this folder %'', new__content_type, v_parent_id; end if; else if v_parent_id != 0 then @@ -135,7 +135,7 @@ if content_item__is_subclass(v_parent_type, ''content_item'') = ''t'' and content_item__is_valid_child(v_parent_id, new__content_type) = ''f'' then - raise EXCEPTION ''-20000: This item\\\'s content type % is not allowed in this container %'', new__content_type, v_parent_id; + raise EXCEPTION ''-20000: This items content type % is not allowed in this container %'', new__content_type, v_parent_id; end if; end if; end if; @@ -278,7 +278,7 @@ content_folder__is_registered( v_parent_id, new__content_type, ''f'') = ''f'' then - raise EXCEPTION ''-20000: This item\\\'s content type % is not registered to this folder %'', new__content_type, v_parent_id; + raise EXCEPTION ''-20000: This items content type % is not registered to this folder %'', new__content_type, v_parent_id; end if; else if v_parent_id != 0 then @@ -293,7 +293,7 @@ if content_item__is_subclass(v_parent_type, ''content_item'') = ''t'' and content_item__is_valid_child(v_parent_id, new__content_type) = ''f'' then - raise EXCEPTION ''-20000: This item\\\'s content type % is not allowed in this container %'', new__content_type, v_parent_id; + raise EXCEPTION ''-20000: This items content type % is not allowed in this container %'', new__content_type, v_parent_id; end if; end if; end if; @@ -481,7 +481,7 @@ content_folder__is_registered( v_parent_id, new__content_type, ''f'') = ''f'' then - raise EXCEPTION ''-20000: This item\\\'s content type % is not registered to this folder %'', new__content_type, v_parent_id; + raise EXCEPTION ''-20000: This items content type % is not registered to this folder %'', new__content_type, v_parent_id; end if; else if v_parent_id != 0 then @@ -496,7 +496,7 @@ if content_item__is_subclass(v_parent_type, ''content_item'') = ''t'' and content_item__is_valid_child(v_parent_id, new__content_type) = ''f'' then - raise EXCEPTION ''-20000: This item\\\'s content type % is not allowed in this container %'', new__content_type, v_parent_id; + raise EXCEPTION ''-20000: This items content type % is not allowed in this container %'', new__content_type, v_parent_id; end if; end if; end if; Index: openacs-4/packages/acs-content-repository/tcl/revision-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/revision-procs-oracle.xql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-content-repository/tcl/revision-procs-oracle.xql 31 Oct 2001 20:42:07 -0000 1.2 +++ openacs-4/packages/acs-content-repository/tcl/revision-procs-oracle.xql 15 Nov 2001 01:47:13 -0000 1.3 @@ -53,4 +53,134 @@ + + + + begin + content_type.register_mime_type('content_revision', :mime_type); + end; + + + + + + select content_item.is_subclass(:image_type, 'image') from dual + + + + + + select content_item.is_subclass(:other_type, 'content_revision') from dual + + + + + + begin + :1 := image.new( + name => :object_name, + parent_id => :parent_id, + item_id => :item_id, + revision_id => :revision_id, + creation_user => :creation_user, + creation_ip => :creation_ip, + content_type => :image_type, + storage_type => :storage_type, + height => :original_height, + width => :original_width + ); + end; + + + + + + begin + :1 := image.new_revision ( + item_id => :item_id, + revision_id => :revision_id, + title => :title, + description => :description, + mime_type => :mime_type, + creation_user => :creation_user, + creation_ip => :creation_ip, + height => :original_height, + width => :original_width + ); + end; + + + + + + begin + :1 := content_item.new( + name => :object_name, + item_id => :item_id, + parent_id => :parent_id, + context_id => :parent_id, + creation_user => :creation_user, + creation_ip => :creation_ip, + content_type => :other_type, + storage_type => :storage_type + ); + end; + + + + + + begin + :1 := image.new_revision ( + item_id => :item_id, + revision_id => :revision_id, + title => :title, + description => :description, + mime_type => :mime_type, + creation_user => :creation_user, + creation_ip => :creation_ip + ); + end; + + + + + + + update cr_revisions + set filename = :filename, + content_length = :tmp_size + where revision_id = :revision_id + + + + + + + update cr_revisions + set mime_type = :mime_type, + content = empty_blob() + where revision_id = :revision_id + returning content into :1 + + + + + + + + update cr_revisions + set content_length = dbms_lob.getlength(content) + where revision_id = :revision_id + + + + + + + begin content_item.set_live_revision (revision_id => :revision_id); + end; + + + Index: openacs-4/packages/acs-content-repository/tcl/revision-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/revision-procs-postgresql.xql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-content-repository/tcl/revision-procs-postgresql.xql 31 Oct 2001 20:42:07 -0000 1.3 +++ openacs-4/packages/acs-content-repository/tcl/revision-procs-postgresql.xql 15 Nov 2001 01:47:13 -0000 1.4 @@ -53,4 +53,139 @@ + + + select content_type__register_mime_type('content_revision', :mime_type) + + + + + + select content_item__is_subclass(:image_type, 'image') + + + + + + select content_item__is_subclass(:other_type, 'content_revision') + + + + + + select image__new( + /* name => */ :object_name, + /* parent_id => */ :parent_id, + /* item_id => */ :item_id, + /* revision_id => */ :revision_id, + /* mime_type => */ :mime_type, + /* creation_user => */ :creation_user, + /* creation_ip => */ :creation_ip, + /* title => */ :title, + /* description => */ :description, + /* storage_type => */ :storage_type, + /* content_type => */ :image_type, + /* nls_language => */ null, + /* publish_date => */ current_timestamp, + /* height => */ :original_height, + /* width => */ :original_width + ); + + + + + + select image__new_revision ( + /* item_id => */ :item_id, + /* revision_id => */ :revision_id, + /* title => */ :title, + /* description => */ :description, + /* publish_date => */ current_timestamp, + /* mime_type => */ :mime_type, + /* nls_language => */ null, + /* creation_user => */ :creation_user, + /* creation_ip => */ :creation_ip, + /* height => */ :original_height, + /* width => */ :original_width + ); + + + + + + select content_item__new ( + /* name => */ varchar :object_name, + /* parent_id => */ :parent_id, + /* item_id => */ :item_id, + /* new_locale => */ null, + /* creation_date => */ current_timestamp, + /* creation_user => */ :creation_user, + /* context_id => */ :parent_id, + /* creation_ip => */ :creation_ip, + /* item_subtype => */ 'content_item', + /* content_type => */ :other_type, + /* title => */ null, + /* description => */ null, + /* mime_type => */ null, + /* nls_language => */ null, + /* text => */ null, + /* storage_type => */ :storage_type + ); + + + + + + select content_revision__new ( + /* title => */ :title, + /* description => */ :description, + /* publish_date => */ current_timestamp, + /* mime_type => */ :mime_type, + /* nls_language => */ null, + /* data => */ null, + /* item_id => */ :item_id, + /* revision_id => */ :revision_id, + /* creation_date => */ current_timestamp, + /* creation_user => */ :creation_user, + /* creation_ip => */ :creation_ip + ); + + + + + + update cr_revisions + set content = :filename, + content_length = :tmp_size + where revision_id = :revision_id + + + + + + + update cr_revisions + set mime_type = :mime_type, + lob = [set __lob_id [db_string get_lob_id "select empty_lob()"]] + where revision_id = :revision_id + + + + + + + + update cr_revisions + set content_length = lob_length(lob) + where revision_id = :revision_id + + + + + + + select content_item__set_live_revision(:revision_id) + + + Index: openacs-4/packages/acs-content-repository/tcl/revision-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/revision-procs.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/acs-content-repository/tcl/revision-procs.tcl 31 Oct 2001 20:42:07 -0000 1.5 +++ openacs-4/packages/acs-content-repository/tcl/revision-procs.tcl 15 Nov 2001 01:47:13 -0000 1.6 @@ -46,32 +46,32 @@ } { if { [info exists revision_id] && [info exists item_id] } { - return -code error "Both revision_id and item_id were specfied" + ad_return -code error "Both revision_id and item_id were specfied" } if { [info exists item_id] } { if { ![db_0or1row get_item_info ""] } { - return -code error "There is no content that matches item_id '$item_id'" + ad_return -code error "There is no content that matches item_id '$item_id'" } } elseif { [info exists revision_id] } { if { ![db_0or1row get_revision_info ""] } { - return -code error "There is no content that matches revision_id '$revision_id'" + ad_return -code error "There is no content that matches revision_id '$revision_id'" } } else { - return -code error "Either revision_id or item_id must be specified" + ad_return -code error "Either revision_id or item_id must be specified" } if { ![string equal $storage_type "file"] && \ ![string equal $storage_type "text"] && \ ![string equal $storage_type "lob"] } { - return -code error "Storage type '$storage_type' is invalid." + ad_return -code error "Storage type '$storage_type' is invalid." } ReturnHeaders $mime_type switch $storage_type { text { - ns_write [db_string write_text_content] + ns_write [db_string write_text_content ""] } file { set path [cr_fs_path $storage_area_key] @@ -84,3 +84,197 @@ return } + +ad_proc -public cr_import_content { + {-storage_type "file"} + -creation_user + -creation_ip + -image_only:boolean + {-image_type "image"} + {-other_type "content_revision"} + {-title ""} + {-description ""} + -item_id + parent_id + tmp_filename + tmp_size + mime_type + object_name +} { + + Import an uploaded file into the content repository. + + @param storage_type Where to store the content (lob or file), defaults to "file" (later + a system-wide parameter) + @param creation_user The creating user (defaults to current user) + @param creation_ip The creating ip (defaults to peeraddr) + @param image_only Only allow images + @param image_type The type of content item to create if the file contains an image + @param other_type The type of content item to create for a non-image file + @param title The title given the new revision + @param description The description of the new revision + @param item_id If present, make a new revision of this item, otherwise, make a new + item + @param parent_id The parent of the content item we create + @param tmp_filename The name of the temporary file holding the uploaded content + @param tmp_size The size of tmp_file + @param mime_type The uploaded file's mime type + @param object_name The name to give the result content item and revision + + This procedure handles all mime_type details, creating a new item of the appropriate + type and stuffing the content into either the file system or the database depending + on "storage_type". The new revision is set live, and its item_id is returned to the + caller. + + image_type and other_type should be supplied when the client package + has extended the image and content_revision types to hold package-specific + information. Checking is done to ensure that image_type has been inherited from + image, and that other_type has been inherited from content_revision. + + It up to the caller to do any checking on size limitations, etc. + +} { + + if { ![info exists creation_user] } { + set creation_user [ad_verify_and_get_user_id] + } + + if { ![info exists creation_ip] } { + set creation_ip [ad_conn peeraddr] + } + + # DRB: Eventually we should allow for text storage ... (CLOB for Oracle) + + if { ![string equal $storage_type "file"] && ![string equal $storage_type "lob"] } { + return -code error "Imported content must be stored in the file system or as a large object" + } + + if {[string equal $mime_type "*/*"]} { + set mime_type "application/octet-stream" + } + + set old_item_p [info exists item_id] + if { !$old_item_p } { + set item_id [db_nextval acs_object_id_seq] + } + + set revision_id [db_nextval acs_object_id_seq] + + db_transaction { + + if { [empty_string_p [cr_registered_type_for_mime_type $mime_type]] } { + db_dml mime_type_insert "" + db_exec_plsql mime_type_register "" + } + + switch [cr_registered_type_for_mime_type $mime_type] { + image { + + if { [db_string image_subclass ""] == "f" } { + ad_return -code error "Image file must be stored in an image object" + } + + set what_aolserver_told_us "" + if { [string equal $mime_type "image/jpeg"] } { + catch { set what_aolserver_told_us [ns_jpegsize $tmp_filename] } + } elseif { [string equal $mime_type "gif"] } { + catch { set what_aolserver_told_us [ns_gifsize $tmp_filename] } + } else { + ad_return -code error "Unknown image type" + } + + # 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 "" + } + + if { !$old_item_p } { + db_exec_plsql image_new "" + } else { + db_exec_plsql image_revision_new "" + } + + } + + default { + + if { $image_only_p } { + ad_return -code error "The file you uploaded was not an image (.gif, .jpg or .jpeg) file" + } + + if { [db_string content_revision_subclass ""] == "f" } { + ad_return -code error "Content must be stored in a content revision object" + } + + if { !$old_item_p } { + db_exec_plsql content_item_new "" + } + db_exec_plsql content_revision_new "" + + } + } + + # insert the attatchment into the database + + switch $storage_type { + file { + set filename [cr_create_content_file $item_id $revision_id $tmp_filename] + db_dml set_file_content "" + } + lob { + db_dml set_lob_content "" -blob_files [list $tmp_filename] + db_dml set_lob_size "" + } + } + + } + + return $revision_id + +} + +ad_proc cr_set_imported_content_live { + -image_sql + -other_sql + mime_type + revision_id +} { + @param image_sql Optional SQL to extend the base image type + @param other_sql Optional SQL to extend the base content revision type + @mime_type Mime type of the new revision + @revision_id The revision we're setting live + + If provided execute the appropriate SQL in the caller's context, then + set the given revision live. + + The idea is to give the caller a clean way of setting the additional information + needed for its private type. This is a hack. Executing this SQL can't be done + within cr_import_content because the caller can't see the new revision's key... +} { + if { [cr_registered_type_for_mime_type $mime_type] == "image" } { + if { [info exists image_sql] } { + uplevel 1 [list db_dml dynamic_query $image_sql] + } + } elseif { [info exists other_sql] } { + uplevel 1 [list db_dml dynamic_query $other_sql] + } + db_exec_plsql set_live "" +} + + +ad_proc cr_registered_type_for_mime_type { + mime_type +} { + Return the type registered for this mime type. + + @mime_type param The mime type +} { + return [db_string registered_type_for_mime_type "" -default ""] +} Index: openacs-4/packages/acs-content-repository/tcl/revision-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/Attic/revision-procs.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-content-repository/tcl/revision-procs.xql 31 Oct 2001 20:46:59 -0000 1.1 +++ openacs-4/packages/acs-content-repository/tcl/revision-procs.xql 15 Nov 2001 01:47:13 -0000 1.2 @@ -44,4 +44,21 @@ + + + insert into cr_mime_types (mime_type) + select :mime_type + from dual + where not exists (select 1 from cr_mime_types where mime_type = :mime_type) + + + + + + select content_type + from cr_content_mime_type_map + where mime_type = :mime_type + + + Index: openacs-4/packages/acs-kernel/sql/oracle/acs-metadata-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/oracle/acs-metadata-create.sql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-kernel/sql/oracle/acs-metadata-create.sql 24 Sep 2001 23:45:12 -0000 1.3 +++ openacs-4/packages/acs-kernel/sql/oracle/acs-metadata-create.sql 15 Nov 2001 01:47:13 -0000 1.4 @@ -38,7 +38,7 @@ constraint acs_obj_types_pretty_plural_un unique, table_name varchar2(30) not null - constraint acs_object_types_tbl_name_un unique, + constraint acs_object_types_table_name_un unique, id_column varchar2(30) not null, package_name varchar2(30) not null constraint acs_object_types_pkg_name_un unique, Index: openacs-4/packages/acs-kernel/sql/postgresql/acs-metadata-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/acs-metadata-create.sql,v diff -u -r1.9 -r1.10 --- openacs-4/packages/acs-kernel/sql/postgresql/acs-metadata-create.sql 24 Sep 2001 23:45:12 -0000 1.9 +++ openacs-4/packages/acs-kernel/sql/postgresql/acs-metadata-create.sql 15 Nov 2001 01:47:13 -0000 1.10 @@ -23,6 +23,12 @@ -- OBJECT TYPES -- ------------------ +-- DRB: As originally defined two types couldn't share an attribute +-- table, which seems stupid. Why in the world should I be forbidden +-- to define two types inherited from two different parent types (specifically +-- content_revision and image) and to extend them with the same attributes +-- table? + create table acs_object_types ( object_type varchar(100) not null constraint acs_object_types_pk primary key, @@ -36,7 +42,7 @@ constraint acs_obj_types_pretty_plural_un unique, table_name varchar(30) not null - constraint acs_object_types_tbl_name_un unique, + constraint acs_object_types_table_name_un unique, id_column varchar(30) not null, package_name varchar(30) not null constraint acs_object_types_pkg_name_un unique, Index: openacs-4/packages/acs-kernel/sql/postgresql/acs-permissions-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/acs-permissions-create.sql,v diff -u -r1.15 -r1.16 --- openacs-4/packages/acs-kernel/sql/postgresql/acs-permissions-create.sql 1 Sep 2001 20:26:39 -0000 1.15 +++ openacs-4/packages/acs-kernel/sql/postgresql/acs-permissions-create.sql 15 Nov 2001 01:47:13 -0000 1.16 @@ -361,7 +361,8 @@ where h1.privilege = p1.privilege and h2.privilege = p2.privilege - and h2.tree_sortkey like h1.tree_sortkey || '%'); + and h2.tree_sortkey like h1.tree_sortkey || '%') or + p1.privilege = p2.privilege; create view acs_permissions_all as select op.object_id, p.grantee_id, p.privilege Index: openacs-4/packages/glossary/sql/postgresql/glossary-sc-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/glossary/sql/postgresql/glossary-sc-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/glossary/sql/postgresql/glossary-sc-create.sql 15 Nov 2001 01:47:13 -0000 1.1 @@ -0,0 +1,25 @@ +-- Implement OpenFTS Search service contracts +-- Dave Bauer dave@thedesignexperience.org +-- 2001-10-27 + +select acs_sc_impl__new( + 'FtsContentProvider', -- impl_contract_name + 'glossary', -- impl_name + 'glossary' -- impl_owner.name +); + +select acs_sc_impl_alias__new( + 'FtsContentProvider', -- impl_contract_name + 'glossary', -- impl_name + 'datasource', -- impl_operation_name + 'glossary__datasource', -- impl_alias + 'TCL' -- impl_pl +); + +select acs_sc_impl_alias__new( + 'FtsContentProvider', -- impl_contract_name + 'glossary', -- impl_name + 'url', -- impl_operation_name + 'glossary__url', -- impl_alias + 'TCL' -- impl_pl +); Index: openacs-4/packages/glossary/sql/postgresql/glossary-sc-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/glossary/sql/postgresql/glossary-sc-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/glossary/sql/postgresql/glossary-sc-drop.sql 15 Nov 2001 01:47:13 -0000 1.1 @@ -0,0 +1,7 @@ +-- Dave Bauer dave@thedesignexperience.org +-- 2001-10-27 + +select acs_sc_impl__delete( + 'FtsContentProvider', -- impl_contract_name + 'glossary' -- impl_name +); Index: openacs-4/packages/glossary/tcl/glossary-sc-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/glossary/tcl/glossary-sc-procs-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/glossary/tcl/glossary-sc-procs-postgresql.xql 15 Nov 2001 01:47:13 -0000 1.1 @@ -0,0 +1,27 @@ + + + + postgresql7.1 + + + + select r.revision_id as object_id, + r.name as title, + r.content as content, + r.mime_type as mime, + r.name as keywords, + 'text' as storage_type + from cr_revisions r + where revision_id = :object_id + + + + + + select site_node__url(node_id) as url_stub + from site_nodes + where object_id=:package_id + + + + Index: openacs-4/packages/glossary/tcl/glossary-sc-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/glossary/tcl/glossary-sc-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/glossary/tcl/glossary-sc-procs.tcl 15 Nov 2001 01:47:13 -0000 1.1 @@ -0,0 +1,33 @@ +# static-pages/tcl/glossary-sc-procs.tcl +# implements OpenFTS Search service contracts +# Don Baccus dhoghaza@pacifier.com +# poached from static-pages and notes + +ad_proc glossary__datasource { + object_id +} { + @author Don Baccus +} { + + set path_stub [cr_fs_path STATIC_PAGES] + + db_0or1row datasource "" -column_array datasource + + return [array get datasource] +} + + +ad_proc notes__url { + object_id +} { + @author Don Baccus +} { + + set package_id [apm_package_id_from_key glossary] + + db_1row get_url_stub "" + + set url "${url_stub}term?item_id=$object_id" + + return $url +} Index: openacs-4/packages/wp-slim/wp-slim.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/wp-slim.info,v diff -u -r1.7 -r1.8 --- openacs-4/packages/wp-slim/wp-slim.info 31 Oct 2001 20:42:07 -0000 1.7 +++ openacs-4/packages/wp-slim/wp-slim.info 15 Nov 2001 01:47:13 -0000 1.8 @@ -39,12 +39,12 @@ + - - + @@ -66,15 +66,15 @@ + - - + @@ -84,6 +84,7 @@ + @@ -143,10 +144,9 @@ - - + @@ -173,6 +173,7 @@ + Index: openacs-4/packages/wp-slim/sql/oracle/upgrade-4.0b-4.0b1.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/sql/oracle/Attic/upgrade-4.0b-4.0b1.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/wp-slim/sql/oracle/upgrade-4.0b-4.0b1.sql 20 Apr 2001 20:51:24 -0000 1.1 +++ openacs-4/packages/wp-slim/sql/oracle/upgrade-4.0b-4.0b1.sql 15 Nov 2001 01:47:13 -0000 1.2 @@ -16,19 +16,19 @@ -- add a parent_id column in all of the auxiliary tables for clobs so that we can keep -- track of all revisions of a specific presentation or slide. -alter table cr_wp_presentations_audience add ( +alter table cr_wp_presentations_aud add ( presentation_id integer - constraint cr_wp_paud_pid_nn + constraint cr_wp_paudience_pid_nn not null - constraint cr_wp_paud_pid_fk + constraint cr_wp_paudience_pid_fk references cr_wp_presentations ); -alter table cr_wp_presentations_background add ( +alter table cr_wp_presentations_back add ( presentation_id integer - constraint cr_wp_pback_pid_nn + constraint cr_wp_pbackground_pid_nn not null - constraint cr_wp_pback_pid_fk + constraint cr_wp_pbackground_pid_fk references cr_wp_presentations ); @@ -62,7 +62,7 @@ begin attr_id := content_type.create_attribute ( - content_type => 'cr_wp_presentation_audience', + content_type => 'cr_wp_presentation_aud', attribute_name => 'presentation_id', datatype => 'integer', pretty_name => 'Prsentation ID', @@ -71,7 +71,7 @@ ); attr_id := content_type.create_attribute ( - content_type => 'cr_wp_presentation_background', + content_type => 'cr_wp_presentation_back', attribute_name => 'presentation_id', datatype => 'integer', pretty_name => 'Prsentation ID', @@ -288,7 +288,7 @@ v_audience_item_id := content_item.new( name => 'audience', parent_id => v_item_id, - content_type => 'cr_wp_presentation_audience', + content_type => 'cr_wp_presentation_aud', creation_date => creation_date, creation_user => creation_user, creation_ip => creation_ip @@ -305,7 +305,7 @@ content_item.set_live_revision(v_audience_revision_id); - insert into cr_wp_presentations_audience + insert into cr_wp_presentations_aud ( id, presentation_id @@ -319,7 +319,7 @@ v_background_item_id := content_item.new( name => 'background', parent_id => v_item_id, - content_type => 'cr_wp_presentation_background', + content_type => 'cr_wp_presentation_back', creation_date => creation_date, creation_user => creation_user, creation_ip => creation_ip @@ -336,7 +336,7 @@ content_item.set_live_revision(v_background_revision_id); - insert into cr_wp_presentations_background + insert into cr_wp_presentations_back ( id, presentation_id @@ -356,8 +356,8 @@ ) is begin - delete from cr_wp_presentations_audience - where exists (select 1 from cr_revisions where revision_id = cr_wp_presentations_audience.id and item_id = audience_item_id); + delete from cr_wp_presentations_aud + where exists (select 1 from cr_revisions where revision_id = cr_wp_presentations_aud.id and item_id = audience_item_id); delete from cr_item_publish_audit where item_id = audience_item_id; @@ -370,8 +370,8 @@ ) is begin - delete from cr_wp_presentations_background - where exists (select 1 from cr_revisions where revision_id = cr_wp_presentations_background.id and item_id = background_item_id); + delete from cr_wp_presentations_back + where exists (select 1 from cr_revisions where revision_id = cr_wp_presentations_back.id and item_id = background_item_id); delete from cr_item_publish_audit where item_id = background_item_id; @@ -397,17 +397,17 @@ select item_id into v_audience_item_id from cr_items - where content_type = 'cr_wp_presentation_audience' + where content_type = 'cr_wp_presentation_aud' and parent_id = pres_item_id; - delete_audience(v_audience_item_id); + delete_aud(v_audience_item_id); select item_id into v_background_item_id from cr_items - where content_type = 'cr_wp_presentation_background' + where content_type = 'cr_wp_presentation_back' and parent_id = pres_item_id; - delete_audience(v_background_item_id); + delete_aud(v_background_item_id); delete from acs_permissions where object_id = pres_item_id; update acs_objects set context_id=null where context_id = pres_item_id; @@ -423,7 +423,7 @@ begin select content into v_blob from cr_revisions, cr_items - where cr_items.content_type = 'cr_wp_presentation_audience' + where cr_items.content_type = 'cr_wp_presentation_aud' and cr_items.parent_id = pres_item_id and cr_revisions.revision_id = cr_items.live_revision; return v_blob; @@ -437,7 +437,7 @@ begin select r.content into v_blob from cr_revisions r, - cr_wp_presentations_audience pa + cr_wp_presentations_aud pa where pa.presentation_id = pres_revision_id and r.revision_id = pa.id; return v_blob; @@ -451,7 +451,7 @@ begin select content into v_blob from cr_revisions, cr_items - where cr_items.content_type = 'cr_wp_presentation_background' + where cr_items.content_type = 'cr_wp_presentation_back' and cr_items.parent_id = pres_item_id and cr_revisions.revision_id = cr_items.live_revision; return v_blob; @@ -465,7 +465,7 @@ begin select r.content into v_blob from cr_revisions r, - cr_wp_presentations_background pb + cr_wp_presentations_back pb where pb.presentation_id = pres_revision_id and r.revision_id = pb.id; return v_blob; @@ -530,20 +530,20 @@ select item_id into v_audience_item_id from cr_items where parent_id = pres_item_id - and content_type = 'cr_wp_presentation_audience'; + and content_type = 'cr_wp_presentation_aud'; v_audience_revision_id := content_revision.new( creation_date => creation_date, creation_user => creation_user, creation_ip => creation_ip, item_id => v_audience_item_id, title => '', - text => audience + text => aud ); content_item.set_live_revision(v_audience_revision_id); - insert into cr_wp_presentations_audience + insert into cr_wp_presentations_aud ( id, presentation_id @@ -557,20 +557,20 @@ select item_id into v_background_item_id from cr_items where parent_id = pres_item_id - and content_type = 'cr_wp_presentation_background'; + and content_type = 'cr_wp_presentation_back'; v_background_revision_id := content_revision.new( creation_date => creation_date, creation_user => creation_user, creation_ip => creation_ip, item_id => v_background_item_id, title => '', - text => background + text => back ); content_item.set_live_revision(v_background_revision_id); - insert into cr_wp_presentations_background + insert into cr_wp_presentations_back ( id, presentation_id @@ -1175,4 +1175,4 @@ end wp_slide; / -show errors \ No newline at end of file +show errors Index: openacs-4/packages/wp-slim/sql/oracle/wp-slim-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/sql/oracle/wp-slim-create.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/wp-slim/sql/oracle/wp-slim-create.sql 20 Apr 2001 20:51:24 -0000 1.1 +++ openacs-4/packages/wp-slim/sql/oracle/wp-slim-create.sql 15 Nov 2001 01:47:13 -0000 1.2 @@ -61,7 +61,7 @@ -- Insert the magic, "default" style. insert into wp_styles(style_id, name, css) values(-1, 'Default (Plain)', - 'BODY { background-color: white; color: black } P { line-height: 120% } UL { line-height: 140% }'); + 'BODY { back-color: white; color: black } P { line-height: 120% } UL { line-height: 140% }'); create table cr_wp_presentations ( @@ -123,21 +123,21 @@ references wp_styles ); -create table cr_wp_presentations_audience ( +create table cr_wp_presentations_aud ( id references cr_revisions, presentation_id integer - constraint cr_wp_paud_pid_nn + constraint cr_wp_paudience_pid_nn not null - constraint cr_wp_paud_pid_fk + constraint cr_wp_paudience_pid_fk references cr_wp_presentations ); -create table cr_wp_presentations_background ( +create table cr_wp_presentations_back ( id references cr_revisions, presentation_id integer - constraint cr_wp_pback_pid_nn + constraint cr_wp_pbackground_pid_nn not null - constraint cr_wp_pback_pid_fk + constraint cr_wp_pbackground_pid_fk references cr_wp_presentations ); @@ -171,18 +171,18 @@ begin content_type.create_type ( - content_type => 'cr_wp_presentation_audience', + content_type => 'cr_wp_presentation_aud', pretty_name => 'WimpyPoint Presentation Audience', pretty_plural => 'WimpyPoint Presentation Audience', - table_name => 'cr_wp_presentations_audience', + table_name => 'cr_wp_presentations_aud', id_column => 'id' ); content_type.create_type ( - content_type => 'cr_wp_presentation_background', + content_type => 'cr_wp_presentation_back', pretty_name => 'WimpyPoint Presentation Background', pretty_plural => 'WimpyPoint Presentation Background', - table_name => 'cr_wp_presentations_background', + table_name => 'cr_wp_presentations_back', id_column => 'id' ); @@ -355,7 +355,7 @@ begin attr_id := content_type.create_attribute ( - content_type => 'cr_wp_presentation_audience', + content_type => 'cr_wp_presentation_aud', attribute_name => 'presentation_id', datatype => 'integer', pretty_name => 'Prsentation ID', @@ -364,7 +364,7 @@ ); attr_id := content_type.create_attribute ( - content_type => 'cr_wp_presentation_background', + content_type => 'cr_wp_presentation_back', attribute_name => 'presentation_id', datatype => 'integer', pretty_name => 'Prsentation ID', @@ -405,8 +405,8 @@ begin - content_type.register_child_type('cr_wp_presentation', 'cr_wp_presentation_audience', 'generic'); - content_type.register_child_type('cr_wp_presentation', 'cr_wp_presentation_background', 'generic'); + content_type.register_child_type('cr_wp_presentation', 'cr_wp_presentation_aud', 'generic'); + content_type.register_child_type('cr_wp_presentation', 'cr_wp_presentation_back', 'generic'); content_type.register_child_type('cr_wp_presentation', 'cr_wp_slide', 'generic'); content_type.register_child_type('cr_wp_slide', 'cr_wp_slide_preamble', 'generic'); @@ -418,8 +418,8 @@ begin content_folder.register_content_type(content_item.c_root_folder_id, 'cr_wp_presentation'); - content_folder.register_content_type(content_item.c_root_folder_id, 'cr_wp_presentation_audience'); - content_folder.register_content_type(content_item.c_root_folder_id, 'cr_wp_presentation_background'); + content_folder.register_content_type(content_item.c_root_folder_id, 'cr_wp_presentation_aud'); + content_folder.register_content_type(content_item.c_root_folder_id, 'cr_wp_presentation_back'); content_folder.register_content_type(content_item.c_root_folder_id, 'cr_wp_slide'); content_folder.register_content_type(content_item.c_root_folder_id, 'cr_wp_slide_preamble'); content_folder.register_content_type(content_item.c_root_folder_id, 'cr_wp_slide_postamble'); @@ -435,16 +435,27 @@ -- ???? should references cr_items --- File attachments (including images). -create table cr_wp_attachments ( +-- File attachments - always displayed as a link + +create table cr_wp_file_attachments ( attach_id integer - constraint cr_wattach_attach_id_fk + constraint cr_fattach_attach_id_fk references cr_revisions - constraint cr_wattach_attach_id_pk + constraint cr_fattach_attach_id_pk + primary key +); + +-- Image attachments. May or may not be displayed as a link. + +create table cr_wp_image_attachments ( + attach_id integer + constraint cr_iattach_attach_id_fk + references cr_revisions + constraint cr_iattach_attach_id_pk primary key, -- Display how? null for a link display varchar(20) - constraint cr_wattach_display_ck + constraint cr_iattach_display_ck check(display in ('preamble', 'bullets', 'postamble', 'top', 'after_preamble', 'after_bullets', 'bottom')) ); @@ -453,35 +464,55 @@ attr_id acs_attributes.attribute_id%TYPE; begin content_type.create_type ( - content_type => 'cr_wp_attachment', - pretty_name => 'Wimpy Attachment', - pretty_plural => 'Wimpy Attachments', - table_name => 'cr_wp_attachments', + content_type => 'cr_wp_image_attachment', + supertype => 'image', + pretty_name => 'Wimpy Image Attachment', + pretty_plural => 'Wimpy Image Attachments', + table_name => 'cr_wp_image_attachments', id_column => 'attach_id' ); attr_id := content_type.create_attribute ( - content_type => 'cr_wp_attachment', + content_type => 'cr_wp_image_attachment', attribute_name => 'display', datatype => 'text', pretty_name => 'Where to display', pretty_plural => 'Where to display', column_spec => 'varchar2(20)' ); + content_type.create_type ( + content_type => 'cr_wp_file_attachment', + pretty_name => 'Wimpy File Attachment', + pretty_plural => 'Wimpy File Attachments', + table_name => 'cr_wp_file_attachments', + id_column => 'attach_id' + ); + + attr_id := content_type.create_attribute ( + content_type => 'cr_wp_file_attachment', + attribute_name => 'display', + datatype => 'text', + pretty_name => 'Where to display', + pretty_plural => 'Where to display', + column_spec => 'varchar2(20)' + ); + end; / show errors begin - content_type.register_child_type('cr_wp_slide', 'cr_wp_attachment', 'generic'); + content_type.register_child_type('cr_wp_slide', 'cr_wp_image_attachment', 'generic'); + content_type.register_child_type('cr_wp_slide', 'cr_wp_file_attachment', 'generic'); end; / show errors begin - content_folder.register_content_type(content_item.c_root_folder_id, 'cr_wp_attachment'); + content_folder.register_content_type(content_item.c_root_folder_id, 'cr_wp_image_attachment'); + content_folder.register_content_type(content_item.c_root_folder_id, 'cr_wp_file_attachment'); end; / show errors @@ -699,16 +730,11 @@ / show errors +-- DRB: Creating an attachment is handled by cr_import_content create or replace package wp_attachment as - function new ( - slide_item_id in cr_items.item_id%TYPE, - creation_date in acs_objects.creation_date%TYPE default sysdate, - creation_user in acs_objects.creation_user%TYPE default null, - creation_ip in acs_objects.creation_ip%TYPE default null - ) return cr_items.item_id%TYPE; - + procedure delete ( attach_item_id in cr_items.item_id%TYPE ); @@ -720,9 +746,6 @@ end wp_attachment; / show errors - - - create or replace package body wp_presentation as @@ -802,9 +825,9 @@ ); v_audience_item_id := content_item.new( - name => 'audience', + name => 'aud', parent_id => v_item_id, - content_type => 'cr_wp_presentation_audience', + content_type => 'cr_wp_presentation_aud', creation_date => creation_date, creation_user => creation_user, creation_ip => creation_ip @@ -821,7 +844,7 @@ content_item.set_live_revision(v_audience_revision_id); - insert into cr_wp_presentations_audience + insert into cr_wp_presentations_aud ( id, presentation_id @@ -833,9 +856,9 @@ ); v_background_item_id := content_item.new( - name => 'background', + name => 'back', parent_id => v_item_id, - content_type => 'cr_wp_presentation_background', + content_type => 'cr_wp_presentation_back', creation_date => creation_date, creation_user => creation_user, creation_ip => creation_ip @@ -852,7 +875,7 @@ content_item.set_live_revision(v_background_revision_id); - insert into cr_wp_presentations_background + insert into cr_wp_presentations_back ( id, presentation_id @@ -872,8 +895,8 @@ ) is begin - delete from cr_wp_presentations_audience - where exists (select 1 from cr_revisions where revision_id = cr_wp_presentations_audience.id and item_id = audience_item_id); + delete from cr_wp_presentations_aud + where exists (select 1 from cr_revisions where revision_id = cr_wp_presentations_aud.id and item_id = audience_item_id); delete from cr_item_publish_audit where item_id = audience_item_id; @@ -886,8 +909,8 @@ ) is begin - delete from cr_wp_presentations_background - where exists (select 1 from cr_revisions where revision_id = cr_wp_presentations_background.id and item_id = background_item_id); + delete from cr_wp_presentations_back + where exists (select 1 from cr_revisions where revision_id = cr_wp_presentations_back.id and item_id = background_item_id); delete from cr_item_publish_audit where item_id = background_item_id; @@ -913,14 +936,14 @@ select item_id into v_audience_item_id from cr_items - where content_type = 'cr_wp_presentation_audience' + where content_type = 'cr_wp_presentation_aud' and parent_id = pres_item_id; delete_audience(v_audience_item_id); select item_id into v_background_item_id from cr_items - where content_type = 'cr_wp_presentation_background' + where content_type = 'cr_wp_presentation_back' and parent_id = pres_item_id; delete_audience(v_background_item_id); @@ -939,7 +962,7 @@ begin select content into v_blob from cr_revisions, cr_items - where cr_items.content_type = 'cr_wp_presentation_audience' + where cr_items.content_type = 'cr_wp_presentation_aud' and cr_items.parent_id = pres_item_id and cr_revisions.revision_id = cr_items.live_revision; return v_blob; @@ -953,7 +976,7 @@ begin select r.content into v_blob from cr_revisions r, - cr_wp_presentations_audience pa + cr_wp_presentations_aud pa where pa.presentation_id = pres_revision_id and r.revision_id = pa.id; return v_blob; @@ -967,7 +990,7 @@ begin select content into v_blob from cr_revisions, cr_items - where cr_items.content_type = 'cr_wp_presentation_background' + where cr_items.content_type = 'cr_wp_presentation_back' and cr_items.parent_id = pres_item_id and cr_revisions.revision_id = cr_items.live_revision; return v_blob; @@ -981,7 +1004,7 @@ begin select r.content into v_blob from cr_revisions r, - cr_wp_presentations_background pb + cr_wp_presentations_back pb where pb.presentation_id = pres_revision_id and r.revision_id = pb.id; return v_blob; @@ -1046,7 +1069,7 @@ select item_id into v_audience_item_id from cr_items where parent_id = pres_item_id - and content_type = 'cr_wp_presentation_audience'; + and content_type = 'cr_wp_presentation_aud'; v_audience_revision_id := content_revision.new( creation_date => creation_date, @@ -1059,7 +1082,7 @@ content_item.set_live_revision(v_audience_revision_id); - insert into cr_wp_presentations_audience + insert into cr_wp_presentations_aud ( id, presentation_id @@ -1073,7 +1096,7 @@ select item_id into v_background_item_id from cr_items where parent_id = pres_item_id - and content_type = 'cr_wp_presentation_background'; + and content_type = 'cr_wp_presentation_back'; v_background_revision_id := content_revision.new( creation_date => creation_date, @@ -1086,7 +1109,7 @@ content_item.set_live_revision(v_background_revision_id); - insert into cr_wp_presentations_background + insert into cr_wp_presentations_back ( id, presentation_id @@ -1343,7 +1366,7 @@ cursor v_attach_cursor is select item_id as attach_item_id from cr_items - where content_type = 'cr_wp_attachment' + where content_type in ('cr_wp_image_attachment', 'cr_wp_file_attachment') and parent_id = slide_item_id; begin for c in v_attach_cursor loop @@ -1615,25 +1638,17 @@ create or replace package body wp_attachment as - function new ( - slide_item_id in cr_items.item_id%TYPE, - creation_date in acs_objects.creation_date%TYPE default sysdate, - creation_user in acs_objects.creation_user%TYPE default null, - creation_ip in acs_objects.creation_ip%TYPE default null - ) return cr_items.item_id%TYPE - is - v_item_id cr_items.item_id%TYPE; - begin - return v_item_id; - end; procedure delete ( attach_item_id in cr_items.item_id%TYPE ) is begin - delete from cr_wp_attachments - where exists (select 1 from cr_revisions where revision_id = cr_wp_attachments.attach_id and item_id = attach_item_id); + delete from cr_wp_image_attachments + where exists (select 1 from cr_revisions where revision_id = cr_wp_image_attachments.attach_id and item_id = attach_item_id); + + delete from cr_wp_file_attachments + where exists (select 1 from cr_revisions where revision_id = cr_wp_file_attachments.attach_id and item_id = attach_item_id); delete from cr_item_publish_audit where item_id = attach_item_id; Index: openacs-4/packages/wp-slim/sql/oracle/wp-slim-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/sql/oracle/wp-slim-drop.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/wp-slim/sql/oracle/wp-slim-drop.sql 20 Apr 2001 20:51:24 -0000 1.1 +++ openacs-4/packages/wp-slim/sql/oracle/wp-slim-drop.sql 15 Nov 2001 01:47:13 -0000 1.2 @@ -7,7 +7,7 @@ -- ?? delete from cr_folder_type_map -where content_type in ('cr_wp_attachment', 'cr_wp_presentation', 'cr_wp_presentation_audience', 'cr_wp_presentation_background', 'cr_wp_slide', 'cr_wp_slide_preamble', 'cr_wp_slide_postamble', 'cr_wp_slide_bullet_items'); +where content_type in ('cr_wp_image_attachment', 'cr_wp_file_attachment', 'cr_wp_presentation', 'cr_wp_presentation_aud', 'cr_wp_presentation_back', 'cr_wp_slide', 'cr_wp_slide_preamble', 'cr_wp_slide_postamble', 'cr_wp_slide_bullet_items'); -- drop clobs tables @@ -17,7 +17,7 @@ cursor v_attach_cursor is select item_id from cr_items - where content_type = 'cr_wp_attachment'; + where content_type in ('cr_wp_image_attachment', 'cr_wp_file_attachment'); begin @@ -33,29 +33,33 @@ -- drop attachment table and views begin - content_type.unregister_child_type('cr_wp_slide', 'cr_wp_attachment', 'generic'); + content_type.unregister_child_type('cr_wp_slide', 'cr_wp_image_attachment', 'generic'); + content_type.unregister_child_type('cr_wp_slide', 'cr_wp_file_attachment', 'generic'); end; / show errors begin - content_folder.unregister_content_type(content_item.c_root_folder_id, 'cr_wp_attachment'); + content_folder.unregister_content_type(content_item.c_root_folder_id, 'cr_wp_image_attachment'); + content_folder.unregister_content_type(content_item.c_root_folder_id, 'cr_wp_file_attachment'); end; / show errors begin - content_type.drop_attribute('cr_wp_attachment', 'display'); + content_type.drop_attribute('cr_wp_file_attachment', 'display'); + content_type.drop_attribute('cr_wp_image_attachment', 'display'); end; / show errors -delete from acs_objects where object_type = 'cr_wp_attachment'; +delete from acs_objects where object_type in ('cr_wp_file_attachment', 'cr_wp_image_attachment'); begin - acs_object_type.drop_type('cr_wp_attachment'); + acs_object_type.drop_type('cr_wp_image_attachment'); + acs_object_type.drop_type('cr_wp_file_attachment'); end; / show errors @@ -76,7 +80,7 @@ cursor v_pres_clob_cursor is select item_id from cr_items - where content_type in ('cr_wp_presentation_audience', 'cr_wp_presentation_background'); + where content_type in ('cr_wp_presentation_aud', 'cr_wp_presentation_back'); cursor v_pres_cursor is @@ -115,8 +119,8 @@ begin - content_type.unregister_child_type('cr_wp_presentation', 'cr_wp_presentation_audience', 'generic'); - content_type.unregister_child_type('cr_wp_presentation', 'cr_wp_presentation_background', 'generic'); + content_type.unregister_child_type('cr_wp_presentation', 'cr_wp_presentation_aud', 'generic'); + content_type.unregister_child_type('cr_wp_presentation', 'cr_wp_presentation_back', 'generic'); content_type.unregister_child_type('cr_wp_presentation', 'cr_wp_slide', 'generic'); content_type.unregister_child_type('cr_wp_slide', 'cr_wp_slide_preamble', 'generic'); @@ -128,8 +132,8 @@ begin content_folder.unregister_content_type(content_item.c_root_folder_id, 'cr_wp_presentation'); - content_folder.unregister_content_type(content_item.c_root_folder_id, 'cr_wp_presentation_audience'); - content_folder.unregister_content_type(content_item.c_root_folder_id, 'cr_wp_presentation_background'); + content_folder.unregister_content_type(content_item.c_root_folder_id, 'cr_wp_presentation_aud'); + content_folder.unregister_content_type(content_item.c_root_folder_id, 'cr_wp_presentation_back'); content_folder.unregister_content_type(content_item.c_root_folder_id, 'cr_wp_slide'); content_folder.unregister_content_type(content_item.c_root_folder_id, 'cr_wp_slide_preamble'); content_folder.unregister_content_type(content_item.c_root_folder_id, 'cr_wp_slide_postamble'); @@ -140,8 +144,8 @@ begin - content_type.drop_attribute('cr_wp_presentation_audience', 'presentation_id'); - content_type.drop_attribute('cr_wp_presentation_background', 'presentation_id'); + content_type.drop_attribute('cr_wp_presentation_aud', 'presentation_id'); + content_type.drop_attribute('cr_wp_presentation_back', 'presentation_id'); content_type.drop_attribute('cr_wp_slide_preamble', 'slide_id'); content_type.drop_attribute('cr_wp_slide_postamble', 'slide_id'); @@ -171,13 +175,13 @@ show errors -delete from acs_objects where object_type in ('cr_wp_attachment', 'cr_wp_presentation', 'cr_wp_presentation_audience', 'cr_wp_presentation_background', 'cr_wp_slide', 'cr_wp_slide_preamble', 'cr_wp_slide_postamble', 'cr_wp_slide_bullet_items'); +delete from acs_objects where object_type in ('cr_wp_image_attachment', 'cr_wp_file_attachment', 'cr_wp_presentation', 'cr_wp_presentation_aud', 'cr_wp_presentation_back', 'cr_wp_slide', 'cr_wp_slide_preamble', 'cr_wp_slide_postamble', 'cr_wp_slide_bullet_items'); begin acs_object_type.drop_type('cr_wp_presentation'); - acs_object_type.drop_type('cr_wp_presentation_audience'); - acs_object_type.drop_type('cr_wp_presentation_background'); + acs_object_type.drop_type('cr_wp_presentation_aud'); + acs_object_type.drop_type('cr_wp_presentation_back'); acs_object_type.drop_type('cr_wp_slide'); acs_object_type.drop_type('cr_wp_slide_preamble'); @@ -234,16 +238,20 @@ drop package wp_presentation; -drop table cr_wp_presentations_audience; -drop table cr_wp_presentations_background; +drop table cr_wp_presentations_aud; +drop table cr_wp_presentations_back; drop table cr_wp_slides_preamble; drop table cr_wp_slides_postamble; drop table cr_wp_slides_bullet_items; -drop view cr_wp_attachmentsi; -drop view cr_wp_attachmentsx; -drop table cr_wp_attachments; +drop table cr_wp_image_attachments; +drop table cr_wp_file_attachments; +drop view cr_wp_image_attachmentsi; +drop view cr_wp_image_attachmentsx; +drop view cr_wp_file_attachmentsi; +drop view cr_wp_file_attachmentsx; + drop view cr_wp_slidesi; drop view cr_wp_slidesx; drop table cr_wp_slides; Index: openacs-4/packages/wp-slim/sql/postgresql/wp-slim-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/sql/postgresql/wp-slim-create.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/wp-slim/sql/postgresql/wp-slim-create.sql 4 Oct 2001 04:18:35 -0000 1.1 +++ openacs-4/packages/wp-slim/sql/postgresql/wp-slim-create.sql 15 Nov 2001 01:47:13 -0000 1.2 @@ -57,9 +57,9 @@ insert into wp_styles(style_id, name, css) values(-1, 'Default (Plain)', - 'BODY { background-color: white; color: black } P { line-height: 120% } UL { line-height: 140% }'); + 'BODY { back-color: white; color: black } P { line-height: 120% } UL { line-height: 140% }'); ---jackp: create the presentation table +--jackp: p_create the presentation table create table cr_wp_presentations ( presentation_id integer constraint cr_wp_presentations_id_fk @@ -114,26 +114,23 @@ references wp_styles ); ---jackp: The table for the audiences. We had to truncate audience to aud create table cr_wp_presentations_aud ( id integer references cr_revisions, presentation_id integer - constraint cr_wp_paud_pid_nn + constraint cr_wp_paudience_pid_nn not null - constraint cr_wp_paud_pid_fk + constraint cr_wp_paudience_pid_fk references cr_wp_presentations ); ---jackp: The table for the background. We had to truncate background to ---back. create table cr_wp_presentations_back ( id integer references cr_revisions, presentation_id integer - constraint cr_wp_pback_pid_nn + constraint cr_wp_pbackground_pid_nn not null - constraint cr_wp_pback_pid_fk + constraint cr_wp_pbackground_pid_fk references cr_wp_presentations ); @@ -171,7 +168,7 @@ ); --jackp: Need to use inline functions in PostgreSQL. ---jackp: We create the main content type here. +--jackp: We p_create the main content type here. --jackp: Need to use PERFORM command line to indicate that the line needs --jackp: to be run. create function inline_0 () @@ -271,7 +268,7 @@ select inline_1 (); drop function inline_1 (); ---jackp: This section creates the attributes that are linked to the +--jackp: This section p_creates the attributes that are linked to the --jackp: different types create function inline_2 () returns integer as' @@ -524,16 +521,26 @@ select inline_6 (); drop function inline_6 (); ---jackp: create a table to store different attachments. ---jackp: As far as I can see this table is not actually used anywhere -create table cr_wp_attachments ( +-- DRB: table for file attachments. Empty but necessary because the object +-- system doesn't allow for simple renaming of types. Nor can two types +-- share an attribute table. + +create table cr_wp_file_attachments ( attach_id integer - constraint cr_wattach_attach_id_fk + constraint cr_fattach_attach_id_fk references cr_revisions - constraint cr_wattach_attach_id_pk + constraint cr_fattach_attach_id_pk + primary key +); + +create table cr_wp_image_attachments ( + attach_id integer + constraint cr_iattach_attach_id_fk + references cr_revisions + constraint cr_iattach_attach_id_pk primary key, display varchar(20) - constraint cr_wattach_display_ck + constraint cr_iattach_display_ck check(display in ( 'preamble', 'bullets', @@ -544,25 +551,46 @@ 'bottom')) ); ---jackp: create the content-type and content-attribute assosciated with +--jackp: p_create the content-type and content-attribute assosciated with --jackp: attachments create function inline_7 () returns integer as' declare attr_id acs_attributes.attribute_id%TYPE; begin PERFORM content_type__create_type ( - ''cr_wp_attachment'', + ''cr_wp_image_attachment'', + ''image'', + ''Wimpy Image Attachment'', + ''Wimpy Image Attachments'', + ''cr_wp_image_attachments'', + ''attach_id'', + null + ); + + attr_id := content_type__create_attribute ( + ''cr_wp_image_attachment'', + ''display'', + ''text'', + ''Where to display'', + ''Where display this'', + null, + null, + ''varchar(20)'' + ); + + PERFORM content_type__create_type ( + ''cr_wp_file_attachment'', ''content_revision'', - ''Wimpy Attachment'', - ''Wimpy Attachments'', - ''cr_wp_attachments'', + ''Wimpy File Attachment'', + ''Wimpy File Attachments'', + ''cr_wp_file_attachments'', ''attach_id'', null ); attr_id := content_type__create_attribute ( - ''cr_wp_attachment'', + ''cr_wp_file_attachment'', ''display'', ''text'', ''Where to display'', @@ -571,6 +599,7 @@ null, ''varchar(20)'' ); + return 0; end;' language 'plpgsql'; select inline_7 (); @@ -582,29 +611,36 @@ begin PERFORM content_type__register_child_type( ''cr_wp_slide'', - ''cr_wp_attachment'', + ''cr_wp_image_attachment'', ''generic'', 0, null ); + PERFORM content_type__register_child_type( + ''cr_wp_slide'', + ''cr_wp_file_attachment'', + ''generic'', + 0, + null + ); return 0; end;' language 'plpgsql'; select inline_8 (); drop function inline_8 (); --jackp: register the different content types for attachments -create function inline_9 () -returns integer as' -begin - PERFORM content_folder__register_content_type( - content_item_globals.c_root_folder_id, - ''cr_wp_attachment'', - ''f'' - ); - return 0; -end;' language 'plpgsql'; -select inline_9 (); -drop function inline_9 (); +--create function inline_9 () +--returns integer as' +--begin +-- PERFORM content_folder__register_content_type( +-- content_item_globals.c_root_folder_id, +-- ''cr_wp_attachment'', +-- ''f'' +-- ); +-- return 0; +--end;' language 'plpgsql'; +--select inline_9 (); +--drop function inline_9 (); commit; @@ -678,7 +714,7 @@ --jackp: From here on the functions are defined ---jackp: To create each presentation +--jackp: To p_create each presentation create function wp_presentation__new ( timestamp, integer, @@ -694,17 +730,17 @@ ) returns integer as' declare - creation_date alias for $1; - creation_user alias for $2; - creation_ip alias for $3; + p_creation_date alias for $1; + p_creation_user alias for $2; + p_creation_ip alias for $3; p_pres_title alias for $4; p_page_signature alias for $5; p_copyright_notice alias for $6; p_style alias for $7; p_public_p alias for $8; p_show_modified_p alias for $9; - audience alias for $10; - background alias for $11; + aud alias for $10; + back alias for $11; v_item_id cr_items.item_id%TYPE; v_audience_item_id cr_items.item_id%TYPE; v_background_item_id cr_items.item_id%TYPE; @@ -721,52 +757,15 @@ v_name := p_pres_title || ''_'' || v_max_id; ---jackp: found in acs-content-repository/sql/postgresql/content-item.sql ---jackp: format for new is: ---jackp: id := content_item__new( ---jackp: name ---jackp: parent_id ---jackp: item_id ---jackp: locale ---jackp: creation_date ---jackp: creation_user ---jackp: context_id ---jackp: creation_ip ---jackp: item_subtype ---jackp: content_type ---jackp: title ---jackp: description ---jackp: mime_type ---jackp: nls_language ---jackp: text ---jackp: storage_type ---jackp: ); - ---jackp: found in acs-content-repository/content-revision.sql ---jackp: format for revision is: ---jackp: id := content_revision__new( ---jackp: title ---jackp: description ---jackp: publish_date ---jackp: mime_type ---jackp: nls_language ---jackp: data ---jackp: item_id ---jackp: revision_id ---jackp: creation_date ---jackp: creation_user ---jackp: creation_ip ---jackp: ); - v_item_id := content_item__new( v_name, null, null, null, - creation_date, - creation_user, + p_creation_date, + p_creation_user, null, - creation_ip, + p_creation_ip, ''content_item'', ''cr_wp_presentation'', null, @@ -778,17 +777,17 @@ ); v_revision_id := content_revision__new( - '''', null, - now(), + null, + current_timestamp, ''text/plain'', null, null, v_item_id, null, - creation_date, - creation_user, - creation_ip + p_creation_date, + p_creation_user, + p_creation_ip ); PERFORM content_item__set_live_revision(v_revision_id); @@ -814,14 +813,14 @@ ); v_audience_item_id := content_item__new( - audience, + aud, v_item_id, null, null, - creation_date, - creation_user, + p_creation_date, + p_creation_user, null, - creation_ip, + p_creation_ip, ''content_item'', ''cr_wp_presentation_aud'', null, @@ -833,17 +832,17 @@ ); v_audience_revision_id := content_revision__new( - '''', null, - now(), + null, + current_timestamp, ''text/plain'', null, - audience, + aud, v_audience_item_id, null, - creation_date, - creation_user, - creation_ip + p_creation_date, + p_creation_user, + p_creation_ip ); PERFORM content_item__set_live_revision(v_audience_revision_id); @@ -858,14 +857,14 @@ ); v_background_item_id := content_item__new( - background, + back, v_item_id, null, null, - creation_date, - creation_user, + p_creation_date, + p_creation_user, null, - creation_ip, + p_creation_ip, ''content_item'', ''cr_wp_presentation_back'', null, @@ -877,17 +876,17 @@ ); v_background_revision_id := content_revision__new( - '''', null, - now(), + null, + current_timestamp, ''text/plain'', null, - background, + back, v_background_item_id, null, - creation_date, - creation_user, - creation_ip + p_creation_date, + p_creation_user, + p_creation_ip ); PERFORM content_item__set_live_revision(v_background_revision_id); @@ -912,7 +911,7 @@ audience_item_id alias $1; begin delete from cr_wp_presentations_aud - where exists (select 1 from cr_revisions where revision_id = cr_wp_presentations_aud__id and item_id = audience_item_id); + where exists (select 1 from cr_revisions where revision_id = cr_wp_presentations_aud.id and item_id = audience_item_id); delete from cr_item_publish_audit where item_id = audience_item_id; @@ -928,7 +927,7 @@ background_item_id alias $1; begin delete from cr_wp_presentations_back - where exists (select 1 from cr_revisions where revision_id = cr_wp_presenta$tions_background__id and item_id = background_item_id); + where exists (select 1 from cr_revisions where revision_id = cr_wp_presentations_back.id and item_id = background_item_id); delete from cr_item_publish_audit where item_id = background_item_id; @@ -959,14 +958,14 @@ where content_type = ''cr_wp_presentation_aud'' and parent_id = pres_item_id; - delete_audience(v_audience_item_id); + delete_aud(v_audience_item_id); select item_id into v_background_item_id from cr_items where content_type = ''cr_wp_presentation_back'' and parent_id = pres_item_id; - delete_background(v_background_item_id); + delete_back(v_background_item_id); delete from acs_permissions where object_id = pres_item_id; update acs_objects set context_id=null where context_id = pres_item_id; @@ -975,66 +974,61 @@ return 0; end;' language 'plpgsql'; +-- DRB: All these could've been implemented as a single function with a type argument +-- but I'm not going to rewrite all of wp-slim's queries just to clean this up... + +create function wp_presentation__get_ad_revision (integer) returns text as ' +declare + p_pres_revision_id alias for $1; +begin + return r.content + from cr_revisions r, + cr_wp_presentations_aud pa + where pa.presentation_id = p_pres_revision_id + and r.revision_id = pa.id; +end;' language 'plpgsql'; + create function wp_presentation__get_audience ( integer -) returns blob as' +) returns text as' declare - pres_item_id alias for $1; - v_blob blob; + p_pres_item_id alias for $1; begin - select content into v_blob + return content from cr_revisions, cr_items - where cr_items__content_type = ''cr_wp_presentation_aud'' - and cr_items__parent_id = pres_item_id - and cr_revisions__revision_id = cr_items__live_revision; - return v_blob; + where cr_items.content_type = ''cr_wp_presentation_aud'' + and cr_items.parent_id = p_pres_item_id + and cr_revisions.revision_id = cr_items__live_revision; end;' language 'plpgsql'; -create function wp_presentation__get_ad_revision( -integer ) returns blob as' +create function wp_presentation__get_bg_revision (integer) returns text as ' declare - pres_revision_id alias for $1; -v_blob blob; + p_pres_revision_id alias for $1; begin - select r__content into v_blob - from cr_revisions r, cr_wp_presentations_aud pa - where pa__presentation_id = pres_revision_id - and r__revision_id = pa__id; - return v_blob; -end;' language'plpgsql'; + return r.content + from cr_revisions r, + cr_wp_presentations_aud pa + where pa.presentation_id = p_pres_revision_id + and r.revision_id = pa.id; +end;' language 'plpgsql'; create function wp_presentation__get_background ( integer -) returns blob as' +) returns text as' declare pres_item_id alias for $1; - v_blob blob; begin - select content into v_blob - from cr_revisions r, cr_items i - where i__content_type = ''cr_wp_presentation_back'' - and i__parent_id = pres_item_id - and r__revision_id = i__live_revision; - return v_blob; -end;' language'plpgsql'; - -create function wp_presentation__get_bg_revision ( - integer -) returns blob as' -declare - pres_revision_id alias for $1; - v_blob blob; - begin - select cr_revisions__content into v_blob - from cr_revisions r, cr_wp_presentations_back pb - where pb__presentation_id = pres_revision_id - and r__revision_id = pb__id; - return v_blob; + return content + from cr_revisions, cr_items + where cr_items.content_type = ''cr_wp_presentation_bak'' + and cr_items.parent_id = p_pres_item_id + and cr_revisions.revision_id = cr_items__live_revision; end;' language 'plpgsql'; + create function wp_presentation__new_revision ( timestamp, - varchar(400), + integer, varchar, integer, varchar(400), @@ -1066,12 +1060,17 @@ v_background_revision_id cr_revisions.revision_id%TYPE; begin v_revision_id := content_revision__new( - '''', null, - now(), + null, + current_timestamp, ''text/plain'', null, - p_pres_item_id + null, + p_pres_item_id, + null, + p_creation_date, + p_creation_user, + p_creation_ip ); PERFORM content_item__set_live_revision(v_revision_id); @@ -1101,12 +1100,17 @@ and content_type = ''cr_wp_presentation_aud''; v_audience_revision_id := content_revision__new( - '''', null, - now(), + null, + current_timestamp, ''text/plain'', + null, p_audience, - v_audience_item_id + v_audience_item_id, + null, + p_creation_date, + p_creation_user, + p_creation_ip ); PERFORM content_item__set_live_revision(v_audience_revision_id); @@ -1126,13 +1130,18 @@ and content_type = ''cr_wp_presentation_back''; v_background_revision_id := content_revision__new( - '''', null, - now(), + null, + current_timestamp, ''text/plain'', + null, p_background, - v_background_item_id - ); + v_background_item_id, + null, + p_creation_date, + p_creation_user, + p_creation_ip + ); PERFORM content_item__set_live_revision(v_background_revision_id); @@ -1141,7 +1150,7 @@ id, presentation_id ) values ( - v_audience_revision_id, + v_background_revision_id, v_revision_id ); return 0; @@ -1216,9 +1225,9 @@ ); v_revision_id := content_revision__new( - '''', + null, null, - now(), + current_timestamp, ''text/plain'', null, null, @@ -1277,12 +1286,17 @@ ); v_preamble_revision_id := content_revision__new( - '''', - null, - now(), - ''text/plain'', - p_preamble, - v_preamble_item_id + null, + null, + current_timestamp, + ''text/plain'', + null, + p_preamble, + v_preamble_item_id, + null, + p_creation_date, + p_creation_user, + p_creation_ip ); PERFORM content_item__set_live_revision(v_preamble_revision_id); @@ -1315,13 +1329,19 @@ ''text'' ); + v_postamble_revision_id := content_revision__new( - '''', null, - now(), - ''text/plain'', + null, + current_timestamp, + ''text/plain'', + null, p_postamble, - v_postamble_item_id + v_postamble_item_id, + null, + p_creation_date, + p_creation_user, + p_creation_ip ); PERFORM content_item__set_live_revision(v_postamble_revision_id); @@ -1346,21 +1366,27 @@ p_creation_ip, ''content_item'', ''cr_wp_slide_bullet_items'', - '''', null, null, + null, ''text/plain'', null, ''text'' ); + v_bullet_items_revision_id := content_revision__new( - '''', null, - now(), - ''text/plain'', + null, + current_timestamp, + ''text/plain'', + null, p_bullet_items, - v_bullet_items_item_id + v_bullet_items_item_id, + null, + p_creation_date, + p_creation_user, + p_creation_ip ); PERFORM content_item__set_live_revision(v_bullet_items_revision_id); @@ -1444,7 +1470,7 @@ begin for del_rec in select item_id as attach_item_id from cr_items - where content_type = ''cr_wp_attachment'' + where content_type in (''cr_wp_image_attachment'', ''cr_wp_file_attachment'') and parent_id = slide_item_id loop wp_attachment__delete(del_rec.attach_item_id); @@ -1505,83 +1531,85 @@ return 0; end;' language 'plpgsql'; -create function wp_slide__get_preamble( +create function wp_slide__get_preamble_revision ( integer -) returns record as' +) returns text as ' declare - get_preamble__slide_item_id alias for $1; - v_blob record; -begin - select content into v_blob - from cr_revisions, cr_items - where cr_items.content_type = ''cr_wp_slide_preamble'' - and cr_items.parent_id = get_preamble.slide_item_id - and cr_revisions.revision_id = cr_items.live_revision; - return v_blob; + p_slide_revision_id alias for $1; +begin + return content + from cr_revisions r, cr_wp_slides_preamble sp + where sp.slide_id = p_slide_revision_id + and r.revision_id = sp.id; end;' language 'plpgsql'; +create function wp_slide__get_postamble_revision ( + integer +) returns text as ' +declare + p_slide_revision_id alias for $1; +begin + return content + from cr_revisions r, cr_wp_slides_postamble sp + where sp.slide_id = p_slide_revision_id + and r.revision_id = sp.id; +end;' language 'plpgsql'; + +create function wp_slide__get_bullet_items_revision ( + integer +) returns text as ' +declare + p_slide_revision_id alias for $1; +begin + return content + from cr_revisions r, cr_wp_slides_bullet_items sp + where sp.slide_id = p_slide_revision_id + and r.revision_id = sp.id; +end;' language 'plpgsql'; + create function wp_slide__get_postamble( integer -) returns record as' +) returns text as ' declare - get_postamble__slide_item_id alias for $1; - v_blob record; + p_slide_item_id alias for $1; begin - select content into v_blob + return content from cr_revisions, cr_items where cr_items.content_type = ''cr_wp_slide_postamble'' - and cr_items.parent_id = get_postamble.slide_item_id + and cr_items.parent_id = p_slide_item_id and cr_revisions.revision_id = cr_items.live_revision; - return v_blob; end;' language 'plpgsql'; -create function wp_slide__get_preamble_revision( +create function wp_slide__get_preamble( integer -) returns blob as' +) returns text as' declare - get_preamble_revision__slide_revision_id alias for $1; - v_blob blob; + p_slide_item_id alias for $1; begin - select content into v_blob - from cr_revisions r, cr_wp_slides_preamble sp - where sp.slide_id = get_preamble_revision.slide_revision_id - and r.revision_id = sp.id; - return v_blob; + return content + from cr_revisions, cr_items + where cr_items.content_type = ''cr_wp_slide_preamble'' + and cr_items.parent_id = p_slide_item_id + and cr_revisions.revision_id = cr_items.live_revision; end;' language 'plpgsql'; create function wp_slide__get_bullet_items( integer -) returns record as' +) returns text as' declare - slide_item_id alias for $1; - v_blob record; + p_slide_item_id alias for $1; begin - select content into v_blob + return content from cr_revisions, cr_items where cr_items.content_type = ''cr_wp_slide_bullet_items'' - and cr_items.parent_id = slide_item_id + and cr_items.parent_id = p_slide_item_id and cr_revisions.revision_id = cr_items.live_revision; - return v_blob; end;' language 'plpgsql'; -create function wp_slide__get_bullet_items_revision( - integer -) returns blob as' -declare - get_bullet_items_revision__slide_revision_id alias for $1; - v_blob blob; -begin - select content into v_blob - from cr_revisions r, cr_wp_slides_bullet_items sb - where sb.slide_id = get_bullet_items_revision.slide_revision_id - and r.revision_id = sb.id; - return v_blob; -end;' language 'plpgsql'; - create function wp_slide__new_revision( timestamp, + integer, varchar, - varchar, integer, varchar, text, @@ -1616,13 +1644,18 @@ v_bullet_items_revision_id cr_revisions.revision_id%TYPE; begin v_revision_id := content_revision__new( - '''', null, - now(), + null, + current_timestamp, ''text/plain'', null, - p_slide_item_id - ); + null, + p_slide_item_id, + null, + p_creation_date, + p_creation_user, + p_creation_ip + ); PERFORM content_item__set_live_revision(v_revision_id); @@ -1651,12 +1684,17 @@ and content_type = ''cr_wp_slide_preamble''; v_preamble_revision_id := content_revision__new( - '''', null, - now(), + null, + current_timestamp, ''text/plain'', + null, p_preamble, - v_preamble_item_id + v_preamble_item_id, + null, + p_creation_date, + p_creation_user, + p_creation_ip ); PERFORM content_item__set_live_revision(v_preamble_revision_id); @@ -1676,12 +1714,17 @@ and content_type = ''cr_wp_slide_postamble''; v_postamble_revision_id := content_revision__new( - '''', null, - now(), + null, + current_timestamp, ''text/plain'', + null, p_postamble, - v_postamble_item_id + v_postamble_item_id, + null, + p_creation_date, + p_creation_user, + p_creation_ip ); PERFORM content_item__set_live_revision(v_postamble_revision_id); @@ -1701,12 +1744,17 @@ and content_type = ''cr_wp_slide_bullet_items''; v_bullet_items_revision_id := content_revision__new( - '''', null, - now(), + null, + current_timestamp, ''text/plain'', + null, p_bullet_items, - v_bullet_items_item_id + v_bullet_items_item_id, + null, + p_creation_date, + p_creation_user, + p_creation_ip ); PERFORM content_item__set_live_revision(v_bullet_items_revision_id); @@ -1722,82 +1770,22 @@ return 0; end;' language 'plpgsql'; -create function wp_attachment__new ( -varchar, -varchar, -integer, -timestamp, -integer, -varchar -) returns integer as' -declare - p_filename alias for $1; - p_display alias for $2; - p_slide_item_id alias for $3; - p_creation_date alias for $4; - p_creation_user alias for $5; - p_creation_ip alias for $6; - v_item_id cr_items.item_id%TYPE; - v_revision_id cr_revisions.revision_id%TYPE; -begin - v_item_id := content_item__new( - p_filename, - p_slide_item_id, - null, - null, - p_creation_date, - p_creation_user, - null, - p_creation_ip, - ''content_item'', - ''cr_wp_attachment'', - null, - null, - ''text/plain'', - null, - null, - ''text'' - ); - - v_revision_id := content_revision__new( - '''', - null, - now(), - ''text/plain'', - null, - null, - v_item_id, - null, - p_creation_date, - p_creation_user, - p_creation_ip - ); - - PERFORM content_item__set_live_revision(v_revision_id); - - insert into cr_wp_attachments - ( - attach_id, - display - ) values ( - v_revision_id, - p_display - ); ---''after_bullets'' - return v_item_id; -end;' language 'plpgsql'; - create function wp_attachment__delete( integer ) returns integer as' declare p_attach_item_id alias for $1; begin - delete from cr_wp_attachments + delete from cr_wp_file_attachments where exists (select 1 from cr_revisions where revision_id - = cr_wp_attachments.attach_id + = cr_wp_file_attachments.attach_id and item_id = p_attach_item_id); + delete from cr_wp_image_attachments + where exists (select 1 from cr_revisions where revision_id + = cr_wp_image_attachments.attach_id + and item_id = p_attach_item_id); + delete from cr_item_publish_audit where item_id = p_attach_item_id; @@ -1813,3 +1801,26 @@ begin return 0; end; 'language 'plpgsql'; + +create function wp_presentation__set_live_revision(integer) returns integer as ' +declare + p_revision_id alias for $1; + v_revision_id integer; +begin + perform content_item__set_live_revision(p_revision_id); + + select id into v_revision_id + from cr_wp_presentations_aud + where presentation_id = p_revision_id; + + perform content_item__set_live_revision(v_revision_id); + + select id into v_revision_id + from cr_wp_presentations_back + where presentation_id = p_revision_id; + + perform content_item__set_live_revision(v_revision_id); + return 0; +end;' language 'plpgsql'; + + Index: openacs-4/packages/wp-slim/sql/postgresql/wp-slim-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/sql/postgresql/wp-slim-drop.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/wp-slim/sql/postgresql/wp-slim-drop.sql 4 Oct 2001 04:18:35 -0000 1.1 +++ openacs-4/packages/wp-slim/sql/postgresql/wp-slim-drop.sql 15 Nov 2001 01:47:13 -0000 1.2 @@ -1,3 +1,4 @@ + -- I think some cascade or something needs to be added to the delete -- statements in case some other object points to a presentation or slide. @@ -17,7 +18,7 @@ del_rec record; begin for del_rec in select item_id from cr_items - where content_type = ''cr_wp_attachment'' + where content_type in (''cr_wp_file_attachment'', ''cr_wp_image_attachment'') loop update acs_objects set context_id = null where context_id = del_rec.item_id; PERFORM content_item__delete(del_rec.item_id); @@ -32,8 +33,8 @@ create function inline_1 () returns integer as' begin -PERFORM -content_type__unregister_child_type(''cr_wp_slide'',''cr_wp_attachment'',null); +PERFORM content_type__unregister_child_type(''cr_wp_slide'',''cr_wp_file_attachment'',null); +PERFORM content_type__unregister_child_type(''cr_wp_slide'',''cr_wp_image_attachment'',null); return 0; end;' language 'plpgsql'; select inline_1 (); @@ -43,18 +44,17 @@ create function inline_2 () returns integer as' begin - PERFORM -content_folder__unregister_content_type(content_item_globals.c_root_folder_id,''cr_wp_attachment'',''f''); - - PERFORM content_type__unregister_child_type(''cr_wp_slide'',''cr_wp_attachment'', ''null''); + PERFORM content_folder__unregister_content_type(content_item_globals.c_root_folder_id,''cr_wp_file_attachment'',''f''); + PERFORM content_folder__unregister_content_type(content_item_globals.c_root_folder_id,''cr_wp_image_attachment'',''f''); return 0; end;' language 'plpgsql'; select inline_2 (); drop function inline_2 (); delete from cr_type_children where parent_type in ( - 'cr_wp_attachment', + 'cr_wp_file_attachment', + 'cr_wp_image_attachment', 'cr_wp_presentation', 'cr_wp_presentation_aud', 'cr_wp_presentation_back', @@ -68,19 +68,22 @@ create function inline_3 () returns integer as' begin - PERFORM acs_attribute__drop_attribute(''cr_wp_attachment'', ''display''); + PERFORM acs_attribute__drop_attribute(''cr_wp_file_attachment'', ''display''); + PERFORM acs_attribute__drop_attribute(''cr_wp_image_attachment'', ''display''); return 0; end;' language 'plpgsql'; select inline_3 (); drop function inline_3 (); -delete from acs_objects where object_type = 'cr_wp_attachment'; +delete from acs_objects where object_type = 'cr_wp_file_attachment'; +delete from acs_objects where object_type = 'cr_wp_image_attachment'; create function inline_4 () returns integer as' begin -PERFORM acs_object_type__drop_type(''cr_wp_attachment'',''f''); +PERFORM acs_object_type__drop_type(''cr_wp_file_attachment'',''f''); +PERFORM acs_object_type__drop_type(''cr_wp_image_attachment'',''f''); return 0; end;' language 'plpgsql'; select inline_4 (); @@ -260,15 +263,7 @@ PERFORM acs_attribute__drop_attribute(''cr_wp_slide'',''include_in_outline_p''); PERFORM acs_attribute__drop_attribute(''cr_wp_slide'',''context_break_after_p''); PERFORM acs_attribute__drop_attribute(''cr_wp_slide'',''style''); - --- PERFORM content_type__drop_attribute(''cr_wp_slide'',''sort_key'',''f''); --- PERFORM content_type__drop_attribute(''cr_wp_slide'',''slide_title'',''f''); --- PERFORM content_type__drop_attribute(''cr_wp_slide'',''include_in_outline_p'',''f''); --- PERFORM content_type__drop_attribute(''cr_wp_slide'',''context_break_after_p'',''f''); --- PERFORM content_type__drop_attribute(''cr_wp_slide'',''style'',''f''); --- PERFORM content_type__drop_attribute(''cr_wp_attachment'', ''display'',''f''); - return 0; end;' language 'plpgsql'; select inline_9 (); @@ -355,23 +350,15 @@ select inline_12 (); drop function inline_12 (); ---DROP package wp_attachment; -DROP FUNCTION wp_attachment__new ( - integer, - timestamp, - varchar, - varchar -); DROP FUNCTION wp_attachment__delete ( integer ); DROP FUNCTION wp_attachment__new_revision( - integer + integer ); - --drop package wp_slide; DROP FUNCTION wp_slide__new( integer, @@ -406,35 +393,13 @@ integer ); -DROP FUNCTION wp_slide__get_preamble( - integer -); - DROP FUNCTION wp_slide__get_preamble_revision( integer ); - -DROP FUNCTION wp_slide__get_bullet_items_revision( +DROP FUNCTION wp_slide__get_preamble( integer ); -DROP FUNCTION wp_slide__new_revision( - timestamp, - varchar, - varchar, - integer, - varchar, - varchar, - varchar, - varchar, - integer, - integer, - varchar, - varchar, - varchar -); - - --drop package wp_presentation; DROP FUNCTION wp_presentation__new( timestamp, @@ -462,52 +427,65 @@ integer ); -DROP FUNCTION wp_presentation__get_audience( +DROP FUNCTION wp_presentation__get_ad_revision ( integer ); ---not sure why is it saying this table is already dropped? ie. not existing -DROP FUNCTION wp_presentation__get_ad_revision( +DROP FUNCTION wp_presentation__get_bg_revision( integer ); - ---not sure why it is sayding this table is already dropped. ie. not existing -DROP FUNCTION wp_presentation__get_background( +DROP FUNCTION wp_presentation__get_audience( integer ); -DROP FUNCTION wp_presentation__get_bg_revision( +DROP FUNCTION wp_presentation__get_background( integer ); -DROP FUNCTION wp_presentation__new_revision( - timestamp, - varchar, - integer, - integer, - varchar, - varchar, - varchar, - integer, - boolean, - boolean, - varchar, - varchar -); +drop function wp_slide__new_revision( + timestamp, + integer, + varchar, + integer, + varchar, + text, + varchar, + varchar, + integer, + integer, + integer, + boolean, + boolean); +drop function wp_presentation__new_revision ( + timestamp, + integer, + varchar, + integer, + varchar(400), + varchar(200), + varchar(400), + integer, + boolean, + boolean, + varchar, + varchar); - --checked drop table cr_wp_presentations_aud; drop table cr_wp_presentations_back; drop table cr_wp_slides_preamble; drop table cr_wp_slides_postamble; drop table cr_wp_slides_bullet_items; -drop view cr_wp_attachmentsi; -drop view cr_wp_attachmentsx; -drop table cr_wp_attachments; +drop view cr_wp_image_attachmentsi; +drop view cr_wp_image_attachmentsx; +drop table cr_wp_image_attachments; +drop view cr_wp_file_attachmentsi; +drop view cr_wp_file_attachmentsx; +drop table cr_wp_file_attachments; + drop view cr_wp_slidesi; drop view cr_wp_slidesx; drop table cr_wp_slides; @@ -516,5 +494,9 @@ drop table cr_wp_presentations; drop table wp_styles; +drop function wp_slide__get_bullet_items_revision(integer); +drop function wp_slide__get_postamble_revision(integer); +drop function wp_slide__get_bullet_items(integer); +drop function wp_slide__get_postamble(integer); - +drop function wp_presentation__set_live_revision(integer); Index: openacs-4/packages/wp-slim/www/attach-detail-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/attach-detail-oracle.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/wp-slim/www/attach-detail-oracle.xql 4 Oct 2001 04:23:13 -0000 1.1 +++ openacs-4/packages/wp-slim/www/attach-detail-oracle.xql 15 Nov 2001 01:47:13 -0000 1.2 @@ -1,21 +1,15 @@ - oracle8.1.6 - + - - select r.revision_id, - to_char(ao.creation_date, 'HH24:MI:SS Mon DD, YYYY') as creation_date, - ao.creation_ip - from cr_revisions r, - acs_objects ao - where r.item_id = :attach_item_id - and ao.object_id = r.revision_id - + select r.revision_id, a.display, r.mime_type + from cr_items i, cr_wp_image_attachments a, cr_revisions r + where i.item_id = :attach_item_id and + i.live_revision = r.revision_id and + r.revision_id = a.attach_id(+) - Index: openacs-4/packages/wp-slim/www/attach-detail-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/attach-detail-postgresql.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/wp-slim/www/attach-detail-postgresql.xql 4 Oct 2001 04:23:13 -0000 1.1 +++ openacs-4/packages/wp-slim/www/attach-detail-postgresql.xql 15 Nov 2001 01:47:13 -0000 1.2 @@ -1,21 +1,15 @@ - postgresql7.1 - + - - select r.revision_id, - to_char(ao.creation_date, 'HH24:MI:SS Mon DD, YYYY') as creation_date, - ao.creation_ip - from cr_revisions r, - acs_objects ao - where r.item_id = :attach_item_id - and ao.object_id = r.revision_id - + select revision_id, display, mime_type + from (select r.revision_id, r.mime_type + from cr_items i, cr_revisions r + where i.item_id = :attach_item_id and i.live_revision = r.revision_id) current + left join cr_wp_image_attachments on (current.revision_id = attach_id) - Index: openacs-4/packages/wp-slim/www/attach-detail.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/attach-detail.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/wp-slim/www/attach-detail.adp 20 Apr 2001 20:51:24 -0000 1.1 +++ openacs-4/packages/wp-slim/www/attach-detail.adp 15 Nov 2001 01:47:13 -0000 1.2 @@ -12,24 +12,26 @@
  • - + Uploaded from @revisions.creation_ip@ at @revisions.creation_date@ (view)

    - + + +
    @@ -40,4 +42,4 @@
- \ No newline at end of file + Index: openacs-4/packages/wp-slim/www/attach-detail.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/attach-detail.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/wp-slim/www/attach-detail.tcl 4 Oct 2001 04:29:01 -0000 1.2 +++ openacs-4/packages/wp-slim/www/attach-detail.tcl 15 Nov 2001 01:47:13 -0000 1.3 @@ -16,9 +16,10 @@ slide_item_id attach_item_id revisions:multirow - live_revision + revision_id display file_name + attachment_type } @@ -51,13 +52,10 @@ set postamble_selected "" set bottom_selected "" -db_1row info_get { - select i.live_revision, x.display - from cr_items i, cr_wp_attachments x - where x.attach_id = i.live_revision - and i.item_id = :attach_item_id -} +db_1row info_get "" +set attachment_type [cr_registered_type_for_mime_type $mime_type] + set ${display}_selected "selected" set return_url [ns_urlencode "attach-detail?[export_url_vars slide_item_id attach_item_id file_name]"] Index: openacs-4/packages/wp-slim/www/attach-detail.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/attach-detail.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/wp-slim/www/attach-detail.xql 4 Oct 2001 04:29:01 -0000 1.1 +++ openacs-4/packages/wp-slim/www/attach-detail.xql 15 Nov 2001 01:47:13 -0000 1.2 @@ -11,18 +11,5 @@ - - - - - select i.live_revision, x.display - from cr_items i, cr_wp_attachments x - where x.attach_id = i.live_revision - and i.item_id = :attach_item_id - - - - - Index: openacs-4/packages/wp-slim/www/attach-list.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/attach-list.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/wp-slim/www/attach-list.xql 4 Oct 2001 04:29:01 -0000 1.1 +++ openacs-4/packages/wp-slim/www/attach-list.xql 15 Nov 2001 01:47:13 -0000 1.2 @@ -18,7 +18,7 @@ select name, item_id from cr_items - where content_type = 'cr_wp_attachment' + where content_type in ('cr_wp_image_attachment', 'cr_wp_file_attachment') and parent_id = :slide_item_id Index: openacs-4/packages/wp-slim/www/attach.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/attach.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/wp-slim/www/attach.tcl 31 Oct 2001 20:42:07 -0000 1.3 +++ openacs-4/packages/wp-slim/www/attach.tcl 15 Nov 2001 01:47:13 -0000 1.4 @@ -19,88 +19,46 @@ set creation_ip [ad_conn peeraddr] set tmp_filename [ns_queryget attachment.tmpfile] -set guessed_file_type [ns_guesstype $attachment] -set n_bytes [file size $tmp_filename] +set mime_type [ns_guesstype $attachment] +set tmp_size [file size $tmp_filename] # strip off the C:\directories... crud and just get the file name if ![regexp {([^/\\]+)$} $attachment match client_filename] { set client_filename $attachment } - - - set exception_count 0 set exception_text "" -if { $n_bytes == 0 } { +if { $tmp_size == 0 } { append exception_text "
  • You haven't uploaded a file.\n" incr exception_count } -if { ![empty_string_p [ad_parameter MaxAttachmentSize "comments"]] && $n_bytes > [ad_parameter MaxAttachmentSize "comments"] } { +if { ![empty_string_p [ad_parameter MaxAttachmentSize "comments"]] && $tmp_size > [ad_parameter MaxAttachmentSize "comments"] } { append exception_text "
  • Your file is too large. The publisher of [ad_system_name] has chosen to limit attachments to [util_commify_number [ad_parameter MaxAttachmentSize "comments"]] bytes.\n" incr exception_count } -if { $inline_image_p == "t" } { - if { ![string equal $guessed_file_type "image/gif"] && - ![string equal $guessed_file_type "image/jpeg"] } { - append exception_text "
  • The file you just uploaded is neither a .gif file nor a .jpg file. Therefore we cannot display it as an image. You have two options. You can either reupload a .gif or .jpg file. Or you must select \"Display a link the viewer can use to download the file\".\n" - incr exception_count - } -} - - if { $exception_count > 0 } { ad_return_complaint $exception_count $exception_text return } -if { $inline_image_p == "f" } { - set display "" +if {[string equal $mime_type "*/*"]} { + set mime_type "application/octet-stream" } - -# The reason I didn't wrap it in a pl/sql procedure is that -# I don't know how to do blob_dml_file_bind in pl/sql. Maybe -# the current oracle driver doesn't support it at all. We -# need to find out. - -set item_id [db_exec_plsql attachment_insert { -begin - select item_id into :1 - from cr_items - where content_type = 'cr_wp_attachment' - and name = :client_filename - and parent_id = :slide_item_id; -exception - when no_data_found then - :1 := wp_attachment__new( - :attachment, - :display, - :slide_item_id, - now(), - :user_id, - :creation_ip - ); -end; -}] - -set path $tmp_filename - -if {[string equal $guessed_file_type "*/*"]} { - set mime_type "application/octet-stream" -} else { - set mime_type $guessed_file_type - # not sure if this is the best way to go. An alternative is to set mime_type to - # application/octet-stream as long as mime_type is neither image/gif nor image/jpeg - db_dml mime_type_insert { - insert into cr_mime_types (mime_type) - select :mime_type - from dual - where not exists (select 1 from cr_mime_types where mime_type = :mime_type) +db_transaction { + if { $inline_image_p == "t" } { + set revision_id [cr_import_content -image_type cr_wp_image_attachment -other_type cr_wp_file_attachment \ + -image_only $slide_item_id $tmp_filename $tmp_size $mime_type $client_filename] + } else { + set revision_id [cr_import_content -image_type cr_wp_image_attachment -other_type cr_wp_file_attachment \ + $slide_item_id $tmp_filename $tmp_size $mime_type $client_filename] } + cr_set_imported_content_live -image_sql [db_map image_data] -other_sql [db_map file_data] \ + $mime_type $revision_id } ad_returnredirect edit-slide?[export_url_vars slide_item_id pres_item_id] Index: openacs-4/packages/wp-slim/www/attach.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/attach.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/wp-slim/www/attach.xql 15 Nov 2001 01:47:13 -0000 1.1 @@ -0,0 +1,23 @@ + + + + + + + insert into cr_wp_image_attachments + (attach_id, display) + values + (:revision_id, :display) + + + + + + insert into cr_wp_file_attachments + (attach_id) + values + (:revision_id) + + + + Index: openacs-4/packages/wp-slim/www/create-presentation-2-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/Attic/create-presentation-2-postgresql.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/wp-slim/www/create-presentation-2-postgresql.xql 4 Oct 2001 04:23:13 -0000 1.1 +++ openacs-4/packages/wp-slim/www/create-presentation-2-postgresql.xql 15 Nov 2001 01:47:13 -0000 1.2 @@ -23,32 +23,22 @@ - - -#select -#acs_permission__grant_permissi(:pres_item_id,:user_id,'wp_admin_presentation'); -#select -#acs_permission__grant_permission(:pres_item_id,:user_id,'wp_view_presentation'); -#select -#acs_permission__grant_permission(:pres_item_id,:user_id,'wp_edit_presentation'); -#select -#acs_permission__grant_permission(:pres_item_id,:user_id,'wp_delete_presenation'); - - - + begin + perform acs_permission__grant_permission(:pres_item_id,:user_id,'wp_admin_presentation'); + perform acs_permission__grant_permission(:pres_item_id,:user_id,'wp_view_presentation'); + perform acs_permission__grant_permission(:pres_item_id,:user_id,'wp_edit_presentation'); + perform acs_permission__grant_permission(:pres_item_id,:user_id,'wp_delete_presentation'); + return 0; + end; - -#select -#acs_permission__grant_permission(:pres_item_id,acs__magic_object_id('the_public'),'wp_view_presentation'); - - + select acs_permission__grant_permission(:pres_item_id,acs__magic_object_id('the_public'),'wp_view_presentation'); Index: openacs-4/packages/wp-slim/www/create-presentation-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/Attic/create-presentation-2.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/wp-slim/www/create-presentation-2.tcl 4 Oct 2001 04:29:01 -0000 1.2 +++ openacs-4/packages/wp-slim/www/create-presentation-2.tcl 15 Nov 2001 01:47:13 -0000 1.3 @@ -16,28 +16,16 @@ set package_id [ad_conn package_id] - - set user_id [ad_verify_and_get_user_id] set creation_ip [ad_conn peeraddr] -set pres_item_id [db_exec_plsql wp_presentation_insert { - begin - :1 := wp_presentation.new( - creation_date => sysdate, - creation_user => :user_id, - creation_ip => :creation_ip, - pres_title => :pres_title, - page_signature => :page_signature, - copyright_notice => :copyright_notice, - style => :style, - public_p => :public_p, - show_modified_p => :show_modified_p, - audience => :audience, - background => :background - ); - end; -}] +set pres_item_id [db_exec_plsql wp_presentation_insert ""] +db_exec_plsql grant_owner_access "" + +if {$public_p == "t"} { + db_exec_plsql make_wp_presentation_public "" +} + ad_returnredirect "presentation-top?[export_url_vars pres_item_id]" Index: openacs-4/packages/wp-slim/www/display-change.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/display-change.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/wp-slim/www/display-change.tcl 4 Oct 2001 04:29:01 -0000 1.2 +++ openacs-4/packages/wp-slim/www/display-change.tcl 15 Nov 2001 01:47:13 -0000 1.3 @@ -15,6 +15,11 @@ file_name:notnull } +# DRB: This code actually should never be called except for images, since +# the user isn't allowed to change the display attribute for links (rather +# stupid, but that's the way it is). Rather than allow the user the opportunity +# to try to make such a change, only to deny it with the following code, I've +# changed the calling page to suppress the option except for images... # check mime type set mime_type [db_string get_mime_type { @@ -24,17 +29,12 @@ }] if { ![empty_string_p $display] } { - if { ![string equal $mime_type "image/gif"] && - ![string equal $mime_type "image/jpeg"] } { + if { [cr_registered_type_for_mime_type $mime_type] != "image" } { ad_return_complaint 1 "
  • The file is neither a .gif file nor a .jpg file. Therefore we cannot display it as an image." return } + db_dml display_change "" } -db_dml display_chagne { - update cr_wp_attachments - set display = :display - where attach_id = :revision_id -} ad_returnredirect "attach-detail?[export_url_vars slide_item_id attach_item_id file_name]" Index: openacs-4/packages/wp-slim/www/display-change.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/display-change.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/wp-slim/www/display-change.xql 4 Oct 2001 04:29:01 -0000 1.1 +++ openacs-4/packages/wp-slim/www/display-change.xql 15 Nov 2001 01:47:13 -0000 1.2 @@ -12,15 +12,14 @@ - + - update cr_wp_attachments + update cr_wp_image_attachments set display = :display where attach_id = :revision_id - Index: openacs-4/packages/wp-slim/www/edit-presentation-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/Attic/edit-presentation-2.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/wp-slim/www/edit-presentation-2.tcl 4 Oct 2001 04:29:01 -0000 1.2 +++ openacs-4/packages/wp-slim/www/edit-presentation-2.tcl 15 Nov 2001 01:47:13 -0000 1.3 @@ -5,12 +5,12 @@ @creation-date Tue Nov 21 08:40:33 2000 @cvs-id } { - pres_item_id + pres_item_id:integer,notnull pres_title page_signature copyright_notice show_modified_p - public_p + public_p:notnull style audience background @@ -39,7 +39,7 @@ end; } -if {[regexp {t} $public_p]} { +if {$public_p == "t"} { db_exec_plsql grant_public_read { begin acs_permission.grant_permission(:pres_item_id,acs.magic_object_id('the_public'),'wp_view_presentation'); Index: openacs-4/packages/wp-slim/www/edit-presentation.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/Attic/edit-presentation.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/wp-slim/www/edit-presentation.tcl 4 Oct 2001 04:29:01 -0000 1.2 +++ openacs-4/packages/wp-slim/www/edit-presentation.tcl 15 Nov 2001 01:47:13 -0000 1.3 @@ -45,15 +45,6 @@ and r.revision_id = i.live_revision } -#set public_p [db_string get_public_read_p " -#select decode(count(*),1,'t','f') -#from acs_permissions -#where object_id = :pres_item_id -#and upper(privilege)='WP_VIEW_PRESENTATION' -#and grantee_id = acs.magic_object_id('the_public') -#"] - - set nav_bar [ad_context_bar [list "presentation-top?[export_url_vars pres_item_id]" "$pres_title"] "Edit Presentation"] ad_return_template Index: openacs-4/packages/wp-slim/www/edit-presentation.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/Attic/edit-presentation.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/wp-slim/www/edit-presentation.xql 15 Nov 2001 01:47:13 -0000 1.1 @@ -0,0 +1,39 @@ + + + + + + + + select p.pres_title, p.page_signature, p.copyright_notice, p.public_p, +p.show_modified_p + from cr_wp_presentations p, cr_items i + where i.item_id = :pres_item_id + and i.live_revision = p.presentation_id + + + + + + + select content as audience + from cr_revisions, cr_items + where cr_items.content_type = 'cr_wp_presentation_aud' + and cr_items.parent_id = :pres_item_id + and cr_revisions.revision_id = cr_items.live_revision + + + + + + + select content as background + from cr_revisions r, cr_items i + where i.content_type = 'cr_wp_presentation_back' + and i.parent_id = :pres_item_id + and r.revision_id = i.live_revision + + + + + Index: openacs-4/packages/wp-slim/www/edit-slide-2.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/Attic/edit-slide-2.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/wp-slim/www/edit-slide-2.xql 4 Oct 2001 04:29:01 -0000 1.1 +++ openacs-4/packages/wp-slim/www/edit-slide-2.xql 15 Nov 2001 01:47:13 -0000 1.2 @@ -6,7 +6,7 @@ select count(1) from cr_items - where content_type = 'cr_wp_attachment' + where content_type in ('cr_wp_image_attachment', 'cr_wp_file_attachment') and parent_id = :slide_item_id Index: openacs-4/packages/wp-slim/www/edit-slide-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/Attic/edit-slide-oracle.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/wp-slim/www/edit-slide-oracle.xql 4 Oct 2001 04:23:13 -0000 1.1 +++ openacs-4/packages/wp-slim/www/edit-slide-oracle.xql 15 Nov 2001 01:47:13 -0000 1.2 @@ -18,6 +18,5 @@ - Index: openacs-4/packages/wp-slim/www/edit-slide-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/Attic/edit-slide-postgresql.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/wp-slim/www/edit-slide-postgresql.xql 4 Oct 2001 04:23:13 -0000 1.1 +++ openacs-4/packages/wp-slim/www/edit-slide-postgresql.xql 15 Nov 2001 01:47:13 -0000 1.2 @@ -8,51 +8,15 @@ select s.slide_title, s.sort_key, - s.original_slide_id + s.original_slide_id, + wp_slide__get_preamble(:slide_item_id) as preamble, + wp_slide__get_postamble(:slide_item_id) as postamble, + wp_slide__get_bullet_items(:slide_item_id) as bullet_items from cr_wp_slides s, cr_items i where i.item_id = :slide_item_id and i.live_revision = s.slide_id - - - - select content as preamble - from cr_revisions, cr_items - where cr_items.content_type = 'cr_wp_slide_preamble' - and cr_items.parent_id = :slide_item_id - and cr_revisions.revision_id = cr_items.live_revision - - - - - - - - -select content as postamble - from cr_revisions, cr_items - where cr_items.content_type = 'cr_wp_slide_postamble' - and cr_items.parent_id = :slide_item_id - and cr_revisions.revision_id = cr_items.live_revision - - - - - - - - - - - select content as bullet_items - from cr_revisions, cr_items - where cr_items.content_type = 'cr_wp_slide_bullet_items' - and cr_items.parent_id = :slide_item_id - and cr_revisions.revision_id = cr_items.live_revision; - - - Index: openacs-4/packages/wp-slim/www/edit-slide.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/Attic/edit-slide.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/wp-slim/www/edit-slide.tcl 4 Oct 2001 04:29:01 -0000 1.2 +++ openacs-4/packages/wp-slim/www/edit-slide.tcl 15 Nov 2001 01:47:13 -0000 1.3 @@ -34,33 +34,33 @@ where i.item_id = :slide_item_id and i.live_revision = s.slide_id } +# +#db_1row get_pre_info { +# select content as preamble +# from cr_revisions, cr_items +# where cr_items.content_type = 'cr_wp_slide_preamble' +# and cr_items.parent_id = :slide_item_id +# and cr_revisions.revision_id = cr_items.live_revision +#} +# +#db_1row get_pos_info { +# select content as postamble +# from cr_revisions, cr_items +# where cr_items.content_type = 'cr_wp_slide_postamble' +# and cr_items.parent_id = :slide_item_id +# and cr_revisions.revision_id = cr_items.live_revision +#} +# +#db_1row get_bul_info { +#select content as bullet_items +# from cr_revisions, cr_items +# where cr_items.content_type = 'cr_wp_slide_bullet_items' +# and cr_items.parent_id = :slide_item_id +# and cr_revisions.revision_id = cr_items.live_revision; +#} +# +# -db_1row get_pre_info { - select content as preamble - from cr_revisions, cr_items - where cr_items.content_type = 'cr_wp_slide_preamble' - and cr_items.parent_id = :slide_item_id - and cr_revisions.revision_id = cr_items.live_revision -} - -db_1row get_pos_info { -elect content as postamble - from cr_revisions, cr_items - where cr_items.content_type = 'cr_wp_slide_postamble' - and cr_items.parent_id = :slide_item_id - and cr_revisions.revision_id = cr_items.live_revision -} - -db_1row get_bul_info { -select content as bullet_items - from cr_revisions, cr_items - where cr_items.content_type = 'cr_wp_slide_bullet_items' - and cr_items.parent_id = :slide_item_id - and cr_revisions.revision_id = cr_items.live_revision; -} - - - set bullet_num [llength $bullet_items] ad_return_template Index: openacs-4/packages/wp-slim/www/get-binary-data.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/get-binary-data.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/wp-slim/www/get-binary-data.tcl 31 Oct 2001 20:42:07 -0000 1.3 +++ openacs-4/packages/wp-slim/www/get-binary-data.tcl 15 Nov 2001 01:47:13 -0000 1.4 @@ -25,4 +25,4 @@ ad_return_error "Wimpy Point" "Could not get a pres_item_id and slide_item_id out of url=$url" } -cr_write_content -item_id $attach_id +cr_write_content -revision_id $attach_id Index: openacs-4/packages/wp-slim/www/presentation-publish-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/presentation-publish-oracle.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/wp-slim/www/presentation-publish-oracle.xql 4 Oct 2001 04:23:13 -0000 1.1 +++ openacs-4/packages/wp-slim/www/presentation-publish-oracle.xql 15 Nov 2001 01:47:13 -0000 1.2 @@ -12,12 +12,12 @@ content_item.set_live_revision(:revision_id); select id into v_revision_id - from cr_wp_presentations_audience + from cr_wp_presentations_aud where presentation_id = :revision_id; content_item.set_live_revision(v_revision_id); select id into v_revision_id - from cr_wp_presentations_background + from cr_wp_presentations_back where presentation_id = :revision_id; content_item.set_live_revision(v_revision_id); end; Index: openacs-4/packages/wp-slim/www/presentation-publish-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/presentation-publish-postgresql.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/wp-slim/www/presentation-publish-postgresql.xql 4 Oct 2001 04:23:13 -0000 1.1 +++ openacs-4/packages/wp-slim/www/presentation-publish-postgresql.xql 15 Nov 2001 01:47:13 -0000 1.2 @@ -5,23 +5,9 @@ -declare - v_revision_id integer; - select content_item.set_live_revision(:revision_id); + select wp_presentation__set_live_revision(:revision_id); - select id into v_revision_id - from cr_wp_presentations_aud - where presentation_id = :revision_id; - - select content_item.set_live_revision(:v_revision_id); - - select id into v_revision_id - from cr_wp_presentations_back - where presentation_id = :revision_id; - - select content_item.set_live_revision(:v_revision_id); - Index: openacs-4/packages/wp-slim/www/presentation-top.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/presentation-top.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/wp-slim/www/presentation-top.adp 20 Apr 2001 20:51:24 -0000 1.1 +++ openacs-4/packages/wp-slim/www/presentation-top.adp 15 Nov 2001 01:47:13 -0000 1.2 @@ -82,4 +82,4 @@ \ No newline at end of file + Index: openacs-4/packages/wp-slim/www/presentation-top.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/presentation-top.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/wp-slim/www/presentation-top.tcl 4 Oct 2001 04:29:01 -0000 1.2 +++ openacs-4/packages/wp-slim/www/presentation-top.tcl 15 Nov 2001 01:47:13 -0000 1.3 @@ -39,7 +39,7 @@ } set encoded_title [ns_urlencode $presentation_title] -set nav_bar [ad_context_bar [list "$presentation_title"]] +set nav_bar [ad_context_bar "$presentation_title"] set subsite_name [ad_conn package_url] db_multirow slides get_slides { Index: openacs-4/packages/wp-slim/www/serve-presentation-revision.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/serve-presentation-revision.adp,v diff -u -r1.2 -r1.3 --- openacs-4/packages/wp-slim/www/serve-presentation-revision.adp 4 Oct 2001 04:29:01 -0000 1.2 +++ openacs-4/packages/wp-slim/www/serve-presentation-revision.adp 15 Nov 2001 01:47:13 -0000 1.3 @@ -35,11 +35,14 @@ +Audience +@audience@ + + + Background @background@ - - Index: openacs-4/packages/wp-slim/www/serve-presentation-revision.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/serve-presentation-revision.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/wp-slim/www/serve-presentation-revision.tcl 4 Oct 2001 04:29:01 -0000 1.2 +++ openacs-4/packages/wp-slim/www/serve-presentation-revision.tcl 15 Nov 2001 01:47:13 -0000 1.3 @@ -39,14 +39,14 @@ and p.presentation_id = :pres_revision_id } -db_1row get_aud_data { +db_1row get_audience_data { select content as audience from cr_revisions r, cr_wp_presentations_aud pa where pa.presentation_id = :pres_revision_id and r.revision_id = pa.id } -db_1row get_back_data { +db_1row get_background_data { select content as background from cr_revisions r, cr_wp_presentations_back pb where pb.presentation_id = :pres_revision_id Index: openacs-4/packages/wp-slim/www/serve-presentation-revision.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/serve-presentation-revision.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/wp-slim/www/serve-presentation-revision.xql 15 Nov 2001 01:47:13 -0000 1.1 @@ -0,0 +1,36 @@ + + + + + + + select p.pres_title, + p.page_signature, + p.copyright_notice, + p.public_p, + p.show_modified_p + from cr_wp_presentations p, cr_items i + where i.item_id = :pres_item_id + and p.presentation_id = :pres_revision_id + + + + + + select content as audience + from cr_revisions r, cr_wp_presentations_aud pa + where pa.presentation_id = :pres_revision_id + and r.revision_id = pa.id + + + + + + select content as background + from cr_revisions r, cr_wp_presentations_back pb + where pb.presentation_id = :pres_revision_id + and r.revision_id = pb.id + + + + Index: openacs-4/packages/wp-slim/www/serve-presentation.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/serve-presentation.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/wp-slim/www/serve-presentation.adp 20 Apr 2001 20:51:24 -0000 1.1 +++ openacs-4/packages/wp-slim/www/serve-presentation.adp 15 Nov 2001 01:47:13 -0000 1.2 @@ -6,7 +6,7 @@ done | - next + next Index: openacs-4/packages/wp-slim/www/serve-slide-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/serve-slide-oracle.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/wp-slim/www/serve-slide-oracle.xql 4 Oct 2001 04:23:13 -0000 1.1 +++ openacs-4/packages/wp-slim/www/serve-slide-oracle.xql 15 Nov 2001 01:47:13 -0000 1.2 @@ -20,5 +20,14 @@ + + + select i.live_revision as attach_id, a.display, i.name as file_name + from cr_items i, cr_wp_image_attachments a + where i.parent_id = :slide_item_id and + i.content_type in ('cr_wp_image_attachment', 'cr_wp_file_attachment') and + i.live_revision = a.attach_id(+) + + Index: openacs-4/packages/wp-slim/www/serve-slide-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/serve-slide-postgresql.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/wp-slim/www/serve-slide-postgresql.xql 4 Oct 2001 04:23:13 -0000 1.1 +++ openacs-4/packages/wp-slim/www/serve-slide-postgresql.xql 15 Nov 2001 01:47:13 -0000 1.2 @@ -8,52 +8,26 @@ select s.slide_title, s.sort_key, + wp_slide__get_preamble(:slide_item_id) as preamble, + wp_slide__get_postamble(:slide_item_id) as postamble, + wp_slide__get_bullet_items(:slide_item_id) as bullet_items, to_char(ao.creation_date, 'HH24:MI, Mon DD, YYYY') as modified_date from cr_wp_slides s, cr_items i, acs_objects ao where i.item_id = :slide_item_id and i.live_revision = s.slide_id and ao.object_id = s.slide_id - - - - - - - select content as preamble - from cr_revisions, cr_items - where cr_items.content_type = 'cr_wp_slide_preamble' - and cr_items.parent_id = :slide_item_id - and cr_revisions.revision_id = cr_items.live_revision - - - + - -select content as postamble - from cr_revisions, cr_items - where cr_items.content_type = 'cr_wp_slide_postamble' - and cr_items.parent_id = :slide_item_id - and cr_revisions.revision_id = cr_items.live_revision - + select live_revision as attach_id, display, name as file_name + from (select live_revision, name + from cr_items + where parent_id = :slide_item_id and + content_type in ('cr_wp_image_attachment', 'cr_wp_file_attachment')) a + left join cr_wp_image_attachments on (a.live_revision = attach_id) - - - - - -select content as bullet_items - from cr_revisions, cr_items - where cr_items.content_type = 'cr_wp_slide_bullet_items' - and cr_items.parent_id = :slide_item_id - and cr_revisions.revision_id = cr_items.live_revision; - - - - - Index: openacs-4/packages/wp-slim/www/serve-slide-revision-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/serve-slide-revision-oracle.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/wp-slim/www/serve-slide-revision-oracle.xql 4 Oct 2001 04:23:13 -0000 1.1 +++ openacs-4/packages/wp-slim/www/serve-slide-revision-oracle.xql 15 Nov 2001 01:47:13 -0000 1.2 @@ -22,5 +22,14 @@ + + + select i.live_revision as attach_id, a.display, i.name as file_name + from cr_items i, cd_wp_image_attachments a + where i.parent_id = :slide_item_id and + i.content_type in ('cr_wp_image_attachment', 'cr_wp_file_attachment') and + i.live_revision = a.attach_id(+) + + Index: openacs-4/packages/wp-slim/www/serve-slide-revision-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/serve-slide-revision-postgresql.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/wp-slim/www/serve-slide-revision-postgresql.xql 4 Oct 2001 04:23:13 -0000 1.1 +++ openacs-4/packages/wp-slim/www/serve-slide-revision-postgresql.xql 15 Nov 2001 01:47:13 -0000 1.2 @@ -22,5 +22,15 @@ + + + select live_revision as attach_id, display, name as file_name + from (select live_revision, name + from cr_items + where parent_id = :slide_item_id and + content_type in ('cr_wp_image_attachment', 'cr_wp_file_attachment')) a + left join cr_wp_image_attachments on (a.live_revision = attach_id) + + Index: openacs-4/packages/wp-slim/www/serve-slide-revision.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/serve-slide-revision.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/wp-slim/www/serve-slide-revision.xql 4 Oct 2001 04:29:01 -0000 1.1 +++ openacs-4/packages/wp-slim/www/serve-slide-revision.xql 15 Nov 2001 01:47:13 -0000 1.2 @@ -14,16 +14,4 @@ - - - - select x.attach_id as attach_id, x.display, i.name as file_name - from cr_wp_attachments x, cr_items i - where i.parent_id = :slide_item_id - and i.live_revision = x.attach_id - - - - - Index: openacs-4/packages/wp-slim/www/serve-slide.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/serve-slide.adp,v diff -u -r1.3 -r1.4 --- openacs-4/packages/wp-slim/www/serve-slide.adp 31 Oct 2001 20:42:07 -0000 1.3 +++ openacs-4/packages/wp-slim/www/serve-slide.adp 15 Nov 2001 01:47:13 -0000 1.4 @@ -15,7 +15,7 @@ - @attach_list.file_name@ + @attach_list.file_name@ @@ -27,7 +27,7 @@ - @attach_list.file_name@ + @attach_list.file_name@ @@ -36,10 +36,10 @@ - @attach_list.file_name@ + @attach_list.file_name@ - @attach_list.file_name@ + @attach_list.file_name@ @@ -56,7 +56,7 @@ - @attach_list.file_name@ + @attach_list.file_name@ @@ -65,7 +65,7 @@ - @attach_list.file_name@ + @attach_list.file_name@ @@ -77,7 +77,7 @@ - @attach_list.file_name@ + @attach_list.file_name@ @@ -86,7 +86,7 @@ - @attach_list.file_name@ + @attach_list.file_name@ Index: openacs-4/packages/wp-slim/www/serve-slide.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/serve-slide.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/wp-slim/www/serve-slide.tcl 4 Oct 2001 04:29:01 -0000 1.2 +++ openacs-4/packages/wp-slim/www/serve-slide.tcl 15 Nov 2001 01:47:13 -0000 1.3 @@ -47,33 +47,6 @@ and ao.object_id = s.slide_id } -# Serve a specific slide. -db_1row get_pre_info { - select content as preamble - from cr_revisions, cr_items - where cr_items.content_type = 'cr_wp_slide_preamble' - and cr_items.parent_id = :slide_item_id - and cr_revisions.revision_id = cr_items.live_revision - -} - -db_1row get_pos_info { -select content as postamble - from cr_revisions, cr_items - where cr_items.content_type = 'cr_wp_slide_postamble' - and cr_items.parent_id = :slide_item_id - and cr_revisions.revision_id = cr_items.live_revision -} - -db_1row get_bul_info { -select content as bullet_items - from cr_revisions, cr_items - where cr_items.content_type = 'cr_wp_slide_bullet_items' - and cr_items.parent_id = :slide_item_id - and cr_revisions.revision_id = cr_items.live_revision; -} - - db_1row get_presentation_page_signature { select p.page_signature, p.show_modified_p @@ -114,12 +87,10 @@ if {$sort_key == 1} { # this is the only slide. set href_back "" - set href_forward "top" - } else { - set href_forward "top" + set href_forward "top" } } else { - set href_forward "next" + set href_forward "next" } Index: openacs-4/packages/wp-slim/www/serve-slide.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/serve-slide.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/wp-slim/www/serve-slide.xql 4 Oct 2001 04:29:01 -0000 1.1 +++ openacs-4/packages/wp-slim/www/serve-slide.xql 15 Nov 2001 01:47:13 -0000 1.2 @@ -39,17 +39,4 @@ - - - - - select x.attach_id as attach_id, x.display, i.name as file_name - from cr_wp_attachments x, cr_items i - where i.parent_id = :slide_item_id - and i.live_revision = x.attach_id - - - - - Index: openacs-4/packages/wp-slim/www/slide-publish-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/slide-publish-postgresql.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/wp-slim/www/slide-publish-postgresql.xql 4 Oct 2001 04:23:13 -0000 1.1 +++ openacs-4/packages/wp-slim/www/slide-publish-postgresql.xql 15 Nov 2001 01:47:13 -0000 1.2 @@ -7,20 +7,17 @@ select content_item__set_live_revision(:revision_id); - select id into v_revision_id - from cr_wp_slides_preamble - where slide_id = :revision_id; - content_item__set_live_revision(v_revision_id); + select content_item__set_live_revision(preamble.id) + from cr_wp_slides_preamble preamble + where preamble.slide_id = :revision_id; - select id into v_revision_id - from cr_wp_slides_postamble - where slide_id = :revision_id; - content_item__set_live_revision(v_revision_id); + select content_item__set_live_revision(postamble.id) + from cr_wp_slides_postamble postamble + where postamble.slide_id = :revision_id; - select id into v_revision_id - from cr_wp_slides_bullet_items - where slide_id = :revision_id; - content_item__set_live_revision(v_revision_id); + select content_item__set_live_revision(bullets.id) + from cr_wp_slides_bullet_items bullets + where bullets.slide_id = :revision_id;