| |
1 |
1 |
|
| |
|
2 |
|
| |
|
3 |
|
| |
|
4 |
|
| |
|
5 |
|
| |
|
6 |
|
| |
|
7 |
|
| |
|
8 |
|
| |
|
9 |
|
| |
|
10 |
|
| |
|
11 |
|
| |
|
12 |
|
| |
|
13 |
|
| |
|
14 |
|
| |
|
15 |
|
| |
|
16 |
|
| |
|
17 |
|
| |
|
18 |
|
| |
|
19 |
|
| |
|
20 |
begin; |
| |
|
21 |
|
| |
|
22 |
select acs_privilege__create_privilege('postcard_create_image',null,null); |
| |
|
23 |
select acs_privilege__create_privilege('postcard_create_card',null,null); |
| |
|
24 |
select acs_privilege__create_privilege('postcard_read',null,null); |
| |
|
25 |
select acs_privilege__create_privilege('postcard_admin',null,null); |
| |
|
26 |
|
| |
|
27 |
|
| |
|
28 |
|
| |
|
29 |
|
| |
|
30 |
|
| |
|
31 |
|
| |
|
32 |
|
| |
|
33 |
drop trigger acs_priv_hier_ins_del_tr on acs_privilege_hierarchy; |
| |
|
34 |
|
| |
|
35 |
select acs_privilege__add_child('create', 'postcard_create_image'); |
| |
|
36 |
select acs_privilege__add_child('create', 'postcard_create_card'); |
| |
|
37 |
select acs_privilege__add_child('read', 'postcard_read'); |
| |
|
38 |
|
| |
|
39 |
|
| |
|
40 |
|
| |
|
41 |
|
| |
|
42 |
create trigger acs_priv_hier_ins_del_tr after insert or delete |
| |
|
43 |
on acs_privilege_hierarchy for each row |
| |
|
44 |
execute procedure acs_priv_hier_ins_del_tr (); |
| |
|
45 |
|
| |
|
46 |
select acs_privilege__add_child('admin','postcard_admin'); |
| |
|
47 |
end; |
| |
|
48 |
|
| |
|
49 |
|
| |
|
50 |
|
| |
|
51 |
|
| |
|
52 |
|
| |
|
53 |
|
| |
|
54 |
|
| |
|
55 |
|
| |
|
56 |
|
| |
|
57 |
|
| |
|
58 |
|
| |
|
59 |
|
| |
|
60 |
|
| |
|
61 |
|
| |
|
62 |
|
| |
|
63 |
create function inline_0 () |
| |
|
64 |
returns integer as ' |
| |
|
65 |
declare |
| |
|
66 |
default_context integer; |
| |
|
67 |
registered_users integer; |
| |
|
68 |
the_public integer; |
| |
|
69 |
begin |
| |
|
70 |
|
| |
|
71 |
default_context := acs__magic_object_id(''default_context''); |
| |
|
72 |
registered_users := acs__magic_object_id(''registered_users''); |
| |
|
73 |
the_public := acs__magic_object_id(''the_public''); |
| |
|
74 |
|
| |
|
75 |
|
| |
|
76 |
|
| |
|
77 |
perform acs_permission__grant_permission ( |
| |
|
78 |
default_context, |
| |
|
79 |
registered_users, |
| |
|
80 |
''postcard_create_card'' |
| |
|
81 |
); |
| |
|
82 |
|
| |
|
83 |
perform acs_permission__grant_permission ( |
| |
|
84 |
default_context, |
| |
|
85 |
registered_users, |
| |
|
86 |
''postcard_create_image'' |
| |
|
87 |
); |
| |
|
88 |
|
| |
|
89 |
|
| |
|
90 |
|
| |
|
91 |
perform acs_permission__grant_permission ( |
| |
|
92 |
default_context, |
| |
|
93 |
the_public, |
| |
|
94 |
''postcard_read'' |
| |
|
95 |
); |
| |
|
96 |
|
| |
|
97 |
return 0; |
| |
|
98 |
end; |
| |
|
99 |
' language 'plpgsql'; |
| |
|
100 |
|
| |
|
101 |
select inline_0 (); |
| |
|
102 |
drop function inline_0 (); |
| |
|
103 |
|
| |
|
104 |
|
| |
|
105 |
|
| |
|
106 |
|
| |
|
107 |
|
| |
|
108 |
|
| |
|
109 |
|
| |
|
110 |
|
| |
|
111 |
|
| |
2 |
112 |
create sequence postcard_seq; |
| |
|
113 |
create view postcard_sequence as |
| |
|
114 |
select nextval('postcard_seq'); |
| |
|
115 |
|
| |
3 |
116 |
create sequence postcard_image_seq; |
| |
|
117 |
create view postcard_image_sequence as |
| |
|
118 |
select nextval('postcard_image_seq'); |
| |
4 |
119 |
|
| |
5 |
120 |
create table postcard_images ( |
| |
6 |
121 |
card_image_id integer primary key, |
| |
7 |
|
image oid not null, |
| |
|
122 |
lob integer references lobs, |
| |
8 |
123 |
mime_type varchar(100), |
| |
9 |
124 |
title varchar(1000), |
| |
10 |
125 |
description varchar(4000) |
| |
11 |
126 |
); |
| |
12 |
127 |
|
| |
|
128 |
|
| |
|
129 |
create trigger postcard_images_lob_trigger before delete or update or insert |
| |
|
130 |
on postcard_images for each row execute procedure on_lob_ref(); |
| |
|
131 |
|
| |
13 |
132 |
create table postcards ( |
| |
14 |
133 |
card_id integer primary key, |
| |
15 |
|
card_picture references postcard_images, |
| |
|
134 |
card_picture integer references postcard_images, |
| |
16 |
135 |
recipient varchar(1000), |
| |
17 |
136 |
sender varchar(1000), |
| |
18 |
137 |
message varchar(4000), |
| |
19 |
138 |
pickup_code varchar(1000), |
| |
20 |
139 |
picked_up date |
| |
21 |
140 |
); |
| |
22 |
141 |
|
| |
23 |
142 |
|
| |
|
143 |
|
| |
|
144 |
|
| |
|
145 |
|