Yii 1.1: Using rights extension with different table and column name

2 followers

Once you have installed and configured the rights extension in your application, you can change the table name from 'User' to any table name you want and similarly for 'username' column to any other column name.

Let say, we have table named 'Employee' with fields (id, name, email,...) and we want to use 'Employee' table name instead of 'User', 'email' column instead of 'username'.

To do so:

  • First goto the main.php and add the following
'modules' => array(
        ...
        'rights' => array(
            'install' => false,
            'userClass' => 'Employee',
            'userNameColumn' => 'email',
        ),
        ...
    ),
  • Secondly, goto to the /modules/rights/components/RAuthorizer.php and change the following code at line # 300
$superusers[] = $user->name;

with

$superusers[] = $user->email;

By doing so, the rights extension will starting using 'Employee' table instead of 'User' and 'email' fields instead of 'username'.

Total 2 comments

#17486 report it
turi at 2014/06/20 07:49am
@Mat_R

You can modify it anyway you want... the above is an example of using the Employee table instead of User, you can use any table instead of Employee

#17477 report it
Mat_R at 2014/06/18 03:30pm
Others Tables

Can I do it to others tables?

Leave a comment

Please to leave your comment.