Phundament App Class Reference
  • Package
  • Class
  • Tree

Packages

  • bootstrap
    • widgets
      • input
  • Image
  • None
  • p3admin
  • p3extensions
    • behaviors
    • commands
    • components
    • helpers
    • widgets
  • p3media
    • actions
    • controllers
    • models
  • p3pages
    • models
  • p3widgets
    • components
    • models
  • PHP
  • system
    • db
      • ar
    • gii
    • web
      • auth
      • helpers
      • widgets
  • yiiext
    • widgets
      • fancybox
      • lipsum
  • zii
    • widgets
      • grid

Classes

  • ActivationController
  • AdminController
  • AssignmentController
  • AssignmentForm
  • AuthChildForm
  • AuthItemController
  • AuthItemForm
  • BaseP3Widget
  • BaseP3WidgetMeta
  • BaseP3WidgetTranslation
  • Bootstrap
  • CImageComponent
  • CKEditor
  • CodeProvider
  • DefaultController
  • EChosen
  • EDbMigration
  • EditableField
  • EditableSaver
  • EMigrateCommand
  • ESelect2
  • EUserFlash
  • FullCrudFieldProvider
  • GenerateForm
  • IdentificationColumnValidator
  • InstallController
  • JSONEditorView
  • JuiJSONEditorInput
  • LoginController
  • LogoutController
  • Metadata
  • P3CrudFieldProvider
  • P3MediaController
  • P3MediaMetaController
  • P3MediaSelect
  • P3PageController
  • P3PageMetaController
  • P3PageTranslationController
  • P3Widget
  • P3WidgetController
  • P3WidgetMetaController
  • P3WidgetTranslation
  • P3WidgetTranslationController
  • ProfileController
  • ProfileFieldController
  • RAuthItemBehavior
  • RAuthItemChildDataProvider
  • RAuthItemDataProvider
  • RAuthItemParentDataProvider
  • RAuthorizer
  • RController
  • RDbAuthManager
  • RecoveryController
  • RegistrationController
  • RegistrationForm
  • RGenerator
  • Rights
  • RightsFilter
  • RightsModule
  • RInstaller
  • RPermissionDataProvider
  • RUserBehavior
  • RWebUser
  • UActiveForm
  • UploadHandler
  • UserChangePassword
  • UserController
  • UserIdentity
  • UserLogin
  • UserModule
  • UserRecoveryForm
  • UWdropDownDep
  • UWfile
  • UWjuiAutoComplete
  • UWjuidate
  • UWrelBelongsTo
  • WebUserBehavior
  1 <?php
  2 
  3 class ProfileController extends Controller
  4 {
  5     public $defaultAction = 'profile';
  6     public $layout='//layouts/column2';
  7 
  8     /**
  9      * @var CActiveRecord the currently loaded data model instance.
 10      */
 11     private $_model;
 12     /**
 13      * Shows a particular model.
 14      */
 15     public function actionProfile()
 16     {
 17         $model = $this->loadUser();
 18         $this->render('profile',array(
 19             'model'=>$model,
 20             'profile'=>$model->profile,
 21         ));
 22     }
 23 
 24 
 25     /**
 26      * Updates a particular model.
 27      * If update is successful, the browser will be redirected to the 'view' page.
 28      */
 29     public function actionEdit()
 30     {
 31         $model = $this->loadUser();
 32         $profile=$model->profile;
 33         
 34         // ajax validator
 35         if(isset($_POST['ajax']) && $_POST['ajax']==='profile-form')
 36         {
 37             echo UActiveForm::validate(array($model,$profile));
 38             Yii::app()->end();
 39         }
 40         
 41         if(isset($_POST['User']))
 42         {
 43             $model->attributes=$_POST['User'];
 44             $profile->attributes=$_POST['Profile'];
 45             
 46             if($model->validate()&&$profile->validate()) {
 47                 $model->save();
 48                 $profile->save();
 49                 Yii::app()->user->setFlash('profileMessage',UserModule::t("Changes is saved."));
 50                 $this->redirect(array('/user/profile'));
 51             } else $profile->validate();
 52         }
 53 
 54         $this->render('edit',array(
 55             'model'=>$model,
 56             'profile'=>$profile,
 57         ));
 58     }
 59     
 60     /**
 61      * Change password
 62      */
 63     public function actionChangepassword() {
 64         $model = new UserChangePassword;
 65         if (Yii::app()->user->id) {
 66             
 67             // ajax validator
 68             if(isset($_POST['ajax']) && $_POST['ajax']==='changepassword-form')
 69             {
 70                 echo UActiveForm::validate($model);
 71                 Yii::app()->end();
 72             }
 73             
 74             if(isset($_POST['UserChangePassword'])) {
 75                     $model->attributes=$_POST['UserChangePassword'];
 76                     if($model->validate()) {
 77                         $new_password = User::model()->notsafe()->findbyPk(Yii::app()->user->id);
 78                         $new_password->password = UserModule::encrypting($model->password);
 79                         $new_password->activkey=UserModule::encrypting(microtime().$model->password);
 80                         $new_password->save();
 81                         Yii::app()->user->setFlash('profileMessage',UserModule::t("New password is saved."));
 82                         $this->redirect(array("profile"));
 83                     }
 84             }
 85             $this->render('changepassword',array('model'=>$model));
 86         }
 87     }
 88 
 89     /**
 90      * Returns the data model based on the primary key given in the GET variable.
 91      * If the data model is not found, an HTTP exception will be raised.
 92      * @param integer the primary key value. Defaults to null, meaning using the 'id' GET variable
 93      */
 94     public function loadUser()
 95     {
 96         if($this->_model===null)
 97         {
 98             if(Yii::app()->user->id)
 99                 $this->_model=Yii::app()->controller->module->user();
100             if($this->_model===null)
101                 $this->redirect(Yii::app()->controller->module->loginUrl);
102         }
103         return $this->_model;
104     }
105 }
Phundament App Class Reference API documentation generated by ApiGen 2.8.0