Advertisement
psi_mmobile

Untitled

Feb 26th, 2020
772
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PL/SQL 2.79 KB | None | 0 0
  1.   PROCEDURE checkPersonAccessRights(p_vehicle_owner_id IN NUMBER, p_person_id IN NUMBER) IS
  2.   BEGIN  
  3.     --PRE
  4.     --POST    gives access rights for gui_users having access to p_vehicle_owner_id
  5.     --        "CAW_limited" access if persons does'nt belong to p_vehicle_owner_id
  6.     --        full access otherwise
  7.     INSERT INTO gu_person (gui_user_id, person_id, caw_limited, creation_date)
  8.      SELECT gui_user_id, person_id, DECODE(access_count,0,'Y',NULL), SYSDATE
  9.     FROM
  10.     (
  11.       SELECT gui_users.gui_user_id, p.person_id,
  12.       (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
  13.       FROM gui_users, gu_vehicle_owner, person p
  14.       WHERE gui_users.gui_user_id = gu_vehicle_owner.gui_user_id
  15.       AND gui_users.preferences LIKE '%checkinAtWork%'
  16.       AND NVL(gui_users.is_archived,'N')='N'
  17.       AND gu_vehicle_owner.vehicle_owner_id=p_vehicle_owner_id -- gu has access to the vo given as argument
  18.       AND p.person_id=p_person_id
  19.      
  20. -- before YKI    
  21. --          and (  (gui_users.user_admin_right in ('SO','FM','VAR'))
  22. --          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) )
  23. --          )
  24. -- ~before YKI  
  25.  
  26. --new code start YKI
  27.        AND ((gui_users.user_admin_right IN ('SO','FM','VAR')  AND
  28.                 ( gu_vehicle_owner.vo_person_category_id = (SELECT p1.vo_person_category_id FROM person p1 WHERE p1.person_id = p_person_id)
  29.                     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 ))
  30.         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))))
  31.  --new code end YKI            
  32.  
  33.        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)
  34.     ) ;      
  35.    
  36.     /* old comment.  
  37.     select gui_users.gui_user_id, p_person_id, 'Y' from gui_users, gu_vehicle_owner
  38.     where gui_users.gui_user_id = gu_vehicle_owner.gui_user_id
  39.     and gui_users.preferences like '%checkinAtWork%'
  40.     and gu_vehicle_owner.vehicle_owner_id=p_vehicle_owner_id
  41.     and (  (gui_users.user_admin_right in ('SO','FM','VAR'))
  42.         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) )
  43.         )
  44.     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);*/
  45.   EXCEPTION WHEN OTHERS THEN
  46.     NULL;
  47.   END;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement