Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: USRLA

USRLA.m

Go to the documentation of this file.
  1. USRLA ; SLC/JER,MA - Authorization Library functions ;6/29/01 11:19
  1. ;;1.0;AUTHORIZATION/SUBSCRIPTION;**15,20,29**;Jun 20, 1997;Build 7
  1. CANDO(DOCTYPE,STATUS,EVENT,USER,USRROLE) ; Evaluate Authorization
  1. ; 18 JUNE 2001 MA added a change to check for "OR" logic
  1. ; when checking roles.
  1. ; Receives: DOCTYPE = Pointer to TIU DOCMT DEF FILE (8925.1)
  1. ; STATUS = Pointer to TIU STATUS FILE (8925.6)
  1. ; EVENT = Pointer to USR EVENT FILE (8930.8)
  1. ; USER = Pointer to NEW PERSON FILE (200)
  1. ; [USRROLE] = Pointer to USER ROLE FILE (8930.2)
  1. ; Role, if received, is a particular role
  1. ; already known to belong to USER for docmt
  1. ; being checked. See CANDO^TIULP.
  1. ; DBIA 2321 ^TIU(8925.1)
  1. N USRC,USRCY,USRRY,USRR,USRY,USRFALSE
  1. ; First, loop thru Class xref "AC" to determine whether USER
  1. ; is a member of any subclasses which are authorized to perform
  1. ; EVENT on DOCTYPE with STATUS.
  1. ;
  1. ; Class Section
  1. ;
  1. S (USRC,USRY,USRFALSE)=0
  1. F S USRC=$O(^USR(8930.1,"AC",DOCTYPE,STATUS,EVENT,USRC)) Q:+USRC'>0!(+$G(USRCY)>0&(USRY>0)) D
  1. . N USRADA,USRAND S USRADA=0
  1. . F S USRADA=+$O(^USR(8930.1,"AC",DOCTYPE,STATUS,EVENT,USRC,USRADA)) Q:+USRADA'>0!(+$G(USRY)>0) D
  1. . . S USRCY=+$$ISA^USRLM(USER,USRC)
  1. . . ; If user is NOT a member of the class for which a rule has been
  1. . . ; defined, set USRFALSE to indicate evaluation of a rule that
  1. . . ; was NOT satisfied.
  1. . . I +USRCY'>0 S USRFALSE=1
  1. . . ; If a match is obtained on user class, check to see whether
  1. . . ; additional conditions on user role exist.
  1. . . I +USRCY>0 D
  1. . . . S USRFALSE=0
  1. . . . I $P($G(^USR(8930.1,USRADA,0)),U,5)="&",($G(USRROLE)=$P($G(^(0)),U,6)) S USRY=1
  1. . . . I $P($G(^USR(8930.1,USRADA,0)),U,5)'="&" S USRY=1
  1. ; In the event that authorization is granted to users with a
  1. ; particular role with respect to the document, without concern
  1. ; for class membership, check the Role xref "AR".
  1. ;
  1. ; Role Section.
  1. ;
  1. I +USRY'>0,+$G(USRROLE) D
  1. . S USRR=0
  1. . F S USRR=$O(^USR(8930.1,"AR",DOCTYPE,STATUS,EVENT,USRROLE,USRR)) Q:+USRR'>0!(USRY>0) D
  1. . . ; Check for "&" condition
  1. . . I $P($G(^USR(8930.1,+USRR,0)),U,5)="&",+$P($G(^(0)),U,4) D
  1. . . . I +$$ISA^USRLM(+$G(USER),+$P($G(^USR(8930.1,+USRR,0)),U,4)) S USRY=1 ; **15** Changed DUZ to USER.
  1. . . ; Check for only a role needed
  1. . . I '+USRY,'+$P($G(^USR(8930.1,+USRR,0)),U,4) S USRY=1
  1. . . ; Check for an "OR" condition
  1. . . ;I '+USRY,$P($G(^USR(8930.1,+USRR,0)),U,5)="!" D
  1. . . I '+USRY,$P($G(^USR(8930.1,+USRR,0)),U,5)'="&" D
  1. . . . N USRCLS
  1. . . . S USRCLS=+$P($G(^USR(8930.1,+USRR,0)),U,4)
  1. . . . I +$$ISA^USRLM(+$G(USER),+USRCLS)!USRROLE=+$P($G(^USR(8930.1,+USRR,0)),U,6) S USRY=1
  1. ;
  1. I +USRY'>0,+$G(USRROLE)'>0,$D(^USR(8930.1,"AR",DOCTYPE,STATUS,EVENT)) S USRFALSE=1
  1. ;
  1. ; To allow heritability of authorization, if the user is not
  1. ; authorized to perform the specified action on the specific
  1. ; document in its current state, AND if no explicit rule for
  1. ; the current document definition failed (i.e., USRFALSE'>0),
  1. ; then traverse up the document class hierarchy and evaluate
  1. ; whether authorization is granted at a higher level.
  1. I +USRY'>0,(+$G(USRFALSE)'>0) D
  1. . N USRTYP S USRTYP=0
  1. . F S USRTYP=$O(^TIU(8925.1,"AD",DOCTYPE,USRTYP)) Q:+USRTYP'>0!(+USRY>0) D
  1. . . S USRY=$$CANDO(USRTYP,STATUS,EVENT,USER,$G(USRROLE))
  1. Q USRY