From ecd159fb7cf47a206627921a836e32654311cf3a Mon Sep 17 00:00:00 2001 From: Nicola Galgano Date: Wed, 7 Sep 2016 07:05:13 +0200 Subject: [PATCH 1/3] [com_contact] - moved the captchaEnabled var out of the default.php file to the view.html.php file moved the captchaEnabled var out of the default.php file to the view.html.php file. --- .../com_contact/views/contact/view.html.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/components/com_contact/views/contact/view.html.php b/components/com_contact/views/contact/view.html.php index 701e0e43e2fc3..240b02b81ff91 100644 --- a/components/com_contact/views/contact/view.html.php +++ b/components/com_contact/views/contact/view.html.php @@ -49,6 +49,14 @@ class ContactViewContact extends JViewLegacy */ protected $return_page; + /** + * Should we show a captcha form for the submission of the contact request? + * + * @var bool + * @since __DEPLOY_VERSION__ + */ + protected $captchaEnabled = false; + /** * Execute and display a template script. * @@ -288,8 +296,17 @@ public function display($tpl = null) $model = $this->getModel(); $model->hit(); - $this->_prepareDocument(); + foreach (JPluginHelper::getPlugin('captcha') as $plugin) + { + if ($captchaSet === $plugin->name) + { + $this->captchaEnabled = true; + break; + } + } + + $this->_prepareDocument(); return parent::display($tpl); } From 1ce657b19c1682c37b279767cde32ff4f771f4a1 Mon Sep 17 00:00:00 2001 From: Nicola Galgano Date: Wed, 7 Sep 2016 07:08:44 +0200 Subject: [PATCH 2/3] moved captchaEnabled to the view moved captchaEnabled to the view --- .../views/contact/tmpl/default_form.php | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/components/com_contact/views/contact/tmpl/default_form.php b/components/com_contact/views/contact/tmpl/default_form.php index 243c562e750b5..31b0e2b282b99 100644 --- a/components/com_contact/views/contact/tmpl/default_form.php +++ b/components/com_contact/views/contact/tmpl/default_form.php @@ -12,23 +12,11 @@ JHtml::_('behavior.keepalive'); JHtml::_('behavior.formvalidator'); -$captchaEnabled = false; - -$captchaSet = $this->params->get('captcha', JFactory::getApplication()->get('captcha', '0')); - -foreach (JPluginHelper::getPlugin('captcha') as $plugin) -{ - if ($captchaSet === $plugin->name) - { - $captchaEnabled = true; - break; - } -} ?>
form->getFieldsets() as $fieldset): ?> - name === 'captcha' && !$captchaEnabled) : ?> + name === 'captcha' && !$this->captchaEnabled) : ?> form->getFieldset($fieldset->name); ?> From 285da535298b3ae17a12141b3043415a8d9d3c04 Mon Sep 17 00:00:00 2001 From: Nicola Galgano Date: Sun, 18 Sep 2016 14:04:08 +0200 Subject: [PATCH 3/3] missed var declarationi/initialization missed var $captchaSet declarationi/initialization --- components/com_contact/views/contact/view.html.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/com_contact/views/contact/view.html.php b/components/com_contact/views/contact/view.html.php index 240b02b81ff91..174c5b37d5fc8 100644 --- a/components/com_contact/views/contact/view.html.php +++ b/components/com_contact/views/contact/view.html.php @@ -297,6 +297,8 @@ public function display($tpl = null) $model = $this->getModel(); $model->hit(); + $captchaSet = $params->get('captcha', JFactory::getApplication()->get('captcha', '0')); + foreach (JPluginHelper::getPlugin('captcha') as $plugin) { if ($captchaSet === $plugin->name)