Пример #1
0
 static function getRoles()
 {
     if (self::$_aUserRoles === FALSE && isset(Yii::app()->getModule('user')->user()->id)) {
         self::$_aUserRoles = Rights::getAssignedRoles(Yii::app()->getModule('user')->user()->id);
     }
     return self::$_aUserRoles;
 }
Пример #2
0
 /**
  * Change password
  */
 public function actionChangepassword()
 {
     $model = new UserChangePassword();
     if (Yii::app()->user->id) {
         // ajax validator
         if (isset($_POST['ajax']) && $_POST['ajax'] === 'changepassword-form') {
             echo UActiveForm::validate($model);
             Yii::app()->end();
         }
         if (isset($_POST['UserChangePassword'])) {
             $model->attributes = $_POST['UserChangePassword'];
             if ($model->validate()) {
                 $new_password = User::model()->notsafe()->findbyPk(Yii::app()->user->id);
                 $new_password->password = UserModule::encrypting($model->password);
                 $new_password->activkey = UserModule::encrypting(microtime() . $model->password);
                 $new_password->save();
                 Yii::app()->user->setFlash('profileMessage', UserModule::t("New password is saved."));
                 $this->redirect(array("profile"));
             }
         }
         $view = 'changepassword';
         if (Yii::app()->getModule('user')->view) {
             $alt_view = Yii::app()->getModule('user')->view . '.profile.' . $view;
             if (is_readable(Yii::getPathOfAlias($alt_view) . '.php')) {
                 $view = $alt_view;
                 $this->layout = Yii::app()->getModule('user')->layout;
             }
         }
         if (DbrUser::isCustomerOfficeUser()) {
             $this->contentHeader = UserModule::t('Change password');
             $this->layout = '//layouts/ace';
             $this->render('ace_changepassword', array('model' => $model));
         } else {
             $this->render($view, array('model' => $model));
         }
     }
 }