Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[com_contact] - moved the captchaEnabled var from default to view #11964

Merged
merged 3 commits into from
Sep 18, 2016
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions components/com_contact/views/contact/tmpl/default_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
?>
<div class="contact-form">
<form id="contact-form" action="<?php echo JRoute::_('index.php'); ?>" method="post" class="form-validate form-horizontal well">
<?php foreach ($this->form->getFieldsets() as $fieldset): ?>
<?php if ($fieldset->name === 'captcha' && !$captchaEnabled) : ?>
<?php if ($fieldset->name === 'captcha' && !$this->captchaEnabled) : ?>
<?php continue; ?>
<?php endif; ?>
<?php $fields = $this->form->getFieldset($fieldset->name); ?>
Expand Down
19 changes: 18 additions & 1 deletion components/com_contact/views/contact/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You didn't set $captchaSet

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shame on me, even unable to do a silly c&p

{
$this->captchaEnabled = true;
break;
}
}

$this->_prepareDocument();
return parent::display($tpl);
}

Expand Down