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.3.4.1 -r1.3.4.2 --- openacs-4/packages/wp-slim/sql/oracle/wp-slim-create.sql 6 Feb 2003 13:07:20 -0000 1.3.4.1 +++ openacs-4/packages/wp-slim/sql/oracle/wp-slim-create.sql 21 May 2003 15:00:38 -0000 1.3.4.2 @@ -40,30 +40,51 @@ where not exists (select 1 from cr_mime_types where mime_type = 'application/octet-stream'); +create sequence wp_style_seq; + create table wp_styles ( style_id integer constraint wp_styles_style_id_pk primary key, name varchar2(400) constraint wp_styles_name_nn not null, - -- CSS source css varchar(4000), - -- HTML style properties. Colors are in the form '192,192,255'. - text_color varchar2(20) check(text_color like '%,%,%'), - background_color varchar2(20) check(background_color like '%,%,%'), - background_image varchar2(200), - link_color varchar2(20) check(link_color like '%,%,%'), - alink_color varchar2(20) check(alink_color like '%,%,%'), - vlink_color varchar2(20) check(vlink_color like '%,%,%') + text_color varchar(20) check(text_color like '%,%,%'), + background_color varchar(20) check(background_color like '%,%,%'), + background_image integer default 0, + link_color varchar(20) check(link_color like '%,%,%'), + alink_color varchar(20) check(alink_color like '%,%,%'), + vlink_color varchar(20) check(vlink_color like '%,%,%'), + public_p char(1) default 'f' check(public_p in ('t','f')), + owner integer + constraint wp_styles_to_users + references users (user_id) ); --- Insert the magic, "default" style. + insert into wp_styles(style_id, name, css) values(-1, 'Default (Plain)', 'BODY { back-color: white; color: black } P { line-height: 120% } UL { line-height: 140% }'); +-- this is also a new index! roc@ +create index wp_styles_by_owner on wp_styles(owner); +-- new table for supporting background images! +-- Images used for styles. + +create table wp_style_images ( +-- this one references to a cr! + wp_style_images_id integer primary key, + style_id integer references wp_styles(style_id) on delete cascade not null, + file_size integer not null, + file_name varchar(200) not null +); + +create index wp_style_images_style_id on wp_style_images(style_id); + + + create table cr_wp_presentations ( presentation_id integer constraint cr_wp_presentations_id_fk @@ -88,7 +109,10 @@ -- Show last-modified date for slides? show_modified_p char(1) default 'f' constraint cr_wp_show_p_ck - check(show_modified_p in ('t','f')) + check(show_modified_p in ('t','f')), + show_comments_p char(1) default 'f' + constraint cr_wp_pres_show_comments_p + check(show_comments_p in ('t','f')) ); @@ -533,20 +557,7 @@ show errors --- begin - -- bind privileges to global names - - -- acs_privilege.add_child('create','wp_create_presentation'); - -- acs_privilege.add_child('write','wp_edit_presentation'); - -- acs_privilege.add_child('delete','wp_delete_presentation'); - -- acs_privilege.add_child('read','wp_view_presentation'); - -- commit; --- end; --- / --- show errors - - declare default_context acs_objects.object_id%TYPE; registered_users acs_objects.object_id%TYPE; @@ -555,7 +566,7 @@ default_context := acs.magic_object_id('default_context'); registered_users := acs.magic_object_id('registered_users'); - the_public := acs.magic_object_id('the_public'); +-- the_public := acs.magic_object_id('the_public'); -- give registered users the power to create presentations by default @@ -567,11 +578,12 @@ -- give the public the power to view by default - acs_permission.grant_permission ( - object_id => default_context, - grantee_id => the_public, - privilege => 'wp_view_presentation' - ); +-- this commented out because permission, with this any user could see an slide that has not become public! +-- acs_permission.grant_permission ( +-- object_id => default_context, +-- grantee_id => the_public, +-- privilege => 'wp_view_presentation' +-- ); end; / @@ -1672,4 +1684,90 @@ show errors +-- adding some new permissions roc@ + +Begin + + acs_privilege.add_child('wp_edit_presentation', 'wp_view_presentation'); + acs_privilege.add_child('wp_admin_presentation', 'wp_create_presentation'); + acs_privilege.add_child('wp_admin_presentation', 'wp_edit_presentation'); + acs_privilege.add_child('wp_admin_presentation', 'wp_delete_presentation'); + +-- lets give site-wide permissions, wp-permissions! + acs_privilege.add_child('admin', 'wp_admin_presentation'); + +end; +/ + +--style package roc@ + +create or replace package wp_style +as + +procedure delete ( + p_style_id in wp_styles.style_id%TYPE +); + +procedure image_delete( + p_revision_id in wp_style_images.wp_style_images_id%TYPE +); + +end wp_style; +/ +show errors + + + +create or replace package body wp_style +as + +procedure delete ( + p_style_id in wp_styles.style_id%TYPE +) +is + p_item_id integer; +begin + + for one_image in ( + select * from wp_style_images + where wp_style_images_id = (select background_image from wp_styles where style_id = wp_style.delete.p_style_id)) + loop + delete from wp_style_images where wp_style_images_id = one_image.wp_style_images_id; + select item_id into p_item_id from cr_revisions where revision_id = one_image.wp_style_images_id; + + content_item.delete(item_id => p_item_id); + end loop; + + update cr_wp_slides set style = -1 where style = wp_style.delete.p_style_id; + update cr_wp_presentations set style = -1 where style = wp_style.delete.p_style_id; + delete from wp_styles where style_id = wp_style.delete.p_style_id; + +end; + + + +procedure image_delete( + p_revision_id in wp_style_images.wp_style_images_id%TYPE +) +is + p_item_id integer; +begin + + update wp_styles set background_image = 0 where background_image = wp_style.image_delete.p_revision_id; + + delete from wp_style_images + where wp_style_images_id = wp_style.image_delete.p_revision_id; + + select item_id into p_item_id from cr_revisions where revision_id = wp_style.image_delete.p_revision_id; + + content_item.delete(item_id => p_item_id); + +end; + + +end wp_style; +/ +show errors + + commit; 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.6.2.2 -r1.6.2.3 --- openacs-4/packages/wp-slim/sql/postgresql/wp-slim-create.sql 2 Mar 2003 22:56:43 -0000 1.6.2.2 +++ openacs-4/packages/wp-slim/sql/postgresql/wp-slim-create.sql 21 May 2003 14:57:46 -0000 1.6.2.3 @@ -38,27 +38,51 @@ from dual where not exists (select 1 from cr_mime_types where mime_type ='application/octet-stream'); ---jackp: Create the different styles + +create sequence wp_style_seq; + create table wp_styles ( style_id integer constraint wp_styles_style_id_pk primary key, name varchar(400) constraint wp_styles_name_nn not null, - css varchar(4000), + css text, text_color varchar(20) check(text_color like '%,%,%'), background_color varchar(20) check(background_color like '%,%,%'), - background_image varchar(200), + background_image integer default 0, link_color varchar(20) check(link_color like '%,%,%'), alink_color varchar(20) check(alink_color like '%,%,%'), - vlink_color varchar(20) check(vlink_color like '%,%,%') + vlink_color varchar(20) check(vlink_color like '%,%,%'), + public_p char(1) default 'f' check(public_p in ('t','f')), + owner integer + constraint wp_styles_to_users + references users (user_id) ); + insert into wp_styles(style_id, name, css) values(-1, 'Default (Plain)', 'BODY { back-color: white; color: black } P { line-height: 120% } UL { line-height: 140% }'); +-- this is also a new index! roc@ +create index wp_styles_by_owner on wp_styles(owner); + +-- new table for supporting background images! +-- Images used for styles. + +create table wp_style_images ( +-- this one references to a cr! + wp_style_images_id integer primary key, + style_id integer references wp_styles(style_id) on delete cascade not null, + file_size integer not null, + file_name varchar(200) not null +); + +create index wp_style_images_style_id on wp_style_images(style_id); + + --jackp: p_create the presentation table create table cr_wp_presentations ( presentation_id integer @@ -84,7 +108,10 @@ -- Show last-modified date for slide? show_modified_p boolean constraint cr_wp_show_p_ck - check(show_modified_p in ('t','f')) + check(show_modified_p in ('t','f')), + show_comments_p char(1) default 'f' + constraint cr_wp_comments_p + check(show_comments_p in ('t','f')) ); @@ -684,6 +711,7 @@ select inline_10 (); drop function inline_10 (); + --jackp: set the permissions applicable to the package create function inline_11 () returns integer as' @@ -694,19 +722,20 @@ begin default_context := acs__magic_object_id(''default_context''); registered_users := acs__magic_object_id(''registered_users''); - the_public := acs__magic_object_id(''the_public''); +-- the_public := acs__magic_object_id(''the_public''); PERFORM acs_permission__grant_permission( default_context, registered_users, ''wp_create_presentation'' ); - PERFORM acs_permission__grant_permission( - default_context, - the_public, - ''wp_view_presentation'' - ); +-- this commented out because permission, with this any user could see an slide that has not become public! +-- PERFORM acs_permission__grant_permission( +-- default_context, +-- the_public, +-- ''wp_view_presentation'' +-- ); return 0; end;' language 'plpgsql'; select inline_11 (); @@ -716,7 +745,7 @@ --jackp: To p_create each presentation create function wp_presentation__new ( - timestamptz, + timestamp, integer, varchar(400), varchar(400), @@ -1029,7 +1058,7 @@ create function wp_presentation__new_revision ( - timestamptz, + timestamp, integer, varchar, integer, @@ -1160,7 +1189,7 @@ create function wp_slide__new ( integer, - timestamptz, + timestamp, integer, varchar, varchar, @@ -1475,7 +1504,7 @@ 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); + PERFORM wp_attachment__delete(del_rec.attach_item_id); end loop; select item_id into v_preamble_item_id @@ -1602,7 +1631,7 @@ end;' language 'plpgsql'; create function wp_slide__new_revision( - timestamptz, + timestamp, integer, varchar, integer, @@ -1765,22 +1794,24 @@ return 0; end;' language 'plpgsql'; +-- bug fixed, delete first an image then a file, roc@ create function wp_attachment__delete( integer ) returns integer as' declare p_attach_item_id alias for $1; begin - 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 = 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_wp_file_attachments + where exists (select 1 from cr_revisions where revision_id + = cr_wp_file_attachments.attach_id + and item_id = p_attach_item_id); + delete from cr_item_publish_audit where item_id = p_attach_item_id; @@ -1822,4 +1853,61 @@ end;' language 'plpgsql'; +-- style functions roc@ +create function wp_style__delete( + integer +) returns integer as' +declare + p_style_id alias for $1; + p_item_id integer; + one_image record; +begin + + for one_image in + select * from wp_style_images + where wp_style_images_id = (select background_image from wp_styles where style_id = p_style_id) + loop + delete from wp_style_images where wp_style_images_id = one_image.wp_style_images_id; + select item_id into p_item_id from cr_revisions where revision_id = one_image.wp_style_images_id; + PERFORM content_item__delete(p_item_id); + end loop; + + update cr_wp_slides set style = -1 where style = p_style_id; + update cr_wp_presentations set style = -1 where style = p_style_id; + delete from wp_styles where style_id = p_style_id; + + return 0; +end;' language 'plpgsql'; + +create function wp_style__image_delete( + integer +) returns integer as' +declare + p_revision_id alias for $1; + p_item_id integer; +begin + + update wp_styles set background_image = 0 where background_image = p_revision_id; + + delete from wp_style_images + where wp_style_images_id = p_revision_id; + + select item_id into p_item_id from cr_revisions where revision_id = p_revision_id; + + PERFORM content_item__delete(p_item_id); + + return 0; +end;' language 'plpgsql'; + + +-- new permissions roc@ +select acs_privilege__add_child('wp_edit_presentation', 'wp_view_presentation'); +select acs_privilege__add_child('wp_admin_presentation', 'wp_create_presentation'); +select acs_privilege__add_child('wp_admin_presentation', 'wp_edit_presentation'); +select acs_privilege__add_child('wp_admin_presentation', 'wp_delete_presentation'); + +-- lets give site-wide permissions, wp-permissions! +select acs_privilege__add_child('admin', 'wp_admin_presentation'); + +