Example #1
0
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     // renders the view file 'protected/views/site/index.php'
     // using the default layout 'protected/views/layouts/main.php'
     //$this->render('index');
     if (!Yii::app()->user->isGuest && !User::checkRole('isSuperAdmin')) {
         if (!empty(User::getCurrentUserHomePage())) {
             $currentUserHomePage = Yii::app()->request->baseUrl . "/index.php/" . User::getCurrentUserHomePage();
         } else {
             $currentUserHomePage = Yii::app()->request->baseUrl . "/index.php/UserAdmin/user/admin";
         }
     } else {
         $currentUserHomePage = Yii::app()->request->baseUrl . "/index.php/UserAdmin/user/admin";
     }
     $this->redirect($currentUserHomePage);
 }
Example #2
0
 /**
  * actionRegistration 
  */
 public function actionRegistration()
 {
     // If you want use this registration page, just delete "return false"
     return false;
     if (!Yii::app()->user->isGuest) {
         $this->redirect(Yii::app()->homeUrl);
     }
     $this->layout = '//layouts/main';
     Yii::import('UserAdmin.models.forms.*');
     $model = new URegistrationForm();
     if (isset($_POST['URegistrationForm'])) {
         $model->attributes = $_POST['URegistrationForm'];
         $model->active = 1;
         $model->is_superadmin = 0;
         if ($model->save()) {
             //=========== Set role ===========
             /*
                                             $roleCode = 'client'; // You should have role with this code
             
                                             $userHasUserRole = new UserHasUserRole;
                                             $userHasUserRole->user_id = $model->id;
                                             $userHasUserRole->user_role_code = $roleCode;
                                             $userHasUserRole->save(false);
             */
             //----------- Set role -----------
             // Authorize freshman
             $model->auth();
             // If this user have role and role have "homePage", then
             // we redirect him there, otherwise redirect to main page
             $homePage = User::getCurrentUserHomePage();
             $redirect = $homePage ? $homePage : Yii::app()->homeUrl;
             $this->redirect($redirect);
         }
     }
     $this->render('registration', compact('model'));
 }