Customer Sub-Module With Same User Management As Main Application

Hello everyone,

I’m have an architectural question. I’m building an order system. There are two main user groups, administrators and customers (users that lay orders). These two groups are very differnet and when looking at the system from the two different groups you would think it is two different systems. However, it is the same system, with the same user management underneath.

The system uses the extensions yii-user together with yii-rights for user management. These two are submodules to the application.

You can see the overall architecture like the main “yii-application” as the administration system and a sub module, called web-order, as the system where customers can lay orders. For the administrative system I don’t really care about the design so using the default html+css for user registration/login/password recovery/activation/etc is fine. However, for customers, that use the web-order module to login I want a different design.

Now, to the question: is there any way I can overide only the view .php-files for the sub module web-order, or do I have to implement the controller with all methods for registration/login/password recovery/activation/etc in the sub module just to get another design?

In an ideal world I guess I want users that go to /web-order/user/login to get the nice design while I don’t have to create a controller ‘user’ with the method ‘login’ inside my module ‘web-order’. So the controller would be the one in the yii-user module, but the view comes from web-order. Is this possible?

Hope you understand what I’m after, please post any question if I’m being vague/unclear.

Thanks in advance!

/Johannes

i would do this way:

design the login & other views user related as ‘customer’ as if there is only one group, other words, take it as default.

in your controllers/beforeAction adding some kind of flag if it’s admin user, then you could easily redirect/render your view accordingly.

You mean change the yii-user module? I generally don’t want to change third-party components. That means that you can’t always take the latest build without re-applying the changes you’ve made.

Or can you do what you suggest without changing the yii-user module?

/J

hmmmm, would a clone of user module for admin be an option?

Thanks for your help but I managed to solve this without duplication of modules or changing the user module a lot.

  1. I created ‘customer’-layouts and put these in the main application (views/layouts/).

  2. I created a base class WebModule that extends CWebModule. In it, I overrode the beforeControllerAction-method, and set the new layouts if it is a customer:




if(Yii::app()->getRequest()->getQuery('isCustomer')) {

	$controller->layout = '//layouts/customer-layout';

}



  1. I let both UserModule and my CustomerModule extend my new WebModule class instead of CWebModule. NOTE: This is the only change to the third-party user module

  2. In my customer module, in it’s Module-file (that extends WebModule), I put the following line in the init-method:




$_GET['isCustomer'] = true;



  1. In my Customer module, I created the controller ‘user’ and put all the methods I need to “override” with new layout for customers. In the methods I just forward to the user module:



public function actionRecovery() {

	$this->forward('/user/recovery');

}


public function actionRegistration() {

	$this->forward('/user/registration');

}


...