source: FOIAVistA/tag/r/KERNEL-XU-A4A7-USC-XG-XLF-XNOA-XPD-XQ-XVIR-ZI-ZOSF-ZOSV-ZT-ZU-%Z-XIP--XQAB--XUC--XUR--ZIN--ZTED/XQCHK.m@ 636

Last change on this file since 636 was 636, checked in by George Lilly, 14 years ago

WorldVistAEHR overlayed on FOIAVistA

File size: 9.4 KB
Line 
1XQCHK ; SEA/MJM - Check security on option # XQCY ; [7/19/06 10:45am]
2 ;;8.0;KERNEL;**47,110,149,303,427**;Jul 10, 1995;Build 3
3 Q:'$D(XQCY)!(XQCY<1) S:'$D(XQJMP) XQJMP=0
4 I '$D(XQY0) S XQY0=^DIC(19,+XQCY,0)
5 I '$D(XQCY0) S XQSAV=XQY0,XQY=XQCY D SET Q:XQCY<0 S XQCY0=XQY0,XQY0=XQSAV
6CHK I XQCY0="" S XQCY=-1 G OUT
7 I $P(XQCY0,U,3)'="" S XQCY=-1 G OUT
8 N XQRT S XQRT=$$CHCKL^XQCHK2(XQCY0,DUZ) I +XQRT S XQCY=-2 G OUT ; add this line to check all Locks
9 I $L($P(XQCY0,U,6)) S %="" F %XQI=1:1 S %=$P($P(XQCY0,U,6),",",%XQI) Q:%="" I '$D(^XUSEC(%,DUZ)) S XQCY=-2 G OUT ; remove
10 N XQRT S XQRT=$$CHCKRL^XQCHK2(XQCY0,DUZ) I +XQRT S XQCY=-3 G OUT ; add this line to check all Reversed Locks
11 I $L($P(XQCY0,U,16)) S %="" F %XQI=1:1 S %=$P($P(XQCY0,U,16),",",%XQI) Q:%="" I $D(^XUSEC(%,DUZ)) S XQCY=-3 G OUT ; remove
12 I $L($P(XQCY0,U,9)) S XQZ=$P(XQCY0,U,9) D ^XQDATE S X=% D XQO^XQ92 I X="" S XQCY=-4 G OUT
13 G:$P(XQCY0,U,10)'["y" OUT
14 S %=0 F %XQI=1:1 S %=$O(^DIC(19,XQCY,3.96,%,0)) Q:%="" I IOS=% G OUT
15 S XQCY=-5 G OUT
16 Q
17 ;
18OUT ;I XQCY=-2 W !,"Locked...Do you have the key "_$P(XQRT,"^",2)
19 ;I XQCY=-3 W !,"Reversed Locked...Don't you have the key "_$P(XQRT,"^",2)
20 K %,%XQI,XQCY0,%Y,XQZ
21 Q
22 ;
23JMP ;Check all options in jump path in %XQJP returned as "" if not OK
24 S XQJMP=1
25 F %XQCI=1:1 S XQCY=$P(%XQJP,",",%XQCI) Q:XQCY="" S XQCY0=$G(^XUTL("XQO",XQDIC,"^",XQCY)),XQCY0=$P(XQCY0,U,2,99) D CHK S:XQCY<0 %XQJP=""
26 K %XQCI,XQCY,XQCY0
27 Q
28 ;
29SET ;Produce the same XQY0 as SET1^XQ7 without the synonym
30 I '$D(^DIC(19,+XQY,0)) S XQY=-1 Q
31S1 Q:XQY'>0 S XQY0=^DIC(19,+XQY,0),XQY0=$P(XQY0,U,1,2)_U_$S($P(XQY0,U,3)]"":1,1:"")_U_$P(XQY0,U,4)_U_U_$P(XQY0,U,6,99)
32 S %="" I $D(^DIC(19,+XQY,3.91)) F %XQI=0:0 S %XQI=$O(^DIC(19,+XQY,3.91,%XQI)) Q:%XQI=""!(%XQI'=+%XQI) I ^(%XQI,0)]"" S %=$S(%'="":%_";",1:"")_$P(^(0),U,1)_$P(^(0),U,2)
33 I %]"" S XQY0=$P(XQY0,U,1,8)_U_%_U_$P(XQY0,U,10,99)
34 I $P(XQY0,U,16),$D(^DIC(19,XQY,3)) S %=$P(^(3),U) I %'="" S XQY0=$P(XQY0,U,1,15)_U_%_U_$P(XQY0,U,17,99)
35 K %,%XQI
36 Q
37 ;
38MES ;Messages for rejected options from a call to XQCHK
39 W $C(7)
40 I XQCY=-1 W !!?5,"==> Sorry, ",$S($D(XQPRMN):"your Primary Menu",1:"this option")," is out of order with the message:",!?10,$P(^DIC(19,XQY,0),U,3)
41 I XQCY=-2 W !!?5,"==> Sorry, ",$S($D(XQPRMN):"your Primary Menu",1:"this option")," is locked."
42 I XQCY=-3 W !!?5,"==> Sorry, ",$S($D(XQPRMN):"your Primary Menu",1:"this option")," has a reverse lock on it."
43 I XQCY=-4 W !!?5,"==> Sorry, ",$S($D(XQPRMN):"your Primary Menu",1:"this option")," not allowed right now."
44 I XQCY=-5 W !!?5,"==> Sorry, ",$S($D(XQPRMN):"your Primary Menu",1:"this option")," not allowed on this device."
45 Q
46 ;
47OP ;Find out what option or protocol is in charge right now
48 ;Returns option or protocol name and text in XQOPT
49 S U="^",%XQ=0
50 I $D(XQORNOD) S %XQ=+XQORNOD,%XQ1=U_$P(XQORNOD,";",2),%XQ=@(%XQ1_%XQ_",0)"),XQOPT=$P(%XQ,U)_U_$P(%XQ,U,2)
51 I '$D(XQORNOD) S %XQ=$S($D(XQY)#2:XQY,1:0) I %XQ S %XQ1=^DIC(19,+%XQ,0),XQOPT=$P(%XQ1,U)_U_$P(%XQ1,U,2)
52 I '$D(XQOPT) S XQOPT="-1^Unknown"
53 K %XQ,%XQ1
54 Q
55 ;
56OP1() ;Extrinsic function call returns 3 pieces: 1. "P", "O", or "U" for
57 ;Protocol, Option, or Unknown. 2: The Option or Protocol's name. 3:
58 ;3: Text name of the Protocol or Option. For example:
59 ;
60 ; O^EVE^System Manager's Menu
61 ;
62 N %,%XQ,%XQ1
63 S U="^",%XQ=0
64 I $D(XQORNOD) S %XQ=+XQORNOD,%XQ1=U_$P(XQORNOD,";",2),%XQ=@(%XQ1_%XQ_",0)"),%="P"_U_$P(%XQ,U)_U_$P(%XQ,U,2)
65 I '$D(XQORNOD) S %XQ=$S($D(XQY)#2:XQY,1:0) I %XQ S %XQ1=^DIC(19,+%XQ,0),%="O"_U_$P(%XQ1,U)_U_$P(%XQ1,U,2)
66 I '$D(%) S %="U"_U_"Unknown"_U_"No option or protocol data available"
67 Q %
68 ;
69 ;
70ACCESS(%XQUSR,%XQOP) ;Find out if a user has access to a particular option
71 ;
72 ; W $$ACCESS(DUZ,Option IEN) returns:
73 ;
74 ;-1:no such user in the New Person File
75 ;-2: User terminated or has no access code
76 ;-3: no such option in the Option File
77 ;0: no access found in any menu tree the user owns
78 ;
79 ; All other cases return a 4-piece string stating
80 ; access ^ menu tree IEN ^ a set of codes ^ key
81 ;
82 ;O^tree^codes^key: No access because of locks (see XQCODES below)
83 ; where 'tree' is the menu where access WOULD be allowed
84 ; and 'key' is the key preventing access
85 ;1^OpIEN^^: Access allowed through Primary Menu
86 ;2^OpIEN^codes^: Access found in the Common Options
87 ;3^OpIEN^codes^: Access found in top level of secondary option
88 ;4^OpIEN^codes^: Access through a the secondary menu tree OpIEN.
89 ;
90 ;XQCODES can contain:
91 ; N=No Primary Menu in the User File (warning only)
92 ; L=Locked and the user does not have the key (forces 0 in first piece)
93 ; R=Reverse lock and user has the key (forces 0 in first piece)
94 ;
95 I '$D(^VA(200,%XQUSR,0)) Q -1
96 N %,DT
97 S DT=$$HTFM^XLFDT($H,1)
98 S %=^VA(200,%XQUSR,0) I ($P(%,U,3)="")!($L($P(%,U,11))&($P(%,U,11)'>DT)) Q -2
99 ;
100 ;Convert %XQOP to its IEN if the name is passed
101 I +%XQOP'=%XQOP D
102 .I $D(^DIC(19,"B",%XQOP))<1 S %XQOP=0 Q
103 .E S %XQOP=$O(^DIC(19,"B",%XQOP,0))
104 .Q
105 I '%XQOP Q -3
106 I '$D(^DIC(19,%XQOP,0)) Q -3
107 ;
108 N XQCODES,XQCOM,XQDIC,XQDONE,XQI,XQJ,XQKEY,XQOK,XQPM,XQRSLT,XQSEC,XQTREE
109 S (%,XQDONE,XQOK)=0,(XQRSLT,XQCODES,XQTREE)=""
110 ;
111 ;
112 ;Look in the user's primary menu tree
113 S XQPM=$P($G(^VA(200,%XQUSR,201)),"^")
114 I 'XQPM S XQCODES=XQCODES_"N"
115 ;
116 ;
117 I XQPM S XQDIC="P"_XQPM I $D(^XUTL("XQO",XQDIC,"^",%XQOP)) D
118 .D KEYS
119 .I XQCODES'["L"&(XQCODES'["M") S XQOK=1
120 .Q
121 I XQOK Q "1^"_XQPM_"^"_XQCODES
122 I XQCODES["L"!(XQCODES["R") S XQRSLT="0^"_XQPM_"^"_XQCODES_"^"_XQKEY
123 ;
124 ; Search the common options
125 S XQCOM=$O(^DIC(19,"B","XUCOMMAND",0))
126 S XQDIC="PXU"
127 I $D(^XUTL("XQO",XQDIC,"^",%XQOP)) D
128 .D KEYS
129 .I XQCODES'["L"&(XQCODES'["R") S XQOK=1
130 .Q
131 I XQOK Q "2^"_XQCOM_"^"_XQCODES
132 I XQRSLT="" I XQCODES["L"!(XQCODES["R") S XQRSLT="0^"_XQCOM_"^"_XQCODES_"^"_XQKEY
133 ;
134 ;Check the top level of the secondary options
135 S XQDIC="U"_%XQUSR
136 I $D(^VA(200,%XQUSR,203,0)),$P(^(0),U,4)>0 D
137 .S XQJ=0,XQDONE=0
138 .F XQI=1:1 D Q:XQDONE
139 ..S XQJ=$O(^VA(200,%XQUSR,203,XQJ))
140 ..I (XQJ'=+XQJ)!('XQJ) S XQDONE=1 Q
141 ..S XQSEC(XQI)=+^VA(200,%XQUSR,203,XQJ,0)
142 ..Q:XQSEC(XQI)'=%XQOP
143 ..D KEYS
144 ..I XQCODES'["L"&(XQCODES'["R") S XQOK=1
145 ..I XQRSLT="" I XQCODES["L"!(XQCODES["R") S XQRSLT="0^"_XQSEC(XQI)_"^"_XQCODES_"^"_XQKEY
146 ..Q
147 .Q
148 I XQOK Q "3^"_%XQOP_"^"_XQCODES
149 ;
150 ;If there are no secondaries quit here
151 I '$D(XQI)&((XQCODES["L")!(XQCODES["R")) Q XQRSLT
152 I '$D(XQI) Q 0
153 ;
154 ;Check each secondary menu tree
155 F XQK=1:1:XQI-1 Q:XQOK D
156 .S XQDIC="P"_XQSEC(XQK)
157 .Q:'$D(^XUTL("XQO",XQDIC,"^",%XQOP))
158 .S XQTREE=$P(XQDIC,"P",2)
159 .D KEYS
160 .I XQCODES'["L"&(XQCODES'["R") S XQOK=1
161 .I XQRSLT="" I XQCODES["L"!(XQCODES["R") S XQRSLT="0^"_XQTREE_"^"_XQCODES_"^"_XQKEY
162 .Q
163 I XQOK Q "4^"_XQTREE_"^"_XQCODES
164 I XQRSLT]"" Q XQRSLT
165 ;
166 ;We doan find nothing nowhere
167 Q "0^^"_XQCODES
168 ;
169KEYS ;Check for keys, reverse keys...
170 N XQK,XQN,XQOPIQ,KFG
171 D CHCK1^XQCHK1 Q:KFG=1
172 I $D(^XUTL("XQO",XQDIC,"^",%XQOP)) S XQOPIQ=^(%XQOP)
173 E S XQOPIQ=U_^DIC(19,%XQOP,0)
174 ;
175 I $L($P(XQOPIQ,U,7)) D
176 .S %=$P(XQOPIQ,U,7)
177 .F XQN=1:1 S XQK=$P(%,",",XQN) Q:XQK="" D
178 ..I '$D(^XUSEC(XQK,%XQUSR)) S XQCODES=XQCODES_"L",XQKEY=XQK
179 ..Q
180 .Q
181 ;
182 I $L($P(XQOPIQ,U,17)) D
183 .S %=$P(XQOPIQ,U,17)
184 .F XQN=1:1 S XQK=$P(%,",",XQN) Q:XQK="" D
185 ..I $D(^XUSEC(XQK,%XQUSR)) S XQCODES=XQCODES_"R",XQKEY=XQK
186 ..Q
187 .Q
188 Q
189 ;
190OPACCES ;Entry point for the option that checks to see if a user has
191 ;access to a particular option by calling the above function.
192 N %,DIC,X,XQANS,XQCODES,XQK,XQKEY,XQOPT,XQOPN,XQPTR,XQRSLT,XQTREE,XQUSER,XQUSN,Y
193 ;
194 S DIC(0)="AEMNQ",DIC="^VA(200,",DIC("A")="Please enter the user's name: " D ^DIC
195 I $D(DUOUT)!($D(DTOUT)) D KILLFM Q
196 I Y=-1 W !!?5,"Sorry we couldn't find that user in the New Person File.",!
197 E S XQUSN=+Y,XQUSER=$P(Y,U,2)
198 I Y=-1 D KILLFM Q
199 D KILLFM
200 ;
201 S DIC(0)="AEMNQ",DIC="^DIC(19,",DIC("A")="Please enter the name of the option: " D ^DIC
202 I $D(DUOUT)!($D(DTOUT)) D KILLFM Q
203 I Y=-1 W !!?5,"Sorry we couldn't find that option.",!
204 E S XQOPN=+Y,XQOPT=$P(Y,U,2)
205 I Y=-1 D KILLFM Q
206 D KILLFM
207 ;
208 S XQANS=$$ACCESS(XQUSN,XQOPN)
209 ;W !,XQANS,!
210 ;
211 S XQRSLT=+XQANS,XQTREE=""
212 S XQPTR=$P(XQANS,U,2) I XQPTR>0 S XQTREE=$P(^DIC(19,$P(XQANS,U,2),0),U)
213 S XQCODES=$P(XQANS,U,3),XQKEY=$P(XQANS,U,4)
214 ;
215 I XQRSLT=-1 W !!?5,"User ",XQUSER," is not in the New Person File."
216 I XQRSLT=-2 W !!?5,"User ",XQUSER," has an active termination date,",!?5,"or no verify code."
217 I XQRSLT=-3 W !!?5,"Option ",XQOPT," is not in the Option File."
218 I XQRSLT=0 D
219 .W !!?5,"User ",XQUSER," does not have access to the option",!?5,XQOPT,"."
220 .I XQCODES["L" W !!?5,"There is a lock somewhere in the menu tree "_XQTREE,!?5,"and the user does not hold the key "_XQKEY_"."
221 .I XQCODES["R" W !!?5,"There is a reverse lock somewhere in the menu tree "_XQTREE,!?5,"and the user holds the key "_XQKEY_"."
222 .Q
223 I XQRSLT=1 W !!?5,"User ",XQUSER," has access to the option ",XQOPT,!?5,"through the primary menu ",XQTREE," (",$P(^DIC(19,XQPTR,0),U,2),")."
224 I XQRSLT=2 W !!?5,"User ",XQUSER," has access to the option ",XQOPT,!?5,"through the Common Options (XUCOMMAND)."
225 I XQRSLT=3 W !!?5,"User ",XQUSER," has access to the option ",XQOPT,!?5,"as a top-level secondary menu option."
226 I XQRSLT=4 W !!?5,"User ",XQUSER," has access to the option ",XQOPT,!?5,"through the secondary menu tree ",XQTREE," (",$P(^DIC(19,XQPTR,0),U,2),")."
227 W !
228 ;W !!,%," ",XQUSER," ",XQOPT
229 Q
230 ;
231KILLFM ;Kill off the FileMan variables
232 K D0,DI,DIC,DIE,DISYS,DQ,DR,DUOUT,DTOUT,X,Y
233 Q
234 ;
235KEYSET(XQU) ;Collect users keys and set them into ^TMP($J)
236 N %,XQI
237 S %=0 F XQI=0:1 S %=$O(^VA(200,XQU,51,"B",%)) Q:%="" S:$D(^DIC(19.1,%,0)) ^TMP($J,$P(^DIC(19.1,%,0),U),%)=""
238 Q
Note: See TracBrowser for help on using the repository browser.