Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PROCEDURE checkPersonAccessRights(p_vehicle_owner_id IN NUMBER, p_person_id IN NUMBER) IS
- BEGIN
- --PRE
- --POST gives access rights for gui_users having access to p_vehicle_owner_id
- -- "CAW_limited" access if persons does'nt belong to p_vehicle_owner_id
- -- full access otherwise
- INSERT INTO gu_person (gui_user_id, person_id, caw_limited, creation_date)
- SELECT gui_user_id, person_id, DECODE(access_count,0,'Y',NULL), SYSDATE
- FROM
- (
- SELECT gui_users.gui_user_id, p.person_id,
- (SELECT COUNT(*) FROM gu_vehicle_owner WHERE gui_user_id=gui_users.gui_user_id AND vehicle_owner_id=p.vehicle_owner_id) access_count --nb of times a gu has access to the vo of the PERSON
- FROM gui_users, gu_vehicle_owner, person p
- WHERE gui_users.gui_user_id = gu_vehicle_owner.gui_user_id
- AND gui_users.preferences LIKE '%checkinAtWork%'
- AND NVL(gui_users.is_archived,'N')='N'
- AND gu_vehicle_owner.vehicle_owner_id=p_vehicle_owner_id -- gu has access to the vo given as argument
- AND p.person_id=p_person_id
- -- before YKI
- -- and ( (gui_users.user_admin_right in ('SO','FM','VAR'))
- -- or ( (gu_vehicle_owner.vo_vehicle_category_id is null) and (gu_vehicle_owner.vo_person_category_id is null) and (gu_vehicle_owner.vo_group_id is null) )
- -- )
- -- ~before YKI
- --new code start YKI
- AND ((gui_users.user_admin_right IN ('SO','FM','VAR') AND
- ( gu_vehicle_owner.vo_person_category_id = (SELECT p1.vo_person_category_id FROM person p1 WHERE p1.person_id = p_person_id)
- OR gu_vehicle_owner.vo_group_id IN (SELECT vpo.vo_group_id FROM vo_group_person vpo WHERE vpo.person_id = p_person_id ))
- OR ( (gu_vehicle_owner.vo_vehicle_category_id IS NULL) AND (gu_vehicle_owner.vo_person_category_id IS NULL) AND (gu_vehicle_owner.vo_group_id IS NULL))))
- --new code end YKI
- AND NOT EXISTS (SELECT gup.person_id FROM gu_person gup WHERE gup.person_id=p.person_id AND gup.gui_user_id = gui_users.gui_user_id)
- ) ;
- /* old comment.
- select gui_users.gui_user_id, p_person_id, 'Y' from gui_users, gu_vehicle_owner
- where gui_users.gui_user_id = gu_vehicle_owner.gui_user_id
- and gui_users.preferences like '%checkinAtWork%'
- and gu_vehicle_owner.vehicle_owner_id=p_vehicle_owner_id
- and ( (gui_users.user_admin_right in ('SO','FM','VAR'))
- or ( (gu_vehicle_owner.vo_vehicle_category_id is null) and (gu_vehicle_owner.vo_person_category_id is null) and (gu_vehicle_owner.vo_group_id is null) )
- )
- and not exists (select gup.person_id from gu_person gup where gup.person_id=p_person_id and gup.gui_user_id = gui_users.gui_user_id);*/
- EXCEPTION WHEN OTHERS THEN
- NULL;
- END;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement