-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPlugin.php
100 lines (90 loc) · 2.65 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
<?php namespace DMA\LACMA;
use App;
use Illuminate\Foundation\AliasLoader;
use System\Classes\PluginBase;
use Illuminate\Support\Facades\Event;
use DMA\Friends\Models\Usermeta as Metadata;
use DMA\LACMA\Classes\LacmaEventHandler;
/**
* LACMA Friends Plugin Information File
*
* @package DMA\LACMA
* @author Kristen Arnold
*/
class Plugin extends PluginBase
{
/**
* @var array Plugin dependencies
*/
public $require = [
'DMA.Friends'
];
/**
* Returns information about this plugin.
*
* @return array
*/
public function pluginDetails()
{
return [
'name' => 'LACMA Friends',
'description' => 'Customizations for LACMA NextGEN platform',
'author' => 'Dallas Museum of Art',
'icon' => 'icon-leaf'
];
}
/**
* {@inheritDoc}
*/
public function boot()
{
// Extend User fields
$context = $this;
Event::listen('backend.form.extendFields', function($widget) use ($context){
$context->extendedUserFields($widget);
});
$subscriber = new LacmaEventHandler;
Event::subscribe($subscriber);
}
/**
* {@inheritDoc}
*/
public function register()
{
$this->registerConsoleCommand('lacma.import-nextgen-users', 'DMA\LACMA\Commands\ImportNextGen');
$this->registerConsoleCommand('lacma.export-nextgen-users', 'DMA\LACMA\Commands\ExportNextGen');
}
/**
* Extend User fields in Rainlab.User plugin
* @param mixed $widget
*/
private function extendedUserFields($widget)
{
if (!$widget->getController() instanceof \RainLab\User\Controllers\Users) return;
if ($widget->getContext() != 'update') return;
// Make sure the User metadata exists for this user.
if (!Metadata::getFromUser($widget->model)) return;
$widget->addFields([
'metadata[middle_name]' => [
'label' => 'Middle Name',
'tab' => 'Metadata',
'span' => 'left',
],
'metadata[guardian_name]' => [
'label' => 'Parent/Guardian Full Name',
'tab' => 'Metadata',
//'span' => 'left',
],
'metadata[expires_on]' => [
'label' => 'Expires On',
'tab' => 'Metadata',
'span' => 'left',
],
'metadata[email]' => [
'label' => 'Email Address',
'tab' => 'Metadata',
'span' => 'right',
],
], 'primary');
}
}