Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions components/com_users/forms/registration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@
validDomains="com_users.domains"
autocomplete="email"
/>
</fieldset>

<fieldset name="captcha">
<field
name="captcha"
type="captcha"
Expand Down
19 changes: 19 additions & 0 deletions components/com_users/src/View/Registration/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Joomla\CMS\MVC\View\GenericDataException;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Object\CMSObject;
use Joomla\CMS\Plugin\PluginHelper;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
Expand Down Expand Up @@ -63,6 +64,15 @@ class HtmlView extends BaseHtmlView
*/
public $document;

/**
* Should we show a captcha form for the submission of the article?
*
* @var boolean
*
* @since 3.7.0
*/
protected $captchaEnabled = false;

/**
* The page class suffix
*
Expand Down Expand Up @@ -101,6 +111,15 @@ public function display($tpl = null)
$this->setLayout($active->query['layout']);
}

$captchaSet = $this->params->get('captcha', Factory::getApplication()->get('captcha', '0'));

foreach (PluginHelper::getPlugin('captcha') as $plugin) {
if ($captchaSet === $plugin->name) {
$this->captchaEnabled = true;
break;
}
}

// Escape strings for HTML output
$this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx', ''), ENT_COMPAT, 'UTF-8');

Expand Down
6 changes: 6 additions & 0 deletions components/com_users/tmpl/registration/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
<form id="member-registration" action="<?php echo Route::_('index.php?option=com_users&task=registration.register'); ?>" method="post" class="com-users-registration__form form-validate" enctype="multipart/form-data">
<?php // Iterate through the form fieldsets and display each one. ?>
<?php foreach ($this->form->getFieldsets() as $fieldset) : ?>
<?php if ($fieldset->name === 'captcha' && $this->captchaEnabled) : ?>
<?php continue; ?>
<?php endif; ?>
<?php $fields = $this->form->getFieldset($fieldset->name); ?>
<?php if (count($fields)) : ?>
<fieldset>
Expand All @@ -39,6 +42,9 @@
</fieldset>
<?php endif; ?>
<?php endforeach; ?>
<?php if ($this->captchaEnabled) : ?>
<?php echo $this->form->renderFieldset('captcha'); ?>
<?php endif; ?>
<div class="com-users-registration__submit control-group">
<div class="controls">
<button type="submit" class="com-users-registration__register btn btn-primary validate">
Expand Down