$This->Controller->Id Not Picking Up The Right Controller

I hope i can make this clear. I have this model with a defaultScope()




	public function defaultScope()

	{

		return array(

			'condition'=>'project_id='.Yii::App()->user->projectId 

			.' and tenant_id='.Yii::App()->user->tenantId

		);

	}



But in one circumstance, when i render site/index i need to bypass the projectId condition and fetch all records regardless of projectId. So i modified it as follows:




           if ($this->id =='site')

            {

 		return array(

			'condition'=>'tenant_id='.Yii::App()->user->tenantId

		);


            }

            else

            {

               'condition'=>'project_id='.Yii::App()->user->projectId 

			.' and tenant_id='.Yii::App()->user->tenantId

		);  

            }    



The site controller fetches the records:


	public function actionIndex()

	{

            $projectModel = Project::model()->findAll();

            $deliverableModel = Deliverable::model()->findAll();

           

            $this->render('index',array(

			'projectModel'=>$projectModel,

                        'deliverableModel'=>$deliverableModel,

		));


	}     

it calls the deliverable controller which calls the defaultScope and makes my deliverable.defaultScope if statement return what i am not expecting. So this means i am not specifying the right controller in the defaultScope if statement.

Is there a way i can specify (pseudocode)

When deliverable model is rendered, If call comes from site controller, then do this, else do that.

Any help would be quite appreciated.

Create another scope without projectID filter, and use it for the site controller.

I think that model should not be dependent on controllers.

you can create a separate scope for that


public function scopes() {

        return array(

            'all'=>array(

                'condition'=>'your condition',

            ),

        );


    }