This repository has been archived by the owner on Nov 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathPlugin.php
83 lines (75 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
<?php
namespace Bedard\RainLabUserApi;
use Event;
use RainLab\User\Models\Settings as UserSettings;
use System\Classes\PluginBase;
/**
* Plugin Information File.
*/
class Plugin extends PluginBase
{
/**
* @var array Dependencies
*/
public $require = [
'RainLab.User',
];
/**
* Returns information about this plugin.
*
* @return array
*/
public function pluginDetails()
{
return [
'author' => 'Scott Bedard',
'description' => 'An HTTP API for RainLab.User',
'icon' => 'icon-leaf',
'name' => 'RainLab.User API',
];
}
/**
* Boot method, called right before the request route.
*
* @return array
*/
public function boot()
{
// extend the rainlab.user settings model
Event::listen('backend.form.extendFields', function ($widget) {
if (!$widget->model instanceof UserSettings) {
return;
}
$widget->addTabFields([
// password reset url
'password_reset_url' => [
'comment' => 'bedard.rainlabuserapi::lang.settings.password_reset_url_comment',
'commentHtml' => true,
'label' => 'bedard.rainlabuserapi::lang.settings.password_reset_url_label',
'span' => 'left',
'tab' => 'rainlab.user::lang.settings.signin_tab',
],
// activation url
'activate_redirect' => [
'comment' => 'bedard.rainlabuserapi::lang.settings.activate_redirect_comment',
'label' => 'bedard.rainlabuserapi::lang.settings.activate_redirect_label',
'span' => 'left',
'tab' => 'rainlab.user::lang.settings.activation_tab',
'trigger' => [
'action' => 'enable',
'condition' => 'value['.UserSettings::ACTIVATE_USER.']',
'field' => 'activate_mode',
],
],
// safe password updates
'safe_password_updates' => [
'comment' => 'bedard.rainlabuserapi::lang.settings.safe_password_updates_comment',
'label' => 'bedard.rainlabuserapi::lang.settings.safe_password_updates_label',
'span' => 'left',
'tab' => 'bedard.rainlabuserapi::lang.settings.api_tab',
'type' => 'switch',
],
]);
});
}
}