Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ' Subroutine: initialize
- '
- ' Initialize the Desktop for the user.
- '
- public sub initialize() : call watchdog()
- dim AC, Resources, usr, template, Ds
- usr = Request.Cookies("Evolved.ERP.Transient")("USR")
- template = Core.loadTextFile( Server.mapPath("/app/views/xhtml/desktop.mustache") )
- set Ds = JSON.parse("{}")
- call loadGetText(template, Ds)
- Ds.set "APPLICATION_NAME", Application("name")
- Ds.set "year", year(now)
- Ds.set "usr", usr
- set AC = new ACL
- set AC.Media = new Acl_Media_Json
- AC.Media.path = Server.mapPath("/app/writable/acl.json")
- call AC.load()
- Ds.set "isAdministrator", AC.is(usr, "administrator")
- set Resources = JSON.parse( Core.loadTextFile( Server.mapPath("/app/models/resources.json") ) )
- dim k, o, hlpr, containers, Container
- set containers = JSON.parse("[]")
- for each k in Resources.keys()
- set Container = JSON.parse("{}")
- for each o in Resources.get(k)
- hlpr = S("{0}_{1}").[]( array( k, o.get("resource") ) )
- if( hlpr <> T(hlpr) ) then o.set "resource", T(hlpr)
- next
- Container.set "idContainer", S(k).propercase(, null)
- Container.set "name", T(k)
- Container.set "items", Resources.get(k)
- if( AC.isAllowed(usr, k, "access") ) then
- containers.push(Container)
- Ds.set "loadCommon", true
- Ds.set "allow" & S(k).propercase(, null), true
- end if
- set Container = nothing
- next
- Ds.set "containers", containers
- set containers = nothing
- set Resources = nothing
- set AC.Media = nothing
- set AC = nothing
- Session("this").add "Output.xml", JSON.stringify(Ds, null, 2)
- Session("this").add "Output.xslt", template
- Session("this").add "Output.value", Mustache.to_html(template, Ds)
- set Ds = nothing
- end sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement