question about Menu and permisions

question about Menu and permisions

Postby mgsoft » Wed Feb 17, 2010 8:24 pm

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
Saludos,

Eduardo
User avatar
mgsoft
 
Posts: 422
Joined: Mon Aug 17, 2009 12:18 pm
Location: España

Re: question about Menu and permisions

Postby James Bott » Thu Feb 18, 2010 2:20 am

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  RUN
Menu oMenu
if user():level > 3
   menuitem...
endif
if user():level > 2
   menuitem...
endif


Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: question about Menu and permisions

Postby anserkk » Thu Feb 18, 2010 6:10 am

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
User avatar
anserkk
 
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: question about Menu and permisions

Postby hmpaquito » Thu Feb 18, 2010 9:51 am

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
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: question about Menu and permisions

Postby James Bott » Thu Feb 18, 2010 11:40 am

¿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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: question about Menu and permisions

Postby mgsoft » Thu Feb 18, 2010 4:53 pm

Thank you very much.

Anserkk, how do you group Menus in xBrowse?.

And how do you set on /off permisions?.

Thanks :D
Saludos,

Eduardo
User avatar
mgsoft
 
Posts: 422
Joined: Mon Aug 17, 2009 12:18 pm
Location: España

Re: question about Menu and permisions

Postby anserkk » Fri Feb 19, 2010 6:32 am

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
User avatar
anserkk
 
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: MaxP and 51 guests