Commit a56d6d55 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Merge branch 'hotfix_mail_president_jury_non_membre'

parents d9ff5537 78fe5304
Loading
Loading
Loading
Loading
+8 −23
Original line number Diff line number Diff line
@@ -1444,34 +1444,19 @@ class These implements HistoriqueAwareInterface, ResourceInterface

    /**
     * Retourne les mails des directeurs de thèse.
     *
     * @param Individu[] $individusSansMail Liste des individus sans mail, format: "Paul Hochon" => Individu
     * @return array
     * @return string|null
     */
    public function getPresidentJuryEmail(array &$individusSansMail = [])
    public function getPresidentJuryEmail() : ?string
    {
        $emails = [];
        /** @var Acteur[] $membres */
        $membres = $this->getActeursByRoleCode(Role::CODE_MEMBRE_JURY)->toArray();
        /** @var Acteur[] $rapporteurs */
        $rapporteurs = $this->getActeursByRoleCode(Role::CODE_RAPPORTEUR_JURY)->toArray();
        $acteurs = array_merge($membres, $rapporteurs);

        /** @var Acteur $acteur */
        foreach ($acteurs as $acteur) {
            if ($acteur->getRole()->getCode() === Role::CODE_PRESIDENT_JURY) {
                $email = $acteur->getIndividu()->getEmail();

                $name = (string)$acteur->getIndividu();
                if (!$email) {
                    $individusSansMail[$name] = $acteur->getIndividu();
                } else {
                    $emails[$email] = $name;
                }
            }
        }
        $president = $this->getActeursByRoleCode(Role::CODE_PRESIDENT_JURY)->toArray();
        if (empty($president)) throw new \RuntimeException("Pas de président ...");
        $president = current($president);

        return $emails;
        if ($president->getIndividu()->getEmail() !== null) return $president->getIndividu()->getEmail();
        if ($president->getMembre()->getEmail() !== null) return $president->getMembre()->getEmail();
        return null;
    }

    /**
+1 −0
Original line number Diff line number Diff line
@@ -103,6 +103,7 @@ class NotifierService
        $nMail->setFrom(implode(',', $mails));
        $mails = [];
        foreach ($email->getTo() as $mail) { $mails[] = $mail->getEmail(); }
        if ($mails === []) $mails = ["unknown"];
        $nMail->setTo(implode(',', $mails));
        $nMail->setSubject($email->getSubject());
        $body = $email->getBodyText();