<commit_before><?php

App::uses('AppModel', 'Model');
App::uses('UserMeta', 'Model');

/**
 * User Model
 *
 * @property Comment $Comment
 * @property Post $Post
 */
class User extends AppModel {

    /**
     * Display field
     *
     * @var string
     */
    public $displayField = 'username';
    public $actsAs = array('Containable');

//The Associations below have been created with all possible keys, those that are not needed can be removed

    /**
     * hasMany associations
     *
     * @var array
     */
    public $hasMany = array(
        'Comment' => array(
            'className' => 'Comment',
            'foreignKey' => 'user_id',
            'dependent' => false,
            'conditions' => '',
            'fields' => '',
            'order' => '',
            'limit' => '',
            'offset' => '',
            'exclusive' => '',
            'finderQuery' => '',
            'counterQuery' => ''
        ),
        'Post' => array(
            'className' => 'Post',
            'foreignKey' => 'user_id',
            'dependent' => false,
            'conditions' => '',
            'fields' => '',
            'order' => '',
            'limit' => '',
            'offset' => '',
            'exclusive' => '',
            'finderQuery' => '',
            'counterQuery' => ''
        ),
        'UserMeta' => array(
            'className' => 'UserMeta',
            'foreignKey' => 'user_id',
            'dependent' => false,
            'conditions' => '',
            //'fields' => array('meta_key', 'meta_value'),
            'order' => '',
            'limit' => '',
            'offset' => '',
            'exclusive' => '',
            'finderQuery' => '',
            'counterQuery' => ''
        )
    );
    public $validate = array(
        'username' => array(
            'usernameRule-1' => array(
                'rule' => array('minLength', 5),
                'last' => true
            ),
            'usernameRule-2' => array(
                'rule' => 'isUnique',
            ),
            'usernameRule-3' => array(
                'rule' => 'notEmpty',
            )
        ),
        'email' => array(
            'emailRule-1' => array(
                'rule' => 'email',
            ),
            'emailRule-2' => array(
                'rule' => 'isUnique',
                'last' => true
            ),
        ),
        'url' => array(
            'urlRule-1' => array(
                'rule' => 'url',
                'allowEmpty' => true
            ),
        ),
        'password' => array(
            'passwordRule-1' => array(
                'rule' => array('between', 5, 32),
            )
        ),
        'confirm_password' => array(
            'confirmPasswordRule-1' => array(
                'rule' => 'checkPasswords',
            )
        )
    );

    public function beforeValidate($options = array()) {
        parent::beforeValidate($options);
        if (Router::getParam('action') == 'admin_profile') {
            if ($this->data['User']['password'] == "" && $this->data['User']['confirm_password'] == "") {
                unset($this->data['User']['password']);
                unset($this->data['User']['confirm_password']);
            }
        }
    }

    public function beforeSave($options = array()) {
        parent::beforeSave($options);
        if (isset($this->data['User']['password'])) {
            $this->data['User']['password'] = AuthComponent::password($this->data['User']['password']);
        }
    }

    public function afterSave($created) {
        parent::afterSave($created);

        if ($created) {
            $userMetaData = array(
                'firstname' => '',
                'lastname' => '',
                'nickname' => '',<commit_msg>added default value to nickname<commit_after><?php

App::uses('AppModel', 'Model');
App::uses('UserMeta', 'Model');

/**
 * User Model
 *
 * @property Comment $Comment
 * @property Post $Post
 */
class User extends AppModel {

    /**
     * Display field
     *
     * @var string
     */
    public $displayField = 'username';
    public $actsAs = array('Containable');

//The Associations below have been created with all possible keys, those that are not needed can be removed

    /**
     * hasMany associations
     *
     * @var array
     */
    public $hasMany = array(
        'Comment' => array(
            'className' => 'Comment',
            'foreignKey' => 'user_id',
            'dependent' => false,
            'conditions' => '',
            'fields' => '',
            'order' => '',
            'limit' => '',
            'offset' => '',
            'exclusive' => '',
            'finderQuery' => '',
            'counterQuery' => ''
        ),
        'Post' => array(
            'className' => 'Post',
            'foreignKey' => 'user_id',
            'dependent' => false,
            'conditions' => '',
            'fields' => '',
            'order' => '',
            'limit' => '',
            'offset' => '',
            'exclusive' => '',
            'finderQuery' => '',
            'counterQuery' => ''
        ),
        'UserMeta' => array(
            'className' => 'UserMeta',
            'foreignKey' => 'user_id',
            'dependent' => false,
            'conditions' => '',
            //'fields' => array('meta_key', 'meta_value'),
            'order' => '',
            'limit' => '',
            'offset' => '',
            'exclusive' => '',
            'finderQuery' => '',
            'counterQuery' => ''
        )
    );
    public $validate = array(
        'username' => array(
            'usernameRule-1' => array(
                'rule' => array('minLength', 5),
                'last' => true
            ),
            'usernameRule-2' => array(
                'rule' => 'isUnique',
            ),
            'usernameRule-3' => array(
                'rule' => 'notEmpty',
            )
        ),
        'email' => array(
            'emailRule-1' => array(
                'rule' => 'email',
            ),
            'emailRule-2' => array(
                'rule' => 'isUnique',
                'last' => true
            ),
        ),
        'url' => array(
            'urlRule-1' => array(
                'rule' => 'url',
                'allowEmpty' => true
            ),
        ),
        'password' => array(
            'passwordRule-1' => array(
                'rule' => array('between', 5, 32),
            )
        ),
        'confirm_password' => array(
            'confirmPasswordRule-1' => array(
                'rule' => 'checkPasswords',
            )
        )
    );

    public function beforeValidate($options = array()) {
        parent::beforeValidate($options);
        if (Router::getParam('action') == 'admin_profile') {
            if ($this->data['User']['password'] == "" && $this->data['User']['confirm_password'] == "") {
                unset($this->data['User']['password']);
                unset($this->data['User']['confirm_password']);
            }
        }
    }

    public function beforeSave($options = array()) {
        parent::beforeSave($options);
        if (isset($this->data['User']['password'])) {
            $this->data['User']['password'] = AuthComponent::password($this->data['User']['password']);
        }
    }

    public function afterSave($created) {
        parent::afterSave($created);

        if ($created) {
            $userMetaData = array(
                'firstname' => '',
                'lastname' => '',
                'nickname' => $this->data['User']['username'],
{'fraction_non_alphanumeric': 0.1829316475701304, 'fraction_numerical': 0.0031608060055314103, 'mean_word_length': 1.4402313624678664, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 144, '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': '293775', 'n_tokens_mistral': 2052, 'n_tokens_neox': 2004, 'n_words': 383}