Skip to content

PHP: API

Kevin Van Lierde edited this page Jan 29, 2019 · 2 revisions

GS UserMgr includes 3 libraries (UserManager, UserGroup, User), which can be used to get/ manipulate data.
The fetch methods of UserGroup and User return an array with the XML files properties as keys.
The create methods create an instance of the UserGroup/ User class for data manipulation.
The store methods store UserGroup/ User instances' data as XML.

Fetching user data

Users can be fetched by their login name (= the name of the XML file without the .xml extension).

$current_user_data = User::fetch($USR);
$current_user_data['PWD']; // gets the password of the current user

Creating and registering a user instance in the UserManager

Building on the previous example:

$current_user = User::create($current_user_data);
$usermgr = usermgr();
$usermgr->register('users', $current_user);

Fetching group data

Groups can be fetched by their group name (= the name of the XML file without the .xml extension).

$publisher_group_data = UserGroup::fetch('publisher');
$publisher_group_data['grant']; // gets all permissions in the XML <grant> node of the group file

Creating and registering a group instance in the UserManager

Building on the previous example:

$publisher_group = UserGroup::create($publisher_group_data);
$usermgr = usermgr();
$usermgr->register('groups', $publisher_group);