Show last authors
1 {{toc/}}
2
3 ----
4
5 = Define Live Security function =
6
7 Open the data model you wish to set a Live Security function
8 [[image:https://lh5.googleusercontent.com/2C5BDoV-7uXAghqZzF6CTnBYtY-3fndDl4HVNnj59KoaQYc3AvCOBiILSUmM_5dIR0qC7eUdOHXBGvsFXtxeskh0b1rgpBrP6Bfy8C-sborNfIsmmkrO1bH7KsPi1Vpq1Aoi2xTA81I||height="517" width="964"]]
9
10 Add the function in the SELTRANS section of the dictionary of functions (You have to duplicate it and update it between (% style="color:#f39c12" %)/* START CONFIG*/(%%) and (% style="color:#f39c12" %)/* END CONFIG */(%%) see below)
11
12 {{code language="js"}}
13 /* START CONFIG */
14 //version: 2019R2
15 var securedDims = {};
16 securedDims["Région"] = getUserAttribute("region");
17
18 /* Ajouter ici les autres dimensions sur lequel du live security doit s’appliquer */
19 /*
20 securedDims["DIMENSION_NAME_2"] = getUserAttribute("USER_PARAM_2");
21 */
22
23 /* END CONFIG */
24
25 /* MODIFY THE SCRIPT BELOW WITH CAUTION */
26 var sLogPrefix = "[LIVE_SECURITY] [live-sec-thread-" + Math.floor(Math.random()*16777215).toString(16) + "]"; /* 16777215 is FFFFFF in decimal */
27
28 for (var dimId in securedDims)
29 {
30 var dim = selection.dm.objName[dimId];
31 var persoVal = securedDims[dimId];
32
33 //Packages.com.digdash.utils.MessageStack.getInstance().addDebug(sLogPrefix + "Applying user filters on: " + dimId + ", persoVal:" + persoVal);
34 if (dim)
35 {
36 if (persoVal == null || persoVal.length == 0)
37 {
38 // user must no see any value
39 var persoValuesTab = ["-noval-"];
40 var filt = new FilterSelection(dim, -1, -1, [], persoValuesTab);
41 selection.setFilter(filt);
42 Packages.com.digdash.utils.MessageStack.getInstance().addDebug(sLogPrefix + " Filters (members) on " + dimId + ": [" + persoValuesTab + "]");
43 }
44 else if (persoVal && persoVal != ".*")
45 {
46 //user is limited to some value(s)
47 var persoValuesTab = persoVal.split("|");
48 Packages.com.digdash.utils.MessageStack.getInstance().addDebug(sLogPrefix + " Applying user filters on " + dimId + ": [" + persoValuesTab + "]");
49
50 var exFilter = selection.filterByDimName[dimId];
51 if (!exFilter)
52 {
53 //there is no exisitng filter on that dimension => create a new one
54 var filt = new FilterSelection(dim, -1, -1, [], persoValuesTab);
55 selection.setFilter(filt);
56 Packages.com.digdash.utils.MessageStack.getInstance().addDebug(sLogPrefix + " Resolved filters (members) on " + dimId + ": [" + persoValuesTab + "]");
57 }
58 else
59 {
60 //there is already a filter on that dimension => merge (intersect) into a new one
61 var filt = new FilterSelection(dim, -1, -1, [], persoValuesTab);
62 filt.recalcIds();
63 exFilter.recalcIds();
64 exFilter = mergeFilters(exFilter, filt);
65 origIdsTab = exFilter.origIds;
66 selection.setFilter(exFilter);
67 Packages.com.digdash.utils.MessageStack.getInstance().addDebug(sLogPrefix + " Resolved filters (origIds) on " + dimId + ": [" + exFilter.origIds + "]");
68 }
69 }
70 else // perso value is .*
71 {
72 // do nothing, user can see everything
73 Packages.com.digdash.utils.MessageStack.getInstance().addDebug(sLogPrefix + " Resolved filters on " + dimId + ": All (.*)");
74 }
75 }
76 else
77 {
78 Packages.com.digdash.utils.MessageStack.getInstance().addError(sLogPrefix + " Dimension " + dimId + "not found");
79 }
80 }
81 {{/code}}
82
83 = User Attribute =
84
85 Make sure to add a user parameter (**USER_PARAM_1** for example) and fill it for the concerned users (Set .* for other users).
86 In the following example, admin will be granted to see the** DIMENSION_NAME_1** where value **A**, **B** or **C** are present.
87 [[image:https://lh3.googleusercontent.com/pi0GKHieoUS7OOnI0ve5AoidI7shqXqnm4l6mfDTFFZsKvWyOSF6xt_5Pw_X2x9epy5w6AIXF8uhO1l-UdrtB9pPcXCQFT-gQ_a3jGaxbQHdXejAaNEz2YmgkQ1jmmb8OZXAOibXj1g||height="378" width="743"]]
88
89 = Live Security to forbid measure display =
90
91 {{code language="js"}}
92 var show_measure = getUserAttribute('show_measure');
93 var measureId = 'CA'; // id of the measure to hide
94
95 if (show_measure == 'non')
96 {
97 var measIndex = selection.indexOfMeasure(measureId);
98 if (measIndex > 0)
99 selection.removeMeasure(measIndex);
100 }
101 {{/code}}
Copyright ©2006-2023 DigDash SAS