<commit_before><?php

class EtablissementSecurity implements SecurityInterface {

    const DECLARANT_DREV = 'DECLARANT_DREV';
    const DECLARANT_PARCELLAIRE = 'DECLARANT_PARCELLAIRE';

    protected $user;
    protected $etablissement;

    public static function getInstance($user, $etablissement) {

        return new EtablissementSecurity($user, $etablissement);
    }

    public function __construct($user, $etablissement) {
        $this->user = $user;
        $this->etablissement = $etablissement;
    }

    public function isAuthorized($droits) {
        if(!is_array($droits)) {
            $droits = array($droits);
        }

        /*** DECLARANT ***/

        if(!$this->user->isAdmin() && $this->user->getEtablissement()->_id != $this->etablissement->_id) {

            return false;
        }

        if(in_array(self::DECLARANT_DREV, $droits) && !$this->etablissement->hasFamille(EtablissementClient::FAMILLE_VINIFICATEUR)) {

            return false;
        }

        return true;
    }

}<commit_msg>Regarde si il y a un registre<commit_after><?php

class EtablissementSecurity implements SecurityInterface {

    const DECLARANT_DREV = 'DECLARANT_DREV';
    const DECLARANT_PARCELLAIRE = 'DECLARANT_PARCELLAIRE';

    protected $user;
    protected $etablissement;

    public static function getInstance($user, $etablissement) {

        return new EtablissementSecurity($user, $etablissement);
    }

    public function __construct($user, $etablissement) {
        $this->user = $user;
        $this->etablissement = $etablissement;
    }

    public function isAuthorized($droits) {
        if(!is_array($droits)) {
            $droits = array($droits);
        }

        /*** DECLARANT ***/

        if(!$this->user->isAdmin() && $this->user->getEtablissement()->_id != $this->etablissement->_id) {

            return false;
        }

        if(in_array(self::DECLARANT_DREV, $droits) && !$this->etablissement->hasFamille(EtablissementClient::FAMILLE_VINIFICATEUR) && !count(RegistreVCIClient::getInstance()->getHistory($this->etablissement->identifiant, acCouchdbClient::HYDRATE_JSON))) {

            return false;
        }

        return true;
    }

}
{'fraction_non_alphanumeric': 0.13069216757741348, 'fraction_numerical': 0.0, 'mean_word_length': 3.0460405156537753, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 28, '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': '2013211', 'n_tokens_mistral': 724, 'n_tokens_neox': 715, 'n_words': 110}