Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Controlling user's access to field level...
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00852741
Message ID:
00852748
Views:
8
Chris,

I would base it off fields in the tables

create table security ( tablename, fieldname, readlevel, writelevel ) and populate this only with fields that need security.

In Form.Init:
...
this.CheckSecurity( this )
...

The method could do something like this:
* CheckSecurity method:
lparameter roObject

for each loObject in roObject.Objects
   if ( pemstatus( loObject, "objects", 5 ) )
      this.CheckSecurity( loObject ) && drill into this container
   else
      if ( pemstatus( loObject, 'controlsource', 5 ) and ! empty( loObject.ControlSource ) )
         select readlevel, writelevel ;
            from security ;
            into cursor thisfield ;
            where tablename = juststem( loObject.ControlSource ) and fieldname = justext( loObject.ControlSource )
         if ( _tally > 0 )
             with loObject
                .Enabled = goUser.nSecurityLevel >= thisfield.ReadLevel
                .Visible = goUser.nSecurityLevel >= thisfield.WriteLevel
             endwith
         endif
      endif
   endif
endfor
It should run fairly fast, it only has to be done once as the form instantiates. You could forego the lookup of security levels by attaching properties to each of your controls and set them in the designer, but that requires changing a lot of classes.

>Thanks David - I guess I will have to pretty every control on every form in the security table - I am just a little worried about the overhead on forms with many controls (most forms with contain a pageframe etc)
>
>Anyway - I will do some testing - it should be OK!
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Reply
Map
View

Click here to load this message in the networking platform