Update cookies preferences
Promotic

Preconfiguration "Runtime users management"

Administrative management of users in runtime mode. The users with defined rights are saved into the CSV file and then in the application memory.

This preconfiguration can be activated when creating a new object (e.g. by "New object ..." in the context menu of the object or by pressing the Insert key after selecting the object).
 
This preconfiguration is included in the "/ Panels (PmaPanel) / Others examples" group.
 
This preconfiguration can be created in the PmaFolder, PmaRoot, PmaPanel, PmaWorkspace or PmaPrototype object.

The preconfiguration is created including the panel (object of the PmaPanel type) is functional also as Web panel.

The preconfiguration creates three PmaPanel objects. The main panel is titled "AdminUsers" and has two subobjects:
The "EditUsers" panel represents a Modal window for adding new user or editin an existing one.
The "ChangePass" panel represents a Modal window for changing the password of current user.

All these objects have, on the "Permissions" tab, defined all items for the users from the $ADMIN group. The "AdminUsers" panel serves for loading a table containing a user list and adding/editing them using the function buttons. The CreateView method is used for opening.

The main panel has the following methods:
Crypt - (complementary) for encrypting and decrypting the user login password
GetGroup - (complementary) for loading the list of available user groups
GetUsers - (complementary) for loading the complete list of all users (saved in ini or pra file)
InitUsers - (essential) adds the users saved In the CSV file into the running application
LoadUsers - (essential) loads the array containing all users with user rights from the CSV file
SaveUsers - (essential) saves the array containing all users with user rights into the CSV file
UserAdd - (essential) prepares the array for saving with values updated from the user editing
UserChangePass - (essential) prepares the array for saving with modified value of password for selected user
UserRemove - (essential) prepares the array for saving without the values for deleted user

The basic essential method is InitUsers. It uses the AddUser method in order to add all users saved in the CSV file into the running application. This method is called always when modifications are being made to user list and it also has to be called after the application is launched. Designer methods LoadUsers and SaveUsers serves for loading or for saving all users together with their permissions into the CSV file. (It is possible to modify them in order to allow saving into some database table.) The EncryptText and DecryptText methods are used in the complementary Crypt method where the sSeed variable for encrypting and decrypting the login password can be changed.

The main panel contains the PmgWTable object and some PmgButton buttons. In the onStart event of the table, there is a script used for filling in the table with the list of users gathered from the CSV file. The script in the onCellClicked event allows to select a row. In the onCellEditRequested event, a new EditUsers window is opened for editing the selected user. Buttons of the PmgButton type contain the a script in the onButtonUp event, that executes the desired action.

The "EditUsers" panel is opened in the onCellEditRequested event of the table or from buttons Add or Edit. The panel itself contains PmgWEdit, PmgString, PmgButton and PmgWTable objects. In the onStart event of the table, each objects is filled with the data of the edited user. These can be edited as needed and the confirmed and saved by the "OK" button.

The ChangePass panel is opened from the main panel by the "Change password" button. The panel contains the PmgWEdit, PmgString and PmgButton objects. In the onStart event of the PmgButton object the original user login data is saved into the hidden Pmg objects. After the new user login data is entered and the OK pressed, the script compares the data and saves it.
These configurators can be set before the preconfiguration is created:
The name of created objectName of the object created in the Pma object tree.
The maximum name length is 30 characters.
This is a system name, so it must contain only alphanumeric and must not contain any diacritics (i.e. national dependent characters), empty string, spaces and first character must not be a number.
Default: "AdminUsers"
PermissionsOn this tab permissions of the object are defined. See the "Permission" tab of the PmaObject object.
Member of logical groupsThe list of the logical groups identifiers (the comma ',' is the separator), the object belongs into (it is a group member), see the "Logical groups" configuration window.
The logical group selection can be done in the "Member of logical groups" window.
After the preconfiguration is created, the "PmaObject > Object > Member of logical groups" configurator will be set to this value.
File name for saving the user permissionsThe file name for saving the users and their user rights (default) users
Password encryption stringstring, for example "xyz" is used as a seed for the EncryptText and DecryptText methods for crypting the user password.
Enable as Web componentSpecifies whether this object has to be registered as a Web server component
After the preconfiguration is created, the "PmaPanel > Web server > Enable as Web component" configurator will be set to this value.
Example1:
Example of calling the "InitUsers" method at application launch. The script must be placed into the onAppStartEnd event of the PmaRoot object.
pMe.Pm("AdminUsers").Methods.InitUsers
Example2:
Example of opening the AdminUsers panel in the onButtonUp event of the PmgButton object located in another panel. (The panel will be opened only by a user that is logged in and belonging to the $ADMIN group).
JavaScriptVBScriptSelect and copy to clipboard

var oCreator = Pm.CreateView(null, "/AdminUsers", "", "target:_blank;");
oCreator.Open();

History:
Pm8.00.03: Created
PROMOTIC 9.0.31 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r.o.