XQSMD ; SEA/MJM - Secure MenuMan Delegation ;7/3/91 08:39 ;6/4/92 12:53 PM [ 04/02/2003 8:29 AM ]
;;8.0;KERNEL;**1002,1003,1004,1005,1007**;APR 1, 2003
;;8.0;KERNEL;;Jul 10, 1995
EN1 S XQDOP=0 G INIT ;Entry point for adding options
EN2 S XQDOP=1 ;Entry point for removing options from users
INIT ;
S U="^" K ^TMP($J) S ^TMP($J)="XQSMD" S (XQUF,XQT,XQPRO,XQDEL,XQHOLD(0))=0
D ^XQDATE S XQDATE=%Y
I $S('$D(IOM):1,IOM=0:1,'$D(IOSL):1,'$L(IOSL):1,'$D(IOF):1,1:0) S IOP="HOME" D ^%ZIS I POP W !!,"*** DEVICE ERROR ***",!,"-delegation software exiting-" G OUT
I '$D(DTIME) S DTIME=$$DTIME^XUP(DUZ,IOS)
;
MGR ;Find out who's delegating here.
S XQDUZ=^XUTL("XQ",$J,"DUZ") I DUZ'=+XQDUZ G H^XUS
S XQMGR=$P(^VA(200,DUZ,0),U,1)
I DUZ(0)="@"!($D(^XUSEC("XUMGR",DUZ))) S XQPRO=1,XQLEV=0
S XQON0="" S:$D(^VA(200,DUZ,19))#2 XQON0=^(19) I 'XQPRO,('$L(XQON0)) W !,"You have not been given the authority to delegate options. See your Site Manager." G OUT
I 'XQPRO S XQLEV=0 S:$L(XQON0) XQLEV=$P(XQON0,U,3) S:'$L(XQLEV)!(XQLEV<1) XQLEV=1
;
USER ;Get the duz of the user being delegated to.
K ^TMP($J,"OP"),^("ZN"),XQHOLD,XQLK,XQKEY S (XQK,XQT,XQHOLD(0),XQKEY(0))=0
W !!,"Enter the name(s) of your delegate(s), one at a time"
NAME S XQUF=1 W !!," Name: " R XQ:DTIME S:'$T XQ=U G:XQ="" DONE G:XQ=U OUT I XQ="?" W !!,"Enter a name, a name preceded by a minus, a '^' to quit, or '??' for help." G NAME
I XQ["??" S XQH="XQSMD-USER" D:XQ="??" EN^XQH D:XQ="???" LIST D:XQ="????" LSTFIL S XQH="XQSMD-MAIN" D:XQ="?????" EN^XQH G NAME
I $E(XQ,1)="-" S XQDEL=1,XQ=$E(XQ,2,99)
S X=XQ,DIC=200,DIC(0)="MEZ" D ^DIC I Y<0 W !!," ** No such person in the User File **" G NAME
I +Y=+DUZ W !,"It is illogical to delegate to oneself." G NAME
I '$D(^VA(200,+Y,.1)) W !,"Sorry, this person has no verify code node in the user file." G NAME
I '$L($P(^VA(200,+Y,.1),U,2)) W !,"Sorry, this person is not an active user." G NAME
I XQDEL S XQDEL=0 K XQHOLD(+Y) G NAME
I 'XQPRO S XQLVL=9999 S:$D(^VA(200,+Y,19))#2 XQLVL=$P(^(19),U,3) I XQLVL'?1N.N!(+XQLVL<+XQLEV) W !,"Delegation level error. You can not modify the options of ",$P(Y,U,2) G NAME
S XQNAM=$P(Y,U,2),XQHOLD(+Y)=XQNAM,XQT=XQT+1 G NAME
DONE S (XQN,XQUF)=0 I $O(XQHOLD(XQN))="" W !!,"Enter a delegate's name or '^' to quit." G NAME
;
G ^XQSMD1
Q
LSTFIL ;Show USER, OPTION, or user's delegated options in ^VA(200,DUZ,19.5)
D LIST S X="?",DIC=$S(XQUF:200,XQPRO:19,1:"^VA(200,DUZ,19.5,"),DIC(0)="Q" D ^DIC K DIC
Q
;
LIST ;List users and options selected so far.
W @IOF S (XQT,XQM)=0,XQM=$O(XQHOLD(XQM)) I XQM="" W !!," No users selected yet." Q
W !!,"For the following user(s):",!
F XQI=1:1 W:'(XQT#2) ! W ?(XQT#2*35),XQI,". ",XQHOLD(XQM) S XQT=XQT+1,XQM=$O(XQHOLD(XQM)) Q:XQM=""
W !!,"You will ",$S(XQDOP:"remove ",1:"delegate "),"the following options: ",!
S XQT=0,XQN="",XQN=$O(^TMP($J,"ZN",XQN)) I XQN="" W !!,"No menu options selected yet" Q
F XQI=0:0 D:$Y+3>IOSL WAIT Q:XQ=U W !,XQN," ",$P(^TMP($J,"ZN",XQN),U,1) S XQN=$O(^(XQN)) Q:XQN=""
W !!,$S(XQDOP:" Removed ",1:" Delegated "),"by ",XQMGR," on ",XQDATE,".",!
Q
WAIT ;Skip to the head of the next page
I 1 R:IOST["C-" !!,"Press RETURN to continue,'^' to quit...",XQ:DTIME S:'$T&(IOST["C-") XQ=U W @IOF
Q
;
OUT K DIC,DIC(0),POP,XQ,XQAL,XQH,XQI,XQJ,XQK,XQL,XQM,XQN,XQT,XQD,XQDATE,XQDEL,XQDUZ,XQDT,XQLEV,XQLVL,XQLK,XQMG,XQMGR,XQNM,XQNAM,XQUF,XQPRO,XQSTART,XQEND,XQHOLD,XQKEY,XQON,XQON0,X,Y,XY,%,^TMP($J)
Q
XQSMD ; SEA/MJM - Secure MenuMan Delegation ;7/3/91 08:39 ;6/4/92 12:53 PM [ 04/02/2003 8:29 AM ]
+1 ;;8.0;KERNEL;**1002,1003,1004,1005,1007**;APR 1, 2003
+2 ;;8.0;KERNEL;;Jul 10, 1995
EN1 ;Entry point for adding options
SET XQDOP=0
GOTO INIT
EN2 ;Entry point for removing options from users
SET XQDOP=1
INIT ;
+1 SET U="^"
KILL ^TMP($JOB)
SET ^TMP($JOB)="XQSMD"
SET (XQUF,XQT,XQPRO,XQDEL,XQHOLD(0))=0
+2 DO ^XQDATE
SET XQDATE=%Y
+3 IF $SELECT('$DATA(IOM):1,IOM=0:1,'$DATA(IOSL):1,'$LENGTH(IOSL):1,'$DATA(IOF):1,1:0)
SET IOP="HOME"
DO ^%ZIS
IF POP
WRITE !!,"*** DEVICE ERROR ***",!,"-delegation software exiting-"
GOTO OUT
+4 IF '$DATA(DTIME)
SET DTIME=$$DTIME^XUP(DUZ,IOS)
+5 ;
MGR ;Find out who's delegating here.
+1 SET XQDUZ=^XUTL("XQ",$JOB,"DUZ")
IF DUZ'=+XQDUZ
GOTO H^XUS
+2 SET XQMGR=$PIECE(^VA(200,DUZ,0),U,1)
+3 IF DUZ(0)="@"!($DATA(^XUSEC("XUMGR",DUZ)))
SET XQPRO=1
SET XQLEV=0
+4 SET XQON0=""
IF $DATA(^VA(200,DUZ,19))#2
SET XQON0=^(19)
IF 'XQPRO
IF ('$LENGTH(XQON0))
WRITE !,"You have not been given the authority to delegate options. See your Site Manager."
GOTO OUT
+5 IF 'XQPRO
SET XQLEV=0
IF $LENGTH(XQON0)
SET XQLEV=$PIECE(XQON0,U,3)
IF '$LENGTH(XQLEV)!(XQLEV<1)
SET XQLEV=1
+6 ;
USER ;Get the duz of the user being delegated to.
+1 KILL ^TMP($JOB,"OP"),^("ZN"),XQHOLD,XQLK,XQKEY
SET (XQK,XQT,XQHOLD(0),XQKEY(0))=0
+2 WRITE !!,"Enter the name(s) of your delegate(s), one at a time"
NAME SET XQUF=1
WRITE !!," Name: "
READ XQ:DTIME
IF '$TEST
SET XQ=U
IF XQ=""
GOTO DONE
IF XQ=U
GOTO OUT
IF XQ="?"
WRITE !!,"Enter a name, a name preceded by a minus, a '^' to quit, or '??' for help."
GOTO NAME
+1 IF XQ["??"
SET XQH="XQSMD-USER"
IF XQ="??"
DO EN^XQH
IF XQ="???"
DO LIST
IF XQ="????"
DO LSTFIL
SET XQH="XQSMD-MAIN"
IF XQ="?????"
DO EN^XQH
GOTO NAME
+2 IF $EXTRACT(XQ,1)="-"
SET XQDEL=1
SET XQ=$EXTRACT(XQ,2,99)
+3 SET X=XQ
SET DIC=200
SET DIC(0)="MEZ"
DO ^DIC
IF Y<0
WRITE !!," ** No such person in the User File **"
GOTO NAME
+4 IF +Y=+DUZ
WRITE !,"It is illogical to delegate to oneself."
GOTO NAME
+5 IF '$DATA(^VA(200,+Y,.1))
WRITE !,"Sorry, this person has no verify code node in the user file."
GOTO NAME
+6 IF '$LENGTH($PIECE(^VA(200,+Y,.1),U,2))
WRITE !,"Sorry, this person is not an active user."
GOTO NAME
+7 IF XQDEL
SET XQDEL=0
KILL XQHOLD(+Y)
GOTO NAME
+8 IF 'XQPRO
SET XQLVL=9999
IF $DATA(^VA(200,+Y,19))#2
SET XQLVL=$PIECE(^(19),U,3)
IF XQLVL'?1N.N!(+XQLVL<+XQLEV)
WRITE !,"Delegation level error. You can not modify the options of ",$PIECE(Y,U,2)
GOTO NAME
+9 SET XQNAM=$PIECE(Y,U,2)
SET XQHOLD(+Y)=XQNAM
SET XQT=XQT+1
GOTO NAME
DONE SET (XQN,XQUF)=0
IF $ORDER(XQHOLD(XQN))=""
WRITE !!,"Enter a delegate's name or '^' to quit."
GOTO NAME
+1 ;
+2 GOTO ^XQSMD1
+3 QUIT
LSTFIL ;Show USER, OPTION, or user's delegated options in ^VA(200,DUZ,19.5)
+1 DO LIST
SET X="?"
SET DIC=$SELECT(XQUF:200,XQPRO:19,1:"^VA(200,DUZ,19.5,")
SET DIC(0)="Q"
DO ^DIC
KILL DIC
+2 QUIT
+3 ;
LIST ;List users and options selected so far.
+1 WRITE @IOF
SET (XQT,XQM)=0
SET XQM=$ORDER(XQHOLD(XQM))
IF XQM=""
WRITE !!," No users selected yet."
QUIT
+2 WRITE !!,"For the following user(s):",!
+3 FOR XQI=1:1
IF '(XQT#2)
WRITE !
WRITE ?(XQT#2*35),XQI,". ",XQHOLD(XQM)
SET XQT=XQT+1
SET XQM=$ORDER(XQHOLD(XQM))
IF XQM=""
QUIT
+4 WRITE !!,"You will ",$SELECT(XQDOP:"remove ",1:"delegate "),"the following options: ",!
+5 SET XQT=0
SET XQN=""
SET XQN=$ORDER(^TMP($JOB,"ZN",XQN))
IF XQN=""
WRITE !!,"No menu options selected yet"
QUIT
+6 FOR XQI=0:0
IF $Y+3>IOSL
DO WAIT
IF XQ=U
QUIT
WRITE !,XQN," ",$PIECE(^TMP($JOB,"ZN",XQN),U,1)
SET XQN=$ORDER(^(XQN))
IF XQN=""
QUIT
+7 WRITE !!,$SELECT(XQDOP:" Removed ",1:" Delegated "),"by ",XQMGR," on ",XQDATE,".",!
+8 QUIT
WAIT ;Skip to the head of the next page
+1 IF 1
IF IOST["C-"
READ !!,"Press RETURN to continue,'^' to quit...",XQ:DTIME
IF '$TEST&(IOST["C-")
SET XQ=U
WRITE @IOF
+2 QUIT
+3 ;
OUT KILL DIC,DIC(0),POP,XQ,XQAL,XQH,XQI,XQJ,XQK,XQL,XQM,XQN,XQT,XQD,XQDATE,XQDEL,XQDUZ,XQDT,XQLEV,XQLVL,XQLK,XQMG,XQMGR,XQNM,XQNAM,XQUF,XQPRO,XQSTART,XQEND,XQHOLD,XQKEY,XQON,XQON0,X,Y,XY,%,^TMP($JOB)
+1 QUIT