<commit_before><?php
App::uses('Component', 'Controller');
App::uses('UserLog', 'Model');
App::uses('VusionConst', 'Lib');

class UserLogMonitorComponent extends Component
{
    
    var $components = array(
        'Session',
        'Auth');
    
    
    function beforeRender($controller)
    {
        $this->logAction();
    }
    
    
    function beforeRedirect($controller)
    {
        $this->logAction();
    }
    
    
    public function initialize($controller)
    {
        $this->Controller = $controller;        
        $this->UserLog    = ClassRegistry::init('UserLog');
        
        $this->userLogActions  = array(
            'programParticipants' => array(
                'POST' => array(
                    'delete' => __('Deleted participant(s)'),
                    'add' => __('Added a new participant'),
                    'edit' => __('Edited participant'),
                    'import' => __('Imported  participant(s)')
                    ),
                'GET' => array(
                    'massTag' => __('Tagged participant(s)'),
                    'massUntag' => __('Untagged participant(s)')
                    )
                ),
            'programs' => array(
                'POST' => array(
                    'add' => __('Added a new program'),
                    'edit' => __('Edited a program'),
                    'delete' => __('Deleted a program'),
                    'archive' => __('Archived a program')
                    )
                ),
            'programDialogues' => array(
                'POST' => array(
                    'save' => __('Added a new draft dialogue'),
                    'delete' => __('Deleted a dialogue'),
                    'activate' => __('Activated a dialogue')
                    )
                ),
            'programUnattachedMessages' => array(
                'POST' => array(
                    'add' => __('Added a new separate message'),
                    'edit' => __('Edited a separate message'),
                    'delete' => __('Deleted a separate message')
                    )
                ),
            'programRequests' => array(
                'POST' => array (
                    'save' => __('Added a new request'),
                    'delete' => __('Deleted a request'),
                    'edit' => __('Edited a request')
                    )
                ),
            'programHistory' => array(
                'POST' => array(
                    'delete' => __('Deleted program history')
                    )
                ),
            'programSettings' => array(
                'POST' => array(
                    'edit' => __('Edited a program setting')
                    )
                ),
            'users' => array(
                'POST' => array(
                    'add' => __('Added new a user'),
                    'edit' => __('Edited a user'),
                    'delete' => __('Deleted a user'),
                    'changePassword' => __('Changed password')
                    )
                )
            );        
    }
    
    
    public function userLogSessionWrite($programDatabaseName = null, $programName = null)
    {
        $controller = 'default';
        if (isset($this->userLogActions[$this->Controller->request->params['controller']])){
            $controller = $this->Controller->request->params['controller'];
        }
        
        $action = 'index';
        if (isset($this->Controller->request->action)) {
            $action = $this->Controller->request->action;
        }
        
        $method = $this->Controller->request->method();
        
        $this->Session->write('UserLogMonitor', array(
            'action' => $action,
            'method' => $method,
            'controller' => $controller,
            'programDatabaseName' => $programDatabaseName,
            'programName' => $programName));
    }
    
    
    public function logAction()
    {
        if ($this->Session->check('UserLogMonitor')) {
            $sessionAction = $this->Session->read('UserLogMonitor');
            $this->_logAction($sessionAction['action'],
                $sessionAction['method'],
                $sessionAction['controller'],
                $sessionAction['programDatabaseName'],
                $sessionAction['programName']);
            $this->Session->delete('UserLogMonitor');
        }
    }
    
    
    protected function _logAction($action, $method, $controller, $programDatabaseName = null, $programName = null)
    {
        $now = new DateTime('now');
        if (isset($this->Controller->programDetails['database'])) {
            $programDatabaseName = $this->Controller->programDetails['database'];
        } 
        <commit_msg>renamed protected function in the component<commit_after><?php
App::uses('Component', 'Controller');
App::uses('UserLog', 'Model');
App::uses('VusionConst', 'Lib');

class UserLogMonitorComponent extends Component
{
    
    var $components = array(
        'Session',
        'Auth');
    
    
    function beforeRender($controller)
    {
        $this->logAction();
    }
    
    
    function beforeRedirect($controller)
    {
        $this->logAction();
    }
    
    
    public function initialize($controller)
    {
        $this->Controller = $controller;        
        $this->UserLog    = ClassRegistry::init('UserLog');
        
        $this->userLogActions  = array(
            'programParticipants' => array(
                'POST' => array(
                    'delete' => __('Deleted participant(s)'),
                    'add' => __('Added a new participant'),
                    'edit' => __('Edited participant'),
                    'import' => __('Imported  participant(s)')
                    ),
                'GET' => array(
                    'massTag' => __('Tagged participant(s)'),
                    'massUntag' => __('Untagged participant(s)')
                    )
                ),
            'programs' => array(
                'POST' => array(
                    'add' => __('Added a new program'),
                    'edit' => __('Edited a program'),
                    'delete' => __('Deleted a program'),
                    'archive' => __('Archived a program')
                    )
                ),
            'programDialogues' => array(
                'POST' => array(
                    'save' => __('Added a new draft dialogue'),
                    'delete' => __('Deleted a dialogue'),
                    'activate' => __('Activated a dialogue')
                    )
                ),
            'programUnattachedMessages' => array(
                'POST' => array(
                    'add' => __('Added a new separate message'),
                    'edit' => __('Edited a separate message'),
                    'delete' => __('Deleted a separate message')
                    )
                ),
            'programRequests' => array(
                'POST' => array (
                    'save' => __('Added a new request'),
                    'delete' => __('Deleted a request'),
                    'edit' => __('Edited a request')
                    )
                ),
            'programHistory' => array(
                'POST' => array(
                    'delete' => __('Deleted program history')
                    )
                ),
            'programSettings' => array(
                'POST' => array(
                    'edit' => __('Edited a program setting')
                    )
                ),
            'users' => array(
                'POST' => array(
                    'add' => __('Added new a user'),
                    'edit' => __('Edited a user'),
                    'delete' => __('Deleted a user'),
                    'changePassword' => __('<PASSWORD>')
                    )
                )
            );        
    }
    
    
    public function userLogSessionWrite($programDatabaseName = null, $programName = null)
    {
        $controller = 'default';
        if (isset($this->userLogActions[$this->Controller->request->params['controller']])){
            $controller = $this->Controller->request->params['controller'];
        }
        
        $action = 'index';
        if (isset($this->Controller->request->action)) {
            $action = $this->Controller->request->action;
        }
        
        $method = $this->Controller->request->method();
        
        $this->Session->write('UserLogMonitor', array(
            'action' => $action,
            'method' => $method,
            'controller' => $controller,
            'programDatabaseName' => $programDatabaseName,
            'programName' => $programName));
    }
    
    
    public function logAction()
    {
        if ($this->Session->check('UserLogMonitor')) {
            $sessionAction = $this->Session->read('UserLogMonitor');
            $this->_saveUserAction($sessionAction['action'],
                $sessionAction['method'],
                $sessionAction['controller'],
                $sessionAction['programDatabaseName'],
                $sessionAction['programName']);
            $this->Session->delete('UserLogMonitor');
        }
    }
    
    
    protected function _saveUserAction($action, $method, $controller, $programDatabaseName = null, $programName = null)
    {
        $now = new DateTime('now');
        if (isset($this->Controller->programDetails['database'])) {
            $programDatabaseName = $this->Controller->programDetails['database'];
        } 
        
{'fraction_non_alphanumeric': 0.14309553608677514, 'fraction_numerical': 0.0, 'mean_word_length': 1.4111139049534824, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 166, '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': '525102', 'n_tokens_mistral': 2382, 'n_tokens_neox': 2293, 'n_words': 466}