<commit_before><?php
class User extends AppModel {
    var $name = 'User';
    var $displayField = 'fullname';
    var $virtualFields = array('fullname' => "CONCAT(User.first_name, ' ', User.last_name)");

    var $hasMany = array(
        'OrderedProduct' => array(
                'className' => 'OrderedProduct',
                'foreignKey' => 'user_id',
                'dependent' => false,
                'conditions' => '',
                'fields' => '',
                'order' => '',
                'limit' => '',
                'offset' => '',
                'exclusive' => '',
                'finderQuery' => '',
                'counterQuery' => ''
        ),
        'MoneyBox' => array(
                'className' => 'MoneyBox',
                'foreignKey' => 'user_id',
                'dependent' => false,
                'conditions' => '',
                'fields' => '',
                'order' => '',
                'limit' => '',
                'offset' => '',
                'exclusive' => '',
                'finderQuery' => '',
                'counterQuery' => ''
        )
    );

    var $belongsTo = array('Seller', 'Usergroup');

    var $validate = array(
        'first_name'    => array('rule' => 'notEmpty', 'on' => 'create'),
        'last_name'     => array('rule' => 'notEmpty', 'on' => 'create'),
        'username'      => array('rule' => 'notEmpty', 'on' => 'create'),
        'password'      => array('rule' => 'notEmpty', 'on' => 'create'),
        'email'         => array('rule' => 'notEmpty', 'on' => 'create')
    );

    var $actsAs = array('Containable');

    function beforeSave($options = array()) {
        if(isset($this->data['User']['password']) 
            && $this->data['User']['password'] == Security::hash('', null, true)) {
            unset($this->data['User']['password']);
        } 

        // salvo il nuovo profilo azienda
        if(isset($this->data['Seller'])) {
            if($this->Seller->save($this->data)) {
                $this->data['User'] = am(<commit_msg>nuova validation nel model User: username deve essere unico<commit_after><?php
class User extends AppModel {
    var $name = 'User';
    var $displayField = 'fullname';
    var $virtualFields = array('fullname' => "CONCAT(User.first_name, ' ', User.last_name)");

    var $hasMany = array(
        'OrderedProduct' => array(
                'className' => 'OrderedProduct',
                'foreignKey' => 'user_id',
                'dependent' => false,
                'conditions' => '',
                'fields' => '',
                'order' => '',
                'limit' => '',
                'offset' => '',
                'exclusive' => '',
                'finderQuery' => '',
                'counterQuery' => ''
        ),
        'MoneyBox' => array(
                'className' => 'MoneyBox',
                'foreignKey' => 'user_id',
                'dependent' => false,
                'conditions' => '',
                'fields' => '',
                'order' => '',
                'limit' => '',
                'offset' => '',
                'exclusive' => '',
                'finderQuery' => '',
                'counterQuery' => ''
        )
    );

    var $belongsTo = array('Seller', 'Usergroup');

    var $validate = array(
        'first_name'    => array('rule' => 'notEmpty', 'on' => 'create'),
        'last_name'     => array('rule' => 'notEmpty', 'on' => 'create'),
        'username'      => array(
			'notEmpty'	=> array('rule' => 'notEmpty', 'on' => 'create'),
			'unique'	=> array('rule' => 'isUnique', 'on' => 'create', 'message' => 'Questo username è già utilizzato per un altro utente')),
        'password'      => array('rule' => 'notEmpty', 'on' => 'create'),
        'email'         => array('rule' => 'notEmpty', 'on' => 'create')
    );

    var $actsAs = array('Containable');

    function beforeSave($options = array()) {
        if(isset($this->data['User']['password']) 
            && $this->data['User']['password'] == Security::hash('', null, true)) {
            unset($this->data['User']['password']);
        } 

        // salvo il nuovo profilo azienda
        if(isset($this->data['Seller'])) {
            if($this->Seller->save($this->data)) {
                $this->data['User'] = am(
{'fraction_non_alphanumeric': 0.20250812819321876, 'fraction_numerical': 0.0, 'mean_word_length': 1.710509754562618, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 104, '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': '3174585', 'n_tokens_mistral': 1266, 'n_tokens_neox': 1191, 'n_words': 232}