rather than building my own action controler and my own view to list my items, I prefer to use the actionAdmin generated by yiic in ItemController and the admin.php view.
Here how I’m doing to restrict it to the user’s items :
/**
* Manages all models.
*/
public function actionAdmin()
{
$model=new item('search');
$model->unsetAttributes(); // clear any default values
// MY MODIFICATION :
$_GET['item']['created_by']= Yii::app()->user->id;
if(isset($_GET['oza_files']))
$model->attributes=$_GET['oza_files'];
$this->render('admin',array(
'model'=>$model,
));
}
there is nothing wrong with that but I would change the search method in my model since thats the method actionAdmin uses to filter data
public function search()
{
...
if (!Yii::app()->user->isGuest)
$criteria->compare('created_by', Yii::app()->user->id);
...
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}