Loading...
Searching...
No Matches
dirlist.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Fetches directories to facilitate configuration
4 @details The service can also be invoked using the following URL param:
5
6 @li &parent= (parent path)
7
8 Requires membership of the DC administrators group.
9
10 <h4> SAS Macros </h4>
11 @li mf_getuser.sas
12 @li mp_abort.sas
13 @li mp_dirlist.sas
14 @li mpe_getgroups.sas
15
16 @version 9.2
17 @author 4GL Apps Ltd
18 @copyright 4GL Apps Ltd. This code may only be used within Data Controller
19 and may not be re-distributed or re-sold without the express permission of
20 4GL Apps Ltd.
21
22**/
23
24%global parent;
25%mpeinit()
26
27/* check user is in admin group */
28%let cnt=0;
29%mpe_getgroups(user=%mf_getuser(),outds=work.usergroups)
30proc sql noprint;
31select count(*) into:cnt
32 from usergroups
33 where groupname="&mpeadmins";
34%mp_abort(iftrue= (&cnt=0)
35 ,mac=&_program
36 ,msg=%str(This service is only available to &mpeadmins members)
37)
38
39/* if no parent is specified, default to root - read with symget
40 * (never re-resolved) so macro content in the param cannot execute */
41%let is_bad=0;
42data _null_;
43length _parent $512;
44_parent=coalescec(symget('parent'),'/');
45 if index(_parent,'%')>0 or index(_parent,'&')>0 then do;
46 putlog 'ERR' 'OR: Invalid parent:' _parent;
47 call symputx('is_bad',1,'l');
48 end;
49 else call symputx('parent',_parent,'g');
50run;
51
52%mp_abort(iftrue=(&is_bad=1)
53 ,mac=&_program..sas
54 ,msg=%str(Invalid parent)
55)
56
57%mp_dirlist(path=&parent,outds=dirlist, maxdepth=2)
58
59%webout(OPEN)
60%webout(OBJ,dirlist)
61%webout(CLOSE)