1 PACKAGE BODY BIS_FN_SECURITY AS
2 /* $Header: BISLNKSB.pls 115.1 99/07/17 16:08:27 porting ship $ */
3
4 --------------------------------------
5 FUNCTION isAccessible
6 (
7 p_function_id in number
8 ,p_responsibility_id in number
9 )
10 RETURN VARCHAR2
11 IS
12
13 CURSOR CM (x_menu_id in number) IS
14 SELECT me.function_id, me.sub_menu_id
15 FROM (SELECT m.menu_id, m.function_id, m.sub_menu_id,
16 decode(m.function_id, NULL, 'M', 'F') entry_type
17 FROM fnd_menu_entries m
18 WHERE m.menu_id = x_menu_id) me,
19 fnd_resp_functions ex
20 WHERE ex.responsibility_id (+) = p_responsibility_id
21 AND ex.rule_type(+) = me.entry_type
22 AND ex.action_id(+) <> decode(me.entry_type, 'F', me.function_id,
23 'M', me.sub_menu_id, null);
24
25 CURSOR CR IS
26 SELECT menu_id
27 FROM fnd_responsibility
28 WHERE responsibility_id = p_responsibility_id
29 AND start_date <= sysdate
30 AND (nvl(end_date, sysdate) >= sysdate);
31
32
33 TYPE t_Menu_Tbl_Type IS TABLE OF fnd_responsibility.menu_id%TYPE
34 INDEX BY BINARY_INTEGER;
35
36 l_menu_tbl t_Menu_Tbl_Type;
37 l_add_index BINARY_INTEGER:= 0;
38 l_read_index BINARY_INTEGER;
39 l_menu_id NUMBER;
40
41
42 BEGIN
43
44 -- get the menu assigned to the responsibility and find if the
45 -- function is an entry on the menu or any of the submenus
46 -- note:submenus could be nested to any number of levels
47 -----------------------------------------------------------
48 OPEN CR;
49 Fetch CR into l_menu_tbl(l_add_index);
50 CLOSE CR;
51
52 If (l_menu_tbl.COUNT = 0) then
53 return 'FALSE';
54 End If;
55
56 -- loop logic:
57 -- store the menus to be processed in the l_menu_tbl
58 -- for each menu, fetch the menu entries and compare the
59 -- function id. if the menu entry is a submenu, add it to
60 -- list of menus to be procesed.
61 -- optimization based on of repeating sub menus on submenus
62 -- is not considered.
63 ------------------------------------------------------------
64 l_read_index := l_menu_tbl.FIRST;
65 l_menu_id := l_menu_tbl(l_read_index);
66 Loop
67
68 For c_rec in CM(l_menu_id) Loop
69 If (c_rec.sub_menu_id IS NOT NULL) Then
70 l_add_index := l_add_index + 1;
71 l_menu_tbl(l_add_index) := c_rec.sub_menu_id;
72 Else
73 If (c_rec.function_id = p_function_id) then
74 return 'TRUE';
75 Exit;
76 End If;
77 End If;
78 End Loop;
79
80 EXIT WHEN l_read_index = l_menu_tbl.LAST;
81 l_read_index := l_menu_tbl.NEXT(l_read_index);
82 l_menu_id := l_menu_tbl(l_read_index);
83 End Loop;
84
85 Return 'FALSE';
86
87 END isAccessible;
88 ---------------------
89
90 END BIS_FN_SECURITY;