Interface to manage LiveUser applications

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:

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 :

Download «LUA_test_app.php»

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:

Code
   ...
    $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

Code
   ...
    $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:

Add an Application

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

Code
   ...
    $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:

Update an Application

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:

Code
   ...
    $applications = $LUA->perm->getApplications();
   ...

Get a filtered list of applications:

Code
   ...
    $application_id = 5;
    $filter = array('filters' => array('application_id' => $application_id));
    $applications = $LUA->perm->getApplications($filter);
   ...

This gives the following result:

Get an Application

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

Code
   ...
    $application_id = 5;
    $filter = array('application_id' => $application_id);
    $removeApp = $LUA->perm->removeApplication($filter);
   ...

This gives the following result:

Remove an Application

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

Code
   ...
    $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';
      }
   ...

Get in touch!

We'd love to hear from you, what you think about this page or what we can do for you.

Contact Us

View this page with IE8+, Mozilla Firefox, Safari, Chrome and Mobiles

Last modificaton on 21 May 2015 by St├ęphane Van Nerom

© 2006-2014 - GVN - All rights reserved
v2.0.14