Hello.
I have problem with passing $id to function loadModel($id), which is executed inside my own filter "filterViewOwn". I have error: Missing argument 1 for PostController::loadModel(). Does anyone can help me? How can i pass this $id? Thanks, greetings.
public function filters()
{
return array(
'viewOwn + view',
'rights',
);
}
public function filterViewOwn($filterChain)
{
$post=$this->loadModel();
// Remove the 'rights' filter if the user is updating an own post
// and has the permission to do so.
if(Yii::app()->user->checkAccess('PostViewOwn', array('userid'=>$post->author_id)))
$filterChain->removeAt(1);
$filterChain->run();
}
public function loadModel($id)
{
$model=Post::model()->findByPk($id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}