Interface to manage administrators of areas in LiveUser

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:

Prerequisite: you need to set the permission management level to «complex» in the configuration file.

Download «conf_admin.php»

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:

Code
   ...
    $data = array('area_id' => $area_id,
                  'perm_user_id' => $users[0]['perm_user_id']);
    $areaAdminId = $LUA->perm->addAreaAdmin($data);
   ...

This gives the following result:

Add an Area Admin

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

Code
   ...
    $area_id = 5;
    $filter = array('area_id' => $area_id);
    $removeAreaAdmin = $LUA->perm->removeAreaAdmin($filter);
   ...

This gives the following result:

Remove an Area Admin

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

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