forked from OFFLINE-GmbH/oc-gdpr-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlugin.php
138 lines (129 loc) · 5.43 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php namespace OFFLINE\GDPR;
use Backend\Facades\Backend;
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\Console\ImportPresets;
use OFFLINE\GDPR\Models\CookieConsentSettings;
use OFFLINE\GDPR\Models\DataRetentionSettings;
use OFFLINE\GDPR\Models\GDPRSettings;
use OFFLINE\GDPR\Models\Log;
use System\Classes\PluginBase;
class Plugin extends PluginBase
{
const EVENT_CLEANUP_REGISTER = 'offline.gdpr::cleanup.register';
public function register()
{
$this->registerConsoleCommand('gdpr.cleanup', CleanUp::class);
$this->registerConsoleCommand('gdpr.import', ImportPresets::class);
}
public function registerSchedule($schedule)
{
$schedule->command('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 boot()
{
\Event::listen('backend.menu.extendItems', function ($manager) {
if ((bool)GDPRSettings::get('log_enabled') !== true) {
$manager->removeMainMenuItem('OFFLINE.GDPR', 'main-menu-item');
}
});
\Event::listen('offline.gdpr::cleanup.register', function () {
return [
'id' => 'offline-gdpr-logs',
'label' => trans('offline.gdpr::lang.plugin.name'),
'models' => [
[
'label' => trans('offline.gdpr::lang.log.log'),
'comment' => trans('offline.gdpr::lang.log.log_comment'),
'class' => Log::class,
],
],
];
});
}
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_settings' => [
'label' => trans('offline.gdpr::lang.settings.general.label'),
'description' => trans('offline.gdpr::lang.settings.general.description'),
'category' => 'GDPR and ePrivacy',
'icon' => 'oc-icon-gear',
'class' => GDPRSettings::class,
'order' => 210,
'keywords' => 'gdpr',
'permissions' => ['offline.gdpr.manage_logs'],
],
'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'],
],
/**
* @deprecated since version 2.1. Add this menu item back using the backend.menu.extendItems event.
*/
// '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'],
// ],
];
}
}