<commit_before><?php

class DSSecurity implements SecurityInterface {

    const DECLARANT = 'DECLARANT';
    const CONSULTATION = 'CONSULTATION';
    const CREATION = 'CREATION';
    const EDITION = 'EDITION';

    protected $ds;
    protected $myUser;
    protected $tiers;

    public static function getInstance($myUser, $ds_principale = null) {

        return new DSSecurity($myUser, $ds_principale);
    }

    public function __construct($myUser, $ds_principale = null) {
        $this->myUser = $myUser;
        $this->ds = $ds_principale;
        $this->tiers = $this->myUser->getDeclarantDS();
    }

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

        /*** DECLARANT ***/

        if(!$this->tiers->isDeclarantStock()) {
            
            return false;
        }

        if(!$this->myUser->getCompte()->hasDroit(_CompteClient::DROIT_DS_DECLARANT)) {
            
            return false;
        }
        
        if(in_array(self::DECLARANT, $droits)) {

            return true;
        }
        
        if(!$this->myUser->hasLieuxStockage() && !$this->tiers->isAjoutLieuxDeStockage()) {

            return false;
        }

        /*** CONSULTATION ***/
<commit_msg>Si le récoltant n'a pas le droit DS on retourne false<commit_after><?php

class DSSecurity implements SecurityInterface {

    const DECLARANT = 'DECLARANT';
    const CONSULTATION = 'CONSULTATION';
    const CREATION = 'CREATION';
    const EDITION = 'EDITION';

    protected $ds;
    protected $myUser;
    protected $tiers;

    public static function getInstance($myUser, $ds_principale = null) {

        return new DSSecurity($myUser, $ds_principale);
    }

    public function __construct($myUser, $ds_principale = null) {
        $this->myUser = $myUser;
        $this->ds = $ds_principale;
        $this->tiers = $this->myUser->getDeclarantDS();
    }

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

        if(!$this->tiers) {

            return false;
        }

        /*** DECLARANT ***/

        if(!$this->tiers->isDeclarantStock()) {
            
            return false;
        }

        if(!$this->myUser->getCompte()->hasDroit(_CompteClient::DROIT_DS_DECLARANT)) {
            
            return false;
        }
        
        if(in_array(self::DECLARANT, $droits)) {

            return true;
        }
        
        if(!$this->myUser->hasLieuxStockage() && !$this->tiers->isAjoutLieuxDeStockage()) {

            return false;
        }

        /*** CONSULTATION ***/

{'fraction_non_alphanumeric': 0.13458646616541353, 'fraction_numerical': 0.0, 'mean_word_length': 2.0834298957126305, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 32, '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': '1365284', 'n_tokens_mistral': 874, 'n_tokens_neox': 835, 'n_words': 145}