diff --git a/plugins/content/kunenadiscuss/kunenadiscuss.php b/plugins/content/kunenadiscuss/kunenadiscuss.php index c39d796a..08c6ce40 100644 --- a/plugins/content/kunenadiscuss/kunenadiscuss.php +++ b/plugins/content/kunenadiscuss/kunenadiscuss.php @@ -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"); @@ -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; } } @@ -1133,3 +1144,4 @@ protected function createTable() } } } + diff --git a/plugins/content/kunenadiscuss/tmpl/form.php b/plugins/content/kunenadiscuss/tmpl/form.php index 9605d7be..518a7c2f 100644 --- a/plugins/content/kunenadiscuss/tmpl/form.php +++ b/plugins/content/kunenadiscuss/tmpl/form.php @@ -61,7 +61,7 @@ hasCaptcha()) : ?> -
+ displayCaptcha(); ?>