<commit_before><?php
/**
 * _CController class file.
 * Add and redefine controller methods of Yii core class CController.
 * Main initialization - it's run before everything else.
 */
class _CController extends CController
{
    /**
     * @var object instance of {@link MVariable}
     * MVariable is a storage of variables to share across all classes.
     * access it using Yii::app()->controller->var (or $this->var in the views).
     */
    public $var;

    /**
     * @var int default page sizes
     */
    const LIST_PAGE_SIZE=10;
    const GRID_PAGE_SIZE=50;

    /**
     * This is where the system is being initialized from.
     */
    public function init()
    {
        // Yii initialization is a must
        parent::init();
        // universal storage 
        $this->var=new MVariable;
        // call our initialization class
        W3Init::controller();
        // set user preferences (interface, language, and so on)
        if(!Yii::app()->user->isGuest)
        {
            if(isset(Yii::app()->user->interface) && !empty(Yii::app()->user->interface))
                // set user preferred interface
                W3::setInterface(Yii::app()->user->interface);
            if(isset(Yii::app()->user->language) && !empty(Yii::app()->user->language))
                // set user preferred language
                W3::setLanguage(Yii::app()->user->language);
        }
        // parameters were loaded before language was set, now it needs to be translated
        MParams::i18n();
    }

    /**
     * Returns the URL where to go now to.
     * @return array action route
     */
    public function getGotoUrl()
    {
        $controller=$this->id;
        $action=$this->action->id;
        $defaultUrl=array('user/show');
        $controllerUrl=array($controller.'/');
        // return url based on the current controller and the action being executed
        if($controller==='site' && $action==='index')
            $retval=Yii::app()->user->isGuest ? Yii::app()->user->loginUrl : $defaultUrl;
        else if($controller==='company' && $action==='grid')
            $retval=$this->_getGotoUrl($defaultUrl);
        else if($controller==='company' && $action==='show')
        {
            if(!Yii::app()->user->isGuest)
                $retval=$controllerUrl;
            else
                $retval=$this->_getGotoUrl($defaultUrl);
        }
        else if($controller==='companyPayment' && $action==='show')
        {
            if(!Yii::app()->user->isGuest)
                $retval=$controllerUrl;
            else
                $retval=$this->_getGotoUrl($defaultUrl);
        }
        else if($controller==='expense' && $action==='delete')
            $retval=$controllerUrl;
        else if($controller==='expense' && $action==='show')
        {
            if(!Yii::app()->user->isGuest)
                $retval=$controllerUrl;
            else
                $retval=$this->_getGotoUrl($defaultUrl);
        }
        else if($controller==='expense' && $action==='update')
            $retval=$controllerUrl;
        else if($controller==='invoice' && $action==='create')
            $retval=$controllerUrl;
        else if($controller==='invoice' && $action==='show')
        {
            if(!Yii::app()->user->isGuest)
                $retval=$controllerUrl;
            else
                $retval=$this->_getGotoUrl($defaultUrl);
        }
        else if($controller==='invoice' && $action==='update')
            $retval=$controllerUrl;
        else if($controller==='project' && $action==='grid')
            $retval=$this->_getGotoUrl($defaultUrl);
        else if($controller==='project' && $action==='show')
        {
            if(User::isClient() || User::isConsultant() || User::isManager() || User::isAdministrator())
                $retval=$controllerUrl;
            else
                $retval=$this->_getGotoUrl($defaultUrl);
        }
        else if($controller==='task' && $action==='grid')
            $retval=$this->_getGotoUrl($defaultUrl);
        else if($controller==='task' && $action==='show')
        {
            if(User::isClient() || User::isConsultant() || User::isManager() || User::isAdministrator())
                $retval=$controllerUrl;
            else
                $retval=$this->_getGotoUrl($defaultUrl);
        }
        else if($controller==='time' && $action==='delete')
            $retval=$controllerUrl;
        else if($controller==='time' && $action==='grid')
            $retval=$this->_getGotoUrl($defaultUrl);
        else if($controller==='time' && $action==='show')
        {
            if(User::isClient() || User::isConsultant() || User::isManager() || User::isAdministrator())
                $retval=$controllerUrl;
            else
                $retval=$this->_getGotoUrl($defaultUrl);
        }
        else if($controller==='time' && $action==='update')
            $retval=$controllerUrl;
        else if($controller==='user' && $action==='create')
            $retval=$controllerUrl;
        else if($controller==='user' && $action==='grid')
            $retval=$this->_getGotoUrl($defaultUrl);
        else if($controller==='user' && $action==='login')
        {
            if(Yii::app()->user->returnUrl!==null &&
                // hmm... {@link CWebUser::getReturnUrl} returns scriptUrl if returnUrl is not set
                // hopefully this will be changed in the Yii 1.1 branch
                Yii::app()->user->returnUrl!==Yii::app()->request->scriptUrl
            )
                // got here via {@link CWebUser::loginRequired} - go to the previous url
                $retval=Yii::app()->user->returnUrl;
            else if(User::isConsultant() || User::isManager() || User::isAdministrator())
                // consultant, manager and administrator - go to the task page
                $retval=array('task/');
            else if(User::isClient())
                // client - go to view my company page
                $retval=array('company/show/my');
            else
                $retval=$defaultUrl;
        }
        else if($controller==='user' && $action==='logout')
            $retval=Yii::app()->user->loginUrl;
        else if($controller==='user' && $action==='register')
            $retval=Yii::app()->user->loginUrl;
        else if($controller==='user' && $action==='show')<commit_msg>Fix issue with getGotoUrl() on login.<commit_after><?php
/**
 * _CController class file.
 * Add and redefine controller methods of Yii core class CController.
 * Main initialization - it's run before everything else.
 */
class _CController extends CController
{
    /**
     * @var object instance of {@link MVariable}
     * MVariable is a storage of variables to share across all classes.
     * access it using Yii::app()->controller->var (or $this->var in the views).
     */
    public $var;

    /**
     * @var int default page sizes
     */
    const LIST_PAGE_SIZE=10;
    const GRID_PAGE_SIZE=50;

    /**
     * This is where the system is being initialized from.
     */
    public function init()
    {
        // Yii initialization is a must
        parent::init();
        // universal storage 
        $this->var=new MVariable;
        // call our initialization class
        W3Init::controller();
        // set user preferences (interface, language, and so on)
        if(!Yii::app()->user->isGuest)
        {
            if(isset(Yii::app()->user->interface) && !empty(Yii::app()->user->interface))
                // set user preferred interface
                W3::setInterface(Yii::app()->user->interface);
            if(isset(Yii::app()->user->language) && !empty(Yii::app()->user->language))
                // set user preferred language
                W3::setLanguage(Yii::app()->user->language);
        }
        // parameters were loaded before language was set, now it needs to be translated
        MParams::i18n();
    }

    /**
     * Returns the URL where to go now to.
     * @return array action route
     */
    public function getGotoUrl()
    {
        $controller=$this->id;
        $action=$this->action->id;
        $defaultUrl=array('user/show');
        $controllerUrl=array($controller.'/');
        // return url based on the current controller and the action being executed
        if($controller==='site' && $action==='index')
            $retval=Yii::app()->user->isGuest ? Yii::app()->user->loginUrl : $defaultUrl;
        else if($controller==='company' && $action==='grid')
            $retval=$this->_getGotoUrl($defaultUrl);
        else if($controller==='company' && $action==='show')
        {
            if(!Yii::app()->user->isGuest)
                $retval=$controllerUrl;
            else
                $retval=$this->_getGotoUrl($defaultUrl);
        }
        else if($controller==='companyPayment' && $action==='show')
        {
            if(!Yii::app()->user->isGuest)
                $retval=$controllerUrl;
            else
                $retval=$this->_getGotoUrl($defaultUrl);
        }
        else if($controller==='expense' && $action==='delete')
            $retval=$controllerUrl;
        else if($controller==='expense' && $action==='show')
        {
            if(!Yii::app()->user->isGuest)
                $retval=$controllerUrl;
            else
                $retval=$this->_getGotoUrl($defaultUrl);
        }
        else if($controller==='expense' && $action==='update')
            $retval=$controllerUrl;
        else if($controller==='invoice' && $action==='create')
            $retval=$controllerUrl;
        else if($controller==='invoice' && $action==='show')
        {
            if(!Yii::app()->user->isGuest)
                $retval=$controllerUrl;
            else
                $retval=$this->_getGotoUrl($defaultUrl);
        }
        else if($controller==='invoice' && $action==='update')
            $retval=$controllerUrl;
        else if($controller==='project' && $action==='grid')
            $retval=$this->_getGotoUrl($defaultUrl);
        else if($controller==='project' && $action==='show')
        {
            if(User::isClient() || User::isConsultant() || User::isManager() || User::isAdministrator())
                $retval=$controllerUrl;
            else
                $retval=$this->_getGotoUrl($defaultUrl);
        }
        else if($controller==='task' && $action==='grid')
            $retval=$this->_getGotoUrl($defaultUrl);
        else if($controller==='task' && $action==='show')
        {
            if(User::isClient() || User::isConsultant() || User::isManager() || User::isAdministrator())
                $retval=$controllerUrl;
            else
                $retval=$this->_getGotoUrl($defaultUrl);
        }
        else if($controller==='time' && $action==='delete')
            $retval=$controllerUrl;
        else if($controller==='time' && $action==='grid')
            $retval=$this->_getGotoUrl($defaultUrl);
        else if($controller==='time' && $action==='show')
        {
            if(User::isClient() || User::isConsultant() || User::isManager() || User::isAdministrator())
                $retval=$controllerUrl;
            else
                $retval=$this->_getGotoUrl($defaultUrl);
        }
        else if($controller==='time' && $action==='update')
            $retval=$controllerUrl;
        else if($controller==='user' && $action==='create')
            $retval=$controllerUrl;
        else if($controller==='user' && $action==='grid')
            $retval=$this->_getGotoUrl($defaultUrl);
        else if($controller==='user' && $action==='login')
        {
            if(Yii::app()->user->returnUrl!==null &&
                // hmm... {@link CWebUser::getReturnUrl} returns scriptUrl if returnUrl is not set
                // hopefully this will be changed in the Yii 1.1 branch
                Yii::app()->user->returnUrl!==Yii::app()->request->scriptUrl
            )
                // got here via {@link CWebUser::loginRequired} - go to the previous url
                $retval=Yii::app()->user->returnUrl;
            else if((User::isConsultant() || User::isManager() || User::isAdministrator()) && file_exists(dirname(__FILE__).'/../controllers/TaskController.php'))
                // consultant, manager and administrator - go to the task page
                $retval=array('task/');
            else if(User::isClient() && file_exists(dirname(__FILE__).'/../controllers/CompanyController.php'))
                // client - go to view my company page
                $retval=array('company/show/my');
            else
                $retval=$defaultUrl;
        }
        else if($controller==='user' && $action==='logout')
            $retval=Yii::app()->user->loginUrl;
        else if($controller==='user' && $action==='register')
            $retval=Yii::app()->user->loginUrl;
        else if($controller==='user' && $action==='show')
{'fraction_non_alphanumeric': 0.17117815869076242, 'fraction_numerical': 0.0017063522841852168, 'mean_word_length': 2.201887260988329, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 117, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2748931', 'n_tokens_mistral': 3540, 'n_tokens_neox': 3445, 'n_words': 688}