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

XQLOCK.m

Go to the documentation of this file.
  1. XQLOCK ;SEA/Luke - Find all the keys in the tree; [6/28/02 5:55am]
  1. ;;8.0;KERNEL;**20,157,237**;Jul 10, 1995
  1. ;
  1. ;
  1. ;Input: XQX is the internal number of the parent menu
  1. ; XQUSR is the DUZ of the owner of that menu
  1. ;
  1. EN1 ;Look up menu trees by user. Entry for option ENLOCK1.
  1. S XQEN=0 D INIT,USR G:Y=-1 OUT D BLD G:'XQN OUT D DISP,SHOW,CHUZ1,OUT
  1. Q
  1. ;
  1. EN2 ;Look up keys for a given menu tree. Entry for option ENLOCK2.
  1. S XQEN=1 D INIT,TREE G:Y=-1 OUT D BLD G:'XQN OUT D DISP,SHOW,CHUZ1,OUT
  1. Q
  1. EN3 ;Look up Keys for menu delegation.
  1. S XQEN=2,XQUSR=XQDA,XQDIC=XQX D INIT,BLD G:'XQN OUT D DISP,SHOW,CHUZ1,OUT
  1. Q
  1. ;
  1. INIT ;Get things set up
  1. S XQBOSS=0 S:$D(^XUSEC("XUMGR",DUZ)) XQBOSS=1
  1. Q
  1. USR ;Find the user and the menu in question
  1. Q:XQEN=2
  1. S DIC="^VA(200,",DIC(0)="AEMQZ",DIC("A")="Please enter the user's name: " W ! D ^DIC Q:Y=-1 S XQUSR=+Y Q:XQEN D SHO Q:Y=-1
  1. ;
  1. W !!,"Enter a menu tree by number : " R %:DTIME S:%="" %=U S:(%=0)!('$D(XQMENU(%)))!(%'=+%) %=U
  1. I %=U S Y=-1 Q
  1. S XQX=+XQMENU(%)
  1. Q
  1. ;
  1. TREE ;Get the name of the menu tree in question
  1. S DIC="^DIC(19,",DIC(0)="AEMQZ",DIC("A")="Please enter the parent menu: " D ^DIC Q:Y=-1 S XQX=+Y
  1. Q
  1. ;
  1. BLD ;See if the menu tree has been built if not, do it
  1. S:$D(XQDIC) XQSAV=XQDIC S:XQX'["P" XQX="P"_XQX S XQDIC=XQX
  1. I '$D(^XUTL("XQO",XQDIC)) S XQXUF="" W !!,"==> Working... "
  1. D PM1^XQ8
  1. I $D(XQPSM) S XQSAVE1=XQPSM
  1. S XQPSM="P"_XQDIC
  1. D MERGE^XQ12
  1. I $D(XQSAVE1) S XQPSM=XQSAVE1
  1. ;
  1. FIND ;Order through the child options and find the locks
  1. S XQJ=0,XQN=0
  1. F S XQJ=$O(^XUTL("XQO",XQDIC,"^",XQJ)) Q:XQJ="" I $P(^(XQJ),U,7)]""&($P(^DIC(19,XQJ,0),U,6)]"") S XQNM=$P(^(0),U,1),XQTXT=$P(^(0),U,2),XQK=$P(^(0),U,6) D GOT1
  1. ;
  1. I 'XQN W:'$D(ZTQUEUED) !!,"No keys need to be given to this user for this menu tree." Q ;There are no keys to give, so quit
  1. Q
  1. ;
  1. DISP ;Display the locked options with their keys
  1. W !!,"There ",$S(XQN=1:"is one ",1:"are some "),"locked option",$S(XQN=1:":",1:"s:")
  1. W !!," Option Name",?23,"Option Text",?62,"Locked With",!
  1. F XQI=0:1:XQN-1 W !,$P(^TMP($J,"XQ",XQI),U),?22,$P(^TMP($J,"XQ",XQI),U,2),?60,$P(^TMP($J,"XQ",XQI),U,3) D:XQI&'(XQI#15) PAUSE^XQLOCK1 Q:XQI=-1
  1. Q
  1. ;
  1. SHOW ;Show the current set of keys
  1. W !!,"This is the current set of keys we are working with: ",! S XQJ="",XQI=5 F XQK=0:1 S XQJ=$O(XQKEY(XQJ)) Q:XQJ="" W:'(XQK#XQI) ! W ?(XQK#XQI*15),XQJ
  1. Q
  1. ;
  1. CHUZ1 W !!,"Please enter one of the following codes:",!!?5,"'A' means allocate these keys",!?5,"'D' means delegate this key set"
  1. W !?5,"'E' to edit the set of keys you wish to allocate",!?5,"'^' or 'RETURN' to quit",!?5,"'L' to list the locked options again, or",!?5,"'S' to show the set of keys you are allocating again."
  1. R !!,"Enter A, D, E, ^, L, or S: ",XQUR:DTIME S:XQUR="" XQUR=U Q:XQUR=U
  1. I "AaDdEe^LlSs"'[$E(XQUR,1) W $C(7),"?? " G CHUZ1
  1. I XQUR="A"!(XQUR="a") S XQAL=1 D:'$D(XQUSR) USR D:$D(XQUSR) DOIT K XQUS Q:XQEN=2 G CHUZ1
  1. I XQUR="D"!(XQUR="d") S XQAL=0 D:'$D(XQUSR) USR D:$D(XQUSR) DOIT K XQUSR Q:XQEN=2 G CHUZ1
  1. I XQUR="E"!(XQUR="e") D EDIT^XQLOCK1 Q:XQUR=U G CHUZ1
  1. I XQUR="L"!(XQUR="l") D DISP G CHUZ1
  1. I XQUR="S"!(XQUR="s") D SHOW G CHUZ1
  1. Q
  1. ;
  1. DOIT ;Add the key set to a user's Aloocated or Delegated Keys file
  1. N DA,DIC,X
  1. S XQFL=$S(XQAL:51,1:52),DIC="^VA(200,"_+XQUSR_","_XQFL_",",DIC(0)="NMQ",DIC("P")=$S(XQAL:"200.051PA",1:"200.052P"),DA(1)=XQUSR
  1. S XQNXT="" F S XQNXT=$O(XQKEY(XQNXT)) Q:XQNXT="" S X=XQKEY(XQNXT),DINUM=X I '$D(^VA(200,XQUSR,XQFL,"B",X,X)) D FILE^DICN
  1. K DINUM
  1. S XQZZGOOD=1
  1. Q
  1. ;
  1. OUT ;Clean up and quit
  1. S:$D(XQSAV) XQDIC=XQSAV
  1. K ^TMP($J,"XQ")
  1. K %,DA,DIC,X,XQ,XQAL,XQEN,XQBOSS,XQI,XQIJ,XQJ,XQK,XQKEY,XQKN,XQMENU,XQN,XQNM,XQNXT,XQOP,XQSAV,XQSAVE1,XQTXT,XQUR,XQUSR,XQX,XQZZGOOD,Y
  1. Q
  1. ;
  1. GOT1 ;Record a lock
  1. S XQKN=$O(^DIC(19.1,"B",XQK,0))
  1. I 'XQBOSS Q:'$D(^VA(200,DUZ,52,XQKN)) ;DUZ can't allocate that key
  1. I $D(XQUSR) Q:$D(^VA(200,+XQUSR,51,"B",XQKN)) ;User already owns that key
  1. S:'$D(ZTQUEUED) ^TMP($J,"XQ",XQN)="["_XQNM_"] "_U_XQTXT_U_" <== "_XQK
  1. S XQN=XQN+1
  1. S XQKEY(XQK)=XQKN
  1. Q
  1. ;
  1. SHO ;Show the primary and secondary menus of +XQUSR
  1. S %=+$G(^VA(200,+XQUSR,201)),XQMENU(1)=$S(%<1:"",1:%_U_$P($G(^DIC(19,%,0)),U,1,2))
  1. I XQMENU(1)="" W !!?5,"==> ",$P(XQUSR,U,2)," has no primary menu." S Y=-1 Q
  1. S %=0 F XQI=2:1 S %=$O(^VA(200,+XQUSR,203,%)) Q:%'>0 S XQSM=+^(%,0) I $D(^DIC(19,XQSM,0))#2 S XQMENU(XQI)=XQSM_U_$P(^(0),U,1,2)
  1. I '$D(ZTQUEUED) W ! S XQIJ=0 F S XQIJ=$O(XQMENU(XQIJ)) Q:XQIJ="" W !,XQIJ,". ",$P(XQMENU(XQIJ),U,2),?23,$P(XQMENU(XQIJ),U,3),?62,$S(XQIJ=1:"Primary Menu",1:"Secondary") D:'(XQIJ#22) PAUSE^XQLOCK1
  1. Q
  1. ;
  1. KEY ;Look up a key in the Key file and get its number
  1. S XQ=$O(^DIC(19.1,"B",XQK,0)) I XQ="" W $C(7),!!?5,"==> A key named ",XQK," ??",!
  1. Q