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

Last change on this file since 1314 was 1314, checked in by Sam Habiel, 12 years ago

added vista:session custom tag implementation

File size: 5.0 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 i $g(return(5)),DUZ>0 q $$s(sessid) ; Single Sign-On Successful!
37 e d q "" ; Otherwise, get INTRO text
38 . N RET
39 . D INTRO^XUSRB(.RET)
40 . d mergeArrayToSession^%zewdAPI(.RET,"introtxt",sessid)
41 ; ---
42so(sessid) ; SO from EWD; routes to $$SO
43 ; TODO: Set IO("CLNM")
44 d NULL ; IO set-up
45 s IO("IP")=$$getServerValue^%zewdAPI("REMOTE_ADDR",sessid)
46 d SETUP^XUSRB(); ; This time, just need partition set-up
47 n ac s ac=$$getSessionValue^%zewdAPI("ac",sessid)
48 n vc s vc=$$getSessionValue^%zewdAPI("vc",sessid)
49 n result s result=$$SO(ac,vc)
50 ;
51 ; Change Verify Code Logic Ahead... Damn Complex!
52 i $l(result),result="CVC" d q "" ; User must change Verify Code
53 . S DUZ=$$STATE^XWBSEC("XUS DUZ") ; VISTA kills off DUZ if vc needs changing.
54 . ; That's fine when it can get it back. But we are not a stateful process.
55 . ; By the time the second request is made, XUS DUZ is gone gone gone.
56 . d s(sessid) ; Save symbol table for next page (including DUZ)
57 . d setRedirect^%zewdAPI("cvc",sessid) ; Next page is cvc.
58 . d setSessionValue^%zewdAPI("cvcForced",1,sessid) ; Need to know that the user is toast!
59 ;
60 i $l(result) q result ; General Error Message - User can't log-in
61 ;
62 e d q "" ; Everything Okay
63 . d s(sessid)
64 . i $$isCheckboxOn^%zewdAPI("cvc","cvc",sessid) d setRedirect^%zewdAPI("cvc",sessid)
65 ;
66SO(ac,vc) ; Sign-on to VISTA, AV way
67 ; TODO: Handle the rest of the return values
68 N return
69 D VALIDAV^XUSRB(.return,$$ENCRYP^XUSRB1(ac_";"_vc))
70 i return(0)>0,'return(2) q "" ; Sign on successful!
71 i return(0)=0,return(2) q "CVC" ; Verify Code must be changed NOW!
72 i $l(return(3)) q return(3) ; Error Message returned whole
73 ; Note: division selection not implemented here
74 quit ""
75 ; ---
76sss(id) ; Test
77 d setRedirect^%zewdAPI("index",id,"bb")
78 q ""
79whoami(sessid) ; Who Am I? PrePage Script
80 d r(sessid)
81 n Name s Name=$$GET1^DIQ(200,DUZ,.01) ; User Name
82 d setSessionValue^%zewdAPI("Name",Name,sessid)
83 q ""
84cvc(sessid) ; Change Verify Code
85 ; get stored session values for DUZ, IO, and U
86 d r(sessid) ; Restore the Symbol Table
87 n VC1,VC2,VC3
88 s VC1=$$getPasswordValue^%zewdAPI("vc1",sessid)
89 s VC2=$$getPasswordValue^%zewdAPI("vc2",sessid)
90 s VC3=$$getPasswordValue^%zewdAPI("vc3",sessid)
91 ; Uppercase them -- otherwise CVC will fail.
92 s VC1=$$UP^XLFSTR(VC1)
93 s VC2=$$UP^XLFSTR(VC2)
94 s VC3=$$UP^XLFSTR(VC3)
95 ; Roman Cipher them vista-wise
96 n eVC1,eVC2,eVC3
97 s eVC1=$$ENCRYP^XUSRB1(VC1)
98 s eVC2=$$ENCRYP^XUSRB1(VC2)
99 s eVC3=$$ENCRYP^XUSRB1(VC3)
100 ; Set-up Call
101 n vcString s vcString=eVC1_U_eVC2_U_eVC3
102 n ret
103 d CVC^XUSRB(.ret,vcString)
104 i ret(0)=0 q "" ; Success
105 i ret(0)>0 q ret(1) ; Failure
106 ;;
107 ;;return(0)=0
108 ;;return(1)=0
109 ;;return(2)=1
110 ;;return(3)="VERIFY CODE must be changed before continued use."
111 ;;return(4)=0
112 ;;return(5)=0
113 ;;return(6)=""
114 ;;return(7)="Good evening DOCTOR,TEN"
115 ;;return(8)=" You last signed on today at 22:19"
116listEWDApps(sessid) ; Lists all available EWD Applicaitons, not including ewdMgr. Intended to be an imitation of a menu.
117 n apps ; Will hold our applications
118 do
119 . n ewdpath s ewdpath=^zewd("config","applicationRootPath")
120 . o "lsApps":(shell="/bin/bash":command="ls -1 "_ewdpath:READONLY)::"PIPE"
121 . u "lsApps"
122 . n line
123 . n counter s counter=1
124 . for read line quit:$zeof do
125 . . i line="ewdMgr" quit ; Don't include ewdMgr
126 . . s apps(counter)=line
127 . . s counter=counter+1
128 . c "lsApps"
129 . zwrite:$g(debug) apps
130 . d mergeArrayToSession^%zewdAPI(.apps,"installedapps",sessid)
131 ;
132 ; Old code: uses JSON
133 ; n appsjson s appsjson=$$arrayToJSON^%zewdJSON("apps")
134 ; zwrite:$g(debug) appsjson
135 ; d setSessionValue^%zewdAPI("appsjson",appsjson,sessid)
136 ;
137 q ""
138redir(sessid)
139 n redirapp s redirapp=$$getRequestValue^%zewdAPI("nextapp",sessid)
140 d setRedirect^%zewdAPI("index",sessid,redirapp)
141 q ""
142 ;
Note: See TracBrowser for help on using the repository browser.