/**
  * Creates a new user account.
  */
 public function actionRegister()
 {
     // TRUE if multiples accounts can be created
     if (!Yii::app()->params['multiplesAccounts']) {
         if (AppTools::masterAdmin()) {
             Yii::app()->user->loginRequired();
             Yii::app()->end();
         }
     }
     $register = new RegisterForm();
     // RegisterForm was sent via POST
     if (isset($_POST['RegisterForm'])) {
         // Get attributes from POST to RegisterForm object model
         $register->attributes = $_POST['RegisterForm'];
         // validate if register has all fields required
         if ($register->validate()) {
             // create new user and account, then redirect to signsucess
             if ($register->create()) {
                 if (Yii::app()->params['multiplesAccounts']) {
                     $this->redirect(Yii::app()->controller->createUrl("site/signsucess"));
                 } else {
                     $this->redirect(Yii::app()->controller->createUrl("site/index"));
                 }
             }
         }
     }
     // output register view
     $this->layout = "login";
     $this->render('register', array('model' => $register));
 }