public function actionUpdate() {
		$model = $this->loadUser();
		$passwordform = new YumUserChangePassword();

		if(isset($_POST['YumUser'])) {
			$model->attributes = $_POST['YumUser'];
			if(Yum::hasModule('role')) {
				Yii::import('application.modules.role.models.*');
				// Assign the roles and belonging Users to the model
				$model->roles = Relation::retrieveValues($_POST);
			}

			if(Yum::hasModule('profile')) {
				$profile = $model->profile;

				if(isset($_POST['YumProfile']) )
					$profile->attributes = $_POST['YumProfile'];
			}

			// Password change is requested ?
			if(isset($_POST['YumUserChangePassword'])
					&& $_POST['YumUserChangePassword']['password'] != '') {
				$passwordform->attributes = $_POST['YumUserChangePassword'];
				if($passwordform->validate())
					$model->setPassword($_POST['YumUserChangePassword']['password']);
			}

			if(!$passwordform->hasErrors() && $model->save()) {
				if(isset($profile)) 
					$profile->save();

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

		$this->render('update', array(
					'model'=>$model,
					'passwordform' =>$passwordform,
					'profile' => isset($profile) ? $profile : false,
					));
	}
 public function actionUpdate($id)
 {
     $user = $this->loadUser($id);
     $profile = false;
     if (Yum::hasModule('profile')) {
         $profile = $user->profile;
     }
     $passwordform = new YumUserChangePassword();
     if (isset($_POST['YumUser'])) {
         $user->attributes = $_POST['YumUser'];
         $user->validate();
         if ($profile && isset($_POST['YumProfile'])) {
             $profile->attributes = $_POST['YumProfile'];
         }
         if (!$user->hasErrors()) {
             if (isset($_POST['YumUser']['roles'])) {
                 $user->syncRoles($_POST['YumUser']['roles']);
             } else {
                 $user->syncRoles();
             }
             // Password change is requested ?
             if (isset($_POST['YumUserChangePassword']) && $_POST['YumUserChangePassword']['password'] != '') {
                 $passwordform->attributes = $_POST['YumUserChangePassword'];
                 if ($passwordform->validate()) {
                     $user->setPassword($_POST['YumUserChangePassword']['password']);
                 }
             }
             if (!$passwordform->hasErrors() && $user->save()) {
                 if (isset($profile) && $profile) {
                     $profile->save();
                 }
                 $this->redirect(array('admin'));
             }
         }
     }
     $this->render('update', array('user' => $user, 'passwordform' => $passwordform, 'profile' => $profile));
 }