I need to be able to display different items in the a navigation tree, based on the roles assigned to the logged in user. Does anyone have an idea what the best way to achieve this would be? It seams that someone would have done this before.
In the Cloud Templates Browser, under Navigation they have a Auto Tree Nav template. Is this something like what you are looking for?
Chris, thanks for the suggestion. I may be able to use the Auto Tree Nav template to help me get started.
The trick is going to be how to omit certain window paths, based on the current user’s roles.
[quote=“iampatrick”]Chris, thanks for the suggestion. I may be able to use the Auto Tree Nav template to help me get started.
The trick is going to be how to omit certain window paths, based on the current user’s roles.[/quote]
store it in the database. have an id for each window path, and then have a separate table in the database that uses that pathid and maps it to a role/roles. then when the user logs in check their role and run a query and or scripting that builds the dataset used by the tree component.
you could add additional custom tables to the template…
Like AdminList, ManagerList, etc…
Then just modify the code a little to include those windows in the skip list…
# dynamically create the set of windows. if event.propertyName == "componentRunning": # get what we already know header = ["windowPath","path","text","icon","background","foreground","tooltip","border","selectedText","selectedIcon","selectedBackground","selectedForeground","selectedTooltip","selectedBorder"] icon = "Builtin/icons/16/document.png" background = "color(255,255,255,255)" foreground = "color(0,0,0,255)" tooltip = "" border = "" selectedIcon = "Builtin/icons/16/document.png" selectedBackground = "color(250,214,138,255)" selectedForeground = "color(0,0,0,255)" selectedTooltip = "" selectedBorder = "" data =  # get the window paths for all windows in the project projectWindows = system.gui.getWindowNames() # set up a list of windows to skip skipList =  skipDataset = system.dataset.toPyDataSet(event.source.parent.skipList) for row in skipDataset: skipList.append(row) if "Administrator" not in system.security.getRoles(): adminDataset = system.dataset.toPyDataSet(event.source.parent.adminList) for row in adminDataset: skipList.append(row) if "Manager" not in system.security.getRoles(): managerDataset = system.dataset.toPyDataSet(event.source.parent.managerList) for row in managerDataset: skipList.append(row) # loop through and add the windows for projectWindow in projectWindows: # seperate the path from the window name windowPath = projectWindow # split the path on the last / index = projectWindow.rfind("/") if index == -1: path = "" text = projectWindow else: path = projectWindow[:index] text = projectWindow[index+1:] # skip the windows in the skip list # skip the folder if there's a / at the end if not (projectWindow in skipList or path+"/" in skipList): # append to the final data set data.append([windowPath,path,text,icon,background,foreground,tooltip,border,text,selectedIcon,selectedBackground,selectedForeground,selectedTooltip,selectedBorder]) # push data to the tree view component event.source.data = system.dataset.toDataSet(header, data)
Hope that helps.
I was able to get this to work for me.