Zuletzt geändert von admin am 2025/02/23 10:22

Zeige letzte Bearbeiter
1 {{velocity}}
2 #if($xcontext.action=='get' && $request.outputSyntax == 'plain')
3 #if(!$services.csrf.isTokenValid($request.form_token))
4 BAD CSRF
5 #elseif(!$xwiki.hasAccessLevel('edit', $xcontext.user, 'PanelsCode.ApplicationsPanelConfiguration'))
6 NO RIGHT
7 #else
8 ## Get the blacklist configuration
9 #set($configDoc = $xwiki.getDocument($services.model.createDocumentReference('', 'PanelsCode', 'ApplicationsPanelConfiguration')))
10 ## Get the desired blacklist
11 #set($list = $jsontool.fromString($request.blacklist))
12 #foreach($app in $list)
13 #set($blackListObj = $configDoc.getObject('PanelsCode.ApplicationsPanelBlackListClass', 'applicationId', $app))
14 #if(!$blackListObj)
15 #set($blackListObj = $configDoc.newObject('PanelsCode.ApplicationsPanelBlackListClass'))
16 #set($discard = $blackListObj.set('applicationId', $app))
17 #end
18 #end
19 #foreach($obj in $configDoc.getObjects('PanelsCode.ApplicationsPanelBlackListClass').clone())
20 #set($app = $obj.getValue('applicationId'))
21 #if(!$list.contains($app))
22 #set($discard = $configDoc.removeObject($obj))
23 #end
24 #end
25 ## Get the orderlist configuration
26 #set ($list = $jsontool.fromString($request.orderlist))
27 #foreach ($app in $list)
28 #set ($orderObj = $configDoc.getObject('PanelsCode.ApplicationsPanelOrderClass', 'applicationId', $app))
29 #if (!$orderObj)
30 #set ($orderObj = $configDoc.newObject('PanelsCode.ApplicationsPanelOrderClass'))
31 #set ($discard = $orderObj.set('applicationId', $app))
32 #end
33 #set ($discard = $orderObj.set('order', $foreach.count))
34 #end
35 ## Remove the order objects that are not set
36 #foreach($obj in $configDoc.getObjects('PanelsCode.ApplicationsPanelOrderClass').clone())
37 #set($app = $obj.getValue('applicationId'))
38 #if(!$list.contains($app))
39 #set($discard = $configDoc.removeObject($obj))
40 #end
41 #end
42 #set($discard = $configDoc.setHidden(true))
43 #set($discard = $configDoc.save("Save the new configuration"))
44 SUCCESS
45 #end
46 #end
47 {{/velocity}}