<commit_before><?php
/**
 * @version		$Id$
 * @category	Nooku
 * @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
 */

/**
 * User Controller Class
 *
 * @author      <NAME> <http://nooku.assembla.com/profile/gergoerdosi>
 * @category	Nooku
 * @package		Nooku_Server
 * @subpackage	Users
 */
class ComUsersControllerUser extends ComDefaultControllerModel
{ 
    public function __construct(KConfig $config)
    {
        parent::__construct($config);

        $this->registerCallback('after.add' , array($this, 'notify'));
        $this->registerCallback('after.edit', array($this, 'reset'));
    }
    
    protected function _initialize(KConfig $config)
    {
        $config->append(array(
            'behaviors' => array(
                'com://admin/activities.controller.behavior.loggable' => array('title_column' => 'name'),
            )
        ));

        parent::_initialize($config);
    }

    protected function _actionDelete(KCommandContext $context)
    {
        $entity = parent::_actionDelete($context);

        $this->getService('com://admin/users.model.sessions')
            ->email($entity->email)
            ->getRowset()
            ->delete();

        return $entity;
    }

    public function reset(KCommandContext $context)
    {
        if ($context->getSubject()->getStatus() == self::STATUS_RESET)
        {
            $user = $context->result;
            JFactory::getUser($user->id)->setData($user->getData());
        }
    }

    public function notify(KCommandContext $context)
    {
        $user = $context->result;
        $reset = $user->reset;

        if(($user->getStatus() != KDatabase::STATUS_FAILED) && $reset)
        {
            $application = $this->getService('application');

            /*
            $url        = $this->getService('koowa:http.url',
                array('url' => "index.php?option=com_users&view=password&layout=form&id={$password->id}&token={$token}"));
            $this->getService('com://site/application.router')->build($url);<commit_msg>Subject appears to not have a getStatus method. Using response (which is set by controller) instead.<commit_after><?php
/**
 * @version		$Id$
 * @category	Nooku
 * @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
 */

/**
 * User Controller Class
 *
 * @author      <NAME> <http://nooku.assembla.com/profile/gergoerdosi>
 * @category	Nooku
 * @package		Nooku_Server
 * @subpackage	Users
 */
class ComUsersControllerUser extends ComDefaultControllerModel
{ 
    public function __construct(KConfig $config)
    {
        parent::__construct($config);

        $this->registerCallback('after.add' , array($this, 'notify'));
        $this->registerCallback('after.edit', array($this, 'reset'));
    }
    
    protected function _initialize(KConfig $config)
    {
        $config->append(array(
            'behaviors' => array(
                'com://admin/activities.controller.behavior.loggable' => array('title_column' => 'name'),
            )
        ));

        parent::_initialize($config);
    }

    protected function _actionDelete(KCommandContext $context)
    {
        $entity = parent::_actionDelete($context);

        $this->getService('com://admin/users.model.sessions')
            ->email($entity->email)
            ->getRowset()
            ->delete();

        return $entity;
    }

    public function reset(KCommandContext $context)
    {
        if ($context->response->getStatusCode() == self::STATUS_RESET)
        {
            $user = $context->result;
            JFactory::getUser($user->id)->setData($user->getData());
        }
    }

    public function notify(KCommandContext $context)
    {
        $user = $context->result;
        $reset = $user->reset;

        if(($user->getStatus() != KDatabase::STATUS_FAILED) && $reset)
        {
            $application = $this->getService('application');

            /*
            $url        = $this->getService('koowa:http.url',
                array('url' => "index.php?option=com_users&view=password&layout=form&id={$password->id}&token={$token}"));
            $this->getService('com://site/application.router')->build($url);
{'fraction_non_alphanumeric': 0.16033755274261605, 'fraction_numerical': 0.003997335109926716, 'mean_word_length': 2.6032, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 61, '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': '979119', 'n_tokens_mistral': 1365, 'n_tokens_neox': 1329, 'n_words': 220}