--
-- The Events Package
--
-- @author Michael Steigman (michael@steigman.net)
-- @version $Id: events-permissions-create.sql,v 1.1 2003/03/09 12:07:30 lars Exp $
--
-- This package was originally written by Bryan Che and Philip Greenspun
--
-- GNU GPL v2
--

--
-- Privileges
--

begin;

 select acs_privilege__create_privilege('events_event_create',null,null);
 select acs_privilege__create_privilege('events_activity_create',null,null);
 select acs_privilege__create_privilege('events_event_write',null,null);
 select acs_privilege__create_privilege('events_activity_write',null,null);
 select acs_privilege__create_privilege('events_event_delete',null,null);
 select acs_privilege__create_privilege('events_activity_delete',null,null);
 select acs_privilege__create_privilege('events_event_read',null,null);
 select acs_privilege__create_privilege('events_activity_read',null,null);


 -- 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('create','events_event_create');
 select acs_privilege__add_child('create','events_activity_create');
 select acs_privilege__add_child('write','events_event_write');
 select acs_privilege__add_child('write','events_activity_write');
 select acs_privilege__add_child('delete','events_event_delete');
 select acs_privilege__add_child('delete','events_activity_delete');
 
 -- 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('read','events_activity_read');
end;




