1: function bboard_user_can_view_topic_p ( v_user_id IN integer, v_topic_id IN integer)
2: return char
3: IS
4: v_read_access varchar(16);
5: v_group_id integer;
6: v_count integer;
7: BEGIN
8: select read_access, group_id into v_read_access, v_group_id
9: from bboard_topics
10: where topic_id = v_topic_id;
11:
12: IF v_read_access = 'any' or v_read_access = 'public' THEN
13: RETURN 't';
14: END IF;
15:
16: -- now, we know that it's in some group, let's make sure this person is in it
17: select count(*) into v_count
18: from user_group_map
19: where user_id = v_user_id
20: and group_id = v_group_id;
21:
22: IF v_count > 0 THEN
23: RETURN 't';
24: END IF;
25:
26: -- if we're up to here, then this person is not allowed to view this page
27: RETURN 'f';
28:
29: END;
|