10 Replies Latest reply on Jan 24, 2012 1:44 AM by NaturSalus

    Controlling Access to Tab Control

    NaturSalus

      Title

      Controlling Access to Tab Control

      Post

      Hello,

      What I would like to achieve is to control the access to the tabs of a Tab Control object on a layout based on the Privilege Set of the logged user. For example,

      User1 with PrivilegeSet1 would have access to all the tabs (Tab1, Tab2; Tab3 & Tab4) of the Tab Control object placed on Table1_Detail layout based on Table1.

      User2  with PrivilegeSet2 would have access to all the tabs (Tab1, Tab2; Tab3) but Tab4  of the Tab Control object placed on Table1_Detail layout based on Table1.

      Since I can't control the access to the tabs of a Tab Control object directly from the settings of the Privilege Set, I must simulate that "access control" directly from the Tabs themselves through scripting and the Go To Object script step.

      The question is what is the best way to do it?

      I have searched for similar questions asked on this forum but I haven't found them. If this has been asked and answered previously, please direct me to that post.

      Thanks,

       

      natursalus

       

       

       

       

        • 1. Re: Controlling Access to Tab Control
          philmodjunk

          I can conceive of two approaches:

          Design two layouts, one with tab panels 1..3 and one with panels 1..4. Use your scripts and security settings to take a user to the layout appropriate for their priviledge set.

          This can be easier to set up but doubles your work load anytime you have to update the design of this layout.

          Use the OnObjectModify script trigger for the tab control to 1) Identify the front tab panel and 2) check privilege set name to determine whether the user has access privileges for that tab panel. This keeps it all on one layout, but requires a pretty complex script.

          You use LayoutObjectAttributes to detect which panel "isFrontPanel" and this requires a set of If-else If steps to test each panel in turn to find out which one is the front panel.

          You then need to use go to object or go to field to reset the focus on the appropriate tab panel to keep the unauthorized panel from appearing. This can require setting object names on each panel and storing the current panel object name in a global variable so that your script can correctly select the panel that was in front when the user clicked tab 4 when they didn't have access.

          • 2. Re: Controlling Access to Tab Control
            NaturSalus

            Hello Phil,

            I guess, I will go for the first option.

            Thanks for the guidance.

            natursalus

            • 3. Re: Controlling Access to Tab Control
              mgores

              You could conditionally format the 4th tab and make it the same color as the background (i.e. unauthorized users would not even see there was a 4th tab)  then have the script exit out if the user's priveledge does not allow them to view the 4th tab if they do happen to click on the invisible tab.

              • 4. Re: Controlling Access to Tab Control
                NaturSalus

                Hello Mark Gores

                 

                It sounds brilliant! I'll try it.

                As a matter or fact Option A, turned out to bring some disruption in my current setting; not the fault of the approach, just my current layout setting  and the dozen of interconnected scripts.

                Thanks,

                 

                naturslaus

                • 5. Re: Controlling Access to Tab Control
                  philmodjunk

                  Hmmm, but how do you conditionally make that tab panel #4 appear and disappear? You can change fill colors with conditional formats, but not the tab border...

                  • 6. Re: Controlling Access to Tab Control
                    mgores

                    Hmmm thought I had done that before in one of my solutions, trying it on a test solution it is not that easy...... Embarassed

                    Will keep playing and see if I can make it work.  I think when I did it before I had the tab panels set to the background color already and the text label was conditionally formatted.

                    • 7. Re: Controlling Access to Tab Control
                      philmodjunk

                      Which works only if the tab control BORDERS are always transparent or zero width---don't know if that would look right when you want the panels to be visible...

                      • 8. Re: Controlling Access to Tab Control
                        NaturSalus

                        The way I interpreted it was to make invisible all the Tabs Control tabs.

                        Recreate the tabs with buttons and finally apply the conditional formatting.

                        This was described sometime ago http://sixfriedrice.com/wp/tab-controls-without-the-tabs/ 

                         

                        Here again, there is another opportunity for FM Inc to improve FM 11 Pro.

                         

                        natursalus

                        • 9. Re: Controlling Access to Tab Control
                          carlo.m

                          If this helps...

                           

                          I created a solution that was pretty heavily engrained in privileges to different modules, different submodules and then different actions on those (read only or read/write).

                          I wanted exactly what you said: having users only see tabs they have access to. And I figured out a way.

                          What I did is that I set up a table that contained the tab names and the order I wanted them to be sorted in (you could even work out a way to have each user choose the sort order). Then I created a privileges table. On file open a script triggers to check what privileges the user has, what tabs he has access to and populates the global fields that display as the tab names so that the tabs say something. All the tabs have conditional formatting to where if the global field that has that tabs label is empty it appears ass background, if that tab is selected it appears highlighted, or if it is not selected but visible appears in another way.

                          Same script to control traffic on all tab names, the script would exit if that tab is inactive or redirect to another script based on the name of that tag.

                          This is the general idea of what I did...

                          The layout design could accomodate ten modules with 10 submodules in each. So basically, one hundred different layouts that come out of the same top 30 pixles of the screen with the variation of what the tabs say depending on which are activated...

                          • 10. Re: Controlling Access to Tab Control
                            NaturSalus

                            Hello Carlo Martinez,

                            Glad you shared your approach.

                            I am not at that level of mastery yet, but it will be very helpful to the FM community.

                            Thanks,

                            natursalus