Index: openacs-4/packages/acs-kernel/sql/postgresql/acs-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/acs-create.sql,v diff -u -r1.8 -r1.9 --- openacs-4/packages/acs-kernel/sql/postgresql/acs-create.sql 16 Jan 2003 13:34:10 -0000 1.8 +++ openacs-4/packages/acs-kernel/sql/postgresql/acs-create.sql 14 Feb 2003 02:47:13 -0000 1.9 @@ -20,46 +20,6 @@ objects like the site-wide organization, and the all users party. '; --- create or replace package acs --- as --- --- function add_user ( --- user_id in users.user_id%TYPE default null, --- object_type in acs_objects.object_type%TYPE --- default 'user', --- creation_date in acs_objects.creation_date%TYPE --- default sysdate, --- creation_user in acs_objects.creation_user%TYPE --- default null, --- creation_ip in acs_objects.creation_ip%TYPE default null, --- email in parties.email%TYPE, --- url in parties.url%TYPE default null, --- first_names in persons.first_names%TYPE, --- last_name in persons.last_name%TYPE, --- password in users.password%TYPE, --- salt in users.salt%TYPE, --- password_question in users.password_question%TYPE default null, --- password_answer in users.password_answer%TYPE default null, --- screen_name in users.screen_name%TYPE default null, --- email_verified_p in users.email_verified_p%TYPE default 't', --- member_state in membership_rels.member_state%TYPE default 'approved' --- ) --- return users.user_id%TYPE; --- --- procedure remove_user ( --- user_id in users.user_id%TYPE --- ); --- --- function magic_object_id ( --- name in acs_magic_objects.name%TYPE --- ) return acs_objects.object_id%TYPE; --- --- end acs; - --- show errors - --- create or replace package body acs --- function add_user create function acs__add_user (integer,varchar,timestamp with time zone,integer,varchar,varchar,varchar,varchar,varchar,char,char,varchar,varchar,varchar,boolean,varchar) returns integer as ' declare @@ -113,8 +73,6 @@ end;' language 'plpgsql'; - --- procedure remove_user create function acs__remove_user (integer) returns integer as ' declare @@ -126,8 +84,6 @@ return 0; end;' language 'plpgsql'; - --- function magic_object_id create function acs__magic_object_id (varchar) returns integer as ' declare @@ -143,10 +99,6 @@ end;' language 'plpgsql' with(isstrict,iscachable); - - --- show errors - -- ****************************************************************** -- * Community Core API -- ****************************************************************** @@ -189,7 +141,7 @@ begin root_id := acs_object__new ( - 0, + -4, ''acs_object'', now(), null, @@ -200,7 +152,7 @@ insert into acs_magic_objects (name, object_id) values - (''security_context_root'', 0); + (''security_context_root'', -4); return root_id; @@ -230,64 +182,92 @@ -- Administrators can read, write, create, and delete. -- --------------------------------------------------------- - -- temporarily drop this trigger to avoid a data-change violation - -- on acs_privilege_hierarchy_index while updating the child privileges. - - drop trigger acs_priv_hier_ins_del_tr on acs_privilege_hierarchy; - select acs_privilege__add_child('admin', 'read'); select acs_privilege__add_child('admin', 'write'); select acs_privilege__add_child('admin', 'create'); - - -- re-enable the trigger before the last insert to force the - -- acs_privilege_hierarchy_index table to be updated. - - create trigger acs_priv_hier_ins_del_tr after insert or delete - on acs_privilege_hierarchy for each row - execute procedure acs_priv_hier_ins_del_tr (); - select acs_privilege__add_child('admin', 'delete'); end; +-- Now create our special groups and users. We can not create the +-- relationships between these entities yet. This is done in acs-install.sql --- show errors - create function inline_2 () returns integer as ' declare v_object_id integer; begin - insert into acs_objects - (object_id, object_type) - values - (-1, ''party''); + -- Make an "Unregistered Visitor" as object 0, which corresponds + -- with the user_id assigned throughout the toolkit Tcl code - insert into parties - (party_id) - values - (-1); + insert into acs_objects + (object_id, object_type) + values + (0, ''person''); - insert into acs_magic_objects - (name, object_id) - values - (''the_public'', -1); + insert into parties + (party_id) + values + (0); + insert into persons + (person_id, first_names, last_name) + values + (0, ''Unregistered'', ''Visitor''); + + insert into acs_magic_objects + (name, object_id) + values + (''unregistered_visitor'', 0); + + v_object_id := acs_group__new ( + -1, + ''group'', + now(), + null, + null, + null, + null, + ''The Public'', + null, + null + ); + + insert into acs_magic_objects + (name, object_id) + values + (''the_public'', -1); + + -- Add our only user, the Unregistered Visitor, to The Public + -- group. + + perform membership_rel__new ( + null, + ''membership_rel'', + acs__magic_object_id(''the_public''), + acs__magic_object_id(''unregistered_visitor''), + ''approved'', + null, + null); + return 0; + end;' language 'plpgsql'; select inline_2 (); drop function inline_2 (); - create function inline_3 () returns integer as ' declare group_id integer; begin + -- We will create the registered users group with type group for the moment + -- because the application_group package has not yet been created. + group_id := acs_group__new ( -2, ''group'', @@ -301,19 +281,29 @@ null ); - insert into acs_magic_objects - (name, object_id) - values - (''registered_users'', -2); + insert into acs_magic_objects + (name, object_id) + values + (''registered_users'', -2); + -- Now declare "The Public" to be composed of itself and the "Registered + -- Users" group + + perform composition_rel__new ( + null, + ''composition_rel'', + acs__magic_object_id(''the_public''), + acs__magic_object_id(''registered_users''), + null, + null); + return 0; end;' language 'plpgsql'; select inline_3 (); drop function inline_3 (); - select acs_object__new ( -3, 'acs_object', @@ -323,10 +313,7 @@ null ); - insert into acs_magic_objects +insert into acs_magic_objects (name, object_id) - values +values ('default_context', -3); - - --- show errors