postgresql7.1
select 1 as available_p
from portal_available_template_map
where
portal_id = portal__parent(:default_portal_id) and
template_id = :template_id
select
1 as portal_exists_p,
case when portal__root_p(portal_id) = 't' then 1 else 0 end as portal_root_p,
case when acs_permission__permission_p(portal_id, :user_id, 'write') = 't' then 1 else 0 end as portal_write_p
from portals
where portal_id = :portal_id
select portal__new (
:portal_id,
:template_id,
:name,
:package_id,
0,
0,
null,
null
)
declare
pid integer;
begin
pid := portal__new (:portal_id,
null,
:name,
0,
0,
:user_id,
:default_portal_id,
null);
acs_permission__grant_permission ( pid, :user_id, 'read' );
acs_permission__grant_permission ( pid, :user_id, 'write' );
acs_permission__grant_permission ( pid, :user_id, 'admin' );
end;