forked from rainlab/forum-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlugin.php
114 lines (103 loc) · 3.96 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
<?php namespace RainLab\Forum;
use Event;
use Backend;
use RainLab\User\Models\User;
use RainLab\Forum\Models\Member;
use System\Classes\PluginBase;
use RainLab\User\Controllers\Users as UsersController;
/**
* Forum Plugin Information File
*/
class Plugin extends PluginBase
{
public $require = ['RainLab.User'];
/**
* Returns information about this plugin.
*
* @return array
*/
public function pluginDetails()
{
return [
'name' => 'rainlab.forum::lang.plugin.name',
'description' => 'rainlab.forum::lang.plugin.description',
'author' => 'Alexey Bobkov, Samuel Georges',
'icon' => 'icon-comments',
'homepage' => 'https://github.com/rainlab/forum-plugin'
];
}
public function boot()
{
User::extend(function($model) {
$model->hasOne['forum_member'] = ['RainLab\Forum\Models\Member'];
});
UsersController::extendFormFields(function($widget, $model, $context) {
if ($context != 'update') return;
if (!Member::getFromUser($model)) return;
$widget->addFields([
'forum_member[username]' => [
'label' => 'rainlab.forum::lang.settings.username',
'tab' => 'Forum',
'comment' => 'rainlab.forum::lang.settings.username_comment'
],
'forum_member[is_moderator]' => [
'label' => 'rainlab.forum::lang.settings.moderator',
'type' => 'checkbox',
'tab' => 'Forum',
'span' => 'auto',
'comment' => 'rainlab.forum::lang.settings.moderator_comment'
],
'forum_member[is_banned]' => [
'label' => 'rainlab.forum::lang.settings.banned',
'type' => 'checkbox',
'tab' => 'Forum',
'span' => 'auto',
'comment' => 'rainlab.forum::lang.settings.banned_comment'
]
], 'primary');
});
UsersController::extendListColumns(function($widget, $model) {
if (!$model instanceof \RainLab\User\Models\User) return;
$widget->addColumns([
'forum_member_username' => [
'label' => 'rainlab.forum::lang.settings.forum_username',
'relation' => 'forum_member',
'select' => 'username',
'searchable' => false
]
]);
});
}
public function registerComponents()
{
return [
'\RainLab\Forum\Components\Channels' => 'forumChannels',
'\RainLab\Forum\Components\Channel' => 'forumChannel',
'\RainLab\Forum\Components\Topic' => 'forumTopic',
'\RainLab\Forum\Components\Topics' => 'forumTopics',
'\RainLab\Forum\Components\Member' => 'forumMember',
'\RainLab\Forum\Components\EmbedTopic' => 'forumEmbedTopic',
'\RainLab\Forum\Components\EmbedChannel' => 'forumEmbedChannel'
];
}
public function registerSettings()
{
return [
'settings' => [
'label' => 'rainlab.forum::lang.settings.channels',
'description' => 'rainlab.forum::lang.settings.channels_desc',
'icon' => 'icon-comments',
'url' => Backend::url('rainlab/forum/channels'),
'category' => 'Forum',
'order' => 500
]
];
}
public function registerMailTemplates()
{
return [
'rainlab.forum::mail.topic_reply' => 'Notification to followers when a post is made to a topic.',
'rainlab.forum::mail.member_report' => 'Notification to moderators when a member is reported to be a spammer.'
];
}
}