Skip to content
Permalink
Browse files

Merge pull request #2882 from justcarakas/fix-authentication-checkboxes

Fix authentication checkboxes not saving when adding a page
  • Loading branch information...
carakas committed Aug 28, 2019
2 parents 15d5de7 + 08825b0 commit 2e9b089acabe3154e6a7793f022d7f620d603714
Showing with 42 additions and 22 deletions.
  1. +42 −22 src/Backend/Modules/Pages/Actions/Add.php
@@ -525,6 +525,24 @@ private function validateForm(): void
$data['image'] = $this->getImage($this->templates[$templateId]['data']['image']);
}
$data['auth_required'] = false;
if (BackendModel::isModuleInstalled('Profiles') && $this->form->getField('auth_required')->isChecked()) {
$data['auth_required'] = true;
// get all groups and parse them in key value pair
$groupItems = BackendProfilesModel::getGroups();
if (!empty($groupItems)) {
$data['auth_groups'] = $this->form->getField('auth_groups')->getValue();
}
}
$data['remove_from_search_index'] = false;
if (BackendModel::isModuleInstalled('Profiles')
&& $this->form->getField('remove_from_search_index')->isChecked()
&& $this->form->getField('auth_required')->isChecked()) {
$data['remove_from_search_index'] = true;
}
// just execute if the site is multi-language
if ($this->getContainer()->getParameter('site.multilanguage')) {
// loop active languages
@@ -627,28 +645,7 @@ private function validateForm(): void
// active
if ($page['status'] === 'active') {
// init var
$text = '';
// build search-text
foreach ($this->blocksContent as $block) {
$text .= ' ' . $block['html'];
}
if ($redirectValue === 'none') {
// add to search index
BackendSearchModel::saveIndex(
$this->getModule(),
$page['id'],
['title' => $page['title'], 'text' => $text]
);
} else {
BackendSearchModel::removeIndex(
$this->getModule(),
$page['id']
);
}
$this->saveSearchIndex($data['remove_from_search_index'] || $redirectValue !== 'none', $page);
// everything is saved, so redirect to the overview
$this->redirect(
@@ -741,4 +738,27 @@ private function getOriginalPage(): ?array
return $originalPage;
}
private function saveSearchIndex(bool $removeFromSearchIndex, array $page): void
{
if ($removeFromSearchIndex) {
BackendSearchModel::removeIndex(
$this->getModule(),
$page['id']
);
return;
}
$searchText = '';
foreach ($this->blocksContent as $block) {
$searchText .= ' ' . $block['html'];
}
BackendSearchModel::saveIndex(
$this->getModule(),
$page['id'],
['title' => $page['title'], 'text' => $searchText]
);
}
}

0 comments on commit 2e9b089

Please sign in to comment.
You can’t perform that action at this time.