Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-drop.sql 27 Mar 2001 02:02:31 -0000 1.1 @@ -0,0 +1,209 @@ +-- Uninstall content repository tables of the ArsDigita Community +-- System + +-- Copyright (C) 1999-2000 ArsDigita Corporation +-- Author: Karl Goldstein (karlg@arsdigita.com) + +-- $Id: content-drop.sql,v 1.1 2001/03/27 02:02:31 danw Exp $ + +-- This is free software distributed under the terms of the GNU Public +-- License. Full text of the license is available from the GNU Project: +-- http://www.fsf.org/copyleft/gpl.html + +-- set serveroutput on + +-- unregistering types, deleting the default folders +create function inline_0 () returns integer as ' +declare + v_id integer; +begin + + -- root folder for templates + v_id := content_template__get_root_folder(); + + PERFORM content_folder__unregister_content_type( + v_id, + ''content_template'', + ''t'' + ); + + PERFORM content_folder__unregister_content_type( + v_id, + ''content_symlink'', + ''t'' + ); + + PERFORM content_folder__unregister_content_type( + v_id, + ''content_folder'', + ''t'' + ); + + PERFORM content_folder__delete(v_id); + + + -- the root folder for content items + v_id := content_item__get_root_folder(); + + PERFORM content_folder__unregister_content_type( + v_id, + ''content_symlink'', + ''t'' + ); + + PERFORM content_folder__unregister_content_type( + v_id, + ''content_folder'', + ''t'' + ); + + PERFORM content_folder__unregister_content_type ( + v_id, + ''content_revision'', + ''t'' + ); + + PERFORM content_folder__delete (v_id); + + return null; + +end;' language 'plpgsql'; + +select inline_0 (); + +drop function inline_0 (); + + + +begin; + select content_type__unregister_mime_type('content_revision', 'text/html'); + select content_type__unregister_mime_type('content_revision', 'text/plain'); +end; + + +-- drop all extended attribute tables + +--declare +-- cursor type_cur is +-- select object_type, table_name +-- from acs_object_types +-- where table_name <> 'cr_revisions' +-- connect by prior object_type = supertype +-- start with object_type = 'content_revision' +-- order by level desc; +--begin + +-- for type_rec in type_cur loop +-- dbms_output.put_line('Dropping ' || type_rec.table_name); +-- execute immediate 'drop table ' || type_rec.table_name; +-- end loop; + +--end; +--/ +--show errors + + +-- dropping pl/sql definitions +--prompt ** dropping content-image +\i content-image-drop.sql + +-- doc-package-drop + +-- content-search-drop +-- begin +-- ctx_ddl.drop_section_group('auto'); +--end; + + +--begin +-- ctx_ddl.drop_preference('CONTENT_FILTER_PREF'); +--end; + + +-- prompt ** dropping object types +\i types-drop.sql + +-- packages-drop + + +-- content-package-drop + +-- prompt ** dropping lots of tables +-- content-xml-drop +drop table cr_xml_docs; +drop sequence cr_xml_doc_seq; + +-- content-util drop + +-- document submission with conversion to html +drop index cr_doc_filter_index; +drop table cr_doc_filter; + + +--text submission +drop table cr_text; + +-- content keywords +drop table cr_item_keyword_map ; +drop table cr_keywords ; + +-- content extlinks +drop table cr_extlinks ; + +-- content symlinks +drop table cr_symlinks ; + +-- content templates +drop table cr_item_template_map ; +drop table cr_type_template_map ; +drop table cr_template_use_contexts ; +drop table cr_templates ; + +-- content folders +drop table cr_folder_type_map ; +drop table cr_folders cascade constraints; + + +-- prompt ** dropping more tables +-- content publishing +drop table cr_scheduled_release_job; +drop table cr_scheduled_release_log; +drop table cr_release_periods; +drop table cr_item_publish_audit; + +-- content revisions +drop table cr_content_text; +drop table cr_revision_attributes; +drop table cr_revisions cascade constraints; + +-- content_items +drop table cr_item_rels ; +drop table cr_child_rels ; +drop table cr_items cascade constraints; + +-- content types +drop table cr_type_relations ; +drop table cr_type_children ; + +-- locales +drop table cr_locales ; + +-- mime types +drop table cr_content_mime_type_map ; +drop table cr_mime_types ; + + +-- dropping ats datatypes for cms +begin; + + delete from acs_datatypes where datatype in ('text'); + + delete from acs_datatypes where datatype in ('keyword'); + + delete from acs_datatypes where datatype in ('integer'); + +commit; + + + + 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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-image-drop.sql 27 Mar 2001 02:02:31 -0000 1.1 @@ -0,0 +1,45 @@ +-- drop the content-image type from the data model + +-- Copyright (C) 20000 ArsDigita Corporation + +-- $Id: content-image-drop.sql,v 1.1 2001/03/27 02:02:31 danw Exp $ + +-- This is free software distributed under the terms of the GNU Public +-- License. Full text of the license is available from the GNU Project: +-- http://www.fsf.org/copyleft/gpl.html + +-- unregister mime types from the image type +begin; + + select content_type__unregister_mime_type( + 'image', + 'image/jpeg' + ); + + select content_type__unregister_mime_type( + 'image', + 'image/gif' + ); + +end; + +-- remove image mime types + +delete from cr_mime_types where mime_type like 'image%'; + + + +-- this should remove the attributes and table related to the +-- the image type + +begin; + + select content_type__drop_type ( + 'image', + 'f', + 't'); + +end; + + + 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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-image.sql 27 Mar 2001 02:02:31 -0000 1.1 @@ -0,0 +1,91 @@ +-- Data model to support content repository of the ArsDigita +-- Publishing System + +-- Copyright (C) 1999-2000 ArsDigita Corporation +-- Author: Hiro Iwashima (iwashima@mit.edu) + +-- $ID$ + +-- This is free software distributed under the terms of the GNU Public +-- License. Full text of the license is available from the GNU Project: +-- http://www.fsf.org/copyleft/gpl.html + +-- This is to handle images + +create table images ( + image_id integer + constraint images_image_id_fk + references cr_revisions + constraint images_pk + primary key, + width integer, + height integer +); + + +begin; + + select content_type__create_type ( + 'image', + 'content_revision', + 'Image', + 'Images', + 'images', + 'image_id', + null + ); + + select content_type__create_attribute ( + content_type => 'image', + attribute_name => 'width', + datatype => 'integer', + pretty_name => 'Width', + pretty_plural => 'Widths', + null, + null, + 'text' + ); + + select content_type__create_attribute ( + content_type => 'image', + attribute_name => 'height', + datatype => 'integer', + pretty_name => 'Height', + pretty_plural => 'Heights', + null, + null, + 'text' + ); + +end; + + +-- insert new MIME types +insert into cr_mime_types ( + label, mime_type, file_extension +) values ( + 'Image - Jpeg', 'image/jpeg','jpg' +); + +insert into cr_mime_types ( + label, mime_type, file_extension +) values ( + 'Image - Gif', 'image/gif','gif' +); + + + +-- register MIME types to this content type +begin; + + select content_type__register_mime_type( + 'image', + 'image/jpeg' + ); + + select content_type__register_mime_type( + 'image', + 'image/gif' + ); + +end; Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-perms.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/Attic/content-perms.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-perms.sql 27 Mar 2001 02:02:31 -0000 1.1 @@ -0,0 +1,349 @@ +-------------------------------------------------------------- +-- +-- Set up the basic permissions used by the CMS, and invent some +-- api in dealing with them +-- +-------------------------------------------------------------- + +create function inline_0 () +returns integer as ' +begin + + select 1 from dual + where exists (select 1 from acs_privileges + where privilege = ''cm_root''); + + if NOT FOUND then + + -- Dummy root privilege + PERFORM acs_privilege__create_privilege(''cm_root'', ''Root'', ''Root''); + -- He can do everything + PERFORM acs_privilege__create_privilege(''cm_admin'', ''Administrator'', ''Administrators''); + PERFORM acs_privilege__create_privilege(''cm_write'', ''Write'', ''Write''); + PERFORM acs_privilege__create_privilege(''cm_new'', ''Create New Item'', ''Create New Item''); + PERFORM acs_privilege__create_privilege(''cm_examine'', ''Admin-level Read'', ''Admin-level Read''); + PERFORM acs_privilege__create_privilege(''cm_read'', ''User-level Read'', ''User-level Read''); + PERFORM acs_privilege__create_privilege(''cm_item_workflow'', ''Modify Workflow'', ''Modify Workflow''); + PERFORM acs_privilege__create_privilege(''cm_perm_admin'', ''Modify Any Permissions'', ''Modify Any Permissions''); + PERFORM acs_privilege__create_privilege(''cm_perm'', ''Donate Permissions'', ''Donate Permissions''); + + PERFORM acs_privilege__add_child(''cm_root'', ''cm_admin''); -- Do anything to an object + PERFORM acs_privilege__add_child(''cm_admin'', ''cm_write''); -- Do anything to an object + PERFORM acs_privilege__add_child(''cm_write'', ''cm_new''); -- Create subitems + PERFORM acs_privilege__add_child(''cm_new'', ''cm_examine''); -- View in admin mode + PERFORM acs_privilege__add_child(''cm_examine'', ''cm_read''); -- View in user mode + PERFORM acs_privilege__add_child(''cm_write'', ''cm_item_workflow''); -- Change item workflow + + PERFORM acs_privilege__add_child(''cm_admin'', ''cm_perm_admin''); -- Modify any permissions + PERFORM acs_privilege__add_child(''cm_perm_admin'', ''cm_perm''); -- Modify any permissions on an item + + -- Proper inheritance + PERFORM acs_privilege__add_child(''admin'', ''cm_root''); + + end if; + + return 0; +end;' language 'plpgsql'; + +select inline_0 (); + +drop function inline_0 (); + + +-- create or replace package body content_permission +-- procedure inherit_permissions +create function content_permission__inherit_permissions (integer,integer,integer) +returns integer as ' +declare + inherit_permissions__parent_object_id alias for $1; + inherit_permissions__child_object_id alias for $2; + inherit_permissions__child_creator_id alias for $3; + v_dummy integer; +begin + + -- Determine if the child is a direct descendant of the + -- parent + select 1 into v_dummy from acs_objects + where object_id = inherit_permissions__child_object_id + and context_id = inherit_permissions__parent_object_id; + + if NOT FOUND then + raise EXCEPTION ''-20000: Child object is not actually a child of the parent object in inherit_permissions''; + end if; + + -- Copy everything one level down + insert into acs_permissions + select + inherit_permissions__child_object_id as object_id, + grantee_id, + privilege + from + acs_permissions + where + object_id = inherit_permissions__parent_object_id; + + if inherit_permissions__child_creator_id is not null then + -- Grant cm_write and cm_perm to the child creator + if content_permission.permission_p ( + child_object_id, child_creator_id, ''cm_perm'' + ) != ''t'' then + -- Turn off inheritance and grant permission + update acs_objects set security_inherit_p = ''f'' + where object_id = inherit_permissions__child_object_id; + PERFORM acs_permission__grant_permission ( + child_object_id, child_creator_id, ''cm_perm'' + ); + end if; + + if content_permission__permission_p ( + child_object_id, child_creator_id, ''cm_write'' + ) != ''t'' then + PERFORM acs_permission__grant_permission ( + child_object_id, child_creator_id, ''cm_write'' + ); + end if; + end if; + + return 0; +end;' language 'plpgsql'; + + +-- function has_grant_authority +create function content_permission__has_grant_authority (integer,integer,varchar) +returns boolean as ' +declare + object_id alias for $1; + holder_id alias for $2; + privilege alias for $3; +begin + -- Can donate permission only if you already have it and you have cm_perm, + -- OR you have cm_perm_admin + if content_permission__permission_p (object_id, holder_id, ''cm_perm_admin'')= ''t'' + or ( + content_permission__permission_p (object_id, holder_id, ''cm_perm'') = ''t'' and + content_permission__permission_p (object_id, holder_id, privilege) = ''t'' + ) + then + return ''t''; + else + return ''f''; + end if; + +end;' language 'plpgsql'; + + +-- function has_revoke_authority +create function content_permission__has_revoke_authority (integer,integer,varchar,integer) +returns varchar as ' +declare + has_revoke_authority__object_id alias for $1; + has_revoke_authority__holder_id alias for $2; + has_revoke_authority__privilege alias for $3; + has_revoke_authority__revokee_id alias for $4; +begin + select 1 from + (select object_id from acs_objects + connect by prior context_id = object_id + start with object_id = has_revoke_authority__object_id) t, + (select privilege, child_privilege from acs_privilege_hierarchy + connect by prior privilege = child_privilege + start with child_privilege = ''cm_perm'') h + where + content_permission__permission_p( + t.object_id, has_revoke_authority__holder_id, h.child_privilege + ) = ''t'' + and + content_permission__permission_p( + t.object_id, has_revoke_authority__revokee_id, h.privilege + ) = ''f''; + + if NOT FOUND then + return ''f''; + else + return ''t''; + end if; + +end;' language 'plpgsql'; + + +-- procedure grant_permission_h +create function content_permission__grant_permission_h (integer,integer,varchar) +returns integer as ' +declare + grant_permission_h__object_id alias for $1; + grant_permission_h__grantee_id alias for $2; + grant_permission_h__privilege alias for $3; + v_privilege acs_privilege_descendant_map.privilege%TYPE; + v_rec record; +begin + + -- If the permission is already granted, do nothing + if content_permission__permission_p ( + object_id, grantee_id, privilege + ) = ''t'' then + return null; + end if; + + -- Grant the parent, make sure there is no inheritance + update acs_objects set security_inherit_p = ''f'' + where object_id = grant_permission_h__object_id; + + PERFORM acs_permission__grant_permission(object_id, grantee_id, privilege); + + -- Revoke the children - they are no longer relevant + + for v_rec in select descendant from acs_privilege_descendant_map + where privilege = grant_permission_h__privilege + and descendant <> grant_permission_h__privilege; + LOOP + PERFORM acs_permission__revoke_permission(grant_permission_h__object_id, + grant_permission_h__grantee_id, + v_rec.descendant); + end LOOP; + + return 0; +end;' language 'plpgsql'; + + +-- procedure grant_permission +create function content_permission__grant_permission (integer,integer,varchar,integer,varchar,varchar) +returns integer as ' +declare + grant_permission__object_id alias for $1; + grant_permission__holder_id alias for $2; + grant_permission__privilege alias for $3; + grant_permission__recepient_id alias for $4; + grant_permission__is_recursive alias for $5; + grant_permission__object_type alias for $6; + v_object_id acs_objects.object_id%TYPE; +begin + + for v_rec in select + o.object_id + from + (select object_id, object_type from acs_objects + connect by context_id = prior object_id + start with object_id = grant_permission__object_id) o + where + content_permission__has_grant_authority ( + o.object_id, holder_id, grant_permission__privilege + ) = ''t'' + and + content_item__is_subclass (o.object_type, grant_permission__object_type) = ''t'' + LOOP + -- Grant the parent and revoke the children, since we don''t need them + -- anymore + PERFORM content_permission__grant_permission_h ( + v_rec.object_id, recepient_id, privilege + ); + exit when grant_permission__is_recursive = ''f''; + end loop; + + return 0; +end;' language 'plpgsql'; + + +-- procedure revoke_permission_h +create function content_permission__revoke_permission_h (integer,integer,varchar) +returns integer as ' +declare + revoke_permission_h__object_id alias for $1; + revoke_permission_h__revokee_id alias for $2; + revoke_permission_h__privilege alias for $3; + v_rec record; +begin + + -- Grant all child privileges of the parent privilege + for v_rec in select child_privilege from acs_privilege_hierarchy + where privilege = revoke_permission_h__privilege + LOOP + PERFORM acs_permission__grant_permission ( + revoke_permission_h__object_id, + revoke_permission_h__revokee_id, + v_rec.child_privilege + ); + end loop; + + -- Revoke the parent privilege + PERFORM acs_permission__revoke_permission ( + revoke_permission_h__object_id, + revoke_permission_h__revokee_id, + revoke_permission_h__privilege + ); + + return 0; +end;' language 'plpgsql'; + + +-- procedure revoke_permission +create function content_permission__revoke_permission (integer,integer,varchar,integer,varchar,varchar) +returns integer as ' +declare + revoke_permission__object_id alias for $1; + revoke_permission__holder_id alias for $2; + revoke_permission__privilege alias for $3; + revoke_permission__revokee_id alias for $4; + revoke_permission__is_recursive alias for $5; + revoke_permission__object_type alias for $6; + v_rec record; +begin + + for v_rec in select + o.object_id + from + (select object_id, object_type from acs_objects + connect by context_id = prior object_id + start with object_id = revoke_permission__object_id) o + where + content_permission__has_revoke_authority (o.object_id, revoke_permission__holder_id, revoke_permission__privilege, revoke_permission__revokee_id) = ''t'' + and + content_item__is_subclass(o.object_type, revoke_permission__object_type) = ''t'' + LOOP + PERFORM content_permission__revoke_permission_h ( + v_rec.object_id, revoke_permission__revokee_id, revoke_permission__privilege + ); + + exit when revoke_permission__is_recursive = ''f''; + end loop; + + return 0; +end;' language 'plpgsql'; + + +-- function permission_p +create function content_permission__permission_p (integer,integer,varchar) +returns boolean as ' +declare + object_id alias for $1; + holder_id alias for $2; + privilege alias for $3; +begin + + return acs_permission__permission_p (object_id, holder_id, privilege); + +end;' language 'plpgsql'; + + -- Determine if the CMS admin exists +create function cm_admin_exists () returns boolean as ' +begin + + select 1 from dual + where exists ( + select 1 from acs_permissions + where privilege in (''cm_admin'', ''cm_root'') + ); + + if NOT FOUND then + return ''f''; + else + return ''t''; + end if; + +end;' language 'plpgsql'; + +-- show errors + + + + + Index: openacs-4/packages/acs-content-repository/sql/postgresql/datatype-upgrade.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/datatype-upgrade.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-content-repository/sql/postgresql/datatype-upgrade.sql 27 Mar 2001 02:02:31 -0000 1.1 @@ -0,0 +1,37 @@ + + + +update acs_attributes + set datatype = 'keyword' + where attribute_name = 'name' + and object_type = 'content_item'; + +update acs_attributes + set datatype = 'keyword' + where attribute_name = 'locale' + and object_type = 'content_item'; + +update acs_attributes + set datatype = 'text' + where attribute_name = 'title' + and object_type = 'content_revision'; + +update acs_attributes + set datatype = 'text' + where attribute_name = 'description' + and object_type = 'content_revision'; + +update acs_attributes + set datatype = 'text' + where attribute_name = 'mime_type' + and object_type = 'content_revision'; + +update acs_attributes + set datatype = 'integer' + where attribute_name = 'width' + and object_type = 'image'; + +update acs_attributes + set datatype = 'integer' + where attribute_name = 'height' + and object_type = 'image'; Index: openacs-4/packages/acs-content-repository/sql/postgresql/doc-package.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/doc-package.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-content-repository/sql/postgresql/doc-package.sql 27 Mar 2001 02:02:31 -0000 1.1 @@ -0,0 +1,135 @@ +---------------------------------------- +-- Return function headers for packages +--------------------------------------- + +-- create or replace package doc +-- is +-- +-- function get_proc_header ( +-- proc_name in varchar2, +-- package_name in varchar2 +-- ) return varchar2; +-- +-- function get_package_header ( +-- package_name in varchar2 +-- ) return varchar2; +-- +-- end doc; + +-- show errors + +-- create or replace package body doc +-- function get_proc_header +create function doc__get_proc_header (varchar,varchar) +returns varchar as ' +declare + proc_name alias for $1; + package_name alias for $2; + v_line integer; + v_result varchar(4000); + v_text varchar(4000); + v_started varchar(1); + v_newline varchar(10) + '; + + cursor v_package_cur + select line, + where lower(name) + and type + order by + +begin + + v_result := ''''; + v_started := ''f''; + + open v_package_cur; + loop + fetch v_package_cur into v_line, v_text; + exit when v_package_cur%NOTFOUND; + + -- Look for the function header + if v_started = ''f'' then + if lower(v_text) like ''%function%'' || lower(proc_name) || ''%'' then + v_started := ''t''; + elsif lower(v_text) like ''%procedure%'' || lower(proc_name) || ''%'' then + v_started := ''t''; + end if; + end if; + + -- Process the header + if v_started = ''t'' then + v_result := v_result || v_text; + if v_text like ''%;%'' then + close v_package_cur; + return v_result; + end if; + end if; + end loop; + + -- Return unfinished result + return v_result; + +end;' language 'plpgsql'; + + +-- function get_package_header +create function doc__get_package_header (varchar) +returns varchar as ' +declare + package_name alias for $1; + v_line integer; + v_result varchar(4000); + v_text varchar(4000); + v_started varchar(1); + v_newline varchar(10) + '; + + cursor v_package_cur + select line, + where lower(name) + and type + order by + +begin + + v_result := ''''; + v_started := ''f''; + + open v_package_cur; + loop + fetch v_package_cur into v_line, v_text; + exit when v_package_cur%NOTFOUND; + + -- Look for the function header + if v_started = ''f'' then + if v_text like ''--%'' then + v_started := ''t''; + end if; + end if; + + -- Process the header + if v_started = ''t'' then + + if v_text not like ''--%'' then + close v_package_cur; + return v_result; + end if; + + v_result := v_result || v_text; + end if; + end loop; + + -- Return unfinished result + return v_result; + + +end;' language 'plpgsql'; + + + +-- show errors + + + + Index: openacs-4/packages/acs-content-repository/sql/postgresql/types-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/types-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-content-repository/sql/postgresql/types-create.sql 27 Mar 2001 02:02:31 -0000 1.1 @@ -0,0 +1,561 @@ +-- Object type declarations to support content repository of the +-- ArsDigita Community System + +-- Copyright (C) 1999-2000 ArsDigita Corporation +-- Author: Karl Goldstein (karlg@arsdigita.com) + +-- $Id: types-create.sql,v 1.1 2001/03/27 02:02:31 danw Exp $ + +-- This is free software distributed under the terms of the GNU Public +-- License. Full text of the license is available from the GNU Project: +-- http://www.fsf.org/copyleft/gpl.html + +-- Define content items. Also the supertype for folders, symlinks and extlinks. + +begin; + + select acs_object_type__create_type ( + 'content_item', + 'Content Item', + 'Content Items', + 'acs_object', + 'cr_items', + 'item_id', + null, + 'f', + null, + 'content_item.get_title' + ); + + select acs_attribute__create_attribute ( + 'content_item', + 'name', + 'keyword', + 'Name', + 'Names', + null, + null, + null, + 1, + 1, + null, + 'type_specific', + 'f' + ); + + select acs_attribute__create_attribute ( + 'content_item', + 'locale', + 'keyword', + 'Locale', + 'Locales', + null, + null, + null, + 1, + 1, + null, + 'type_specific', + 'f' + ); + + select acs_attribute__create_attribute ( + 'content_item', + 'live_revision', + 'integer', + 'Live Revision', + 'Live Revisions', + null, + null, + null, + 1, + 1, + null, + 'type_specific', + 'f' + ); + +end; + +-- Define content folders. A folder is equivalent to a directory in +-- the file system. It is used for grouping content items that have +-- public URL's. + +begin; + + select acs_object_type__create_type ( + 'content_folder', + 'Content Folder', + 'Content Folders', + 'content_item', + 'cr_folders', + 'folder_id', + null, + 'f', + null, + name_method => 'content_folder.get_label' + ); + + select acs_attribute__create_attribute ( + 'content_folder', + 'label', + 'string', + 'Label', + 'Labels', + null, + null, + null, + 1, + 1, + null, + 'type_specific', + 'f' + ); + + select acs_attribute__create_attribute ( + 'content_folder', + 'description', + 'string', + 'Description', + 'Descriptions', + null, + null, + null, + 1, + 1, + null, + 'type_specific', + 'f' + ); + +end; + + +-- Define content keywords + +begin; + + select acs_object_type__create_type ( + 'content_keyword', + 'Content Keyword', + 'Content Keywords', + 'acs_object', + 'cr_keywords', + 'keyword_id', + null, + 'f', + null, + name_method => 'acs_object.default_name' + ); + + select acs_attribute__create_attribute ( + 'content_keyword', + 'heading', + 'string', + 'Heading', + 'Headings', + null, + null, + null, + 1, + 1, + null, + 'type_specific', + 'f' + ); + + select acs_attribute__create_attribute ( + 'content_keyword', + 'description', + 'string', + 'Description', + 'Descriptions', + null, + null, + null, + 1, + 1, + null, + 'type_specific', + 'f' + ); + +end; + +-- Symlinks are represented by a subclass of content_item (content_link) + +-- Each symlink thus has a row in the acs_objects table. Each symlink +-- also has a row in the cr_items table. The name column for the symlink +-- is the name that appears in the path to the symlink. + +begin; + + select acs_object_type__create_type ( + 'content_symlink', + 'Content Symlink', + 'Content Symlinks', + 'content_item', + 'cr_symlinks', + 'symlink_id', + null, + 'f', + null, + name_method => 'acs_object.default_name' + ); + + select acs_attribute__create_attribute ( + 'content_symlink', + 'target_id', + 'integer', + 'Target ID', + 'Target IDs', + null, + null, + null, + 1, + 1, + null, + 'type_specific', + 'f' + ); + +end; + +-- Extlinks are links to external content (offsite URL's) + +begin; + + select acs_object_type__create_type ( + 'content_extlink', + 'External Link', + 'External Links', + 'content_item', + 'cr_extlinks', + 'extlink_id', + null, + 'f', + null, + name_method => 'acs_object.default_name' + ); + + select acs_attribute__create_attribute ( + 'content_extlink', + 'url', + 'text', + 'URL', + 'URLs', + null, + null, + null, + 1, + 1, + null, + 'type_specific', + 'f' + ); + + select acs_attribute__create_attribute ( + 'content_extlink', + 'label', + 'text', + 'Label', + 'Labels', + null, + null, + null, + 1, + 1, + null, + 'type_specific', + 'f' + ); + + select acs_attribute__create_attribute ( + 'content_extlink', + 'description', + 'text', + 'Description', + 'Descriptions', + null, + null, + null, + 1, + 1, + null, + 'type_specific', + 'f' + ); + +end; + +-- Define content templates. + +begin; + + select acs_object_type__create_type ( + 'content_template', + 'Content Template', + 'Content Templates', + 'content_item', + 'cr_templates', + 'template_id', + null, + 'f', + null, + 'acs_object.default_name' + ); + +end; + +-- Define content revisions, children of content items + +begin; + + select content_type__create_type ( + 'content_revision', + 'acs_object', + 'Basic Item', + 'Basic Items', + 'cr_revisions', + 'revision_id' + null + ); + + select content_type__create_attribute ( + 'content_revision', + 'title', + 'text', + 'Title', + 'Titles', + 1, + null, + 'text' + ); + + select content_type__create_attribute ( + 'content_revision', + 'description', + 'text', + 'Description', + 'Descriptions', + 2, + null, + 'text' + ); + + select content_type__create_attribute ( + 'content_revision', + 'publish_date', + 'date', + 'Publish Date', + 'Publish Dates', + 3, + null, + 'text' + ); + + select content_type__create_attribute ( + 'content_revision', + 'mime_type', + 'text', + 'Mime Type', + 'Mime Types', + 4, + null, + 'text' + ); + + select content_type__create_attribute ( + 'content_revision', + 'nls_language', + 'text', + 'Language', + 'Language', + null, + 'text' + ); + +end; + +-- Declare standard relationships with children and other items + +begin; + + select acs_object_type__create_type ( + 'cr_item_child_rel', + 'Child Item', + 'Child Items', + 'acs_object', + 'cr_child_rels', + 'rel_id', + null, + 'f', + null, + 'acs_object.default_name' + ); + + select acs_attribute__create_attribute ( + 'cr_item_child_rel', + 'parent_id', + 'text', + 'Parent ID', + 'Parent IDs', + null, + null, + null, + 1, + 1, + null, + 'type_specific', + 'f' + ); + + select acs_attribute__create_attribute ( + 'cr_item_child_rel', + 'child_id', + 'text', + 'Child ID', + 'Child IDs', + null, + null, + null, + 1, + 1, + null, + 'type_specific', + 'f' + ); + + select acs_attribute__create_attribute ( + 'cr_item_child_rel', + 'relation_tag', + 'text', + 'Relationship Tag', + 'Relationship Tags', + null, + null, + null, + 1, + 1, + null, + 'type_specific', + 'f' + ); + + select acs_attribute__create_attribute ( + 'cr_item_child_rel', + 'order_n', + 'text', + 'Sort Order', + 'Sort Orders', + null, + null, + null, + 1, + 1, + null, + 'type_specific', + 'f' + ); + + select acs_object_type__create_type ( + 'cr_item_rel', + 'Item Relationship', + 'Item Relationships', + 'acs_object', + 'cr_item_rels', + 'rel_id', + null, + 'f', + null, + 'acs_object.default_name' + ); + + select acs_attribute__create_attribute ( + 'cr_item_rel', + 'item_id', + 'text', + 'Item ID', + 'Item IDs', + null, + null, + null, + 1, + 1, + null, + 'type_specific', + 'f' + ); + + select acs_attribute__create_attribute ( + 'cr_item_rel', + 'related_object_id', + 'text', + 'Related Object ID', + 'Related Object IDs', + null, + null, + null, + 1, + 1, + null, + 'type_specific', + 'f' + ); + + select acs_attribute__create_attribute ( + 'cr_item_rel', + 'relation_tag', + 'text', + 'Relationship Tag', + 'Relationship Tags', + null, + null, + null, + 1, + 1, + null, + 'type_specific', + 'f' + ); + + select acs_attribute__create_attribute ( + 'cr_item_rel', + 'order_n', + 'text', + 'Sort Order', + 'Sort Orders', + null, + null, + null, + 1, + 1, + null, + 'type_specific', + 'f' + ); + +end; + +-- Refresh the attribute views + +-- prompt *** Refreshing content type attribute views... + +create function inline_0 () returns integer as ' +declare + type_rec record; +begin + + for type_rec in select object_type from acs_object_types + connect by supertype = prior object_type + start with object_type = ''content_revision'' + LOOP + PERFORM content_type__refresh_view(type_rec.object_type); + end LOOP; + + return null; +end;' language 'plpgsql'; + +select inline_0(); + +drop function inline_0(); Index: openacs-4/packages/acs-content-repository/sql/postgresql/types-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/types-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-content-repository/sql/postgresql/types-drop.sql 27 Mar 2001 02:02:31 -0000 1.1 @@ -0,0 +1,161 @@ +-- Drop script for clearing content-repositry object type declarations + +-- Copyright (C) 20000 ArsDigita Corporation + +-- $ID$ + +-- This is free software distributed under the terms of the GNU Public +-- License. Full text of the license is available from the GNU Project: +-- http://www.fsf.org/copyleft/gpl.html + +-- just working backwards from types declared in types-create.sql + + +-- removing the standard relationship types +begin; + +select acs_attribute__drop_attribute ( + 'cr_item_rel', + 'order_n'); + + +select acs_attribute__drop_attribute ( + 'cr_item_rel', + 'relation_tag'); + + +select acs_attribute__drop_attribute ( + 'cr_item_rl', + 'related_object_id'); + +select acs_attribute__drop_attribute ( + 'cr_item_rl', + 'item_id'); + +select acs_object_type__drop_type ( + 'cr_item_rel', 'f'); + + +-- cr_item_child_rel type +select acs_attribute__drop_attribute ( + 'cr_item_child_rel', + 'order_n'); + +select acs_attribute__drop_attribute ( + 'cr_item_child_rel', + 'relation_tag'); + +select acs_attribute__drop_attribute ( + 'cr_item_child_rel', + 'child_id'); + +select acs_attribute__drop_attribute ( + 'cr_item_child_rel', + 'parent_id'); + +select acs_object_type__drop_type ( + 'cr_item_child_rel', 'f'); + +end; + + +-- drop content revisions, +begin; + + select content_type__drop_type('content_revision',f','f'); + +end; + + +--dropping content templates +begin; + +select acs_object_type__drop_type( + 'content_template','f'); + +end; + +-- extlinks +begin; + + select acs_attribute__drop_attribute ( + 'content_extlink', + 'description'); + + select acs_attribute__drop_attribute ( + 'content_extlink', + attribute_name => 'label'); + + select acs_attribute__drop_attribute ( + 'content_extlink', + attribute_name => 'url'); + + select acs_object_type__drop_type( + 'content_extlink','f'); + +end; + +-- symlinks +begin; + + select acs_attribute__drop_attribute ( + 'content_symlink', + 'target_id'); + + select acs_object_type__drop_type ( + 'content_symlink'); + +end; + +--content keywords +begin; + + select acs_attribute__drop_attribute ( + 'content_keyword', + attribute_name => 'description'); + + select acs_attribute__drop_attribute ( + 'content_keyword', + attribute_name => 'heading'); + + select acs_object_type__drop_type ( + 'content_keyword','f'); + +end; + +begin; + + select acs_attribute__drop_attribute ( + 'content_folder', + 'description'); + + select acs_attribute__drop_attribute ( + 'content_folder', + 'label'); + + select acs_object_type__drop_type ( + 'content_folder','f'); + +end; + +begin; + +select acs_attribute__drop_attribute ( + 'content_item', + 'live_revision'); + +select acs_attribute__drop_attribute ( + 'content_item', + 'locale'); + +select acs_attribute__drop_attribute ( + 'content_item', + 'name'); + +select acs_object_type__drop_type ( + 'content_item','f'); + +end; + + +