Promote a User as an Area Administrator
The LiveUser_Admin package allows you to manage area admins to be used within LiveUser. It provides a series of methods to interact with the «liveuser_area_admin_areas» table.
Refer to the usage of permission types for its use in LiveUser.
The example 1 provided with this PEAR package should help you starting quite quickly.
There are a few methods for areas management:
- addAreaAdmin: to add an area admin to the list of area admins
- removeAreaAdmin: to remove an area admin from the list of area admins
Prerequisite: you need to set the permission management level to «complex» in the configuration file.
We'll start by adding an area admin, then deleting it.
Here is the full example :
Download «LUA_test_area_admin.php»
Add an Area Admin (addAreaAdmin)
function addAreaAdmin($data)
Parameter(s)
This method takes 1 parameter:
- an array with a pair key/value of all fields in the «liveuser_area_admin_areas»
In the easiest way, you may just provide the area name and the application id it is related to. In this case, the method will automatically allocate an area id (using the «liveuser_areas_seq» table).
Otherwise, you may provide the area name, the area id and the application id it is related to.
Return value
This method returns:
- «false» in case of error
- «true» otherwise
Example
To add an area admin:
...
$data = array('area_id' => $area_id,
'perm_user_id' => $users[0]['perm_user_id']);
$areaAdminId = $LUA->perm->addAreaAdmin($data);
...
This gives the following result:

Remove an Area Admin (removeAreaAdmin)
function removeAreaAdmin($filter)
This method will remove the area admin.
Parameter(s)
This method takes 1 parameter:
- an array with key/value to select the record to be deleted.
Attention: if no parameter is passed, all area admins will be removed.
Return value
This method returns:
- «false» in case of error
- «true» otherwise
Example
...
$area_id = 5;
$filter = array('area_id' => $area_id);
$removeAreaAdmin = $LUA->perm->removeAreaAdmin($filter);
...
This gives the following result:

Getting Information on the last Error (getErrors)
function getErrors()
In case a function returns «false», it means that it has encountered a problem. You can get information on this error by calling this method.
Parameter(s)
This method takes no parameter.
Return value
This method returns:
- the error information
Example
...
$data = array('area_id' => $area_id,
'perm_user_id' => $users[0]['perm_user_id']);
$areaAdminId = $LUA->perm->addAreaAdmin($data);
if ($areaAdminId == false)
{
echo 'Add_area_admin: error on line: '.__LINE__;
print_r($LUA->getErrors());
}
else
{
echo 'Area admin created';
}
...



