Skip to content

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
thielpeter committed May 18, 2018
1 parent 2e818b5 commit 98697c3
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 14 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@

Last Changes
-------
### Version 1.3.2 // 18.05.2018

* Bugfix

### Version 1.3.1 // 17.05.2018

* Statistikanzeige verbessert, Datenschutzcheckbox
Expand Down
14 changes: 13 additions & 1 deletion lib/poll.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function executeVote($option_id, $hash)
break;

case "email":

if (rex_poll_user::getVote($this, $hash)) {
return false;
}
Expand Down Expand Up @@ -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()
{
Expand Down Expand Up @@ -177,7 +189,7 @@ function getFormByType()
checkbox|Datenschutz|<p>Ich habe die <a target="_blank" rel="noopener" href="'.rex_getUrl(120).'">Datenschutzerklärung</a> zur Kenntnis genommen.</p>|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|<p>' . rex_i18n::msg('poll_vote_confirm') . '</p>|||1
';
break;
Expand Down
29 changes: 17 additions & 12 deletions lib/yform/action/poll_executevote.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,41 @@ 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();
if ($email != '') {
$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;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package: poll
version: '1.3.1'
version: '1.3.2'
author: Friends Of REDAXO
supportpage: www.github.org/friendsofredaxo/poll

Expand Down

0 comments on commit 98697c3

Please sign in to comment.