Hello.
I trying to write filter for "updateOwnPost". I know that easy to do it by RBAC, but…
PostController.php
public function filters()
{
return array(
'updateOwn + update', // Apply this filter only for the update action
'accessControl', // perform access control for CRUD operations
);
}
.......
.....
public function filterUpdateOwn($filterChain)
{
$id = ( !empty($_GET['Post']) ? (int) $_GET['Post'] : 0);
$Model = Post::model()->findByPk($id);
if( Yii::app()->user->getId() == $Model->author_id ) {
$filterChain->removeAt(1);
}
$filterChain->run();
}
Looks like everything’s good. But it doesn’t work.
Help please. Where i’m wrong ?