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 -