我已经做了很多尝试,查询是在用户模型中执行。我的数据是插入(user,authassignment,authitem,authitemchild)这些表中,但不会在Rights表中插入。
public function afterSave() {
if ($this->isNewRecord) {
$model = User::model()->findByPk($this->id);
echo $role = ucfirst($model->usertype); die;
$authorizer = Yii::app()->getModule("rights")->getAuthorizer();
$authorizer->authManager->assign($role, $this->id);
return parent::afterSave();
}
}