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