Skip to content

Commit

Permalink
feat: added possibility to enable/disable the privacy link, closes th…
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsten committed Jun 30, 2024
1 parent 52cd023 commit dd61f10
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 24 deletions.
16 changes: 10 additions & 6 deletions phpmyfaq/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
use phpMyFAQ\User\CurrentUser;
use phpMyFAQ\User\TwoFactor;
use phpMyFAQ\User\UserAuthentication;
use phpMyFAQ\Utils;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand Down Expand Up @@ -625,6 +624,15 @@
);
}

if ($faqConfig->get('main.enablePrivacyLink')) {
$privacyLink = sprintf(
'<a class="pmf-nav-link-footer" target="_blank" href="%s">%s</a>',
Strings::htmlentities($faqConfig->get('main.privacyURL')),
Translation::get('msgPrivacyNote')
);
} else {
$privacyLink = '';
}

$tplNavigation = [
'backToHome' => '<a class="nav-link" href="./index.html">' . Translation::get('msgHome') . '</a>',
Expand All @@ -648,11 +656,7 @@
'</a>',
'msgGlossary' => '<a class="pmf-nav-link-footer" href="./glossary.html">' .
Translation::get('ad_menu_glossary') . '</a>',
'privacyLink' => sprintf(
'<a class="pmf-nav-link-footer" target="_blank" href="%s">%s</a>',
Strings::htmlentities($faqConfig->get('main.privacyURL')),
Translation::get('msgPrivacyNote')
),
'privacyLink' => $privacyLink,
'cookiePreferences' => '<a id="showCookieConsent" class="pmf-nav-link-footer">'
. Translation::get('cookiePreferences') . '</a>',
'faqOverview' => '<a class="pmf-nav-link-footer" href="./overview.html">' .
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public function removeTwofactorConfig(Request $request): JsonResponse

if ($user->setUserData(['secret' => $newSecret, 'twofactor_enabled' => 0])) {
return $this->json(
['success' => Translation::get('msgRemoveTwofactorConfigSuccessfull')],
['success' => Translation::get('msgRemoveTwofactorConfigSuccessful')],
Response::HTTP_OK
);
} else {
Expand Down
1 change: 1 addition & 0 deletions phpmyfaq/src/phpMyFAQ/Setup/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ class Installer extends Setup
'w3c,controler,wget,bot,spider,Yahoo! Slurp,htdig,gsa-crawler,AirControler,Uptime-Kuma,facebookcatalog/1.0,' .
'facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php),facebookexternalhit/1.1',
'main.enableCookieConsent' => 'true',
'main.enablePrivacyLink' => 'true',

'records.numberOfRecordsPerPage' => '10',
'records.numberOfShownNewsEntries' => '3',
Expand Down
27 changes: 11 additions & 16 deletions phpmyfaq/src/phpMyFAQ/Setup/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -709,21 +709,6 @@ private function applyUpdates400Alpha2(): void
private function applyUpdates400Alpha3(): void
{
if (version_compare($this->version, '4.0.0-alpha.3', '<')) {
// Add Facebook crawlers to botIgnoreList
$this->configuration->update(['main.botIgnoreList' => 'nustcrape,webpost,GoogleBot,msnbot,crawler,scooter,
bravobrian,archiver,w3c,controler,wget,bot,spider,Yahoo! Slurp,htdig,gsa-crawler,AirControler,Uptime-Kuma,
facebookcatalog/1.0,facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php),
facebookexternalhit/1.1']);

// Add sender address for mail
$this->configuration->add('mail.noReplySenderAddress', '');

// Add allowed external media hosts
$this->configuration->add('records.allowedMediaHosts', 'www.youtube.com');

// New SEO feature
$this->configuration->add('seo.title', $this->configuration->get('main.titleFAQ'));
$this->configuration->add('seo.description', $this->configuration->get('main.metaDescription'));
switch (Database::getType()) {
case 'mysqli':
$this->queries[] = sprintf(
Expand Down Expand Up @@ -782,7 +767,17 @@ private function applyUpdates400Alpha3(): void
);
break;
}
// Cleanup of old configuration items

// Configuration items
$this->configuration->update(['main.botIgnoreList' => 'nustcrape,webpost,GoogleBot,msnbot,crawler,scooter,
bravobrian,archiver,w3c,controler,wget,bot,spider,Yahoo! Slurp,htdig,gsa-crawler,AirControler,Uptime-Kuma,
facebookcatalog/1.0,facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php),
facebookexternalhit/1.1']);
$this->configuration->add('mail.noReplySenderAddress', '');
$this->configuration->add('records.allowedMediaHosts', 'www.youtube.com');
$this->configuration->add('seo.title', $this->configuration->get('main.titleFAQ'));
$this->configuration->add('seo.description', $this->configuration->get('main.metaDescription'));
$this->configuration->add('main.enablePrivacyLink', 'true');
$this->configuration->delete('main.urlValidateInterval');
}
}
Expand Down
5 changes: 4 additions & 1 deletion phpmyfaq/translations/language_de.php
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,9 @@
$LANG_CONF['records.allowedMediaHosts'] = ['area', 'Erlaubte externe Hosts für Medieninhalte (Mit Kommas trennen)'];
$PMF_LANG['msgConfirmTwofactorConfig'] = 'Bist du sicher, dass du deine aktuelle Konfiguration der 2-Faktor-Authentifizierung löschen möchtest?';
$PMF_LANG['msgGravatarNotConnected'] = 'Gravatar ist aktuell nicht aktiviert.';
$PMF_LANG['msgRemoveTwofactorConfigSuccessfull'] = 'Das Löschen der aktuellen 2-Faktor-Konfiguration war erfolgreich.';
$PMF_LANG['msgRemoveTwofactorConfigSuccessful'] = 'Das Löschen der aktuellen 2-Faktor-Konfiguration war erfolgreich.';

// added v4.0.0-alpha.3 - 2024-06-30 by Thorsten
$LANG_CONF['main.enablePrivacyLink'] = ['checkbox', 'Aktiviere Link zur Datenschutzerklärung'];

return $PMF_LANG;
4 changes: 4 additions & 0 deletions phpmyfaq/translations/language_en.php
Original file line number Diff line number Diff line change
Expand Up @@ -1468,5 +1468,9 @@
$LANG_CONF['records.allowedMediaHosts'] = ['area', 'Allowed external hosts for media content (separate with commas)'];
$PMF_LANG['msgConfirmTwofactorConfig'] = 'Are you sure that you want to remove your current Two Factor Authentication-configuration?';
$PMF_LANG['msgGravatarNotConnected'] = 'Gravatar is currently not enabled.';
$PMF_LANG['msgRemoveTwofactorConfigSuccessful'] = 'The deletion of the current 2-factor configuration was successful.';

// added v4.0.0-alpha.3 - 2024-06-30 by Thorsten
$LANG_CONF['main.enablePrivacyLink'] = ['checkbox', 'Activate link to privacy policy'];

return $PMF_LANG;

0 comments on commit dd61f10

Please sign in to comment.