Applications Management
The LiveUser_Admin package allows you to manage applications to be used within LiveUser. It provides a series of methods to interact with the «liveuser_applications» table.
The example 1 provided with this PEAR package should help you starting quite quickly.
There are a few methods for applications management:
- addApplication: to add an application to the list of applications
- updateApplication: to modify an application in the list of applications
- removeApplication: to remove an application from the list of applications
- getApplications: to retrieve a list of applications
We'll start by adding an application, then updating it. We can then list all applications in the table before deleting an application
Here is the full example :
Add an Application (addApplication)
function addApplication($data)
Parameter(s)
This method takes 1 parameter:
- an array with a pair key/value of all fields in the «liveuser_applications»
In the easiest way, you may just provide the application name. In this case, the method will automatically allocate an application id (using the «liveuser_applications_seq» table).
Otherwise, you may provide the application name and the application id.
Return value
This method returns:
- «false» in case of error
- the new application id in case of success
Example
To add an application name:
...
$application_name = 'Another application';
$data = array('application_define_name' => $application_name);
$appId = $LUA->perm->addApplication($data);
...
To add an application name and an application id
...
$application_id = 5;
$application_name = 'Another application';
$data = array('application_id' => $application_id,
'application_define_name' => $application_name);
$appId = $LUA->perm->addApplication($data);
...
This gives the following result:

Update an Application (updateApplication)
function updateApplication($data, $filter)
Parameter(s)
This method takes 2 parameters:
- an array with key/value containing the updated values
- an array with key/value to select the record to be updated
Attention: if no parameter is passed, all applications will be modified.
Return value
This method returns:
- «false» in case of error
- «true» otherwise
Example
...
$new_application_name = 'Another application';
$application_id = 5;
$data = array('application_define_name' => $new_application_name);
$filters = array('application_id' => $application_id);
$updateApp = $LUA->perm->updateApplication($data, $filters);
...
This gives the following result:

List Applications (getApplications)
function getApplications($params = array())
Parameter(s)
This method takes 1 parameter, i.e. an array with some possible parameters for the selection:
- «filter»: an array with key/value in order to apply the selection criterion
Return value
This method returns:
- «false» in case of error
- an array with selected data in case of success
Example
Get the list of all applications:
...
$applications = $LUA->perm->getApplications();
...
Get a filtered list of applications:
...
$application_id = 5;
$filter = array('filters' => array('application_id' => $application_id));
$applications = $LUA->perm->getApplications($filter);
...
This gives the following result:

Remove an Application (removeApplication)
function removeApplication($filters)
This method will remove the application and all associated areas.
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 applications will be removed.
Return value
This method returns:
- «false» in case of error
- «true» otherwise
Example
...
$application_id = 5;
$filter = array('application_id' => $application_id);
$removeApp = $LUA->perm->removeApplication($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('application_id' => $application_id,
'application_define_name' => $application_name);
$appId = $LUA->perm->addApplication($data);
if ($appId == false)
{
echo 'Add_app: error on line: '.__LINE__;
print_r($LUA->getErrors());
}
else
{
echo 'Application with id ' . $appId . ' created';
}
...



