Database Solutions - Hints & Tips

Tip 32:
$editmode

Using $editmode to assist with form level security

UNIFACE has commands that allow the user to start a particular component in a particular mode - e.g., "edit" for full edit mode, or "display" for display-only mode. One of the problems with these commands is that the mode is set, it cannot be changed until the form is exited and re-started. For example, it may be the case that a user has full access to certain database records, and read-only access to others. This functionality would not be easily available (without exiting and re-starting the form) using the commands listed above.

UNIFACE 7.2.04 offers an additional function to assist with edit modes - $editmode. The synopsis for this command is

$editmode {= edit_type}

where edit_type =

0 - Set the form to "Edit" mode, allowing values to be altered and stored in the database.

1 - Set the form to "Query" mode, allowing values to be altered but not stored.

2 - Set the form to "Display" mode, preventing the user from making any alterations or storing.

In the example listed above, if a record was retrieved from the database for which the user had full access rights, the command "$editmode = 0" would allow the user to amend and store the record. If a record was retrieved for which the user had read-only access, the command "$editmode = 1" would prevent them from storing any changes. It would be possible to use "$editmode = 2", but this would have the effect of preventing the user from clearing the screen.

Using $editmode to assist with form re-use

Many applications use small tables to allow access to "Code" groupings - for example, colours could be stored in a simple database table following the structure

1=Red

2=White

and so on.

Due to the simplistic nature of this table, it is likely that an "index" type form for this table would be similar in nature to a "maintenance" type form - see below for example.

Using $editmode, the same form could be used as both an index by certain users ($editmode = 1, preventing any "stores) and a maintenance form by others ($editmode = 0). It is worth noting that using "$editmode = 1" has a similar (but not identical) effect to making the form type "Limited"

compuware_01.gif (3977 bytes)


Copyright ©2000 OCS Consulting plc

dbs_block_logo.gif (2150 bytes)
Refresh Frames