|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Manage personal messages settings. |
|
5
|
|
|
* |
|
6
|
|
|
* @package ElkArte Forum |
|
7
|
|
|
* @copyright ElkArte Forum contributors |
|
8
|
|
|
* @license BSD http://opensource.org/licenses/BSD-3-Clause (see accompanying LICENSE.txt file) |
|
9
|
|
|
* |
|
10
|
|
|
* @version 2.0 Beta 1 |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace ElkArte\AdminController; |
|
14
|
|
|
|
|
15
|
|
|
use ElkArte\AbstractController; |
|
16
|
|
|
use ElkArte\Action; |
|
17
|
|
|
use ElkArte\Languages\Txt; |
|
18
|
|
|
use ElkArte\SettingsForm\SettingsForm; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* PM administration controller. |
|
22
|
|
|
* This class allows modifying personal messages settings for the forum. |
|
23
|
|
|
*/ |
|
24
|
|
|
class ManagePmSettings extends AbstractController |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* Pre-dispatch, called before other methods. |
|
28
|
|
|
*/ |
|
29
|
|
|
public function pre_dispatch() |
|
30
|
|
|
{ |
|
31
|
|
|
// We need this in a few places, so it's easier to have it loaded here |
|
32
|
|
|
require_once(SUBSDIR . '/ManageFeatures.subs.php'); |
|
33
|
|
|
|
|
34
|
|
|
Txt::load('Help+ManageSettings'); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Default action for this controller. |
|
39
|
|
|
*/ |
|
40
|
|
|
public function action_index() |
|
41
|
|
|
{ |
|
42
|
|
|
$subActions = [ |
|
43
|
|
|
'pmsettings' => [$this, 'action_pmsettings', 'permission' => 'admin_forum'], |
|
44
|
|
|
]; |
|
45
|
|
|
|
|
46
|
|
|
// Set up the action control |
|
47
|
|
|
$action = new Action('modify_pmsettings'); |
|
48
|
|
|
|
|
49
|
|
|
// There is only one option |
|
50
|
|
|
$subAction = $action->initialize($subActions, 'pmsettings'); |
|
51
|
|
|
$action->dispatch($subAction); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Editing personal messages settings |
|
56
|
|
|
* |
|
57
|
|
|
* - Accessed with ?action=admin;area=pmsettings |
|
58
|
|
|
* |
|
59
|
|
|
* @event integrate_save_pmsettings_settings |
|
60
|
|
|
*/ |
|
61
|
|
|
public function action_pmsettings(): void |
|
62
|
|
|
{ |
|
63
|
|
|
global $txt, $context; |
|
64
|
|
|
|
|
65
|
|
|
// Initialize the form |
|
66
|
|
|
$settingsForm = new SettingsForm(SettingsForm::DB_ADAPTER); |
|
67
|
|
|
|
|
68
|
|
|
// Initialize it with our settings |
|
69
|
|
|
$settingsForm->setConfigVars($this->_pmSettings()); |
|
70
|
|
|
|
|
71
|
|
|
require_once(SUBSDIR . '/PersonalMessage.subs.php'); |
|
72
|
|
|
Txt::load('ManageMembers'); |
|
73
|
|
|
|
|
74
|
|
|
$context['pm_limits'] = loadPMLimits(); |
|
75
|
|
|
|
|
76
|
|
|
// Saving? |
|
77
|
|
|
if ($this->_req->hasQuery('save')) |
|
78
|
|
|
{ |
|
79
|
|
|
checkSession(); |
|
80
|
|
|
|
|
81
|
|
|
require_once(SUBSDIR . '/Membergroups.subs.php'); |
|
82
|
|
|
foreach ($context['pm_limits'] as $group_id => $group) |
|
83
|
|
|
{ |
|
84
|
|
|
if (!isset($this->_req->post->group[$group_id])) |
|
85
|
|
|
{ |
|
86
|
|
|
continue; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
if ($this->_req->post->group[$group_id] == $group['max_messages']) |
|
90
|
|
|
{ |
|
91
|
|
|
continue; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
updateMembergroupProperties(['current_group' => $group_id, 'max_messages' => $this->_req->post->group[$group_id]]); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
call_integration_hook('integrate_save_pmsettings_settings'); |
|
98
|
|
|
|
|
99
|
|
|
$settingsForm->setConfigValues((array) $this->_req->post); |
|
100
|
|
|
$settingsForm->save(); |
|
101
|
|
|
redirectexit('action=admin;area=featuresettings;sa=pmsettings'); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
$context['post_url'] = getUrl('admin', ['action' => 'admin', 'area' => 'featuresettings', 'sa' => 'pmsettings', 'save']); |
|
105
|
|
|
$context['settings_title'] = $txt['personal_messages']; |
|
106
|
|
|
$context['sub_template'] = 'show_settings'; |
|
107
|
|
|
$context['page_title'] = $txt['modSettings_title']; |
|
108
|
|
|
|
|
109
|
|
|
$settingsForm->prepare(); |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* Return pm settings. |
|
114
|
|
|
* |
|
115
|
|
|
* - Used in admin center search and settings form |
|
116
|
|
|
* |
|
117
|
|
|
* @event integrate_modify_pmsettings_settings Adds / Modifies PM Settings |
|
118
|
|
|
*/ |
|
119
|
|
|
private function _pmSettings() |
|
120
|
|
|
{ |
|
121
|
|
|
global $txt; |
|
122
|
|
|
|
|
123
|
|
|
$config_vars = [ |
|
124
|
|
|
// Reporting of personal messages? |
|
125
|
|
|
['check', 'enableReportPM'], |
|
126
|
|
|
// Inline permissions. |
|
127
|
|
|
['permissions', 'pm_send'], |
|
128
|
|
|
// PM Settings |
|
129
|
|
|
['title', 'antispam_PM'], |
|
130
|
|
|
'pm1' => ['int', 'max_pm_recipients', 'postinput' => $txt['max_pm_recipients_note']], |
|
131
|
|
|
'pm2' => ['int', 'pm_posts_verification', 'postinput' => $txt['pm_posts_verification_note']], |
|
132
|
|
|
'pm3' => ['int', 'pm_posts_per_hour', 'postinput' => $txt['pm_posts_per_hour_note']], |
|
133
|
|
|
['title', 'membergroups_max_messages'], |
|
134
|
|
|
['desc', 'membergroups_max_messages_desc'], |
|
135
|
|
|
['callback', 'pm_limits'], |
|
136
|
|
|
]; |
|
137
|
|
|
|
|
138
|
|
|
call_integration_hook('integrate_modify_pmsettings_settings', [&$config_vars]); |
|
139
|
|
|
|
|
140
|
|
|
return $config_vars; |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
/** |
|
144
|
|
|
* Public method to return the PM settings, used for admin search |
|
145
|
|
|
*/ |
|
146
|
|
|
public function pmSettings_search() |
|
147
|
|
|
{ |
|
148
|
|
|
return $this->_pmSettings(); |
|
149
|
|
|
} |
|
150
|
|
|
} |
|
151
|
|
|
|