Hi Schmunk,
You make progress I see with P3. For my project unfortunately P3 wasn’t suitable enough yet, but I watch your progress…
In my project like you I try to implement the two modules Rights (Crisu83) and User (mishamx). I came across a problem and perhaps this is also good for you to know. And also perhaps you could give me some feedback about how to solve this, because I think you have more experience.
In the User module, actionEdit in ProfileController calls an method called updateSession expecting to be in the WebUser class.
‘user/profile/edit’:
public function actionEdit()
{
$model = $this->loadUser();
$profile=$model->profile;
// ajax validator
if(isset($_POST['ajax']) && $_POST['ajax']==='profile-form')
{
echo UActiveForm::validate(array($model,$profile));
Yii::app()->end();
}
if(isset($_POST['User']))
{
$model->attributes=$_POST['User'];
$profile->attributes=$_POST['Profile'];
if($model->validate()&&$profile->validate()) {
$model->save();
$profile->save();
Yii::app()->user->updateSession();
Yii::app()->user->setFlash('profileMessage',UserModule::t("Changes are saved."));
$this->redirect(array('/user/profile'));
} else $profile->validate();
}
$this->render('edit',array(
'model'=>$model,
'profile'=>$profile,
));
}
But you use another User class because of the implementation of Rights. Therefore after an update of a user-profile from within the ProfileController (usually accessible for the logged-in user to update his own profile) there will be an Error:
RWebUser and its behaviors do not have a method or closure named "updateSession".
The updateSession() method in the WebUser class in the User module:
public function updateSession() {
$user = Yii::app()->getModule('user')->user($this->id);
$userAttributes = CMap::mergeArray(array(
'email'=>$user->email,
'username'=>$user->username,
'create_at'=>$user->create_at,
'lastvisit_at'=>$user->lastvisit_at,
),$user->profile->getAttributes());
foreach ($userAttributes as $attrName=>$attrValue) {
$this->setState($attrName,$attrValue);
}
}
I think this method is not really necessary… So I commented it out in the ProfileController. When you look at this, what do you think is a good solution? Is this method really needed to function?
Hopefully this helps you also in developing P3.
Write to you later!