Name Last Update
assets Loading commit data...
components Loading commit data...
controllers Loading commit data...
data Loading commit data...
messages/ru Loading commit data...
models Loading commit data...
views Loading commit data... Loading commit data...
UserAdminModule.php Loading commit data...

UserAdmin module

Helps manage users, they roles and allowed tasks.


user list user task details user details

Requriements: Twitter bootstrap 2.+


1) Extract and place

Probably you have folder in lowercase useradmin. Change it to UserAdmin And place it in '/modules/'

2) Database

Import "UserAdmin/data/user_admin.sql"

3) Config file


You can also set cache expiration time (default is 3600)

       'UserAdmin' => array(
               'cache_time' => 3600,

4) Extending base Controller

Extend your base "Controller" with "UAccessController"

class Controller extends UAccessController

4) Changing layout

In "UserAdmin/components/AdminDefaultController" change "public $layout" to your layout

5) Links for CMenu

//=========== Main controllers ===========

array('label'=>"Users", 'url'=>array('/UserAdmin/user/admin'), 'visible'=>User::checkTask('userAdmin')),
array('label'=>"Roles", 'url'=>array('/UserAdmin/userRole/admin'), 'visible'=>User::checkTask('userRoleAdmin')),
array('label'=>"Tasks", 'url'=>array('/UserAdmin/userTask/admin'), 'visible'=>User::checkRole('isSuperAdmin')),

//=========== Login, logout, registration, profile ===========

array('label'=>"Login", 'url'=>array('/UserAdmin/auth/login'), 'visible'=>!User::checkRole('isGuest')),
array('label'=>"Logout", 'url'=>array('/UserAdmin/auth/logout')),
array('label'=>"Registration", 'url'=>array('/UserAdmin/auth/registration'), 'visible'=>!User::checkRole('isGuest')),
array('label'=>"Profile", 'url'=>array('/UserAdmin/profile/personal'), 'visible'=>(!User::checkRole('isGuest') AND User::checkTask('personalProfileAccess'))),

6) If you want to enable registration

Comment or delete return false in 'UserAdmin/controllers/AuthController' in actionRegistration (line 69)


To login use: superadmin/superadmin or admin/admin

Additional features

1) In order to make All controller actions available for everyone, add property

public $freeAccess = true;

2) In order to make only some of the controller actions available for everyone, add property

public $freeAccessActions = array('index', 'update', 'view');

3) If your controller extends some other controller and you want to set rules for parent controller actions, you can add this property to you parent controller so all this actions will be availiable for moderation in child controllers or add it to the child controller, so it will be availiable for moderation only there

public $moderatedActions = array('index', 'update', 'view');

4) To check user's role, use User::checkRole($roles, $superAdminHasAccess = true)

User::checkRole(array('reader', 'moderator', 'player'));  // You can specify array of roles

5) To check user's tasks, use User::checkTask($task, $superAdminHasAccess = true)


6) You can set backend home page for every role (except superadmin, since it's not actually a role). User with this role will be redirected there after login or registration

7) To get current user model


8) To get array of user models for specified role


9) To get current user backend home page


10) To get active users use scope active()


Little candy in the end

There is a nice template controller AdminDefaultController in the 'UserAdmin/components'.