public function isGuest($redirectCode = false, $typeAjax = false, $returnAjaxUrl = false, $returnInt = false) { $isGuest = Yii::app()->user->isGuest; if ($returnInt) { return intval($isGuest); } if ($isGuest && $typeAjax) { header('Content-Type: application/json'); if ($returnAjaxUrl) { echo CJSON::encode(array('s' => 0, 'x' => Ini::redirecAuthtUrl($_POST, true))); } else { echo CJSON::encode(array('s' => 0, 'r' => 'You need to login first.')); } Ini::end(); } if ($isGuest) { if ($redirectCode) { Ini::redirecAuthtUrl('http://' . $_SERVER['HTTP_HOST'], $returnRedirectUrl); } } return $isGuest; }