<commit_before><?php
/**
 * @version		$Id: dispatcher.php 5146 2012-09-03 23:25:47Z johanjanssens $
 * @package     Nooku_Server
 * @subpackage  Application
 * @copyright	Copyright (C) 2011 - 2012 Timble CVBA and Contributors. (http://www.timble.net)
 * @license		GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link		http://www.nooku.org
 */

/**
 * Unauthorized Event Subscriber Class
 *
 * @author    	<NAME> <http://nooku.assembla.com/profile/johanjanssens>
 * @package     Nooku_Server
 * @subpackage  Application
 */
class ComApplicationEventSubscriberUnauthorized extends KEventSubscriberAbstract
{
    protected function _initialize(KConfig $config)
    {
        $config->append(array(
            'priority' => KEvent::PRIORITY_HIGH
        ));

        parent::_initialize($config);
    }

    public function onException(KEventException $event)
    {
        if($event->getException() instanceof KControllerExceptionUnauthorized)
        {
            $application = $this->getService('application');

            if($application->getRequest()->getFormat() == 'html')
            {
                $application->getRequest()->query->clear()->add(array('view' => 'session', 'tmpl' => 'login'));
                $application->setController('com://admin/users.dispatcher')->dispatch();

                $event->stopPropagation();
            }
        }
    }
}<commit_msg>re #228 : Use setComponent function to dispatch to a new component.<commit_after><?php
/**
 * @version		$Id: dispatcher.php 5146 2012-09-03 23:25:47Z johanjanssens $
 * @package     Nooku_Server
 * @subpackage  Application
 * @copyright	Copyright (C) 2011 - 2012 Timble CVBA and Contributors. (http://www.timble.net)
 * @license		GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link		http://www.nooku.org
 */

/**
 * Unauthorized Event Subscriber Class
 *
 * @author    	<NAME> <http://nooku.assembla.com/profile/johanjanssens>
 * @package     Nooku_Server
 * @subpackage  Application
 */
class ComApplicationEventSubscriberUnauthorized extends KEventSubscriberAbstract
{
    protected function _initialize(KConfig $config)
    {
        $config->append(array(
            'priority' => KEvent::PRIORITY_HIGH
        ));

        parent::_initialize($config);
    }

    public function onException(KEventException $event)
    {
        if($event->getException() instanceof KControllerExceptionUnauthorized)
        {
            $application = $this->getService('application');

            if($application->getRequest()->getFormat() == 'html')
            {
                $application->getRequest()->query->clear()->add(array('view' => 'session', 'tmpl' => 'login'));
                $application->setComponent('users')->dispatch();

                $event->stopPropagation();
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.1433666191155492, 'fraction_numerical': 0.020328102710413694, 'mean_word_length': 2.8372093023255816, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, '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': '6892689', 'n_tokens_mistral': 873, 'n_tokens_neox': 813, 'n_words': 146}