forked from rainlab/user-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plugin.php
130 lines (117 loc) · 4.26 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
<?php namespace RainLab\User;
use App;
use Event;
use Backend;
use System\Classes\PluginBase;
use Illuminate\Foundation\AliasLoader;
use RainLab\User\Models\MailBlocker;
class Plugin extends PluginBase
{
/**
* @var boolean Determine if this plugin should have elevated privileges.
*/
public $elevated = true;
public function pluginDetails()
{
return [
'name' => 'rainlab.user::lang.plugin.name',
'description' => 'rainlab.user::lang.plugin.description',
'author' => 'Alexey Bobkov, Samuel Georges',
'icon' => 'icon-user',
'homepage' => 'https://github.com/rainlab/user-plugin'
];
}
public function register()
{
$alias = AliasLoader::getInstance();
$alias->alias('Auth', 'RainLab\User\Facades\Auth');
App::singleton('user.auth', function() {
return \RainLab\User\Classes\AuthManager::instance();
});
/*
* Apply user-based mail blocking
*/
Event::listen('mailer.prepareSend', function($mailer, $view, $message) {
return MailBlocker::filterMessage($view, $message);
});
}
public function registerComponents()
{
return [
'RainLab\User\Components\Session' => 'session',
'RainLab\User\Components\Account' => 'account',
'RainLab\User\Components\ResetPassword' => 'resetPassword'
];
}
public function registerPermissions()
{
return [
'rainlab.users.access_users' => ['tab' => 'rainlab.user::lang.plugin.tab', 'label' => 'rainlab.user::lang.plugin.access_users']
];
}
public function registerNavigation()
{
return [
'user' => [
'label' => 'rainlab.user::lang.users.menu_label',
'url' => Backend::url('rainlab/user/users'),
'icon' => 'icon-user',
'permissions' => ['rainlab.users.*'],
'order' => 500,
'sideMenu' => [
'users' => [
'label' => 'rainlab.user::lang.users.all_users',
'icon' => 'icon-user',
'url' => Backend::url('rainlab/user/users'),
'permissions' => ['rainlab.users.access_users']
]
]
]
];
}
public function registerSettings()
{
return [
'settings' => [
'label' => 'rainlab.user::lang.settings.menu_label',
'description' => 'rainlab.user::lang.settings.menu_description',
'category' => 'rainlab.user::lang.settings.users',
'icon' => 'icon-cog',
'class' => 'RainLab\User\Models\Settings',
'order' => 500,
'permissions' => ['rainlab.users.*']
],
'location' => [
'label' => 'rainlab.user::lang.locations.menu_label',
'description' => 'rainlab.user::lang.locations.menu_description',
'category' => 'rainlab.user::lang.settings.users',
'icon' => 'icon-globe',
'url' => Backend::url('rainlab/user/locations'),
'order' => 500,
'permissions' => ['rainlab.users.*']
]
];
}
public function registerMailTemplates()
{
return [
'rainlab.user::mail.activate' => 'Activation email sent to new users.',
'rainlab.user::mail.welcome' => 'Welcome email sent when a user is activated.',
'rainlab.user::mail.restore' => 'Password reset instructions for front-end users.',
'rainlab.user::mail.new_user' => 'Sent to administrators when a new user joins.'
];
}
/**
* Register new Twig variables
* @return array
*/
public function registerMarkupTags()
{
return [
'functions' => [
'form_select_country' => ['RainLab\User\Models\Country', 'formSelect'],
'form_select_state' => ['RainLab\User\Models\State', 'formSelect']
]
];
}
}