Interface to manage LiveUser implied rights

The LiveUser_Admin package allows you to manage implied rights to be used within LiveUser. It provides a series of methods to interact with the «liveuser_right_implied» table.

The example 1 provided with this PEAR package should help you starting quite quickly.

There are a few methods for implied rights management:

  • implyRight: to add an implied right to the list of implied rights
  • unimplyRight: to remove an implied right from the list of implied rights

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

Download «conf_admin.php»

We'll start by adding a right an implied right, then deleting it.

Here is the full example :

Download «LUA_test_implyright.php»


Add an implied Right (implyRight)

function implyRight($data)

Make sure the right_id and the imply_right_id are defined in the «liveuser_rights» table before adding the implied right.

Parameter(s)

This method takes 1 parameter:

  • an array with a pair key/value of all fields in the «liveuser_right_implied»

Return value

This method returns:

  • «false» in case of error
  • «true» otherwise

Example

To add an implied right:

Code
   ...
    $right_id = 5;
    $implied_right_id = 1;
    $data = array('right_id' => $right_id,
                  'implied_right_id' => $implied_right_id);
    $impliedright = $LUA->perm->implyRight($data);
   ...

This gives the following result:

Add an implied Right

Remove an implied Right (unimplyRight)

function unimplyRight($filters, $update = true)

This method will remove an implied right.

Parameter(s)

This method takes 2 parameters:

  • an array with key/value to select the record to be deleted.
  • a boolean:
    • if set to true, the 'has_implied' field in the «liveuser_rights» table for this right_id will be set to 0 if this right has no more implied rights.
    • if set to no, nothing will be done

Note: the $update boolean should be set to «true». The «false» value is intended for internal use.

Return value

This method returns:

  • «false» in case of error
  • «true» otherwise

Example

Code
   ...
    $right_id = 5;
    $implied_right_id = 1;
    $update_imply_status = false;
    $filter = array('right_id' => $right_id
                    'implied_right_id' => $implied_right_id
                   );
    $deleteImpliedRight = $LUA->perm->unimplyRight($filter, $update_imply_status);
   ...

This gives the following result:

Remove an implied Right

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
   ...
    $right_id = 5;
    $implied_right_id = 1;
    $data = array('right_id' => $right_id,
                  'implied_right_id' => $implied_right_id);
    $impliedright = $LUA->perm->implyRight($data);

    if ($impliedright === false)
      {
      echo 'Add_impliedright: error on line: '.__LINE__;
      print_r($LUA->getErrors());
      }
    else
      {
      echo 'Implied right 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