Repository navigation
Expand file tree
/
Copy pathPlugin.php
More file actions
166 lines (152 loc) · 5.15 KB
/
Copy pathPlugin.php
File metadata and controls
166 lines (152 loc) · 5.15 KB
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?php namespace Mohsin\User;
use Lang;
use Event;
use Backend;
use System\Classes\PluginBase;
use System\Classes\PluginManager;
use Mohsin\User\Classes\ProviderManager;
use Mohsin\User\Models\Settings as SettingsModel;
/**
* User Plugin Information File
*/
class Plugin extends PluginBase
{
public $require = ['Mohsin.Rest'];
/**
* Returns information about this plugin.
*
* @return array
*/
public function pluginDetails()
{
return [
'name' => 'mohsin.user::lang.plugin.name',
'description' => 'mohsin.user::lang.plugin.description',
'author' => 'Saifur Rahman Mohsin',
'icon' => 'icon-user'
];
}
/**
* Boot method, called right before the request route.
*
* @return array
*/
public function boot()
{
if (PluginManager::instance()->exists('Mohsin.Install') && PluginManager::instance()->exists('RainLab.User')) {
\RainLab\User\Models\User::extend(function ($model) {
$model->hasMany['mobileuser_installs'] = ['Mohsin\Mobile\Models\Install'];
});
\RainLab\User\Controllers\Users::extend(function ($controller) {
$controller->addCss('/plugins/mohsin/user/assets/css/custom.css');
if (!$controller->isClassExtendedWith('Backend.Behaviors.RelationController')) {
$controller->implement[] = 'Backend.Behaviors.RelationController';
}
if (!isset($controller->relationConfig)) {
$controller->addDynamicProperty('relationConfig');
}
$controller->relationConfig = $controller->mergeConfig(
$controller->relationConfig,
'$/mohsin/user/models/relation.yaml'
);
});
\RainLab\User\Controllers\Users::extendFormFields(function ($form, $model, $context) {
if (!$model instanceof \RainLab\User\Models\User) {
return;
}
if (!$model->exists) {
return;
}
$form->addTabFields([
'mobileuser_installs' => [
'label' => 'mohsin.user::lang.users.mobileuser_installs_label',
'tab' => 'Mobile',
'type' => 'partial',
'path' => '$/mohsin/user/assets/partials/_field_mobileuser_installs.htm',
],
]);
});
}
Event::listen('backend.form.extendFields', function ($form) {
if (!$form->model instanceof SettingsModel) {
return;
}
$providers = ProviderManager::instance()->listProviderObjects();
foreach ($providers as $provider) {
$config = $provider -> getFieldConfig();
if (!is_null($config)) {
$form->addFields($config);
}
}
});
}
/**
* Registers any back-end permissions used by this plugin.
*
* @return array
*/
public function registerPermissions()
{
return [
'mohsin.user.access_users' => [
'tab' => 'Mobile',
'label' => 'mohsin.user::lang.plugin.access_users'
],
'mohsin.user.access_settings' => [
'tab' => 'Mobile',
'label' => 'mohsin.user::lang.plugin.access_settings'
]
];
}
/**
* Registers settings controller for this plugin.
*
* @return array
*/
public function registerSettings()
{
return [
'settings' => [
'label' => 'mohsin.user::lang.settings.name',
'description' => 'mohsin.user::lang.settings.description',
'category' => 'Mobile',
'icon' => 'icon-user-plus',
'class' => 'Mohsin\User\Models\Settings',
'order' => 502,
'permissions' => ['mohsin.user.access_settings'],
]
];
}
/**
* Registers API nodes exposed by this plugin.
*
* @return array
*/
public function registerNodes()
{
return [
'account/signin' => [
'controller' => 'Mohsin\User\Http\Account@signin',
'action' => 'store'
],
'account/register' => [
'controller' => 'Mohsin\User\Http\Account@register',
'action' => 'store'
]
];
}
/**
* Registers any mobile login providers implemented in this plugin.
* The providers must be returned in the following format:
* ['className1' => 'alias'],
* ['className2' => 'anotherAlias']
*/
public function registerMobileLoginProviders()
{
// Note that the DefaultProvider does not need Provider suffix
//but it's there due to PHP class naming restriction to use the reserved Default keyword.
return [
'Mohsin\User\Providers\DefaultProvider' => 'default'
];
}
}