<commit_before><?php

/**
 * Description of class drmGeneriqueActions
 * @author mathurin
 */
class drmGeneriqueActions extends sfActions {

    protected function initSocieteAndEtablissementPrincipal() {
        $this->compte = $this->getUser()->getCompte();
        if ($this->isTeledeclarationDrm()) {

            /*if (!$this->compte) {
                new sfException("Le compte $compte n'existe pas");
            }*/
            $this->etablissementPrincipal = $this->getRoute()->getEtablissement();
            $this->societe = $this->etablissementPrincipal->getSociete();
        }

        $this->etablissementPrincipal = $this->getRoute()->getEtablissement();
    }

    protected function redirect403IfIsNotTeledeclaration() {
        if (!$this->isTeledeclarationDrm()) {
            $this->redirect403();
        }
    }

     protected function redirect403IfIsTeledeclaration() {
        if ($this->isTeledeclarationDrm()) {
            $this->redirect403();
        }
    }

    protected function redirect403IfIsNotTeledeclarationAndNotMe() {
        $this->redirect403IfIsNotTeledeclaration();
        if ($this->getUser()->getCompte()->identifiant != $this->identifiant) {
            $this->redirect403();
        }
    }

    private function redirect403Unless($bool) {
        if (!$bool) {
          $this->forward(sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action'));
        }
    }


    private function redirect403() {
        $this->forward(sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action'));
    }

    protected function isTeledeclarationDrm() {
    	return $this->getUser()->hasTeledeclarationDrm();
    }

    protected function initDeleteForm() {
        $this->deleteForm = new DRMDeleteForm($this->drm);
    }

    protected function isUsurpationMode() {
        return $this->getUser()->isUsurpationCompte();
    }
  <commit_msg>redirection si on est en teledeclaration et qu'on a pour seul droit admin drev<commit_after><?php

/**
 * Description of class drmGeneriqueActions
 * @author mathurin
 */
class drmGeneriqueActions extends sfActions {

    protected function initSocieteAndEtablissementPrincipal() {
        $this->compte = $this->getUser()->getCompte();
        if ($this->isTeledeclarationDrm()) {

            /*if (!$this->compte) {
                new sfException("Le compte $compte n'existe pas");
            }*/
            $this->etablissementPrincipal = $this->getRoute()->getEtablissement();
            $this->societe = $this->etablissementPrincipal->getSociete();
        }

        $this->etablissementPrincipal = $this->getRoute()->getEtablissement();
        if ($this->isTeledeclaration()) {
        $this->hasTeledeclarationDrevAdmin = $this->getUser()->hasTeledeclarationDrevAdmin();
          if($this->hasTeledeclarationDrevAdmin){
            return $this->redirect("/odg/declaration?usurpation=".intval($this->getUser()->isUsurpationCompte())."&login=".$this->getUser()->getCompte()->getSociete()->getMasterCompte()->identifiant);
          }
        }

    }

    protected function redirect403IfIsNotTeledeclaration() {
        if (!$this->isTeledeclarationDrm()) {
            $this->redirect403();
        }
    }

     protected function redirect403IfIsTeledeclaration() {
        if ($this->isTeledeclarationDrm()) {
            $this->redirect403();
        }
    }

    protected function redirect403IfIsNotTeledeclarationAndNotMe() {
        $this->redirect403IfIsNotTeledeclaration();
        if ($this->getUser()->getCompte()->identifiant != $this->identifiant) {
            $this->redirect403();
        }
    }

    private function redirect403Unless($bool) {
        if (!$bool) {
          $this->forward(sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action'));
        }
    }


    private function redirect403() {
        $this->forward(sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action'));
    }

    protected function isTeledeclarationDrm() {
    	return $this->getUser()->hasTeledeclarationDrm();
    }

    protected function initDeleteForm() {
        $this->deleteForm = new DRMDeleteForm($this->drm);
    }

    protected function isUsurpationMode() {
        return $this->getUser()->isUsurpationCompte();
    }

{'fraction_non_alphanumeric': 0.1448936667445665, 'fraction_numerical': 0.012619770974526759, 'mean_word_length': 2.962962962962963, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 80, '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': '4557113', 'n_tokens_mistral': 1338, 'n_tokens_neox': 1245, 'n_words': 180}