-
Book Overview & Buying
-
Table Of Contents
Yii Application Development Cookbook - Second Edition - Second Edition
RBAC is the most powerful access control method available in Yii. It is described in the guide, but since it is rather complex and powerful, it is not so easy to understand how it actually works without getting under the hood a little.
In this recipe, we will take the roles hierarchy from the definitive guide, import it, and explain what is happening internally.
Create a fresh web application by using yiic webapp.
Create a MySQL database and configure it.
Import SQL from framework/web/auth/schema-mysql.sql.
Configure the authManager component in your protected/config/main.php as follows:
return array(
'components'=>array(
…
'authManager'=>array(
'class'=>'CDbAuthManager',
'connectionID'=>'db',
),
),
…
);Add additional roles to protected/components/UserIdentity.php. The users array should look like the following:
$users=array( // username => password 'demo'=>'demo', 'admin'=>'admin', 'readerA'=>'123', 'authorB'...
Change the font size
Change margin width
Change background colour