<commit_before><?php
/**
 * @version     $Id$
 * @package     Nooku_Server
 * @subpackage  Users
 * @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
 */

/**
 * Password Controller Class.
 *
 * @author     <NAME> <http://nooku.assembla.com/profile/arunasmazeika>
 * @package    Nooku_Server
 * @subpackage Users
 */
class ComUsersControllerPassword extends ComDefaultControllerDefault
{
    public function __construct(KConfig $config) {
        parent::__construct($config);

        $this->registerCallback('after.save', array($this, 'redirect'));
    }

    protected function _initialize(KConfig $config) {
        $config->append(array(
            'behaviors' => array(
                'com://site/users.controller.behavior.password.executable',
                'com://site/users.controller.behavior.password.resettable')));
        parent::_initialize($config);
    }

    public function redirect(KCommandContext $context) {
        $password = $context->result;

        if ($password->getStatus() == KDatabase::STATUS_FAILED) {
            $this->setRedirect(KRequest::referrer(), $password->getStatusMessage(), 'error');
        } else {
            $this->setRedirect($this->getService('application.pages')->getHome()->url, 'PASSWORD_SUCCESSFULLY_SAVED');
        }
    }
}<commit_msg>Set the redirect through $context->response.<commit_after><?php
/**
 * @version     $Id$
 * @package     Nooku_Server
 * @subpackage  Users
 * @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
 */

/**
 * Password Controller Class.
 *
 * @author     <NAME> <http://nooku.assembla.com/profile/arunasmazeika>
 * @package    Nooku_Server
 * @subpackage Users
 */
class ComUsersControllerPassword extends ComDefaultControllerDefault
{
    public function __construct(KConfig $config)
    {
        parent::__construct($config);

        $this->registerCallback('after.save', array($this, 'redirect'));
    }

    protected function _initialize(KConfig $config)
    {
        $config->append(array(
            'behaviors' => array(
                'com://site/users.controller.behavior.password.executable',
                'com://site/users.controller.behavior.password.resettable')));
        parent::_initialize($config);
    }

    public function redirect(KCommandContext $context)
    {
        $password = $context->result;

        if ($password->getStatus() == KDatabase::STATUS_FAILED)
        {
            $context->response->setRedirect(KRequest::referrer());
            //@TODO : Set message in session
            //$this->setRedirect(KRequest::referrer(), $password->getStatusMessage(), 'error');
        }
        else
        {
            $context->response->setRedirect($this->getService('application.pages')->getHome()->url);
            //@TODO : Set message in session
            //$this->setRedirect($this->getService('application.pages')->getHome()->url, 'PASSWORD_SUCCESSFULLY_SAVED');
        }
    }
}
{'fraction_non_alphanumeric': 0.15169412496114393, 'fraction_numerical': 0.005595275101025801, 'mean_word_length': 2.84468339307049, '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': '6198730', 'n_tokens_mistral': 946, 'n_tokens_neox': 919, 'n_words': 156}