The z4m_userlimits module is useful to limit the number of users declared in a ZnetDK 4 Mobile application.
In addition, the declaration of users with full menu access can be forbidden.
Finally, a monitoring panel can be displayed on the home view to visualize the current number of user accounts compared to the maximum user accounts allowed.
This module is published under the version 3 of GPL General Public Licence.
- ZnetDK 4 Mobile version 3.0 or higher,
- PHP version 7.4 or higher.
- Add a new subdirectory named
z4m_userlimits
within the./engine/modules/
subdirectory of your ZnetDK 4 Mobile starter App, - Copy module's code in the new
./engine/modules/z4m_userlimits/
subdirectory, or from your IDE, pull the code from this module's GitHub repository.
To configure the maximum number of user accounts, add a definition of the MOD_Z4M_USERLIMITS_MAX_USER_ACCOUNTS
PHP constant in the config.php
script of the application.
For example:
// Maximum of 10 user accounts
define('MOD_Z4M_USERLIMITS_MAX_USER_ACCOUNTS', 10);
To exclude one or several login names to the maximum user accounts calculation, add a definition of the MOD_Z4M_USERLIMITS_UNCOUNTED_USER_ACCOUNTS
PHP constant in the config.php
script of the application.
// Two user accounts are uncounted
define('MOD_Z4M_USERLIMITS_UNCOUNTED_USER_ACCOUNTS', ['helvin_c', 'joe_logan']);
To forbid declaration of user accounts with full menu access except for the user whose login name is superuser
, add a definition of the MOD_Z4M_USERLIMITS_FULL_MENU_ACCESS_RESTRICTION
PHP constant in the config.php
script of the application as shown below.
For example:
// Only user whose login name is superuser can have full menu access.
define('MOD_Z4M_USERLIMITS_FULL_MENU_ACCESS_RESTRICTION', ['superuser']);
In the case you declare users via the ZnetDK 4 Mobile \User
class, you can check before adding a new user if the maximum number of user accounts is reached or not by calling the z4m_userlimits\mod\UserLimits::isMaxUserAccountReached()
method.
For example:
if (z4m_userlimits\mod\UserLimits::isMaxUserAccountReached()) {
return FALSE; // Max user accounts is reached.
}
This module is translated in French, English and Spanish languages.
To translate this module in another language or change the standard translations:
- Copy in the clipboard the PHP constants declared within the
locale_en.php
script of the module, - Paste them from the clipboard within the
locale.php
script of your application, - Finally, translate each text associated with these PHP constants into your own language.
See CHANGELOG.md file.
Your contribution to the ZnetDK 4 Mobile project is welcome. Please refer to the CONTRIBUTING.md file.