FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour question about Menu and permisions
Posts: 422
Joined: Mon Aug 17, 2009 12:18 PM
question about Menu and permisions
Posted: Wed Feb 17, 2010 08: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
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: question about Menu and permisions
Posted: Thu Feb 18, 2010 02: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 (fw): Select all Collapse
Menu oMenu
if user():level > 3
   menuitem...
endif
if user():level > 2
   menuitem...
endif


Regards,
James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: question about Menu and permisions
Posted: Thu Feb 18, 2010 06: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


Regards
Anser
Posts: 1515
Joined: Thu Oct 30, 2008 02:37 PM
Re: question about Menu and permisions
Posted: Thu Feb 18, 2010 09: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!!! :-)
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: question about Menu and permisions
Posted: 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
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 422
Joined: Mon Aug 17, 2009 12:18 PM
Re: question about Menu and permisions
Posted: Thu Feb 18, 2010 04: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
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: question about Menu and permisions
Posted: Fri Feb 19, 2010 06: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

Continue the discussion