forked from elkarte/Elkarte
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathManageTopics.php
162 lines (136 loc) · 4.35 KB
/
ManageTopics.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
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
<?php
/**
* Handles all the administration settings for topics and posts
*
* @package ElkArte Forum
* @copyright ElkArte Forum contributors
* @license BSD http://opensource.org/licenses/BSD-3-Clause (see accompanying LICENSE.txt file)
*
* @version 2.0 dev
*
*/
namespace ElkArte\AdminController;
use ElkArte\AbstractController;
use ElkArte\Action;
use ElkArte\SettingsForm\SettingsForm;
/**
* ManagePosts controller handles all the administration settings for topics and posts.
*/
class ManageTopics extends AbstractController
{
/**
* Check permissions and forward to the right method.
*
* @event integrate_sa_manage_topics
* @see AbstractController::action_index()
*/
public function action_index()
{
global $context, $txt;
$subActions = array(
'display' => array(
'controller' => $this,
'function' => 'action_topicSettings_display',
'permission' => 'admin_forum')
);
// Control for an action, why not!
$action = new Action('manage_topics');
// Only one option I'm afraid, but integrate_sa_manage_topics may add more
$subAction = $action->initialize($subActions, 'display');
// Page items for the template
$context['sub_action'] = $subAction;
$context['page_title'] = $txt['manageposts_topic_settings'];
// Set up action/subaction stuff.
$action->dispatch($subAction);
}
/**
* Administration page for topics: allows the display and set settings related to topics.
*
* What it does:
*
* - Requires the admin_forum permission.
* - Accessed from ?action=admin;area=postsettings;sa=topics.
*
* @event integrate_save_topic_settings
* @uses Admin template, edit_topic_settings sub-template.
*/
public function action_topicSettings_display()
{
global $context, $txt;
// Initialize the form
$settingsForm = new SettingsForm(SettingsForm::DB_ADAPTER);
// Initialize it with our settings
$settingsForm->setConfigVars($this->_settings());
// Setup the template.
$context['sub_template'] = 'show_settings';
// Are we saving them - are we??
if (isset($this->_req->query->save))
{
// Security checks
checkSession();
// Notify addons and integrations of the settings change.
call_integration_hook('integrate_save_topic_settings');
// Save the result!
$settingsForm->setConfigValues((array) $this->_req->post);
$settingsForm->save();
// Polls are modules
if (!empty($this->_req->post->pollMode))
{
enableModules('poll', ['post', 'display']);
}
else
{
disableModules('poll', ['post', 'display']);
}
// We're done here, pal.
redirectexit('action=admin;area=postsettings;sa=topics');
}
// Set up the template stuff nicely.
$context['post_url'] = getUrl('admin', ['action' => 'admin', 'area' => 'postsettings', 'save', 'sa' => 'topics']);
$context['settings_title'] = $txt['manageposts_topic_settings'];
// Prepare the settings
$settingsForm->prepare();
}
/**
* Return configuration settings for topics.
*
* @event integrate_modify_topic_settings
*/
private function _settings()
{
global $txt;
// @todo there is not interface for $modSettings['subject_length'], should it be added here?
// initialize it with our settings
$config_vars = array(
// Some simple big bools...
array('check', 'enableParticipation'),
array('check', 'enableFollowup'),
array('check', 'enable_unwatch'),
array('check', 'pollMode'),
'',
// Pagination etc...
array('int', 'oldTopicDays', 'postinput' => $txt['manageposts_days'], 'subtext' => $txt['oldTopicDays_zero']),
array('int', 'defaultMaxTopics', 'postinput' => $txt['manageposts_topics']),
array('int', 'defaultMaxMessages', 'postinput' => $txt['manageposts_posts']),
array('check', 'disable_print_topic'),
'',
// Hot topics (etc)...
array('int', 'hotTopicPosts', 'postinput' => $txt['manageposts_posts']),
array('int', 'hotTopicVeryPosts', 'postinput' => $txt['manageposts_posts']),
'',
// All, next/prev...
array('int', 'enableAllMessages', 'postinput' => $txt['manageposts_posts'], 'subtext' => $txt['enableAllMessages_zero']),
array('check', 'disableCustomPerPage'),
array('check', 'enablePreviousNext'),
);
call_integration_hook('integrate_modify_topic_settings', array(&$config_vars));
return $config_vars;
}
/**
* Return the topic settings for use in admin search
*/
public function settings_search()
{
return $this->_settings();
}
}