From 98697c3a6aeff0cfd3b040bd45dd43dfe50aeb1d Mon Sep 17 00:00:00 2001 From: Peter Thiel Date: Fri, 18 May 2018 13:15:22 +0200 Subject: [PATCH] Bugfix https://github.com/FriendsOfREDAXO/poll/issues/4 --- README.md | 4 ++++ lib/poll.php | 14 ++++++++++++- lib/yform/action/poll_executevote.php | 29 ++++++++++++++++----------- package.yml | 2 +- 4 files changed, 35 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 3604274..78f4209 100755 --- a/README.md +++ b/README.md @@ -13,6 +13,10 @@ Last Changes ------- +### Version 1.3.2 // 18.05.2018 + +* Bugfix + ### Version 1.3.1 // 17.05.2018 * Statistikanzeige verbessert, Datenschutzcheckbox diff --git a/lib/poll.php b/lib/poll.php index 9aa47bd..72b7079 100755 --- a/lib/poll.php +++ b/lib/poll.php @@ -68,6 +68,7 @@ public function executeVote($option_id, $hash) break; case "email": + if (rex_poll_user::getVote($this, $hash)) { return false; } @@ -135,6 +136,17 @@ function getOptionsSorted($sortedby = 'hits') return $options; } + public function getEmailTemplateById($id) + { + $gt = rex_sql::factory(); + $gt->setQuery('select * from ' . rex::getTablePrefix() . 'yform_email_template where id=:id', [':id' => $id]); + if ($gt->getRows() == 1) { + $b = $gt->getArray(); + return current($b); + } + return false; + } + public function getFormByType() { @@ -177,7 +189,7 @@ function getFormByType() checkbox|Datenschutz|

Ich habe die Datenschutzerklärung zur Kenntnis genommen.

|0,1|0|no_db validate|empty|Datenschutz|Bitte bestätigen Sie, dass Sie die Datenschutzerklärung zur Kenntnis genommen haben und stimmen Sie der elektronischen Verwendung Ihrer Daten zur Abstimmung zu. - action|poll_executevote|poll-id|poll-option|poll-email|poll_user + action|poll_executevote|poll-id|poll-option|poll-email|'.$this->emailtemplate.' action|showtext|

' . rex_i18n::msg('poll_vote_confirm') . '

|||1 '; break; diff --git a/lib/yform/action/poll_executevote.php b/lib/yform/action/poll_executevote.php index 14a9a04..5f65b34 100644 --- a/lib/yform/action/poll_executevote.php +++ b/lib/yform/action/poll_executevote.php @@ -11,12 +11,12 @@ class rex_yform_action_poll_executevote extends rex_yform_action_abstract { public function executeAction() { - $poll_id = $this->params['value_pool']['sql'][$this->getElement(2)]; - $option_id = $this->params['value_pool']['sql'][$this->getElement(3)]; + $pollId = $this->params['value_pool']['sql'][$this->getElement(2)]; + $optionId = $this->params['value_pool']['sql'][$this->getElement(3)]; $email = isset($this->params['value_pool']['sql'][$this->getElement(4)]) ? $this->params['value_pool']['sql'][$this->getElement(4)] : ''; - $template_name = $this->getElement(5); + $templateId = $this->getElement(5); - $poll = rex_poll::get($poll_id); + $poll = rex_poll::get($pollId); if ($poll) { $hash = rex_poll_user::getHash(); @@ -24,23 +24,28 @@ public function executeAction() $hash = rex_poll_user::getHash($email . $poll->id . rex::getProperty('instname')); } - if ($poll->executeVote($option_id, $hash)) { + if ($poll->executeVote($optionId, $hash)) { if ($poll->type == 'direct') { $_REQUEST['vote_success'] = true; } if ($poll->type == 'email') { $this->params['value_pool']['email']['poll-link'] = rtrim(rex::getServer(), "/") . rex_getUrl(rex_article::getCurrentid(), rex_clang::getCurrentid(), ['hash' => $hash]); - $etpl = rex_yform_email_template::getTemplate($template_name); - $etpl = rex_yform_email_template::replaceVars($etpl, $this->params['value_pool']['email']); - $etpl['mail_to'] = $email; - $etpl['mail_to_name'] = $email; + $etpl = $poll->getEmailTemplateById($templateId); + if($etpl){ + $etpl = rex_yform_email_template::replaceVars($etpl, $this->params['value_pool']['email']); - if (!rex_yform_email_template::sendMail($etpl, $template_name)) { - return false; + $etpl['mail_to'] = $email; + $etpl['mail_to_name'] = $email; + + if (!rex_yform_email_template::sendMail($etpl)) { + return false; + } } -// dump($etpl); + +// dump($etpl); + return false; } } } diff --git a/package.yml b/package.yml index 2daf284..5983216 100755 --- a/package.yml +++ b/package.yml @@ -1,5 +1,5 @@ package: poll -version: '1.3.1' +version: '1.3.2' author: Friends Of REDAXO supportpage: www.github.org/friendsofredaxo/poll