forked from OFFLINE-GmbH/oc-gdpr-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlugin.php
101 lines (93 loc) · 3.87 KB
/
Plugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php namespace OFFLINE\GDPR;
use Backend\Facades\Backend;
use Illuminate\Support\Facades\Cookie;
use Illuminate\Support\Facades\Session;
use OFFLINE\GDPR\Classes\Cookies\ConsentCookie;
use OFFLINE\GDPR\Components\ConsentManager;
use OFFLINE\GDPR\Components\CookieBanner;
use OFFLINE\GDPR\Components\CookieManager;
use OFFLINE\GDPR\Console\CleanUp;
use OFFLINE\GDPR\Models\CookieConsentSettings;
use OFFLINE\GDPR\Models\DataRetentionSettings;
use System\Classes\PluginBase;
class Plugin extends PluginBase
{
const EVENT_CLEANUP_REGISTER = 'offline.gdpr::cleanup.register';
public function boot()
{
$this->registerConsoleCommand('gdpr.cleanup', CleanUp::class);
}
public function registerSchedule($schedule)
{
$schedule->call('gdpr:cleanup')->daily();
}
public function registerComponents()
{
return [
ConsentManager::class => 'consentManager',
CookieManager::class => 'cookieManager',
CookieBanner::class => 'cookieBanner',
];
}
public function registerMarkupTags()
{
return [
'functions' => [
'gdprCookieAllowed' => function ($code, $level = 0) {
return (new ConsentCookie())->isAllowed($code, $level);
},
'gdprAllowedCookieLevel' => function ($code) {
return (new ConsentCookie())->allowedCookieLevel($code);
},
'gdprIsUndecided' => function () {
return (new ConsentCookie())->isUndecided();
},
],
];
}
public function registerSettings()
{
return [
'gdpr_info' => [
'label' => trans('offline.gdpr::lang.settings.info.label'),
'description' => trans('offline.gdpr::lang.settings.info.description'),
'category' => 'GDPR and ePrivacy',
'icon' => 'icon-info-circle',
'url' => Backend::url('offline/gdpr/info'),
'order' => 200,
'keywords' => 'gdpr',
'permissions' => ['offline.gdpr.manage_cookie_info'],
],
'gdpr_cookies' => [
'label' => trans('offline.gdpr::lang.settings.cookies.label'),
'description' => trans('offline.gdpr::lang.settings.cookies.description'),
'category' => 'GDPR and ePrivacy',
'icon' => 'oc-icon-list',
'url' => Backend::url('offline/gdpr/cookiegroups'),
'order' => 210,
'keywords' => 'gdpr',
'permissions' => ['offline.gdpr.manage_cookie_groups'],
],
'gdpr_data_retention' => [
'label' => trans('offline.gdpr::lang.settings.data_retention.label'),
'description' => trans('offline.gdpr::lang.settings.data_retention.description'),
'category' => 'GDPR and ePrivacy',
'icon' => 'oc-icon-trash',
'class' => DataRetentionSettings::class,
'order' => 220,
'keywords' => 'gdpr',
'permissions' => ['offline.gdpr.manage_data_retention'],
],
'gdpr_cookie_consent' => [
'label' => trans('offline.gdpr::lang.settings.cookie_consent.label'),
'description' => trans('offline.gdpr::lang.settings.cookie_consent.description'),
'category' => 'GDPR and ePrivacy',
'icon' => 'oc-icon-check-square',
'class' => CookieConsentSettings::class,
'order' => 200,
'keywords' => 'gdpr',
'permissions' => ['offline.gdpr.manage_cookie_consent'],
],
];
}
}