i am bit confused with what modules does in yii ??
i need to develop a back end system which has 3 user levels… (admin, user, superAdmin)
my question is, do we need to have separate controllers ? for each user as AdminController, UserController and SuperAdminController inside the normal Controller folder or…
i will have to create separate folders for each user and direct them to there or i will create modules for each user… i am very confused of how to handle this matter…
i am new to yii and have been working on writing php from the scratch… so normally how i do is, inside the website folder… i will have a admin folder (which is the backend) so when a user logs in i will send him there inside admin’s folder…
so i am confused of how to accomplish that task with yii ? is there any inbuilt way or any extension.
please give your suggestions… bit urgent… thanks[/size]
"A module is a self-contained software unit that consists of models, views, controllers and other supporting components. In many aspects, a module resembles to an application. The main difference is that a module cannot be deployed alone and it must reside inside of an application. Users can access the controllers in a module like they do with normal application controllers."
So for your admin area, yeh you can create a module and then you can access the module like this:
index.php?r=admin/controller/action
For the users authorization part, read about the Yii’s RBAC, or can also implement a non-RBAC type authorization system.
Its depend on your site functionality as you want different controller or single controller for task ( functionality ), you can give access to each action/page by access rules as shown below, its in your controller,
public function accessRules()
{
return array(
array('allow', // allow all users to perform 'index' and 'view' actions
'actions'=>array('index','view'),
'users'=>array('*'),
),
array('allow', // allow authenticated user to perform 'create' and 'update' actions
'actions'=>array('create','update'),
'users'=>array('@'),
),
array('allow', // allow admin user to perform 'admin' and 'delete' actions
'actions'=>array('admin','delete'),
'users'=>array('@'),
),
array('deny', // deny all users
'users'=>array('*'),
),
);
}
you can define type of user in globally as Yii::app()->user->role and can use them to set different access in controller.
or
as your functionality you can make admin module and create nested modules inside admin module and you can access them seperately.
so the hierarchy will ?r=admin/customer/customerdetail/admin ( ?r=parentModule/childModule/controller/action )