Custom redirect

Hi,

I’m creating an app for Facebook and I want to change the way CController::redirect works. In the base controller, I override the redirect method to give my custom definition. It has to serve 2 purpose

  1. When user is in Canvas, it has to redirect to the top of iFrame

  2. When user is in Tab page, it has to inject signed_request in every redirect request

  3. When user is in Website, just perform the default redirect.

I started with this,


public function redirect($url, $terminate = true, $statusCode = 302)

	{

		//@todo troubleshoot later

		if(is_array($url))

		{

			$route	=	isset($url[0]) ? $url[0] : '';

			$url	=	$this->createUrl($route,array_splice($url,1));

		}

					

		if(strpos($url,'/')===0)

			$url=Yii::app()->fb->canvasPage.$url;

		

		//die($url);

			

		if(preg_match('#^https?:\/\/(www|apps|graph)\.facebook\.com(:\d+)?#i', $url))

			echo '<script type="text/javascript">top.location.href = "'.$url.'";</script>';

		else

		{

			$this->widget('application.widgets.FacebookRedirect',

			array(

					'url'	=>	$url,

			));

		}

		

		if($terminate)

			Yii::app()->end();	

	}

The widget is nothing but a html form with signed_request included as hidden form field and form’s action is the redirect url.

still it sucks. Can anyone provide a reliable way to override the redirect and help me accomplish the desired purpose?