Page 1 of 1

question about Menu and permisions

PostPosted: Wed Feb 17, 2010 8:24 pm
by mgsoft
Hi

I would like to introduce a permission´s control for users in the menu´s option.

¿Is there a way to obtain the Array with all the items of the Menu?.

My Menu is like this:

MENU oMenu

MENUITEM "&Ficheros"
MENU

MENUITEM "&Auxiliares"
MENU

MENUITEM OemToAnsi( "C¢digos P&ostales" ) ;
RESOURCE "MNUPOSTAL" ;
ACTION Postal() ;
MESSAGE OemToAnsi( "Mantenimiento de C¢digos Postales" )

MENUITEM "P&rovincias" ;
RESOURCE "MNUPROVINCIAS" ;
ACTION Provincias() ;
MESSAGE "Mantenimiento de Provincias"

MENUITEM "&Zonas" ;
RESOURCE "MNUZONAS" ;
ACTION Zonas() ;
MESSAGE OemToAnsi( "Mantenimiento de Zonas de facturaci¢n" )


Thanks a lot!!! :D

Re: question about Menu and permisions

PostPosted: Thu Feb 18, 2010 2:20 am
by James Bott
I only define menu items that the user has access to. I think this is better than disabling menu items. When menu items are disabled then the user wonders why, or if they know why then it is kind of an insult.

So, I have a set/get function that stores a copy of the user object. Then you can retrieve the user object anywhere in the program without using a public.

Note that user():level is the same as doing oUser:= user(); oUser:level

Code: Select all  Expand view
Menu oMenu
if user():level > 3
   menuitem...
endif
if user():level > 2
   menuitem...
endif


Regards,
James

Re: question about Menu and permisions

PostPosted: Thu Feb 18, 2010 6:10 am
by anserkk
Dear MgSoft,

In my application I am using Menu's based on User's permission. I am using MySQL. I have the following tables

Table Menu (Contains all menu items available in my application)
--------------
Menu ID
Menu Item
Menu Action
Menu BMP REsource Name
Menu Message

Table USers ( All users )
-----------
USer Code
User Name

Table UserMenu ( contain records only for the permitted menu for the users, if no records means, no permission for the user)
User Code
Menu ID

And finally,the administrator user will have a screen interface (screen snapshot given below) where he is able to set menu permission for the application users
Image

Regards
Anser

Re: question about Menu and permisions

PostPosted: Thu Feb 18, 2010 9:51 am
by hmpaquito
mgsoft wrote:Hi

I would like to introduce a permission´s control for users in the menu´s option.

¿Is there a way to obtain the Array with all the items of the Menu?.

My Menu is like this:

MENU oMenu

MENUITEM "&Ficheros"
MENU

MENUITEM "&Auxiliares"
MENU

MENUITEM OemToAnsi( "C¢digos P&ostales" ) ;
RESOURCE "MNUPOSTAL" ;
ACTION Postal() ;
MESSAGE OemToAnsi( "Mantenimiento de C¢digos Postales" )

MENUITEM "P&rovincias" ;
RESOURCE "MNUPROVINCIAS" ;
ACTION Provincias() ;
MESSAGE "Mantenimiento de Provincias"

MENUITEM "&Zonas" ;
RESOURCE "MNUZONAS" ;
ACTION Zonas() ;
MESSAGE OemToAnsi( "Mantenimiento de Zonas de facturaci¢n" )


Thanks a lot!!! :D

Re: question about Menu and permisions

PostPosted: Thu Feb 18, 2010 11:40 am
by James Bott
¿Is there a way to obtain the Array with all the items of the Menu?.


oMenu:aItems() -> returns an array of menu items as objects

James

Re: question about Menu and permisions

PostPosted: Thu Feb 18, 2010 4:53 pm
by mgsoft
Thank you very much.

Anserkk, how do you group Menus in xBrowse?.

And how do you set on /off permisions?.

Thanks :D

Re: question about Menu and permisions

PostPosted: Fri Feb 19, 2010 6:32 am
by anserkk
MgSoft,

Sorry, I forgot to mention about an important column named Parent Menu ID in the Menu Table. This will help me to group the menu's in xBrowse as well as while creating Menu and SubMenu's Objects

Table Menu (Contains all menu items available in my application)
--------------
Menu ID
Menu Item
Menu Action
Menu BMP Resource Name
Menu Message
Parent Menu ID ( This will help me to setup parent child relationships between the Menu Items )

Regards
Anser