Index: openacs-4/packages/file-storage/sql/postgresql/file-storage-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/sql/postgresql/file-storage-package-create.sql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/file-storage/sql/postgresql/file-storage-package-create.sql 19 Jul 2002 23:17:15 -0000 1.3 +++ openacs-4/packages/file-storage/sql/postgresql/file-storage-package-create.sql 29 Jul 2002 03:53:15 -0000 1.4 @@ -15,9 +15,9 @@ ) returns integer as ' -- fs_root_folders.folder_id%TYPE declare - get_root_folder__package_id alias for $1; - v_folder_id fs_root_folders.folder_id%TYPE; - v_count integer; + get_root_folder__package_id alias for $1; + v_folder_id fs_root_folders.folder_id%TYPE; + v_count integer; begin select count(*) into v_count @@ -75,14 +75,14 @@ varchar, -- cr_folders.label%TYPE varchar -- cr_folders.description%TYPE ) -returns integer as ' -- fs_root_folders.folder_id%TYPE +returns integer as ' -- fs_root_folders.folder_id%TYPE declare - new_root_folder__package_id alias for $1; + new_root_folder__package_id alias for $1; new_root_folder__folder_name alias for $2; new_root_folder__description alias for $3; - v_folder_id fs_root_folders.folder_id%TYPE; - v_package_name apm_packages.instance_name%TYPE; - v_package_key apm_packages.package_key%TYPE; + v_folder_id fs_root_folders.folder_id%TYPE; + v_package_name apm_packages.instance_name%TYPE; + v_package_key apm_packages.package_key%TYPE; v_folder_name cr_folders.label%TYPE; v_description cr_folders.description%TYPE; begin @@ -110,7 +110,7 @@ v_package_key || ''_'' || new_root_folder__package_id, -- name v_folder_name, -- label v_description, -- description - null -- parent_id (default) + null -- parent_id (default) ); insert into fs_root_folders @@ -119,33 +119,33 @@ (new_root_folder__package_id, v_folder_id); -- allow child items to be added - -- JS: Note that we need to set include_subtypes to - -- JS: true since we created a new subtype. + -- JS: Note that we need to set include_subtypes to + -- JS: true since we created a new subtype. PERFORM content_folder__register_content_type( - v_folder_id, -- folder_id - ''content_revision'', -- content_types - ''t'' -- include_subtypes - ); + v_folder_id, -- folder_id + ''content_revision'', -- content_types + ''t'' -- include_subtypes + ); PERFORM content_folder__register_content_type( - v_folder_id, -- folder_id - ''content_folder'', -- content_types - ''t'' -- include_subtypes - ); + v_folder_id, -- folder_id + ''content_folder'', -- content_types + ''t'' -- include_subtypes + ); -- set up default permissions PERFORM acs_permission__grant_permission ( - v_folder_id, -- object_id - acs__magic_object_id(''the_public''), -- grantee_id - ''read'' -- privilege - ); + v_folder_id, -- object_id + acs__magic_object_id(''the_public''), -- grantee_id + ''read'' -- privilege + ); PERFORM acs_permission__grant_permission ( - v_folder_id, -- object_id - acs__magic_object_id(''registered_users''), -- grantee_id - ''write'' -- privilege - ); + v_folder_id, -- object_id + acs__magic_object_id(''registered_users''), -- grantee_id + ''write'' -- privilege + ); - return v_folder_id; + return v_folder_id; end;' language 'plpgsql'; @@ -157,86 +157,84 @@ -- -- DRB: I added this version to allow one to predefine item_id, among other things to -- make it easier to use with ad_form - varchar, -- cr_items.name%TYPE, - integer, -- cr_items.parent_id%TYPE, - integer, -- acs_objects.creation_user%TYPE, - varchar, -- acs_objects.creation_ip%TYPE, - boolean, -- store in db? + varchar, -- cr_items.name%TYPE, + integer, -- cr_items.parent_id%TYPE, + integer, -- acs_objects.creation_user%TYPE, + varchar, -- acs_objects.creation_ip%TYPE, + boolean, -- store in db? integer -- cr_items.item_id%TYPE, ) returns integer as ' -- cr_items.item_id%TYPE declare - new_file__title alias for $1; - new_file__folder_id alias for $2; - new_file__user_id alias for $3; - new_file__creation_ip alias for $4; - new_file__indb_p alias for $5; + new_file__title alias for $1; + new_file__folder_id alias for $2; + new_file__user_id alias for $3; + new_file__creation_ip alias for $4; + new_file__indb_p alias for $5; new_file__item_id alias for $6; - v_item_id cr_items.item_id%TYPE; + v_item_id integer; begin - if new_file__indb_p - then - select content_item__new ( - new_file__title, -- name + if new_file__indb_p + then + v_item_id := content_item__new ( + new_file__title, -- name new_file__folder_id, -- parent_id - new_file__item_id, -- item_id (default) - null, -- locale (default) - now(), -- creation_date (default) + new_file__item_id, -- item_id (default) + null, -- locale (default) + now(), -- creation_date (default) new_file__user_id, -- creation_user new_file__folder_id, -- context_id new_file__creation_ip, -- creation_ip ''content_item'', -- item_subtype (default) ''file_storage_object'', -- content_type (needed by site-wide search) - null, -- title (default) - null, -- description - ''text/plain'', -- mime_type (default) - null, -- nls_language (default) - null -- data (default) - ) - into v_item_id; - else - select content_item__new ( - new_file__title, -- name - new_file__folder_id, -- parent_id - new_file__item_id, -- item_id (default) - null, -- locale (default) - now(), -- creation_date (default) - new_file__user_id, -- creation_user - new_file__folder_id, -- context_id + null, -- title (default) + null, -- description + ''text/plain'', -- mime_type (default) + null, -- nls_language (default) + null -- data (default) + ); + else + v_item_id := content_item__new ( + new_file__title, -- name + new_file__folder_id, -- parent_id + new_file__item_id, -- item_id (default) + null, -- locale (default) + now(), -- creation_date (default) + new_file__user_id, -- creation_user + new_file__folder_id, -- context_id new_file__creation_ip, -- creation_ip ''content_item'', -- item_subtype (default) ''file_storage_object'', -- content_type (needed by site-wide search) - null, -- title (default) - null, -- description - ''text/plain'', -- mime_type (default) - null, -- nls_language (default) - null, -- text (default) - ''file'' -- storage_type - ) - into v_item_id; + null, -- title (default) + null, -- description + ''text/plain'', -- mime_type (default) + null, -- nls_language (default) + null, -- text (default) + ''file'' -- storage_type + ); - end if; + end if; - select acs_object__update_last_modified(new_file__folder_id); + perform acs_object__update_last_modified(new_file__folder_id); return v_item_id; end;' language 'plpgsql'; create function file_storage__new_file( - varchar, -- cr_items.name%TYPE, - integer, -- cr_items.parent_id%TYPE, - integer, -- acs_objects.creation_user%TYPE, - varchar, -- acs_objects.creation_ip%TYPE, - boolean -- store in db? + varchar, -- cr_items.name%TYPE, + integer, -- cr_items.parent_id%TYPE, + integer, -- acs_objects.creation_user%TYPE, + varchar, -- acs_objects.creation_ip%TYPE, + boolean -- store in db? ) returns integer as ' -- cr_items.item_id%TYPE declare - new_file__title alias for $1; - new_file__folder_id alias for $2; - new_file__user_id alias for $3; - new_file__creation_ip alias for $4; - new_file__indb_p alias for $5; + new_file__title alias for $1; + new_file__folder_id alias for $2; + new_file__user_id alias for $3; + new_file__creation_ip alias for $4; + new_file__indb_p alias for $5; begin return file_storage__new_file( @@ -256,13 +254,13 @@ -- Delete a file and all its version -- Wrapper to content_item__delete -- - integer -- cr_items.item_id%TYPE + integer -- cr_items.item_id%TYPE ) returns integer as ' declare - delete_file__file_id alias for $1; + delete_file__file_id alias for $1; begin - return content_item__delete(delete_file__file_id); + return content_item__delete(delete_file__file_id); end;' language 'plpgsql'; @@ -272,19 +270,19 @@ -- Rename a file and all -- Wrapper to content_item__rename -- - integer, -- cr_items.item_id%TYPE, - varchar -- cr_items.name%TYPE + integer, -- cr_items.item_id%TYPE, + varchar -- cr_items.name%TYPE ) returns integer as ' declare - rename_file__file_id alias for $1; - rename_file__title alias for $2; + rename_file__file_id alias for $1; + rename_file__title alias for $2; begin - return content_item__rename( - rename_file__file_id, -- item_id - rename_file__title -- name - ); + return content_item__rename( + rename_file__file_id, -- item_id + rename_file__title -- name + ); end;' language 'plpgsql'; @@ -293,100 +291,100 @@ -- -- Copy a file, but only copy the live_revision -- - integer, -- cr_items.item_id%TYPE, - integer, -- cr_items.parent_id%TYPE, - integer, -- acs_objects.creation_user%TYPE, - varchar -- acs_objects.creation_ip%TYPE -) returns integer as ' -- cr_revisions.revision_id%TYPE + integer, -- cr_items.item_id%TYPE, + integer, -- cr_items.parent_id%TYPE, + integer, -- acs_objects.creation_user%TYPE, + varchar -- acs_objects.creation_ip%TYPE +) returns integer as ' -- cr_revisions.revision_id%TYPE declare - copy_file__file_id alias for $1; - copy_file__target_folder_id alias for $2; - copy_file__creation_user alias for $3; - copy_file__creation_ip alias for $4; - v_title cr_items.name%TYPE; - v_live_revision cr_items.live_revision%TYPE; - v_filename cr_revisions.title%TYPE; - v_description cr_revisions.description%TYPE; - v_mime_type cr_revisions.mime_type%TYPE; - v_content_length cr_revisions.content_length%TYPE; - v_lob_id cr_revisions.lob%TYPE; - v_new_lob_id cr_revisions.lob%TYPE; - v_file_path cr_revisions.content%TYPE; - v_new_file_id cr_items.item_id%TYPE; - v_new_version_id cr_revisions.revision_id%TYPE; - v_indb_p boolean; + copy_file__file_id alias for $1; + copy_file__target_folder_id alias for $2; + copy_file__creation_user alias for $3; + copy_file__creation_ip alias for $4; + v_title cr_items.name%TYPE; + v_live_revision cr_items.live_revision%TYPE; + v_filename cr_revisions.title%TYPE; + v_description cr_revisions.description%TYPE; + v_mime_type cr_revisions.mime_type%TYPE; + v_content_length cr_revisions.content_length%TYPE; + v_lob_id cr_revisions.lob%TYPE; + v_new_lob_id cr_revisions.lob%TYPE; + v_file_path cr_revisions.content%TYPE; + v_new_file_id cr_items.item_id%TYPE; + v_new_version_id cr_revisions.revision_id%TYPE; + v_indb_p boolean; begin - -- We copy only the title from the file being copied, and attributes of the - -- live revision - select i.name,i.live_revision,r.title,r.description,r.mime_type,r.content_length, - (case when i.storage_type = ''lob'' - then true - else false - end) - into v_title,v_live_revision,v_filename,v_description,v_mime_type,v_content_length,v_indb_p - from cr_items i, cr_revisions r - where r.item_id = i.item_id - and r.revision_id = i.live_revision - and i.item_id = copy_file__file_id; + -- We copy only the title from the file being copied, and attributes of the + -- live revision + select i.name,i.live_revision,r.title,r.description,r.mime_type,r.content_length, + (case when i.storage_type = ''lob'' + then true + else false + end) + into v_title,v_live_revision,v_filename,v_description,v_mime_type,v_content_length,v_indb_p + from cr_items i, cr_revisions r + where r.item_id = i.item_id + and r.revision_id = i.live_revision + and i.item_id = copy_file__file_id; - -- We should probably use the copy functions of CR - -- when we optimize this function - v_new_file_id := file_storage__new_file( - v_title, -- title - copy_file__target_folder_id, -- folder_id - copy_file__creation_user, -- creation_user - copy_file__creation_ip, -- creation_ip - v_indb_p -- indb_p - ); + -- We should probably use the copy functions of CR + -- when we optimize this function + v_new_file_id := file_storage__new_file( + v_title, -- title + copy_file__target_folder_id, -- folder_id + copy_file__creation_user, -- creation_user + copy_file__creation_ip, -- creation_ip + v_indb_p -- indb_p + ); - v_new_version_id := file_storage__new_version ( - v_filename, -- title - v_description, -- description - v_mime_type, -- mime_type - v_new_file_id, -- item_id - copy_file__creation_user, -- creation_user - copy_file__creation_ip -- creation_ip - ); - - if v_indb_p - then + v_new_version_id := file_storage__new_version ( + v_filename, -- title + v_description, -- description + v_mime_type, -- mime_type + v_new_file_id, -- item_id + copy_file__creation_user, -- creation_user + copy_file__creation_ip -- creation_ip + ); + + if v_indb_p + then - -- Lob to copy from - select lob into v_lob_id - from cr_revisions - where revision_id = v_live_revision; + -- Lob to copy from + select lob into v_lob_id + from cr_revisions + where revision_id = v_live_revision; - -- New lob id - v_new_lob_id := empty_lob(); + -- New lob id + v_new_lob_id := empty_lob(); - -- copy the blob - select lob_copy(v_lob_id,v_new_lob_id); + -- copy the blob + select lob_copy(v_lob_id,v_new_lob_id); - -- Update the lob id on the new version - update cr_revisions - set lob = v_new_lob_id, - content_length = v_content_length - where revision_id = v_new_version_id; + -- Update the lob id on the new version + update cr_revisions + set lob = v_new_lob_id, + content_length = v_content_length + where revision_id = v_new_version_id; - else + else - -- For now, we simply copy the file name - select content into v_file_path - from cr_revisions - where revision_id = v_live_revision; + -- For now, we simply copy the file name + select content into v_file_path + from cr_revisions + where revision_id = v_live_revision; - -- Update the file path - update cr_revisions - set content = v_file_path, - content_length = v_content_length - where revision_id = v_new_version_id; + -- Update the file path + update cr_revisions + set content = v_file_path, + content_length = v_content_length + where revision_id = v_new_version_id; - end if; + end if; - select acs_object__update_last_modified(copy_file__target_folder_id); + perform acs_object__update_last_modified(copy_file__target_folder_id); - return v_new_version_id; + return v_new_version_id; end;' language 'plpgsql'; @@ -396,20 +394,20 @@ -- Move a file (ans all its versions) to a different folder. -- Wrapper for content_item__move -- - integer, -- cr_folders.folder_id%TYPE, - integer -- cr_folders.folder_id%TYPE -) returns integer as ' -- 0 for success + integer, -- cr_folders.folder_id%TYPE, + integer -- cr_folders.folder_id%TYPE +) returns integer as ' -- 0 for success declare - move_file__file_id alias for $1; - move_file__target_folder_id alias for $2; + move_file__file_id alias for $1; + move_file__target_folder_id alias for $2; begin - select content_item__move( - move_file__file_id, -- item_id - move_file__target_folder_id -- target_folder_id - ); + select content_item__move( + move_file__file_id, -- item_id + move_file__target_folder_id -- target_folder_id + ); - select acs_object__update_last_modified(move_file__target_folder_id); + perform acs_object__update_last_modified(move_file__target_folder_id); return 0; end;' language 'plpgsql'; @@ -420,7 +418,7 @@ -- Unfortunately, title in the file-storage context refers -- to the name attribute in cr_items, not the title attribute in -- cr_revisions - integer -- cr_items.item_id%TYPE + integer -- cr_items.item_id%TYPE ) returns varchar as ' declare get_title__item_id alias for $1; @@ -440,7 +438,7 @@ else if v_content_type = ''content_symlink'' then select label into v_title f - rom cr_symlinks + rom cr_symlinks where symlink_id = get_title__item_id; else select name into v_title @@ -457,14 +455,14 @@ create function file_storage__get_content_type ( -- -- Wrapper for content_item__get_content_type - integer -- cr_items.item_id%TYPE + integer -- cr_items.item_id%TYPE ) returns varchar as ' -- cr_items.content_type%TYPE declare - get_content_type__file_id alias for $1; + get_content_type__file_id alias for $1; begin - return content_item__get_content_type( - get_content_type__file_id - ); + return content_item__get_content_type( + get_content_type__file_id + ); end;' language 'plpgsql'; @@ -473,14 +471,14 @@ create function file_storage__get_folder_name ( -- -- Wrapper for content_folder__get_label - integer -- cr_folders.folder_id%TYPE + integer -- cr_folders.folder_id%TYPE ) returns varchar as ' -- cr_folders.label%TYPE declare - get_folder_name__folder_id alias for $1; + get_folder_name__folder_id alias for $1; begin - return content_folder__get_label( - get_folder_name__folder_id - ); + return content_folder__get_label( + get_folder_name__folder_id + ); end;' language 'plpgsql'; @@ -490,49 +488,49 @@ -- Create a new version of a file -- Wrapper for content_revision__new -- - varchar, -- cr_revisions.title%TYPE, - varchar, -- cr_revisions.description%TYPE, - varchar, -- cr_revisions.mime_type%TYPE, - integer, -- cr_items.item_id%TYPE, - integer, -- acs_objects.creation_user%TYPE, - varchar -- acs_objects.creation_ip%TYPE -) returns integer as ' -- cr_revisions.revision_id + varchar, -- cr_revisions.title%TYPE, + varchar, -- cr_revisions.description%TYPE, + varchar, -- cr_revisions.mime_type%TYPE, + integer, -- cr_items.item_id%TYPE, + integer, -- acs_objects.creation_user%TYPE, + varchar -- acs_objects.creation_ip%TYPE +) returns integer as ' -- cr_revisions.revision_id declare - new_version__filename alias for $1; - new_version__description alias for $2; - new_version__mime_type alias for $3; - new_version__item_id alias for $4; - new_version__creation_user alias for $5; - new_version__creation_ip alias for $6; - v_revision_id cr_revisions.revision_id%TYPE; + new_version__filename alias for $1; + new_version__description alias for $2; + new_version__mime_type alias for $3; + new_version__item_id alias for $4; + new_version__creation_user alias for $5; + new_version__creation_ip alias for $6; + v_revision_id cr_revisions.revision_id%TYPE; v_folder_id cr_items.parent_id%TYPE; begin - -- Create a revision - v_revision_id := content_revision__new ( - new_version__filename, -- title - new_version__description, -- description - now(), -- publish_date - new_version__mime_type, -- mime_type - null, -- nls_language - null, -- data (default) - new_version__item_id, -- item_id - null, -- revision_id - now(), -- creation_date - new_version__creation_user, -- creation_user - new_version__creation_ip -- creation_ip - ); + -- Create a revision + v_revision_id := content_revision__new ( + new_version__filename, -- title + new_version__description, -- description + now(), -- publish_date + new_version__mime_type, -- mime_type + null, -- nls_language + null, -- data (default) + new_version__item_id, -- item_id + null, -- revision_id + now(), -- creation_date + new_version__creation_user, -- creation_user + new_version__creation_ip -- creation_ip + ); - -- Make live the newly created revision - select content_item__set_live_revision(v_revision_id); + -- Make live the newly created revision + perform content_item__set_live_revision(v_revision_id); select cr_items.parent_id into v_folder_id from cr_items where cr_items.item_id = new_version__item_id; - select acs_object__update_last_modified(v_folder_id); + perform acs_object__update_last_modified(v_folder_id); - return v_revision_id; + return v_revision_id; end;' language 'plpgsql'; @@ -541,38 +539,38 @@ -- -- Delete a version of a file -- - integer, -- cr_items.item_id%TYPE, - integer -- cr_revisions.revision_id%TYPE + integer, -- cr_items.item_id%TYPE, + integer -- cr_revisions.revision_id%TYPE ) returns integer as ' -- cr_items.parent_id%TYPE declare - delete_version__file_id alias for $1; - delete_version__version_id alias for $2; - v_parent_id cr_items.parent_id%TYPE; - v_deleted_last_version_p boolean; + delete_version__file_id alias for $1; + delete_version__version_id alias for $2; + v_parent_id cr_items.parent_id%TYPE; + v_deleted_last_version_p boolean; begin if delete_version__version_id = content_item__get_live_revision(delete_version__file_id) - then + then PERFORM content_revision__delete(delete_version__version_id); PERFORM content_item__set_live_revision( - content_item__get_latest_revision(delete_version__file_id) - ); + content_item__get_latest_revision(delete_version__file_id) + ); else PERFORM content_revision__delete(delete_version__version_id); end if; - -- If the live revision is null, we have deleted the last version above + -- If the live revision is null, we have deleted the last version above select (case when live_revision is null then parent_id else 0 end) - into v_parent_id + into v_parent_id from cr_items where item_id = delete_version__file_id; - -- Unfortunately, due to PostgreSQL behavior with regards referential integrity, - -- we cannot delete the content_item entry if there are no more revisions. - return v_parent_id; + -- Unfortunately, due to PostgreSQL behavior with regards referential integrity, + -- we cannot delete the content_item entry if there are no more revisions. + return v_parent_id; end;' language 'plpgsql'; @@ -581,56 +579,56 @@ -- -- Create a folder -- - varchar, -- cr_items.name%TYPE, - varchar, -- cr_folders.label%TYPE, - integer, -- cr_items.parent_id%TYPE, - integer, -- acs_objects.creation_user%TYPE, - varchar -- acs_objects.creation_ip%TYPE -) returns integer as ' -- cr_folders.folder_id%TYPE + varchar, -- cr_items.name%TYPE, + varchar, -- cr_folders.label%TYPE, + integer, -- cr_items.parent_id%TYPE, + integer, -- acs_objects.creation_user%TYPE, + varchar -- acs_objects.creation_ip%TYPE +) returns integer as ' -- cr_folders.folder_id%TYPE declare - new_folder__name alias for $1; - new_folder__folder_name alias for $2; - new_folder__parent_id alias for $3; - new_folder__creation_user alias for $4; - new_folder__creation_ip alias for $5; - v_folder_id cr_folders.folder_id%TYPE; + new_folder__name alias for $1; + new_folder__folder_name alias for $2; + new_folder__parent_id alias for $3; + new_folder__creation_user alias for $4; + new_folder__creation_ip alias for $5; + v_folder_id cr_folders.folder_id%TYPE; begin - -- Create a new folder - v_folder_id := content_folder__new ( - new_folder__name, -- name - new_folder__folder_name, -- label - null, -- description - new_folder__parent_id, -- parent_id - null, -- context_id (default) - null, -- folder_id (default) - now(), -- creation_date - new_folder__creation_user, -- creation_user - new_folder__creation_ip -- creation_ip - ); + -- Create a new folder + v_folder_id := content_folder__new ( + new_folder__name, -- name + new_folder__folder_name, -- label + null, -- description + new_folder__parent_id, -- parent_id + null, -- context_id (default) + null, -- folder_id (default) + now(), -- creation_date + new_folder__creation_user, -- creation_user + new_folder__creation_ip -- creation_ip + ); - -- register the standard content types - -- JS: Note that we need to set include_subtypes - -- JS: to true since we created a new subtype. - PERFORM content_folder__register_content_type( - v_folder_id, -- folder_id - ''content_revision'', -- content_type - ''t''); -- include_subtypes (default) + -- register the standard content types + -- JS: Note that we need to set include_subtypes + -- JS: to true since we created a new subtype. + PERFORM content_folder__register_content_type( + v_folder_id, -- folder_id + ''content_revision'', -- content_type + ''t''); -- include_subtypes (default) - PERFORM content_folder__register_content_type( - v_folder_id, -- folder_id - ''content_folder'', -- content_type - ''t'' -- include_subtypes (default) - ); + PERFORM content_folder__register_content_type( + v_folder_id, -- folder_id + ''content_folder'', -- content_type + ''t'' -- include_subtypes (default) + ); - -- Give the creator admin privileges on the folder - PERFORM acs_permission__grant_permission ( - v_folder_id, -- object_id - new_folder__creation_user, -- grantee_id - ''admin'' -- privilege - ); + -- Give the creator admin privileges on the folder + PERFORM acs_permission__grant_permission ( + v_folder_id, -- object_id + new_folder__creation_user, -- grantee_id + ''admin'' -- privilege + ); - return v_folder_id; + return v_folder_id; end;' language 'plpgsql'; @@ -639,15 +637,15 @@ -- -- Delete a folder -- - integer -- cr_folders.folder_id%TYPE -) returns integer as ' -- 0 for success + integer -- cr_folders.folder_id%TYPE +) returns integer as ' -- 0 for success declare - delete_folder__folder_id alias for $1; + delete_folder__folder_id alias for $1; begin - return content_folder__delete( - delete_folder__folder_id -- folder_id - ); + return content_folder__delete( + delete_folder__folder_id -- folder_id + ); end;' language 'plpgsql'; @@ -656,43 +654,43 @@ create function fs_package_items_delete_trig () returns opaque as ' declare - v_rec record; + v_rec record; begin - for v_rec in - - -- We want to delete all cr_items entries, starting from the leaves all - -- the way up the root folder (old.folder_id). - select c1.item_id, c1.content_type - from cr_items c1, cr_items c2 + for v_rec in + + -- We want to delete all cr_items entries, starting from the leaves all + -- the way up the root folder (old.folder_id). + select c1.item_id, c1.content_type + from cr_items c1, cr_items c2 where c2.item_id = old.folder_id - and c1.tree_sortkey between c2.tree_sortkey and tree_right(c2.tree_sortkey) - and c1.item_id <> old.folder_id + and c1.tree_sortkey between c2.tree_sortkey and tree_right(c2.tree_sortkey) + and c1.item_id <> old.folder_id order by c1.tree_sortkey desc - loop + loop - -- We delete the item. On delete cascade should take care - -- of deletion of revisions. - if v_rec.content_type = ''file_storage_object'' - then - raise notice ''Deleting item_id = %'',v_rec.item_id; - PERFORM content_item__delete(v_rec.item_id); - end if; + -- We delete the item. On delete cascade should take care + -- of deletion of revisions. + if v_rec.content_type = ''file_storage_object'' + then + raise notice ''Deleting item_id = %'',v_rec.item_id; + PERFORM content_item__delete(v_rec.item_id); + end if; - -- Instead of doing an if-else, we make sure we are deleting a folder. - if v_rec.content_type = ''content_folder'' - then - raise notice ''Deleting folder_id = %'',v_rec.item_id; - PERFORM content_folder__delete(v_rec.item_id); - end if; + -- Instead of doing an if-else, we make sure we are deleting a folder. + if v_rec.content_type = ''content_folder'' + then + raise notice ''Deleting folder_id = %'',v_rec.item_id; + PERFORM content_folder__delete(v_rec.item_id); + end if; - -- We may have to delete other items here, e.g., symlinks (future feature) + -- We may have to delete other items here, e.g., symlinks (future feature) - end loop; + end loop; - -- We need to return something for the trigger to be activated - return old; + -- We need to return something for the trigger to be activated + return old; end;' language 'plpgsql'; @@ -704,8 +702,8 @@ -- JS: AFTER DELETE TRIGGER to clean up last CR entry create function fs_root_folder_delete_trig () returns opaque as ' begin - PERFORM content_folder__delete(old.folder_id); - return null; + PERFORM content_folder__delete(old.folder_id); + return null; end;' language 'plpgsql'; Index: openacs-4/packages/file-storage/tcl/file-storage-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/tcl/file-storage-procs.tcl,v diff -u -r1.19 -r1.20 --- openacs-4/packages/file-storage/tcl/file-storage-procs.tcl 2 Jul 2002 19:40:00 -0000 1.19 +++ openacs-4/packages/file-storage/tcl/file-storage-procs.tcl 29 Jul 2002 03:53:15 -0000 1.20 @@ -336,7 +336,7 @@ ad_proc -public get_folder_contents { {-folder_id ""} {-user_id ""} - {-n_past_days "-1"} + {-n_past_days "99999"} } { Retrieve the contents of the specified folder in the form of a list of ns_sets, one for each row returned. The keys for each row are as Index: openacs-4/packages/file-storage/www/file-add-2-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/Attic/file-add-2-postgresql.xql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/file-storage/www/file-add-2-postgresql.xql 22 Sep 2001 05:42:03 -0000 1.3 +++ openacs-4/packages/file-storage/www/file-add-2-postgresql.xql 29 Jul 2002 03:53:15 -0000 1.4 @@ -5,30 +5,25 @@ - select file_storage__new_file ( :title, -- title :folder_id, -- parent_id :user_id, -- creation_user :creation_ip, -- creation_ip true -- indb_p ); - - - select file_storage__new_file ( :title, -- title :folder_id, -- parent_id :user_id, -- creation_user :creation_ip, -- creation_ip false -- indb_p ); - Index: openacs-4/packages/file-storage/www/file-add-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/Attic/file-add-2.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/file-storage/www/file-add-2.tcl 24 Sep 2001 19:52:07 -0000 1.4 +++ openacs-4/packages/file-storage/www/file-add-2.tcl 29 Jul 2002 03:53:15 -0000 1.5 @@ -54,79 +54,27 @@ # create the new item if {$indb_p} { - set file_id [db_exec_plsql new_lob_file " - begin - :1 := file_storage.new_file ( - title => :title, - folder_id => :folder_id, - creation_user => :user_id, - creation_ip => :creation_ip, - indb_p => 't' - ); + set file_id [db_exec_plsql new_lob_file {}] - end;"] + set version_id [db_exec_plsql new_version {}] - set version_id [db_exec_plsql new_version " - begin - :1 := file_storage.new_version ( - filename => :filename, - description => :description, - mime_type => :mime_type, - item_id => :file_id, - creation_user => :user_id, - creation_ip => :creation_ip - ); - end;"] + db_dml lob_content {} -blob_files [list ${upload_file.tmpfile}] - db_dml lob_content " - update cr_revisions - set content = empty_lob() - where revision_id = :version_id - returning content into :1" -blob_files [list ${upload_file.tmpfile}] - # Unfortunately, we can only calculate the file size after the lob is uploaded - db_dml lob_size " - update cr_revisions - set content_length = dbms_lob.getlength(content) - where revision_id = :version_id" + db_dml lob_size {} } else { - set file_id [db_exec_plsql new_fs_file " - begin - :1 := file_storage.new_file ( - title => :title, - folder_id => :folder_id, - creation_user => :user_id, - creation_ip => :creation_ip, - indb_p => 'f' - ); - end;"] + set file_id [db_exec_plsql new_fs_file {}] - set version_id [db_exec_plsql new_version " - begin + set version_id [db_exec_plsql new_version {}] - :1 := file_storage.new_version ( - filename => :filename, - description => :description, - mime_type => :mime_type, - item_id => :file_id, - creation_user => :user_id, - creation_ip => :creation_ip - ); - - end;"] - set tmp_filename [cr_create_content_file $file_id $version_id ${upload_file.tmpfile}] set tmp_size [cr_file_size $tmp_filename] - db_dml fs_content_size " - update cr_revisions - set content = '$tmp_filename', - content_length = $tmp_size - where revision_id = :version_id" + db_dml fs_content_size {} } Index: openacs-4/packages/file-storage/www/folder-chunk.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/folder-chunk.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/file-storage/www/folder-chunk.tcl 22 May 2002 16:42:31 -0000 1.5 +++ openacs-4/packages/file-storage/www/folder-chunk.tcl 29 Jul 2002 03:53:15 -0000 1.6 @@ -20,7 +20,7 @@ } if {![exists_and_not_null n_past_days]} { - set n_past_days -1 + set n_past_days 99999 } set folder_name [fs::get_object_name -object_id $folder_id] Index: openacs-4/packages/file-storage/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/index.tcl,v diff -u -r1.15 -r1.16 --- openacs-4/packages/file-storage/www/index.tcl 22 May 2002 16:47:41 -0000 1.15 +++ openacs-4/packages/file-storage/www/index.tcl 29 Jul 2002 03:53:15 -0000 1.16 @@ -7,7 +7,7 @@ @version $Id$ } { {folder_id:integer [fs_get_root_folder]} - {n_past_days:integer "-1"} + {n_past_days:integer "99999"} } -validate { valid_folder -requires {folder_id:integer} { if {![fs_folder_p $folder_id]} {