Skip to content

Commit

Permalink
(new) Fix KunenaDiscuss recaptcha Joomla! 3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
810 committed Aug 5, 2016
2 parents 37afd84 + 7e93169 commit c4898a9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
26 changes: 19 additions & 7 deletions plugins/content/kunenadiscuss/kunenadiscuss.php
Expand Up @@ -650,11 +650,6 @@ protected function showForm($row, KunenaForumCategory $category, KunenaForumTopi
$this->email = JRequest::getString('email', null, 'POST');
$this->message = JRequest::getString('message', null, 'POST');

if ($this->hasCaptcha())
{
$this->displayCaptcha();
}

ob_start();
$this->debug("showForm: Rendering form");
include(__DIR__ . "/tmpl/form.php");
Expand Down Expand Up @@ -1047,13 +1042,29 @@ protected function displayCaptcha()
$params = new JRegistry($plugin[0]->params);
$captcha_pubkey = $params->get('public_key');
$catcha_privkey = $params->get('private_key');
$random = mt_rand(99, 999);

if (!empty($captcha_pubkey) && !empty($catcha_privkey))
{
JPluginHelper::importPlugin('captcha');
$dispatcher = JDispatcher::getInstance();
$dispatcher->trigger('onInit', 'dynamic_recaptcha_1');

if (version_compare(JVERSION, '3.5', '<'))
{
$dispatcher = JDispatcher::getInstance();
$dispatcher->trigger('onInit', 'dynamic_recaptcha_' . $random);
$output = $dispatcher->trigger('onDisplay', array(null, 'dynamic_recaptcha_' . $random));
}
else
{
$dispatcher = JEventDispatcher::getInstance();
$dispatcher->trigger('onInit', 'dynamic_recaptcha_' . $random);
$output = $dispatcher->trigger('onDisplay', array(null, 'dynamic_recaptcha_' . $random, 'class="controls g-recaptcha"'));
}

return $output[0];
}

return false;
}
}

Expand Down Expand Up @@ -1133,3 +1144,4 @@ protected function createTable()
}
}
}

2 changes: 1 addition & 1 deletion plugins/content/kunenadiscuss/tmpl/form.php
Expand Up @@ -61,7 +61,7 @@
</tr>
<?php if ($this->hasCaptcha()) : ?>
<tr>
<td><div id="dynamic_recaptcha_1"> </div></td>
<td><?php echo $this->displayCaptcha(); ?></td>
</tr>
<?php endif; ?>
<tr>
Expand Down

0 comments on commit c4898a9

Please sign in to comment.