source: EWD/ewdapps/so/r/ewdu.m@ 1317

Last change on this file since 1317 was 1317, checked in by Sam Habiel, 13 years ago

some vars prefixed by so; SETUP d2 setup

File size: 5.6 KB
Line 
1ewdu ; JJIH/SMH - Utilities for EWD to VISTA interaction ; 11/18/11 5:39pm
2 ;
3r(sessid) ; Restore Symbol Table
4 d mergeArrayFromSession^%zewdAPI(.DUZ,"DUZ",sessid)
5 d mergeArrayFromSession^%zewdAPI(.IO,"IO",sessid)
6 s U=$$getSessionValue^%zewdAPI("U",sessid)
7 quit
8 ;
9s(sessid) ; Save to Symbol Table
10 d mergeArrayToSession^%zewdAPI(.DUZ,"DUZ",sessid)
11 d mergeArrayToSession^%zewdAPI(.IO,"IO",sessid)
12 d setSessionValue^%zewdAPI("U","^",sessid)
13 quit
14 ;
15 ; Custom Tag
16SS(nodeOID,attrValues,docOID,technology) ; <vista:session> to get VISTA Session Variables
17 N attr
18 S attr("method")="r^ewdu"
19 S attr("param1")="#ewd_sessid"
20 S attr("type")="procedure"
21 N xOID s xOID=$$addElementToDOM^%zewdDOM("ewd:execute",nodeOID,"",.attr)
22 D removeIntermediateNode^%zewdDOM(nodeOID)
23 quit
24 ;
25NULL ; Open Null Device
26 s %ZIS="0H",IOP="NULL" d ^%ZIS
27 i POP s $ec=",U1," ; this crashes everything... intended...
28 q
29 ;
30setup(sessid) ; Set-up and SSO
31 ; TODO: Set IO("CLNM")
32 i '$data(IO) d NULL ; Open Null Device
33 s IO("IP")=$$getServerValue^%zewdAPI("REMOTE_ADDR",sessid)
34 n return
35 d SETUP^XUSRB(.return) ; Set-up and Try SSO
36 ;0=server name, 1=volume, 2=uci, 3=device, 4=# attempts, 5=skip signon-screen,6=Domain Name, 7=Production (0=no, 1=Yes)
37 i $g(return(5)),DUZ>0 q $$s(sessid) ; Single Sign-On Successful; need redirect though here.
38 e d q "" ; Otherwise, get INTRO text
39 . N INTROTXT
40 . D INTRO^XUSRB(.INTROTXT)
41 . d mergeArrayToSession^%zewdAPI(.INTROTXT,"so.introtxt",sessid)
42 . d setSessionValue^%zewdAPI("so.serverName",return(0),sessid)
43 . d setSessionValue^%zewdAPI("so.volume",return(1),sessid)
44 . d setSessionValue^%zewdAPI("so.uci",return(2),sessid)
45 . ; Don't care about device! (return(3))
46 . ; Number of Attempts (return(4))
47 . d setSessionValue^%zewdAPI("so.fqdn",return(6),sessid)
48 . d setSessionValue^%zewdAPI("so.prod",return(7),sessid)
49 ; ---
50so(sessid) ; SO from EWD; routes to $$SO
51 ; TODO: Set IO("CLNM")
52 d NULL ; IO set-up
53 s IO("IP")=$$getServerValue^%zewdAPI("REMOTE_ADDR",sessid)
54 d SETUP^XUSRB(); ; This time, just need partition set-up
55 n ac s ac=$$getSessionValue^%zewdAPI("ac",sessid)
56 n vc s vc=$$getSessionValue^%zewdAPI("vc",sessid)
57 n result s result=$$SO(ac,vc)
58 ;
59 ; Change Verify Code Logic Ahead... Damn Complex!
60 i $l(result),result="CVC" d q "" ; User must change Verify Code
61 . S DUZ=$$STATE^XWBSEC("XUS DUZ") ; VISTA kills off DUZ if vc needs changing.
62 . ; That's fine when it can get it back. But we are not a stateful process.
63 . ; By the time the second request is made, XUS DUZ is gone gone gone.
64 . d s(sessid) ; Save symbol table for next page (including DUZ)
65 . d setRedirect^%zewdAPI("cvc",sessid) ; Next page is cvc.
66 . d setSessionValue^%zewdAPI("cvcForced",1,sessid) ; Need to know that the user is toast!
67 ;
68 i $l(result) q result ; General Error Message - User can't log-in
69 ;
70 e d q "" ; Everything Okay
71 . d s(sessid)
72 . i $$isCheckboxOn^%zewdAPI("cvc","cvc",sessid) d setRedirect^%zewdAPI("cvc",sessid)
73 ;
74SO(ac,vc) ; Sign-on to VISTA, AV way
75 ; TODO: Handle the rest of the return values
76 N return
77 ; if ac contains ;, then it contains the verify code
78 ; else, send ac;vc
79 if ac[";" d VALIDAV^XUSRB(.return,$$ENCRYP^XUSRB1(ac))
80 else d VALIDAV^XUSRB(.return,$$ENCRYP^XUSRB1(ac_";"_vc))
81 i return(0)>0,'return(2) q "" ; Sign on successful!
82 i return(0)=0,return(2) q "CVC" ; Verify Code must be changed NOW!
83 i $l(return(3)) q return(3) ; Error Message returned whole
84 ; Note: division selection not implemented here
85 quit ""
86 ; ---
87sss(id) ; Test
88 d setRedirect^%zewdAPI("index",id,"bb")
89 q ""
90whoami(sessid) ; Who Am I? PrePage Script
91 d r(sessid)
92 n Name s Name=$$GET1^DIQ(200,DUZ,.01) ; User Name
93 d setSessionValue^%zewdAPI("Name",Name,sessid)
94 q ""
95cvc(sessid) ; Change Verify Code
96 ; get stored session values for DUZ, IO, and U
97 d r(sessid) ; Restore the Symbol Table
98 n VC1,VC2,VC3
99 s VC1=$$getPasswordValue^%zewdAPI("vc1",sessid)
100 s VC2=$$getPasswordValue^%zewdAPI("vc2",sessid)
101 s VC3=$$getPasswordValue^%zewdAPI("vc3",sessid)
102 ; Uppercase them -- otherwise CVC will fail.
103 s VC1=$$UP^XLFSTR(VC1)
104 s VC2=$$UP^XLFSTR(VC2)
105 s VC3=$$UP^XLFSTR(VC3)
106 ; Roman Cipher them vista-wise
107 n eVC1,eVC2,eVC3
108 s eVC1=$$ENCRYP^XUSRB1(VC1)
109 s eVC2=$$ENCRYP^XUSRB1(VC2)
110 s eVC3=$$ENCRYP^XUSRB1(VC3)
111 ; Set-up Call
112 n vcString s vcString=eVC1_U_eVC2_U_eVC3
113 n ret
114 d CVC^XUSRB(.ret,vcString)
115 i ret(0)=0 q "" ; Success
116 i ret(0)>0 q ret(1) ; Failure
117 ;;
118 ;;return(0)=0
119 ;;return(1)=0
120 ;;return(2)=1
121 ;;return(3)="VERIFY CODE must be changed before continued use."
122 ;;return(4)=0
123 ;;return(5)=0
124 ;;return(6)=""
125 ;;return(7)="Good evening DOCTOR,TEN"
126 ;;return(8)=" You last signed on today at 22:19"
127listEWDApps(sessid) ; Lists all available EWD Applicaitons, not including ewdMgr. Intended to be an imitation of a menu.
128 n apps ; Will hold our applications
129 do
130 . n ewdpath s ewdpath=^zewd("config","applicationRootPath")
131 . o "lsApps":(shell="/bin/bash":command="ls -1 "_ewdpath:READONLY)::"PIPE"
132 . u "lsApps"
133 . n line
134 . n counter s counter=1
135 . for read line quit:$zeof do
136 . . i line="ewdMgr" quit ; Don't include ewdMgr
137 . . s apps(counter)=line
138 . . s counter=counter+1
139 . c "lsApps"
140 . zwrite:$g(debug) apps
141 . d mergeArrayToSession^%zewdAPI(.apps,"installedapps",sessid)
142 ;
143 ; Old code: uses JSON
144 ; n appsjson s appsjson=$$arrayToJSON^%zewdJSON("apps")
145 ; zwrite:$g(debug) appsjson
146 ; d setSessionValue^%zewdAPI("appsjson",appsjson,sessid)
147 ;
148 q ""
149redir(sessid)
150 n redirapp s redirapp=$$getRequestValue^%zewdAPI("nextapp",sessid)
151 d setRedirect^%zewdAPI("index",sessid,redirapp)
152 q ""
153 ;
Note: See TracBrowser for help on using the repository browser.