From 9a1b8c90a4209f3e90dabea1a342034d8fd902ea Mon Sep 17 00:00:00 2001 From: Tykayn Date: Tue, 18 May 2021 23:26:33 +0200 Subject: [PATCH] up mail templates --- config/packages/dev/mailer.yaml | 8 + src/Controller/EmailsController.php | 3 +- src/Controller/api/v1/PollController.php | 17 +- src/Entity/Poll.php | 899 +++++++++--------- templates/emails/creation-mail.html.twig | 8 +- templates/emails/expiration-mail.html.twig | 8 +- templates/emails/footer.html.twig | 4 +- templates/emails/partial/admin_link.html.twig | 3 +- templates/emails/partial/poll.html.twig | 23 +- .../emails/partial/public_link.html.twig | 9 +- 10 files changed, 512 insertions(+), 470 deletions(-) create mode 100644 config/packages/dev/mailer.yaml diff --git a/config/packages/dev/mailer.yaml b/config/packages/dev/mailer.yaml new file mode 100644 index 0000000..f641857 --- /dev/null +++ b/config/packages/dev/mailer.yaml @@ -0,0 +1,8 @@ +# config/packages/dev/mailer.yaml +framework: + mailer: + envelope: + sender: 'noreply@tktest.com' + recipients: ['tykayn@pm.me'] + headers: + from: 'dev framadate funky ' diff --git a/src/Controller/EmailsController.php b/src/Controller/EmailsController.php index 187d09a..17d4495 100644 --- a/src/Controller/EmailsController.php +++ b/src/Controller/EmailsController.php @@ -9,7 +9,6 @@ use Swift_Mailer; use Swift_Message; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Mailer\Exception\TransportExceptionInterface; - /** * sending emails controller * @@ -83,7 +82,7 @@ class EmailsController extends AbstractController { $message = ( new Swift_Message( $config[ 'title' ] ) ) ->setContentType( "text/html" ) ->setCharset( 'UTF-8' ) - ->setFrom( [ 'ne-pas-repondre@framadate-api.cipherbliss.com' ] ) + ->setFrom( [ 'ne-pas-repondre@framadate-api.cipherbliss.com'] ) ->setTo( [ $config[ 'owner' ]->getEmail() ] ) ->setBody( $htmlbody, 'text/html' ); diff --git a/src/Controller/api/v1/PollController.php b/src/Controller/api/v1/PollController.php index 9d03cb3..a8fe803 100644 --- a/src/Controller/api/v1/PollController.php +++ b/src/Controller/api/v1/PollController.php @@ -405,16 +405,23 @@ class PollController extends EmailsController { $em = $this->getDoctrine()->getRepository( Owner::class ); $foundOwner = $em->findOneByEmail( $emailChoice ); if ( $foundOwner ) { - $poll = $foundOwner->getPolls()[ 0 ]; - $comment = $foundOwner->getComments()[ 0 ]; - $sent = $this->sendOwnerPollsAction( $foundOwner ); if ( $sent ) { - return $this->json( [ "message" => "test email sent to " . $foundOwner->getEmail() . "!" ], 200 ); + $config = [ + 'owner' => $foundOwner, + 'title' => $this->getParameter( 'WEBSITE_NAME' ) . ' | Mes sondages', + 'email_template' => 'emails/owner-list.html.twig', + ]; + return $this->render( 'emails/owner-list.html.twig', $config ); +// return $this->json( [ "message" => "test email sent to " . $foundOwner->getEmail() . "!" ], 200 ); } } - return $this->json( [ "message" => "user with this email was not found" ], 400 ); + +// $this->sendMailWithVars( $config ); + + +// return $this->json( [ "message" => "user with this email was not found" ], 400 ); } diff --git a/src/Entity/Poll.php b/src/Entity/Poll.php index 04deeb0..1ac2311 100755 --- a/src/Entity/Poll.php +++ b/src/Entity/Poll.php @@ -85,6 +85,15 @@ class Poll { * @Serializer\Expose() */ public $votesAllowed = true; + + /** + * people can add votes + * @ORM\Column(type="boolean", nullable=true) + * @Serializer\Type("boolean") + * @Serializer\Expose() + */ + public $isZeroKnowledge ; + /** * max number of stack of votes possible. * limits the number of people who can answer. as long as you trust the people to give only one answer with a reliable system. @@ -193,575 +202,587 @@ class Poll { private $maxChoicesLimit = 25; public function __construct() { - - $this->initiate(); - $this->setCreatedAt( new DateTime() ); - $this->setAdminKey( $this->generateRandomKey() ); - $this->votes = new ArrayCollection(); - $this->stacksOfVotes = new ArrayCollection(); - $this->choices = new ArrayCollection(); - $this->comments = new ArrayCollection(); - } + + $this->initiate(); + $this->setCreatedAt( new DateTime() ); + $this->setAdminKey( $this->generateRandomKey() ); + $this->votes = new ArrayCollection(); + $this->stacksOfVotes = new ArrayCollection(); + $this->choices = new ArrayCollection(); + $this->comments = new ArrayCollection(); + } private function initiate() { - $this->votes = new ArrayCollection(); - $this->stacksOfVotes = new ArrayCollection(); - $this->choices = new ArrayCollection(); - $this->comments = new ArrayCollection(); - $this->setAdminKey( $this->generateRandomKey() ); - $this->setCreatedAt( new DateTime() ); - $this->setExpiracyDate( $this->addDaysToDate( - new DateTime(), - $this->defaultExpiracyDaysFromNow - ) ); - $this->setAllowedAnswers( [ 'yes', 'maybe', 'no' ] ); - } + $this->votes = new ArrayCollection(); + $this->stacksOfVotes = new ArrayCollection(); + $this->choices = new ArrayCollection(); + $this->comments = new ArrayCollection(); + $this->setAdminKey( $this->generateRandomKey() ); + $this->setCreatedAt( new DateTime() ); + $this->setExpiracyDate( $this->addDaysToDate( + new DateTime(), + $this->defaultExpiracyDaysFromNow + ) ); + $this->setAllowedAnswers( [ 'yes', 'maybe', 'no' ] ); + } public function setCreatedAt( DateTimeInterface $createdAt ): self { - $this->createdAt = $createdAt; - - return $this; - } + $this->createdAt = $createdAt; + + return $this; + } public function displayForAdmin() { - $content = $this->display(); - $content[ 'owner' ] = $this->getOwner()->displayForAdmin(); - $content[ 'admin_key' ] = $this->getAdminKey(); - $content[ 'password_hash' ] = $this->getPassword(); - $content[ 'id' ] = $this->getId(); - - return $content; - } + $content = $this->display(); + $content[ 'owner' ] = $this->getOwner()->displayForAdmin(); + $content[ 'admin_key' ] = $this->getAdminKey(); + $content[ 'password_hash' ] = $this->getPassword(); + $content[ 'id' ] = $this->getId(); + + return $content; + } // counts each number of answer for this choice public function display() { - - $computedAnswers = $this->computeAnswers(); - $displayedStackOfVotes = []; - foreach ( $this->getStacksOfVotes() as $stack ) { - $displayedStackOfVotes[] = $stack->display(); - } - $displayedChoices = []; - foreach ( $this->getChoices() as $choice ) { - $displayedChoices[] = $choice->display( $this->getKind() ); - } - $displayedComments = []; - foreach ( $this->getComments() as $comment ) { - $displayedComments[] = $comment->display(); - } - - - $resp = [ - 'title' => $this->getTitle(), - 'description' => $this->getDescription(), - 'created_at' => $this->getCreatedAt()->format( 'c' ), - 'expiracy_date' => $this->getExpiracyDate()->format( 'c' ), - 'votes_max' => $this->getVotesMax(), - 'custom_url' => $this->getCustomUrl(), - 'choices_max' => $this->getChoicesMax(), - 'kind' => $this->getKind(), - 'allowed_answers' => $this->getAllowedAnswers(), - 'votes_allowed' => $this->getVotesAllowed(), - 'modification_policy' => $this->getModificationPolicy(), - 'hide_results' => $this->getHideResults(), - 'show_results_even_if_password' => $this->getShowResultEvenIfPasswords(), - 'owner' => [ - 'pseudo' => $this->getOwner()->getPseudo(), - ] - , - 'password_protected' => $this->getPassword() ? 'yes' : 'no', - 'max_score' => $computedAnswers[ 'max_score' ], - 'choices' => $computedAnswers[ 'answers' ], - 'stacks' => $displayedStackOfVotes, - 'comments' => $displayedComments, - ]; - - if ( $this->getKind() == 'text' ) { - $resp[ 'choices' ] = $computedAnswers[ 'answers' ]; - } elseif ( $this->getKind() == 'date' ) { - $resp[ 'choices_grouped' ] = $computedAnswers[ 'grouped_dates' ]; - } - - return $resp; - } + + $computedAnswers = $this->computeAnswers(); + $displayedStackOfVotes = []; + foreach ( $this->getStacksOfVotes() as $stack ) { + $displayedStackOfVotes[] = $stack->display(); + } + $displayedChoices = []; + foreach ( $this->getChoices() as $choice ) { + $displayedChoices[] = $choice->display( $this->getKind() ); + } + $displayedComments = []; + foreach ( $this->getComments() as $comment ) { + $displayedComments[] = $comment->display(); + } + + + $resp = [ + 'title' => $this->getTitle(), + 'description' => $this->getDescription(), + 'created_at' => $this->getCreatedAt()->format( 'c' ), + 'expiracy_date' => $this->getExpiracyDate()->format( 'c' ), + 'votes_max' => $this->getVotesMax(), + 'custom_url' => $this->getCustomUrl(), + 'choices_max' => $this->getChoicesMax(), + 'kind' => $this->getKind(), + 'allowed_answers' => $this->getAllowedAnswers(), + 'votes_allowed' => $this->getVotesAllowed(), + 'modification_policy' => $this->getModificationPolicy(), + 'hide_results' => $this->getHideResults(), + 'show_results_even_if_password' => $this->getShowResultEvenIfPasswords(), + 'owner' => [ + 'pseudo' => $this->getOwner()->getPseudo(), + ] + , + 'password_protected' => $this->getPassword() ? 'yes' : 'no', + 'max_score' => $computedAnswers[ 'max_score' ], + 'choices' => $computedAnswers[ 'answers' ], + 'stacks' => $displayedStackOfVotes, + 'comments' => $displayedComments, + ]; + + if ( $this->getKind() == 'text' ) { + $resp[ 'choices' ] = $computedAnswers[ 'answers' ]; + } elseif ( $this->getKind() == 'date' ) { + $resp[ 'choices_grouped' ] = $computedAnswers[ 'grouped_dates' ]; + } + + return $resp; + } public function computeAnswers() { - $computedArray = []; - $grouped_dates = []; - $maxScore = 0; - - if ( $this->getKind() == 'date' ) { - foreach ( $this->getChoices() as $choice ) { - $boom = explode( ' >>> ', $choice->getName() ); - - if ( count( $boom ) == 2 ) { - - - if ( ! isset( $grouped_dates[ $boom[ 0 ] ] ) ) { - - $grouped_dates[ $boom[ 0 ] ] = [ - - "date_string" => $boom[ 0 ], - "choices" => [], - ]; - } - $grouped_dates[ $boom[ 0 ] ][ "choices" ][] = [ - "choice_id" => $choice->getId(), - "name" => $boom[ 1 ], - ]; - } - } - } - $scoreInfos = [ - 'score' => 0, - 'yes' => [ - 'count' => 0, - 'people' => [], - ], - 'maybe' => [ - 'count' => 0, - 'people' => [], - ], - 'no' => [ - 'count' => 0, - 'people' => [], - ], - ]; - - // first, prefill all choices - foreach ( $this->getChoices() as $choice ) { - $computedArray[ $choice->getId() ] = array_merge( $scoreInfos, $choice->display( $this->getKind() ) ); - } - // then, compute stack of votes scores on each choice - foreach ( $this->getStacksOfVotes() as $stack_of_vote ) { - foreach ( $stack_of_vote->getVotes() as $vote ) { - $answer = $vote->getValue(); - $choice_id = $vote->getChoice()->getId(); - $choice_url = $vote->getChoice()->getUrl(); - - if ( ! isset( $computedArray[ $choice_id ] ) ) { - $computedArray[ $choice_id ] = [ - 'id' => $choice_id, - 'url' => $choice_url, - 'name' => $vote->getChoice()->getName(), - 'score' => 0, - 'yes' => [ - 'count' => 0, - 'people' => [], - ], - 'maybe' => [ - 'count' => 0, - 'people' => [], - ], - 'no' => [ - 'count' => 0, - 'people' => [], - ], - - ]; - } - $computedArray[ $choice_id ][ $answer ][ 'count' ] ++; - $computedArray[ $choice_id ][ $answer ][ 'people' ][] = $stack_of_vote->getOwner()->getPseudo(); - - if ( $answer == 'yes' ) { - $computedArray[ $choice_id ][ 'score' ] += 1; - } elseif ( $answer == 'maybe' ) { - $computedArray[ $choice_id ][ 'score' ] += 0.5; - } - // compare with max value - if ( $computedArray[ $choice_id ][ 'score' ] > $maxScore ) { - $maxScore = $computedArray[ $choice_id ][ 'score' ]; - } - } - } - $answersWithStats = []; - foreach ( $computedArray as $choice_stat ) { - $answersWithStats[] = $choice_stat; - } - $groupsOfDates = []; - foreach ( $grouped_dates as $group ) { - $ii = 0; - foreach ( $group[ "choices" ] as $slice ) { - $slice[ 'score' ] = $computedArray[ $slice[ 'choice_id' ] ][ 'score' ]; - $slice[ 'yes' ] = $computedArray[ $slice[ 'choice_id' ] ][ 'yes' ]; - $slice[ 'maybe' ] = $computedArray[ $slice[ 'choice_id' ] ][ 'maybe' ]; - $slice[ 'no' ] = $computedArray[ $slice[ 'choice_id' ] ][ 'no' ]; - $slice[ 'id' ] = $slice[ 'choice_id' ]; - $group[ "choices" ][ $ii ] = $slice; - $ii ++; - } - - $groupsOfDates[] = $group; - } - - return [ - 'answers' => $answersWithStats, - 'grouped_dates' => $groupsOfDates, - 'max_score' => $maxScore, - ]; - } + $computedArray = []; + $grouped_dates = []; + $maxScore = 0; + + if ( $this->getKind() == 'date' ) { + foreach ( $this->getChoices() as $choice ) { + $boom = explode( ' >>> ', $choice->getName() ); + + if ( count( $boom ) == 2 ) { + + + if ( ! isset( $grouped_dates[ $boom[ 0 ] ] ) ) { + + $grouped_dates[ $boom[ 0 ] ] = [ + + "date_string" => $boom[ 0 ], + "choices" => [], + ]; + } + $grouped_dates[ $boom[ 0 ] ][ "choices" ][] = [ + "choice_id" => $choice->getId(), + "name" => $boom[ 1 ], + ]; + } + } + } + $scoreInfos = [ + 'score' => 0, + 'yes' => [ + 'count' => 0, + 'people' => [], + ], + 'maybe' => [ + 'count' => 0, + 'people' => [], + ], + 'no' => [ + 'count' => 0, + 'people' => [], + ], + ]; + + // first, prefill all choices + foreach ( $this->getChoices() as $choice ) { + $computedArray[ $choice->getId() ] = array_merge( $scoreInfos, $choice->display( $this->getKind() ) ); + } + // then, compute stack of votes scores on each choice + foreach ( $this->getStacksOfVotes() as $stack_of_vote ) { + foreach ( $stack_of_vote->getVotes() as $vote ) { + $answer = $vote->getValue(); + $choice_id = $vote->getChoice()->getId(); + $choice_url = $vote->getChoice()->getUrl(); + + if ( ! isset( $computedArray[ $choice_id ] ) ) { + $computedArray[ $choice_id ] = [ + 'id' => $choice_id, + 'url' => $choice_url, + 'name' => $vote->getChoice()->getName(), + 'score' => 0, + 'yes' => [ + 'count' => 0, + 'people' => [], + ], + 'maybe' => [ + 'count' => 0, + 'people' => [], + ], + 'no' => [ + 'count' => 0, + 'people' => [], + ], + + ]; + } + $computedArray[ $choice_id ][ $answer ][ 'count' ] ++; + $computedArray[ $choice_id ][ $answer ][ 'people' ][] = $stack_of_vote->getOwner()->getPseudo(); + + if ( $answer == 'yes' ) { + $computedArray[ $choice_id ][ 'score' ] += 1; + } elseif ( $answer == 'maybe' ) { + $computedArray[ $choice_id ][ 'score' ] += 0.5; + } + // compare with max value + if ( $computedArray[ $choice_id ][ 'score' ] > $maxScore ) { + $maxScore = $computedArray[ $choice_id ][ 'score' ]; + } + } + } + $answersWithStats = []; + foreach ( $computedArray as $choice_stat ) { + $answersWithStats[] = $choice_stat; + } + $groupsOfDates = []; + foreach ( $grouped_dates as $group ) { + $ii = 0; + foreach ( $group[ "choices" ] as $slice ) { + $slice[ 'score' ] = $computedArray[ $slice[ 'choice_id' ] ][ 'score' ]; + $slice[ 'yes' ] = $computedArray[ $slice[ 'choice_id' ] ][ 'yes' ]; + $slice[ 'maybe' ] = $computedArray[ $slice[ 'choice_id' ] ][ 'maybe' ]; + $slice[ 'no' ] = $computedArray[ $slice[ 'choice_id' ] ][ 'no' ]; + $slice[ 'id' ] = $slice[ 'choice_id' ]; + $group[ "choices" ][ $ii ] = $slice; + $ii ++; + } + + $groupsOfDates[] = $group; + } + + return [ + 'answers' => $answersWithStats, + 'grouped_dates' => $groupsOfDates, + 'max_score' => $maxScore, + ]; + } /** * @return Collection|Choice[] */ public function getChoices(): Collection { - return $this->choices; - } + return $this->choices; + } public function getKind(): ?string { - return $this->kind; - } + return $this->kind; + } public function setKind( string $kind ): self { - $this->kind = $kind; - - return $this; - } + $this->kind = $kind; + + return $this; + } public function getStacksOfVotes() { - return $this->stacksOfVotes; - } + return $this->stacksOfVotes; + } public function setStacksOfVotes( ?StackOfVotes $stacksOfVotes ): self { - $this->stacksOfVotes = $stacksOfVotes; - - return $this; - } + $this->stacksOfVotes = $stacksOfVotes; + + return $this; + } /** * @return Collection|Comment[] */ public function getComments(): Collection { - return $this->comments; - } + return $this->comments; + } public function getTitle(): ?string { - return $this->title; - } + return $this->title; + } public function setTitle( string $title ): self { - $this->title = $title; - - return $this; - } + $this->title = $title; + + return $this; + } public function getDescription(): ?string { - return $this->description; - } + return $this->description; + } public function setDescription( string $description ): self { - $this->description = $description; - - return $this; - } + $this->description = $description; + + return $this; + } public function getCreatedAt(): ?DateTimeInterface { - return $this->createdAt; - } + return $this->createdAt; + } public function getExpiracyDate(): ?DateTimeInterface { - return $this->expiracyDate; - } + return $this->expiracyDate; + } public function setExpiracyDate( DateTimeInterface $expiracyDate ): self { - $this->expiracyDate = $expiracyDate; - - return $this; - } + $this->expiracyDate = $expiracyDate; + + return $this; + } public function getVotesMax() { - return $this->votesMax; - } + return $this->votesMax; + } public function setVotesMax( $votesMax ): self { - $this->votesMax = $votesMax; - - return $this; - } + $this->votesMax = $votesMax; + + return $this; + } public function getChoicesMax() { - return $this->choicesMax; - } + return $this->choicesMax; + } public function setChoicesMax( $choicesMax ): self { - $this->choicesMax = $choicesMax; - - return $this; - } + $this->choicesMax = $choicesMax; + + return $this; + } public function getAllowedAnswers(): ?array { - return $this->allowedAnswers; - } + return $this->allowedAnswers; + } public function setAllowedAnswers( array $allowedAnswers ): self { - if ( ! count( $allowedAnswers ) ) { - $this->allowedAnswers = [ 'yes' ]; - } else { - $this->allowedAnswers = $allowedAnswers; - } - - return $this; - } + if ( ! count( $allowedAnswers ) ) { + $this->allowedAnswers = [ 'yes' ]; + } else { + $this->allowedAnswers = $allowedAnswers; + } + + return $this; + } public function getVotesAllowed(): ?bool { - return $this->votesAllowed; - } + return $this->votesAllowed; + } public function setVotesAllowed( ?bool $votesAllowed ): self { - $this->votesAllowed = $votesAllowed; - - return $this; - } + $this->votesAllowed = $votesAllowed; + + return $this; + } public function getModificationPolicy(): ?string { - return $this->modificationPolicy; - } + return $this->modificationPolicy; + } public function setModificationPolicy( string $modificationPolicy ): self { - $this->modificationPolicy = $modificationPolicy; - - return $this; - } + $this->modificationPolicy = $modificationPolicy; + + return $this; + } public function getHideResults(): ?bool { - return $this->hideResults; - } + return $this->hideResults; + } public function setHideResults( bool $hideResults ): self { - $this->hideResults = $hideResults; - - return $this; - } + $this->hideResults = $hideResults; + + return $this; + } public function getShowResultEvenIfPasswords(): ?bool { - return $this->showResultEvenIfPasswords; - } + return $this->showResultEvenIfPasswords; + } public function setShowResultEvenIfPasswords( bool $showResultEvenIfPasswords ): self { - $this->showResultEvenIfPasswords = $showResultEvenIfPasswords; - - return $this; - } + $this->showResultEvenIfPasswords = $showResultEvenIfPasswords; + + return $this; + } public function getOwner(): ?Owner { - return $this->owner; - } + return $this->owner; + } public function setOwner( ?Owner $owner ): self { - $this->owner = $owner; - - return $this; - } + $this->owner = $owner; + + return $this; + } public function getPassword(): ?string { - return $this->password; - } + return $this->password; + } public function setPassword( string $password ): self { - $this->password = md5( $password ); - - return $this; - } + $this->password = md5( $password ); + + return $this; + } public function getAdminKey(): ?string { - return $this->adminKey; - } + return $this->adminKey; + } public function setAdminKey( string $adminKey ): self { - $this->adminKey = $adminKey; - - return $this; - } + $this->adminKey = $adminKey; + + return $this; + } public function getId(): ?int { - return $this->id; - } + return $this->id; + } public function findChoiceById( int $id ) { - - $choices = $this->getChoices(); - $counter = 0; - // there must be something cleaner than this in Doctrine ArrayCollection - foreach ( $choices as $choice ) { - $counter ++; - if ( $counter > $this->maxChoicesLimit ) { - throw new ErrorException( "max number of choices reached for this poll" ); - } - if ( $choice && $choice->getId() == $id ) { - return $choice; - } - - } - - return null; - } + + $choices = $this->getChoices(); + $counter = 0; + // there must be something cleaner than this in Doctrine ArrayCollection + foreach ( $choices as $choice ) { + $counter ++; + if ( $counter > $this->maxChoicesLimit ) { + throw new ErrorException( "max number of choices reached for this poll" ); + } + if ( $choice && $choice->getId() == $id ) { + return $choice; + } + + } + + return null; + } /** * @return Collection|Vote[] */ public function getVotes(): Collection { - return $this->votes; - } + return $this->votes; + } public function getCustomUrl(): ?string { - return $this->customUrl; - } + return $this->customUrl; + } public function setCustomUrl( string $customUrl ): self { - $this->customUrl = $customUrl; - - return $this; - } + $this->customUrl = $customUrl; + + return $this; + } public function getMailOnComment(): ?bool { - return $this->mailOnComment; - } + return $this->mailOnComment; + } public function setMailOnComment( bool $mailOnComment ): self { - $this->mailOnComment = $mailOnComment; - - return $this; - } + $this->mailOnComment = $mailOnComment; + + return $this; + } public function getMailOnVote(): ?bool { - return $this->mailOnVote; - } + return $this->mailOnVote; + } public function setMailOnVote( bool $mailOnVote ): self { - $this->mailOnVote = $mailOnVote; - - return $this; - } + $this->mailOnVote = $mailOnVote; + + return $this; + } public function addComment( Comment $comment ): self { - if ( ! $this->comments->contains( $comment ) ) { - $this->comments[] = $comment; - $comment->setPoll( $this ); - } - - return $this; - } + if ( ! $this->comments->contains( $comment ) ) { + $this->comments[] = $comment; + $comment->setPoll( $this ); + } + + return $this; + } public function removeComment( Comment $comment ): self { - if ( $this->comments->contains( $comment ) ) { - $this->comments->removeElement( $comment ); - // set the owning side to null (unless already changed) - if ( $comment->getPoll() === $this ) { - $comment->setPoll( null ); - } - } - - return $this; - } + if ( $this->comments->contains( $comment ) ) { + $this->comments->removeElement( $comment ); + // set the owning side to null (unless already changed) + if ( $comment->getPoll() === $this ) { + $comment->setPoll( null ); + } + } + + return $this; + } public function addStackOfVote( StackOfVotes $stackOfVote ): self { - if ( ! $this->stacksOfVotes->contains( $stackOfVote ) ) { - $this->stacksOfVotes[] = $stackOfVote; - $stackOfVote->setPoll( $this ); - } - - return $this; - } + if ( ! $this->stacksOfVotes->contains( $stackOfVote ) ) { + $this->stacksOfVotes[] = $stackOfVote; + $stackOfVote->setPoll( $this ); + } + + return $this; + } public function removeStackOfVote( StackOfVotes $stackOfVote ): self { - if ( $this->stacksOfVotes->contains( $stackOfVote ) ) { - $this->stacksOfVotes->removeElement( $stackOfVote ); - // set the owning side to null (unless already changed) - if ( $stackOfVote->getPoll() === $this ) { - $stackOfVote->setPoll( null ); - } - } - - return $this; - } + if ( $this->stacksOfVotes->contains( $stackOfVote ) ) { + $this->stacksOfVotes->removeElement( $stackOfVote ); + // set the owning side to null (unless already changed) + if ( $stackOfVote->getPoll() === $this ) { + $stackOfVote->setPoll( null ); + } + } + + return $this; + } public function addVote( Vote $vote ): self { - if ( ! $this->votes->contains( $vote ) ) { - $this->votes[] = $vote; - $vote->setPoll( $this ); - } - - return $this; - } + if ( ! $this->votes->contains( $vote ) ) { + $this->votes[] = $vote; + $vote->setPoll( $this ); + } + + return $this; + } public function removeVote( Vote $vote ): self { - if ( $this->votes->contains( $vote ) ) { - $this->votes->removeElement( $vote ); - // set the owning side to null (unless already changed) - if ( $vote->getPoll() === $this ) { - $vote->setPoll( null ); - } - } - - return $this; - } + if ( $this->votes->contains( $vote ) ) { + $this->votes->removeElement( $vote ); + // set the owning side to null (unless already changed) + if ( $vote->getPoll() === $this ) { + $vote->setPoll( null ); + } + } + + return $this; + } public function addTextChoiceArray( array $choiceTextArray ): self { - foreach ( $choiceTextArray as $text ) { - $newChoice = new Choice(); - $newChoice->setName( $text ); - $this->addChoice( $newChoice ); - } - - return $this; - } + foreach ( $choiceTextArray as $text ) { + $newChoice = new Choice(); + $newChoice->setName( $text ); + $this->addChoice( $newChoice ); + } + + return $this; + } public function addChoice( Choice $choice ): self { - if ( ! is_null( $this->choices ) ) { - if ( ! $this->choices->contains( $choice ) ) { - $this->choices[] = $choice; - $choice->setPoll( $this ); - } - } else { - $this->choices[] = $choice; - $choice->setPoll( $this ); - } - - - return $this; - } + if ( ! is_null( $this->choices ) ) { + if ( ! $this->choices->contains( $choice ) ) { + $this->choices[] = $choice; + $choice->setPoll( $this ); + } + } else { + $this->choices[] = $choice; + $choice->setPoll( $this ); + } + + + return $this; + } public function addStacksOfVote( StackOfVotes $stacksOfVote ): self { - if ( ! $this->stacksOfVotes->contains( $stacksOfVote ) ) { - $this->stacksOfVotes[] = $stacksOfVote; - $stacksOfVote->setPoll( $this ); - } - - return $this; - } + if ( ! $this->stacksOfVotes->contains( $stacksOfVote ) ) { + $this->stacksOfVotes[] = $stacksOfVote; + $stacksOfVote->setPoll( $this ); + } + + return $this; + } public function removeStacksOfVote( StackOfVotes $stacksOfVote ): self { - if ( $this->stacksOfVotes->contains( $stacksOfVote ) ) { - $this->stacksOfVotes->removeElement( $stacksOfVote ); - // set the owning side to null (unless already changed) - if ( $stacksOfVote->getPoll() === $this ) { - $stacksOfVote->setPoll( null ); - } - } - - return $this; - } + if ( $this->stacksOfVotes->contains( $stacksOfVote ) ) { + $this->stacksOfVotes->removeElement( $stacksOfVote ); + // set the owning side to null (unless already changed) + if ( $stacksOfVote->getPoll() === $this ) { + $stacksOfVote->setPoll( null ); + } + } + + return $this; + } public function removeChoice( Choice $choice ): self { - if ( $this->choices->contains( $choice ) ) { - $this->choices->removeElement( $choice ); - // set the owning side to null (unless already changed) - if ( $choice->getPoll() === $this ) { - $choice->setPoll( null ); - } - } - - return $this; - } + if ( $this->choices->contains( $choice ) ) { + $this->choices->removeElement( $choice ); + // set the owning side to null (unless already changed) + if ( $choice->getPoll() === $this ) { + $choice->setPoll( null ); + } + } + + return $this; + } public function getCommentsAllowed(): ?bool { - return $this->commentsAllowed; - } + return $this->commentsAllowed; + } public function setCommentsAllowed( ?bool $commentsAllowed ): self { - $this->commentsAllowed = $commentsAllowed; + $this->commentsAllowed = $commentsAllowed; + + return $this; + } - return $this; - } + public function getIsZeroKnowledge(): ?bool + { + return $this->isZeroKnowledge; + } + + public function setIsZeroKnowledge(?bool $isZeroKnowledge): self + { + $this->isZeroKnowledge = $isZeroKnowledge; + + return $this; + } } diff --git a/templates/emails/creation-mail.html.twig b/templates/emails/creation-mail.html.twig index 081beef..eb0c471 100755 --- a/templates/emails/creation-mail.html.twig +++ b/templates/emails/creation-mail.html.twig @@ -2,12 +2,12 @@ {% extends 'email-base.html.twig' %} {% block content %} - - Suite à la création de votre sondage {{ title }} vous recevez deux emails afin de ne pas transmettre par erreur aux sondés le lien d'administration de votre sondage. +

✨ Création de votre sondage {{ title }}

+ Suite à la création de votre sondage {{ title }} vous recevez deux emails afin de ne pas transmettre par erreur aux sondés le lien d'administration de votre sondage.
Ce mail est le premier, comportant le message qui doit être envoyé aux sondés.
- Vous pouvez maintenant transmettre ce message à toutes les personnes susceptibles de participer au vote.
+ Vous pouvez maintenant transmettre ce message à toutes les personnes susceptibles de participer au vote. ✔️

@@ -15,7 +15,7 @@
- {{ owner.pseudo }} ( {{ owner.email }} ) vient de créer un sondage intitulé : " {{ title }} + 💡 {{ owner.pseudo }} ( {{ owner.email }} ) vient de créer un sondage intitulé : " {{ title }} ".

diff --git a/templates/emails/expiration-mail.html.twig b/templates/emails/expiration-mail.html.twig index 49adf56..42ea94d 100755 --- a/templates/emails/expiration-mail.html.twig +++ b/templates/emails/expiration-mail.html.twig @@ -3,13 +3,17 @@ {% block content %} - Ce sondage va bientôt expirer dans 1 jour,
+

🎌 Votre sondage {{ poll.title }} va bientôt expirer dans 1 jour,

- le {{ poll.expiracyDate | date('D Y-m-d') }} + le {{ poll.expiracyDate | date('D Y-m-d') }} :
il ne sera plus possible d'y voter.
Dans 31 jours il sera supprimé.
Vous pouvez exporter ses données à tout moment en vous rendant à ce lien pour l'administrer:
{% include 'emails/partial/admin_link.html.twig' %} + +
+ Plus de détails sur votre sondage : + {% include 'emails/partial/poll.html.twig' %} {% endblock %} diff --git a/templates/emails/footer.html.twig b/templates/emails/footer.html.twig index bb67a38..4452390 100755 --- a/templates/emails/footer.html.twig +++ b/templates/emails/footer.html.twig @@ -13,10 +13,10 @@ Sources du client Front end, - + API back end. - + Documentation diff --git a/templates/emails/partial/admin_link.html.twig b/templates/emails/partial/admin_link.html.twig index 9743509..913e7df 100644 --- a/templates/emails/partial/admin_link.html.twig +++ b/templates/emails/partial/admin_link.html.twig @@ -1,2 +1 @@ -{{ BASE_URL }} - /admin/{{ poll.adminKey }} +{{ BASE_URL }}/#/poll/{{ poll.customUrl }}/admin/{{ poll.adminKey }} diff --git a/templates/emails/partial/poll.html.twig b/templates/emails/partial/poll.html.twig index 764aa70..b186819 100644 --- a/templates/emails/partial/poll.html.twig +++ b/templates/emails/partial/poll.html.twig @@ -2,11 +2,9 @@

Sondage {{ poll.title }}

- -
- créé le {{ poll.creationDate| date('Y m d ') }} + créé le {{ poll.createdAt| date('Y m d ') }}
expirera le {{ poll.expiracyDate| date('Y m d ') }} @@ -18,22 +16,29 @@ {{ poll.comments |length }} commentaires {% if poll.password |length %} - (accès avec mot de passe) +
+ 🔐 (accès avec mot de passe) +
+ {% else %} + {% endif %} + {% if poll.isZeroKnowledge |length %} +
+ 🔐 Ce sondage bénéficie du chiffrement Zéro knowledge, nos administrateurs ne sont pas en mesure de connaître les informations du sondage. +
{% else %} {% endif %} -
- +
lien à donner aux votants: - +
{% include 'emails/partial/public_link.html.twig' %}
- +
administration: - +
{% include 'emails/partial/admin_link.html.twig' %}
diff --git a/templates/emails/partial/public_link.html.twig b/templates/emails/partial/public_link.html.twig index 41114ce..5ffc10d 100644 --- a/templates/emails/partial/public_link.html.twig +++ b/templates/emails/partial/public_link.html.twig @@ -1,11 +1,10 @@ {% if poll.customUrl |length %} - - {{ BASE_URL }}/#/vote/poll/key/{{ poll.customUrl }} + + +✉️ {{ BASE_URL }}/#/poll/{{ poll.customUrl }}/consultation {% else %} - - {{ BASE_URL }}/#/vote/poll/id/{{ poll.id }} - + erreur, il manque la customUrl de ce sondage. {% endif %}