Saas Aplication inYii

I started developing a saas application by refering to following link on Yii:

http://www.yiiframework.com/wiki/603/a-multi-tenant-strategy-using-yii-and-mysql

When I tried implementing it it gives me an error message: CWebUser and its behaviors do not have a method or closure named "isUserTenantAdmin".

I want to know what code might been written in WebUser.php where these two functions are defined isUserTenantAdmin() , isUserTenantStaff() function.

It would be very convinient if I get the webuser.php file along with the above mentioned function definitions

And also once the above mentioned steps are followed, what page we have to run??

I want to know the start process after its implementation beginning from the login/registration.

You need to make sure that Yii::app()->user will return WebUser and not CWebUser, since the two function you mention are stored in the WebUser.

Change your configuration file and make sure the ‘class’ key refers to the right file:




'components'=>array(

   ...

   'user'=>array(

      'class'=>'application.components.WebUser',

      ...

   ),

   ...






Also initially the tbl_user table is empty, now when I try to create a new user it shows the following error message:

"Fatal error: Call to a member function isadmin() on a non-object in C:\xampp\htdocs\saasdemo\protected\components\WebUser.php on line 87"

I am providing you with the controller code a

UserController.php:

public function actionCreate()

{	


	$model = (Yii::app()->user->isUserTenantAdmin()) ? new VUser : new TUser;


	


    if(Yii::app()->user->isUserTenantAdmin() && isset($_POST['VUser'])) {


        $postVars = $_POST['VUser'];


    }


    elseif (Yii::app()->user->isUserAppStaff() && isset($_POST['TUser'])) {


        $postVars = $_POST['TUser'];


    }


	


	if(isset($postVars)) {


        $model->attributes = $postVars;


        if(Yii::app()->user->isUserTenantAdmin()) {


            // force new user to belong to same tenant as its admin; the db trigger will insert the MySQL username


            $model->tenant_id = VUser::model()->findByPk(Yii::app()->user->id)->tenant_id;


            $model->tenant_owner = 0; // tenant owner is defined by app staff only


        }


        if ($model->validate()) {


            if(Yii::app()->user->isUserAppStaff()) {


              // force new user to belong to assigned tenant; the listData() in _form.php will insert the tenant_id


              $model->tenant_dbu = TTenant::model()->findByPk($model->tenant_id)->dbu;


            }


            if($model->save(false)) { // already validated


                $this->redirect(array('view','id'=>$model->id));


            }


        }


	}





	$this->render('create',array(


		'model'=>$model,


	));


}

The functionality will be as follows:

  1. create user (This might act as user registration)

  2. Username and password of the created user should be used for login

Suggestions are welcomed…!!