summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@webtrees.net>2019-11-02 23:57:11 +0000
committerGreg Roach <fisharebest@webtrees.net>2019-11-03 00:08:29 +0000
commitb3a775f6a370b67e80b292212c765673a0177ffc (patch)
tree0151d47240e3742e0baaeee0eda065eff5b3f0d1 /app
parent00e28091d5dbdf816443155193c9fd33a0b3dd34 (diff)
downloadwebtrees-b3a775f6a370b67e80b292212c765673a0177ffc.tar.gz
webtrees-b3a775f6a370b67e80b292212c765673a0177ffc.tar.bz2
webtrees-b3a775f6a370b67e80b292212c765673a0177ffc.zip
Add privacy-policy/impressum - #2654
Diffstat (limited to 'app')
-rw-r--r--app/Contracts/UserInterface.php2
-rw-r--r--app/Functions/FunctionsExport.php2
-rw-r--r--app/Http/RequestHandlers/PasswordRequestPage.php2
-rw-r--r--app/Http/RequestHandlers/PrivacyPolicy.php53
-rw-r--r--app/Http/Routes/WebRoutes.php1
-rw-r--r--app/Media.php2
-rw-r--r--app/Module/BingWebmasterToolsModule.php10
-rw-r--r--app/Module/GoogleWebmasterToolsModule.php10
-rw-r--r--app/Module/ModuleAnalyticsInterface.php7
-rw-r--r--app/Module/ModuleAnalyticsTrait.php10
-rw-r--r--app/Module/PrivacyPolicy.php (renamed from app/Module/CookieWarningModule.php)77
-rw-r--r--app/Note.php2
-rw-r--r--app/Services/ModuleService.php4
-rw-r--r--app/Source.php2
14 files changed, 97 insertions, 87 deletions
diff --git a/app/Contracts/UserInterface.php b/app/Contracts/UserInterface.php
index 46f8b9e3db..8293772bcc 100644
--- a/app/Contracts/UserInterface.php
+++ b/app/Contracts/UserInterface.php
@@ -20,7 +20,7 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees\Contracts;
/**
- * Behaviour required of a user object.
+ * behavior required of a user object.
*/
interface UserInterface
{
diff --git a/app/Functions/FunctionsExport.php b/app/Functions/FunctionsExport.php
index 21134060f4..d6c899fcc1 100644
--- a/app/Functions/FunctionsExport.php
+++ b/app/Functions/FunctionsExport.php
@@ -59,7 +59,7 @@ class FunctionsExport
do {
// Split after $pos chars
$pos = Gedcom::LINE_LENGTH;
- // Split on a non-space (standard gedcom behaviour)
+ // Split on a non-space (standard gedcom behavior)
while (mb_substr($line, $pos - 1, 1) === ' ') {
--$pos;
}
diff --git a/app/Http/RequestHandlers/PasswordRequestPage.php b/app/Http/RequestHandlers/PasswordRequestPage.php
index a8593266ff..61d244cb02 100644
--- a/app/Http/RequestHandlers/PasswordRequestPage.php
+++ b/app/Http/RequestHandlers/PasswordRequestPage.php
@@ -54,6 +54,6 @@ class PasswordRequestPage implements RequestHandlerInterface
$title = I18N::translate('Request a new password');
- return $this->viewResponse('password-request-page', ['title' => $title, 'tree' => $tree instanceof Tree ? $tree->name() : null]);
+ return $this->viewResponse('password-request-page', ['title' => $title, 'tree' => $tree]);
}
}
diff --git a/app/Http/RequestHandlers/PrivacyPolicy.php b/app/Http/RequestHandlers/PrivacyPolicy.php
deleted file mode 100644
index 76ecdb663e..0000000000
--- a/app/Http/RequestHandlers/PrivacyPolicy.php
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-
-/**
- * webtrees: online genealogy
- * Copyright (C) 2019 webtrees development team
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-declare(strict_types=1);
-
-namespace Fisharebest\Webtrees\Http\RequestHandlers;
-
-use Fisharebest\Webtrees\Http\ViewResponseTrait;
-use Fisharebest\Webtrees\I18N;
-use Psr\Http\Message\ResponseInterface;
-use Psr\Http\Message\ServerRequestInterface;
-use Psr\Http\Server\RequestHandlerInterface;
-
-/**
- * Show the privacy policy page.
- */
-class PrivacyPolicy implements RequestHandlerInterface
-{
- use ViewResponseTrait;
-
- /**
- * @param ServerRequestInterface $request
- *
- * @return ResponseInterface
- */
- public function handle(ServerRequestInterface $request): ResponseInterface
- {
- $tree = $request->getAttribute('tree');
- $title = I18N::translate('Privacy policy');
-
- $uses_analytics = true;
-
- return $this->viewResponse('privacy-policy', [
- 'title' => $title,
- 'tree' => $tree,
- 'uses_analytics' => $uses_analytics,
- ]);
- }
-}
diff --git a/app/Http/Routes/WebRoutes.php b/app/Http/Routes/WebRoutes.php
index 7520f7944b..c4187da0b9 100644
--- a/app/Http/Routes/WebRoutes.php
+++ b/app/Http/Routes/WebRoutes.php
@@ -487,7 +487,6 @@ class WebRoutes
$router->get(RobotsTxt::class, '/robots.txt', RobotsTxt::class);
$router->post(SelectTheme::class, '/theme/{theme}', SelectTheme::class);
$router->get(VerifyEmail::class, '/verify', VerifyEmail::class);
- $router->get(PrivacyPolicy::class, '/privacy-policy', PrivacyPolicy::class);
$router->get(HomePage::class, '/', HomePage::class);
// Legacy URLs from older software.
diff --git a/app/Media.php b/app/Media.php
index 1c5f46f3ae..00a08cee29 100644
--- a/app/Media.php
+++ b/app/Media.php
@@ -94,7 +94,7 @@ class Media extends GedcomRecord
}
}
- // ... otherwise apply default behaviour
+ // ... otherwise apply default behavior
return parent::canShowByType($access_level);
}
diff --git a/app/Module/BingWebmasterToolsModule.php b/app/Module/BingWebmasterToolsModule.php
index eb57f0f82b..58efdd8420 100644
--- a/app/Module/BingWebmasterToolsModule.php
+++ b/app/Module/BingWebmasterToolsModule.php
@@ -50,6 +50,16 @@ class BingWebmasterToolsModule extends AbstractModule implements ModuleAnalytics
}
/**
+ * Is this a tracker, as opposed to just a site-verification.
+ *
+ * @return bool
+ */
+ public function isTracker(): bool
+ {
+ return false;
+ }
+
+ /**
* Form fields to edit the parameters.
*
* @return string
diff --git a/app/Module/GoogleWebmasterToolsModule.php b/app/Module/GoogleWebmasterToolsModule.php
index 65ddf63605..8e2505c2b9 100644
--- a/app/Module/GoogleWebmasterToolsModule.php
+++ b/app/Module/GoogleWebmasterToolsModule.php
@@ -50,6 +50,16 @@ class GoogleWebmasterToolsModule extends AbstractModule implements ModuleAnalyti
}
/**
+ * Is this a tracker, as opposed to just a site-verification.
+ *
+ * @return bool
+ */
+ public function isTracker(): bool
+ {
+ return false;
+ }
+
+ /**
* Form fields to edit the parameters.
*
* @return string
diff --git a/app/Module/ModuleAnalyticsInterface.php b/app/Module/ModuleAnalyticsInterface.php
index 3655e26952..08ba488ee9 100644
--- a/app/Module/ModuleAnalyticsInterface.php
+++ b/app/Module/ModuleAnalyticsInterface.php
@@ -58,6 +58,13 @@ interface ModuleAnalyticsInterface extends ModuleInterface
public function analyticsSnippet(array $parameters): string;
/**
+ * Is this a tracker, as opposed to just a site-verification.
+ *
+ * @return bool
+ */
+ public function isTracker(): bool;
+
+ /**
* @param ServerRequestInterface $request
*
* @return ResponseInterface
diff --git a/app/Module/ModuleAnalyticsTrait.php b/app/Module/ModuleAnalyticsTrait.php
index 3227d51efb..7d890b2ee5 100644
--- a/app/Module/ModuleAnalyticsTrait.php
+++ b/app/Module/ModuleAnalyticsTrait.php
@@ -131,6 +131,16 @@ trait ModuleAnalyticsTrait
abstract public function title(): string;
/**
+ * Is this a tracker, as opposed to just a site-verification.
+ *
+ * @return bool
+ */
+ public function isTracker(): bool
+ {
+ return true;
+ }
+
+ /**
* @param ServerRequestInterface $request
*
* @return ResponseInterface
diff --git a/app/Module/CookieWarningModule.php b/app/Module/PrivacyPolicy.php
index 83036b1607..877e20294e 100644
--- a/app/Module/CookieWarningModule.php
+++ b/app/Module/PrivacyPolicy.php
@@ -19,30 +19,41 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees\Module;
+use Fisharebest\Webtrees\Contracts\UserInterface;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Services\ModuleService;
+use Fisharebest\Webtrees\Services\UserService;
+use Fisharebest\Webtrees\Tree;
+use Illuminate\Support\Collection;
+use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
+use function assert;
+use function view;
+
/**
- * Class PoweredByWebtreesModule - show a cookie warning, to comply with the GDPR.
+ * Class PrivacyPolicy - to comply with the GDPR and similar local laws.
*/
-class CookieWarningModule extends AbstractModule implements ModuleFooterInterface
+class PrivacyPolicy extends AbstractModule implements ModuleFooterInterface
{
use ModuleFooterTrait;
- /**
- * @var ModuleService
- */
+ /** @var ModuleService */
private $module_service;
+ /** @var UserService */
+ private $user_service;
+
/**
* Dependency injection.
*
* @param ModuleService $module_service
+ * @param UserService $user_service
*/
- public function __construct(ModuleService $module_service)
+ public function __construct(ModuleService $module_service, UserService $user_service)
{
$this->module_service = $module_service;
+ $this->user_service = $user_service;
}
/**
@@ -53,7 +64,7 @@ class CookieWarningModule extends AbstractModule implements ModuleFooterInterfac
public function title(): string
{
/* I18N: Name of a module */
- return I18N::translate('Cookie warning');
+ return I18N::translate('Privacy policy');
}
/**
@@ -64,7 +75,7 @@ class CookieWarningModule extends AbstractModule implements ModuleFooterInterfac
public function description(): string
{
/* I18N: Description of the “Cookie warning” module */
- return I18N::translate('Tell visitors why this site uses cookies.');
+ return I18N::translate('Show a privacy policy.');
}
/**
@@ -86,40 +97,56 @@ class CookieWarningModule extends AbstractModule implements ModuleFooterInterfac
*/
public function getFooter(ServerRequestInterface $request): string
{
- if ($this->isCookieWarningAcknowledged()) {
+ $tree = $request->getAttribute('tree');
+
+ if ($tree === null) {
return '';
}
- if ($this->siteUsesAnalytics()) {
- return view('modules/cookie-warning/footer');
- }
+ $user = $request->getAttribute('user');
+ assert($user instanceof UserInterface);
- return '';
+ return view('modules/privacy-policy/footer', [
+ 'tree' => $tree,
+ 'uses_analytics' => $this->analyticsModules($tree, $user)->isNotEmpty(),
+ ]);
}
/**
- * @return bool
+ * @param ServerRequestInterface $request
+ *
+ * @return ResponseInterface
*/
- protected function isCookieWarningAcknowledged(): bool
+ public function getPageAction(ServerRequestInterface $request): ResponseInterface
{
- // We store acceptance of cookies in a .... cookie.
- $request = app(ServerRequestInterface::class);
+ $tree = $request->getAttribute('tree');
+ assert($tree instanceof Tree);
- $cookies_ok = $request->getCookieParams()['cookie'] ?? '';
+ $user = $request->getAttribute('user');
+ assert($user instanceof UserInterface);
- return $cookies_ok !== '';
+ $title = I18N::translate('Privacy policy');
+
+ return $this->viewResponse('modules/privacy-policy/page', [
+ 'administrators' => $this->user_service->administrators(),
+ 'analytics' => $this->analyticsModules($tree, $user),
+ 'title' => $title,
+ 'tree' => $tree,
+ ]);
}
/**
- * @return bool
+ * @param Tree $tree
+ * @param UserInterface $user
+ *
+ * @return Collection
*/
- protected function siteUsesAnalytics(): bool
+ protected function analyticsModules(Tree $tree, UserInterface $user): Collection
{
return $this->module_service
- ->findByInterface(ModuleAnalyticsInterface::class)
+ ->findByComponent(ModuleAnalyticsInterface::class, $tree, $user)
->filter(static function (ModuleAnalyticsInterface $module): bool {
- return $module->analyticsCanShow();
- })
- ->isNotEmpty();
+ return $module->isTracker();
+ });
}
}
diff --git a/app/Note.php b/app/Note.php
index 8445e6ae43..cd01e130f2 100644
--- a/app/Note.php
+++ b/app/Note.php
@@ -107,7 +107,7 @@ class Note extends GedcomRecord
}
}
- // Apply default behaviour
+ // Apply default behavior
return parent::canShowByType($access_level);
}
diff --git a/app/Services/ModuleService.php b/app/Services/ModuleService.php
index 7a6a7b5139..e7e6981228 100644
--- a/app/Services/ModuleService.php
+++ b/app/Services/ModuleService.php
@@ -47,7 +47,6 @@ use Fisharebest\Webtrees\Module\CloudsTheme;
use Fisharebest\Webtrees\Module\ColorsTheme;
use Fisharebest\Webtrees\Module\CompactTreeChartModule;
use Fisharebest\Webtrees\Module\ContactsFooterModule;
-use Fisharebest\Webtrees\Module\CookieWarningModule;
use Fisharebest\Webtrees\Module\CustomCssJsModule;
use Fisharebest\Webtrees\Module\DeathReportModule;
use Fisharebest\Webtrees\Module\DescendancyChartModule;
@@ -174,6 +173,7 @@ use Fisharebest\Webtrees\Module\PedigreeReportModule;
use Fisharebest\Webtrees\Module\PlaceHierarchyListModule;
use Fisharebest\Webtrees\Module\PlacesModule;
use Fisharebest\Webtrees\Module\PoweredByWebtreesModule;
+use Fisharebest\Webtrees\Module\PrivacyPolicy;
use Fisharebest\Webtrees\Module\RecentChangesModule;
use Fisharebest\Webtrees\Module\RelatedIndividualsReportModule;
use Fisharebest\Webtrees\Module\RelationshipsChartModule;
@@ -280,7 +280,6 @@ class ModuleService
'colors' => ColorsTheme::class,
'compact-chart' => CompactTreeChartModule::class,
'contact-links' => ContactsFooterModule::class,
- 'cookie-warning' => CookieWarningModule::class,
'custom-css-js' => CustomCssJsModule::class,
'death_report' => DeathReportModule::class,
'descendancy' => DescendancyModule::class,
@@ -393,6 +392,7 @@ class ModuleService
'places' => PlacesModule::class,
'places_list' => PlaceHierarchyListModule::class,
'powered-by-webtrees' => PoweredByWebtreesModule::class,
+ 'privacy-policy' => PrivacyPolicy::class,
'random_media' => SlideShowModule::class,
'recent_changes' => RecentChangesModule::class,
'relationships_chart' => RelationshipsChartModule::class,
diff --git a/app/Source.php b/app/Source.php
index b6966c5b1c..fba2fbfea1 100644
--- a/app/Source.php
+++ b/app/Source.php
@@ -88,7 +88,7 @@ class Source extends GedcomRecord
}
}
- // ... otherwise apply default behaviour
+ // ... otherwise apply default behavior
return parent::canShowByType($access_level);
}