Interface to manage rights of a LiveUser group

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

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

There are a few methods for group rights management:

Prerequisite: you need to set the permission management level to, at least, «Medium» in the configuration file.

Download «conf_admin.php»

We'll start by adding a user to a group, then deleting the user from the group

Here is the full example :

Download «LUA_test_groupright.php»

Add a Right to a Group (grantGroupRight)

function grantGroupRight($data)

Parameter(s)

This method takes 1 parameter:

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

You must provide the group id and the right id. Unless you provide another value, a right level of 3 will be set by default.

Return value

This method returns:

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

Example

To grant a right to a group:

Code
   ...
    $data = array('right_id' => 5,
                  'group_id' => 6
                 );
    $added = $LUA->perm->grantGroupRight($data);
   ...

This gives the following result:

Add a group

Update a Right granted to a Group (updateGroupRight)

function updateGroupRight($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

Return value

This method returns:

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

Example

To update a right granted to a group:

Code
   ...
    $new_right_level = 1;
    $right_id = 5;
    $group_id = 6;
    $data = array('right_level' => $new_right_level);
    $filters = array('right_id' => $right_id,
                     'group_id' => $group_id);
    $updated = $LUA->perm->updateGroupRight($data, $filters);
   ...

This gives the following result:

Update a group right

Remove a Right granted to a Group (revokeGroupRight)

function removeUserFromGroup($filters)

Parameter(s)

This method takes 1 parameter:

  • an array with key/value to select the record(s) to be deleted.

Attention: if no parameter is passed, all group rights will be removed.

Return value

This method returns:

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

Example

Code
   ...
    $filter = array(
        'group_id' => $group_id
       );
    $removed = $LUA->perm->revokeGroupRight($filter);
   ...

This gives the following result:

Revoke a right granted to group

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
   ...
    $added = $LUA->perm->grantGroupRight($data);
    if ($added == false)
      {
      echo 'Add_groupright: error on line: '.__LINE__;
      print_r($LUA->getErrors());
      }
    else
      {
      echo 'Group with id ' . $data['group_id'];
      echo ' has been granted right id ' . $data['right_id'];
      }
   ...

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