<commit_before><?php
/**
 * @package     Nooku_Components
 * @subpackage  Default
 * @copyright   Copyright (C) 2007 - 2012 <NAME>. All rights reserved.
 * @license     GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link        http://www.nooku.org
 */

use Nooku\Library;

/**
 * Controller Permission Default Class
 *
 * @author      <NAME> <<EMAIL>>
 * @package     Nooku_Components
 * @subpackage  Default
 */
class ApplicationControllerPermissionDefault extends Library\ControllerPermissionAbstract
{
    /**
     * Generic authorize handler for controller render actions
     *
     * @return  boolean     Can return both true or false.
     */
    public function canRender()
    {
        $application = $this->getObject('application');
        $user        = $this->getUser();
        $request     = $this->getRequest();

        if(!($application->getCfg('offline') && !$user->isAuthentic()))
        {
            $page = $request->query->get('Itemid', 'int');

            if($this->getObject('application.pages')->isAuthorized($page, $user)) {
               return true;
            }
        }

        return false;
    }

    /**
     * Generic authorize handler for controller add actions
     *<commit_msg>Only check page authorization if the component is being dispatched.<commit_after><?php
/**
 * @package     Nooku_Components
 * @subpackage  Default
 * @copyright   Copyright (C) 2007 - 2012 <NAME>. All rights reserved.
 * @license     GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link        http://www.nooku.org
 */

use Nooku\Library;

/**
 * Controller Permission Default Class
 *
 * @author      <NAME> <<EMAIL>>
 * @package     Nooku_Components
 * @subpackage  Default
 */
class ApplicationControllerPermissionDefault extends Library\ControllerPermissionAbstract
{
    /**
     * Generic authorize handler for controller render actions
     *
     * @return  boolean     Can return both true or false.
     */
    public function canRender()
    {
        $application = $this->getObject('application');
        $user        = $this->getUser();
        $request     = $this->getRequest();

        if(!($application->getCfg('offline') && !$user->isAuthentic()))
        {
            $page = $request->query->get('Itemid', 'int');

            if($this->isDispatched())
            {
                if($this->getObject('application.pages')->isAuthorized($page, $user)) {
                    return true;
                }
            }
            else return true;
        }

        return false;
    }

    /**
     * Generic authorize handler for controller add actions
     *
{'fraction_non_alphanumeric': 0.1321904761904762, 'fraction_numerical': 0.006857142857142857, 'mean_word_length': 2.2379778051787915, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '3836858', 'n_tokens_mistral': 741, 'n_tokens_neox': 704, 'n_words': 171}