forked from skydiver/wn-forms-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plugin.php
116 lines (105 loc) · 4.41 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
<?php
namespace Martin\Forms;
use Backend\Facades\Backend;
use Martin\Forms\Classes\GDPR;
use System\Classes\PluginBase;
use Martin\Forms\Models\Settings;
use System\Classes\SettingsManager;
use Illuminate\Support\Facades\Lang;
use Martin\Forms\Classes\UnreadRecords;
use Martin\Forms\Classes\BackendHelpers;
use Winter\Storm\Support\Facades\Validator;
class Plugin extends PluginBase
{
public function pluginDetails()
{
return [
'name' => 'martin.forms::lang.plugin.name',
'description' => 'martin.forms::lang.plugin.description',
'author' => 'Martin M.',
'icon' => 'icon-bolt',
'homepage' => 'https://github.com/skydiver/'
];
}
public function registerNavigation()
{
if (Settings::get('global_hide_button', false)) {
return;
}
return [
'forms' => [
'label' => 'martin.forms::lang.menu.label',
'icon' => 'icon-bolt',
'iconSvg' => 'plugins/martin/forms/assets/imgs/icon.svg',
'url' => BackendHelpers::getBackendURL(['martin.forms.access_records' => 'martin/forms/records', 'martin.forms.access_exports' => 'martin/forms/exports'], 'martin.forms.access_records'),
'permissions' => ['martin.forms.*'],
'sideMenu' => [
'records' => [
'label' => 'martin.forms::lang.menu.records.label',
'icon' => 'icon-database',
'url' => Backend::url('martin/forms/records'),
'permissions' => ['martin.forms.access_records'],
'counter' => UnreadRecords::getTotal(),
'counterLabel' => 'Un-Read Messages'
],
'exports' => [
'label' => 'martin.forms::lang.menu.exports.label',
'icon' => 'icon-download',
'url' => Backend::url('martin/forms/exports'),
'permissions' => ['martin.forms.access_exports']
],
]
]
];
}
public function registerSettings()
{
return [
'config' => [
'label' => 'martin.forms::lang.menu.label',
'description' => 'martin.forms::lang.menu.settings',
'category' => SettingsManager::CATEGORY_CMS,
'icon' => 'icon-bolt',
'class' => 'Martin\Forms\Models\Settings',
'permissions' => ['martin.forms.access_settings'],
'order' => 500
]
];
}
public function registerPermissions()
{
return [
'martin.forms.access_settings' => ['tab' => 'martin.forms::lang.permissions.tab', 'label' => 'martin.forms::lang.permissions.access_settings'],
'martin.forms.access_records' => ['tab' => 'martin.forms::lang.permissions.tab', 'label' => 'martin.forms::lang.permissions.access_records'],
'martin.forms.access_exports' => ['tab' => 'martin.forms::lang.permissions.tab', 'label' => 'martin.forms::lang.permissions.access_exports'],
'martin.forms.gdpr_cleanup' => ['tab' => 'martin.forms::lang.permissions.tab', 'label' => 'martin.forms::lang.permissions.gdpr_cleanup'],
];
}
public function registerComponents()
{
return [
'Martin\Forms\Components\GenericForm' => 'genericForm',
'Martin\Forms\Components\FilePondForm' => 'filepondForm',
'Martin\Forms\Components\EmptyForm' => 'emptyForm',
];
}
public function registerMailTemplates()
{
return [
'martin.forms::mail.notification' => Lang::get('martin.forms::lang.mails.form_notification.description'),
'martin.forms::mail.autoresponse' => Lang::get('martin.forms::lang.mails.form_autoresponse.description'),
];
}
public function register()
{
$this->app->resolving('validator', function () {
Validator::extend('recaptcha', 'Martin\Forms\Classes\ReCaptchaValidator@validateReCaptcha');
});
}
public function registerSchedule($schedule)
{
$schedule->call(function () {
GDPR::cleanRecords();
})->daily();
}
}