Skip to content

Commit

Permalink
Hide the member widget if searching protected sites is disabled (see #…
Browse files Browse the repository at this point in the history
…1291)

Description
-----------

Fixes #1280

@contao/developers Should we disable indexing protected pages by default?

Commits
-------

97d7f19 Hide the member widget if searching protected sites is disabled (see #1280)
  • Loading branch information
leofeyer committed Feb 7, 2020
1 parent c540367 commit 8b94dba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
9 changes: 7 additions & 2 deletions core-bundle/src/Resources/contao/classes/Crawl.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ public function run()
$factory = System::getContainer()->get('contao.crawl.escargot_factory');
$subscriberNames = $factory->getSubscriberNames();
$subscribersWidget = $this->generateSubscribersWidget($subscriberNames);
$memberWidget = $this->generateMemberWidget();
$memberWidget = null;

if (System::getContainer()->getParameter('contao.search.index_protected'))
{
$memberWidget = $this->generateMemberWidget();
}

$template = new BackendTemplate('be_crawl');
$template->isActive = $this->isActive();
Expand Down Expand Up @@ -102,7 +107,7 @@ public function run()
/** @var FrontendPreviewAuthenticator $objAuthenticator */
$objAuthenticator = System::getContainer()->get('contao.security.frontend_preview_authenticator');

if ($memberWidget->value)
if ($memberWidget && $memberWidget->value)
{
$objMember = Database::getInstance()->prepare('SELECT username FROM tl_member WHERE id=?')
->execute((int) $memberWidget->value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@
<p class="tl_help tl_tip"><?= $this->trans('tl_maintenance.crawlSubscribers.1') ?></p>
<?php endif; ?>
</div>
<div>
<?= $this->memberWidget->parse() ?>
<?php if (!$this->memberWidget->hasErrors()): ?>
<p class="tl_help tl_tip"><?= $this->trans('tl_maintenance.crawlMember.1') ?></p>
<?php endif; ?>
</div>
<?php if ($this->memberWidget): ?>
<div>
<?= $this->memberWidget->parse() ?>
<?php if (!$this->memberWidget->hasErrors()): ?>
<p class="tl_help tl_tip"><?= $this->trans('tl_maintenance.crawlMember.1') ?></p>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
</div>
<div class="tl_submit_container">
Expand Down

0 comments on commit 8b94dba

Please sign in to comment.