Advertisement
Guest User

Untitled

a guest
Sep 15th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ASP 2.20 KB | None | 0 0
  1.     ' Subroutine: initialize
  2.     '
  3.     ' Initialize the Desktop for the user.
  4.     '
  5.     public sub initialize() : call watchdog()
  6.         dim AC, Resources, usr, template, Ds
  7.        
  8.         usr = Request.Cookies("Evolved.ERP.Transient")("USR")
  9.         template = Core.loadTextFile( Server.mapPath("/app/views/xhtml/desktop.mustache") )
  10.        
  11.         set Ds = JSON.parse("{}")
  12.        
  13.         call loadGetText(template, Ds)
  14.        
  15.         Ds.set "APPLICATION_NAME", Application("name")
  16.         Ds.set "year", year(now)
  17.         Ds.set "usr", usr
  18.        
  19.         set AC = new ACL
  20.         set AC.Media = new Acl_Media_Json
  21.         AC.Media.path = Server.mapPath("/app/writable/acl.json")
  22.         call AC.load()
  23.        
  24.         Ds.set "isAdministrator", AC.is(usr, "administrator")
  25.        
  26.         set Resources = JSON.parse( Core.loadTextFile( Server.mapPath("/app/models/resources.json") ) )
  27.        
  28.         dim k, o, hlpr, containers, Container
  29.         set containers = JSON.parse("[]")
  30.         for each k in Resources.keys()
  31.             set Container = JSON.parse("{}")
  32.            
  33.             for each o in Resources.get(k)
  34.                 hlpr = S("{0}_{1}").[]( array( k, o.get("resource") ) )
  35.                 if( hlpr <> T(hlpr) ) then o.set "resource", T(hlpr)
  36.             next
  37.            
  38.             Container.set "idContainer", S(k).propercase(, null)
  39.             Container.set "name", T(k)
  40.             Container.set "items", Resources.get(k)
  41.            
  42.             if( AC.isAllowed(usr, k, "access") ) then
  43.                 containers.push(Container)
  44.                 Ds.set "loadCommon", true
  45.                 Ds.set "allow" & S(k).propercase(, null), true
  46.             end if
  47.            
  48.             set Container = nothing
  49.         next
  50.         Ds.set "containers", containers
  51.         set containers = nothing
  52.        
  53.         set Resources = nothing
  54.        
  55.         set AC.Media = nothing
  56.         set AC = nothing
  57.        
  58.         Session("this").add "Output.xml", JSON.stringify(Ds, null, 2)
  59.         Session("this").add "Output.xslt", template
  60.         Session("this").add "Output.value", Mustache.to_html(template, Ds)
  61.        
  62.         set Ds = nothing
  63.     end sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement