Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-folder.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-folder.sql,v diff -u -r1.18 -r1.19 --- openacs-4/packages/acs-content-repository/sql/postgresql/content-folder.sql 14 Jun 2001 00:23:21 -0000 1.18 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-folder.sql 23 Oct 2001 19:41:02 -0000 1.19 @@ -113,7 +113,89 @@ return null; end;' language 'plpgsql'; +-- function new -- accepts security_inherit_p DaveB +create function content_folder__new (varchar,varchar,varchar,integer,integer,integer,timestamp,integer,varchar, boolean) +returns integer as ' +declare + new__name alias for $1; + new__label alias for $2; + new__description alias for $3; -- default null + new__parent_id alias for $4; -- default null + new__context_id alias for $5; -- default null + new__folder_id alias for $6; -- default null + new__creation_date alias for $7; -- default now() + new__creation_user alias for $8; -- default null + new__creation_ip alias for $9; -- default null + new__security_inherit_p alias for $10; -- default true + v_folder_id cr_folders.folder_id%TYPE; + v_context_id acs_objects.context_id%TYPE; +begin + + -- set the context_id + if new__context_id is null then + v_context_id := new__parent_id; + else + v_context_id := new__context_id; + end if; + + -- parent_id = 0 means that this is a mount point + if new__parent_id != 0 and + content_folder__is_registered(new__parent_id,''content_folder'',''f'') = ''f'' then + + raise EXCEPTION ''-20000: This folder does not allow subfolders to be created''; + return null; + + else + + v_folder_id := content_item__new( + new__folder_id, + new__name, + new__parent_id, + null, + new__creation_date, + new__creation_user, + new__context_id, + new__creation_ip, + ''f'', + ''text/plain'', + null, + ''text'', + new__security_inherit_p, + ''CR_FILES'', + ''content_folder'', + ''content_folder''); + + insert into cr_folders ( + folder_id, label, description + ) values ( + v_folder_id, new__label, new__description + ); + + -- inherit the attributes of the parent folder + if new__parent_id is not null then + + insert into cr_folder_type_map + select + v_folder_id as folder_id, content_type + from + cr_folder_type_map + +where + folder_id = new__parent_id; + end if; + + -- update the child flag on the parent + update cr_folders set has_child_folders = ''t'' + where folder_id = new__parent_id; + + return v_folder_id; + + end if; + + return null; +end;' language 'plpgsql'; + -- procedure delete create function content_folder__delete (integer) returns integer as ' @@ -718,4 +800,3 @@ -- show errors - 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.31 -r1.32 --- openacs-4/packages/acs-content-repository/sql/postgresql/content-item.sql 27 Sep 2001 22:48:16 -0000 1.31 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-item.sql 23 Oct 2001 19:41:02 -0000 1.32 @@ -425,7 +425,7 @@ -- function new -- sets security_inherit_p to FALSE -DaveB -create function content_item__new ( integer, varchar, integer, varchar, timestamp, integer, integer, varchar, boolean, varchar, text, varchar, boolean, varchar) +create function content_item__new ( integer, varchar, integer, varchar, timestamp, integer, integer, varchar, boolean, varchar, text, varchar, boolean, varchar,varchar,varchar) returns integer as ' declare @@ -443,8 +443,8 @@ new__storage_type alias for $12; -- check in (''text'', ''file'') new__security_inherit_p alias for $13; -- default ''t'' new__storage_area_key alias for $14; -- default ''CR_FILES'' - new__item_subtype varchar default ''content_item''; - new__content_type varchar default ''content_revision''; + new__item_subtype alias for $15; + new__content_type alias for $16; new__description varchar default null; new__relation_tag varchar default null; new__nls_language varchar default null; @@ -529,7 +529,7 @@ v_rel_id := acs_object__new( null, ''cr_item_child_rel'', - now(), + new__creation_date, null, null, v_parent_id, @@ -586,168 +586,6 @@ end;' language 'plpgsql'; -create function content_item__new ( integer, varchar, integer, varchar, timestamp, integer, integer, varchar, boolean, varchar, text, varchar, boolean) - -returns integer as ' -declare - new__item_id alias for $1; --default null - new__name alias for $2; - new__parent_id alias for $3; -- default null - new__title alias for $4; -- default null - new__creation_date alias for $5; -- default now() - new__creation_user alias for $6; -- default null - new__context_id alias for $7; -- default null - new__creation_ip alias for $8; -- default null - new__is_live alias for $9; -- default ''f'' - new__mime_type alias for $10; - new__text alias for $11; -- default null - new__storage_type alias for $12; -- check in (''text'', ''file'') - new__security_inherit_p alias for $13; - new__item_subtype varchar default ''content_item''; - new__content_type varchar default ''content_revision''; - new__description varchar default null; - new__relation_tag varchar default null; - new__nls_language varchar default null; - v_parent_id cr_items.parent_id%TYPE; - v_parent_type acs_objects.object_type%TYPE; - v_item_id cr_items.item_id%TYPE; - v_revision_id cr_revisions.revision_id%TYPE; - v_title cr_revisions.title%TYPE; - v_rel_id acs_objects.object_id%TYPE; - v_rel_tag cr_child_rels.relation_tag%TYPE; - v_context_id acs_objects.context_id%TYPE; - -begin - - -- place the item in the context of the pages folder if no - -- context specified - - if new__parent_id is null then - v_parent_id := content_item_globals.c_root_folder_id; - else - v_parent_id := new__parent_id; - end if; - - -- Determine context_id - if new__context_id is null then - v_context_id := v_parent_id; - else - v_context_id := new__context_id; - end if; - - if v_parent_id = 0 or - content_folder__is_folder(v_parent_id) = ''t'' then - - if v_parent_id != 0 and - 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; - end if; - - else if v_parent_id != 0 then - - select object_type into v_parent_type from acs_objects - where object_id = v_parent_id; - - if NOT FOUND then - raise EXCEPTION ''-20000: Invalid parent ID % specified in content_item.new'', v_parent_id; - end if; - - 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; - end if; - - end if; end if; - - - -- Create the object - - v_item_id := acs_object__new( - new__item_id, - new__item_subtype, - new__creation_date, - new__creation_user, - new__creation_ip, - v_context_id, - new__security_inherit_p - ); - - insert into cr_items ( - item_id, name, content_type, parent_id, storage_type - ) values ( - v_item_id, new__name, new__content_type, v_parent_id, new__storage_type - ); - - -- if the parent is not a folder, insert into cr_child_rels - if v_parent_id != 0 and - content_folder__is_folder(v_parent_id) = ''f'' and - content_item__is_valid_child(v_parent_id, new__content_type) = ''t'' then - - v_rel_id := acs_object__new( - null, - ''cr_item_child_rel'', - now(), - null, - null, - v_parent_id, - ''f'' - ); - - if new__relation_tag is null then - v_rel_tag := content_item__get_content_type(v_parent_id) - || ''-'' || new__content_type; - else - v_rel_tag := new__relation_tag; - end if; - - insert into cr_child_rels ( - rel_id, parent_id, child_id, relation_tag, order_n - ) values ( - v_rel_id, v_parent_id, v_item_id, v_rel_tag, v_item_id - ); - - end if; - - -- use the name of the item if no title is supplied - if new__title is null then - v_title := new__name; - else - v_title := new__title; - end if; - - if new__title is not null or - new__text is not null then - - v_revision_id := content_revision__new( - v_title, - new__description, - now(), - new__mime_type, - null, - new__text, - v_item_id, - null, - new__creation_date, - new__creation_user, - new__creation_ip - ); - - end if; - - -- make the revision live if is_live is true - if new__is_live = ''t'' then - PERFORM content_item__set_live_revision(v_revision_id); - end if; - - return v_item_id; - -end;' language 'plpgsql'; - - - -- function is_published create function content_item__is_published (integer) returns boolean as '