public function init()
    {
        //user model required
        if(!Yii::app()->hasModule('user')){
            return false;
        }
        
        if(!Yii::app()->getModule('user')->user()){
            return false;
        }        
        // parsing needed if urlFormat 'path'
        Yii::app()->urlManager->parseUrl(Yii::app()->getRequest());

		// 1. get language preference
		$preferred = null;
		if (isset($_GET[$this->data_key]) && preg_match('/^\d+$/',$_GET[$this->data_key])) {

			// use company from URL
			$preferred = $_GET[$this->data_key];

            //validate new comapny
            if(!$this->isValidUserCompany($preferred)){
                throw new CHttpException(404, "Company '{$_GET[$this->data_key ]}' is not available.");
            }

            //set new company as active
            $this->_setActiveCompany($preferred);

            return TRUE;

		} 
        
        if ($this->getActiveCompany()) {

			// use active company from profile.ccmp_id
			$preferred = $this->getActiveCompany();
            if($this->isValidUserCompany($preferred)){
                $this->_setActiveCompany($preferred);
                return TRUE;
            }
    	}

        //get first user company
        $a = $this->getClientCompanies();
        if(empty($a)){
            throw new CHttpException(404, "For user companies are not available.");
        }

        //set new company as active
        $this->_setActiveCompany($a[0]['ccmp_id']);

	}