PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / 2.10.01
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses v2.10.01
2.10.0 2.10.01 2.9.1 2.9.0 2.8.1 2.8.0 2.7.7 2.7.5 2.7.0 2.6.01 2.6.0 2.5.0 2.4.01 trunk 1.0.90 1.0.91 1.0.92 1.0.93 1.0.94 1.0.95 1.0.96 1.0.97 1.0.98 1.0.99 1.1.0 All 77 releases
← All changes | app/Http/Controllers/AdminController.php +61 -14 2.5.02.10.01 View file →
@@ -8,8 +8,9 @@
8 8 use FluentCommunity\App\Services\CustomSanitizer;
9 9 use FluentCommunity\App\Services\FeedsHelper;
10 10 use FluentCommunity\App\Services\ProfileHelper;
11 11 use FluentCommunity\Modules\Auth\AuthHelper;
12 +use FluentCommunity\Modules\PushNotification\PushNotificationModule;
12 13 use FluentCommunity\App\Services\Helper;
13 14 use FluentCommunity\App\Services\OnboardingService;
14 15 use FluentCommunity\Framework\Http\Request\Request;
15 16 use FluentCommunity\Framework\Support\Arr;
@@ -41,8 +42,9 @@
41 42 public function saveGeneralSettings(Request $request)
42 43 {
43 44 $inputs = $request->get('settings', []);
44 45 $settings = Helper::generalSettings(false);
46 + $storedSettings = $settings;
45 47 $inputs = Arr::only($inputs, array_keys($settings));
46 48
47 49 $settings['logo'] = Arr::get($inputs, 'logo', '');
48 50 $settings['white_logo'] = Arr::get($inputs, 'white_logo', '');
@@ -123,13 +125,24 @@
123 125 ]);
124 126 }
125 127
126 128 $slugChanged = false;
127 - if ($settings['slug'] != $inputs['slug'] && !defined('FLUENT_COMMUNITY_PORTAL_SLUG')) {
128 - $settings['slug'] = $inputs['slug'];
129 + $newSlug = sanitize_title($inputs['slug'] ?? '');
130 + if ($newSlug && $settings['slug'] != $newSlug && !defined('FLUENT_COMMUNITY_PORTAL_SLUG')) {
131 + $settings['slug'] = $newSlug;
129 132 $slugChanged = true;
130 133 }
131 134
135 + if (!Helper::isSuperAdmin()) {
136 + foreach (['auth_url', 'cutsom_auth_url', 'auth_form_type', 'auth_redirect', 'custom_signup_url', 'use_custom_signup_page', 'explicit_registration'] as $restrictedKey) {
137 + if ($settings[$restrictedKey] != Arr::get($storedSettings, $restrictedKey, '')) {
138 + return $this->sendError([
139 + 'message' => __('You do not have permission to change the authentication and login settings', 'fluent-community')
140 + ]);
141 + }
142 + }
143 + }
144 +
132 145 update_option('fluent_community_settings', $settings);
133 146
134 147 $redirectUrl = '';
135 148
@@ -199,8 +212,52 @@
199 212 'message' => __('Email notification settings have been updated', 'fluent-community')
200 213 ];
201 214 }
202 215
216 + public function getPushSettings(Request $request)
217 + {
218 + $data = [
219 + 'push_settings' => Utility::getPushNotificationSettings(),
220 + 'push_available' => PushNotificationModule::isFluentNotifyActive(),
221 + 'push_setup' => [
222 + 'state' => PushNotificationModule::getSetupState(),
223 + 'settings_url' => PushNotificationModule::getSettingsUrl(),
224 + 'can_install' => current_user_can('install_plugins'),
225 + 'can_activate' => current_user_can('activate_plugins'),
226 + 'has_installer' => (bool)has_action('fluent_community/install_fluent_notify_plugin'),
227 + 'learn_more_url' => 'https://fluentnotify.com'
228 + ]
229 + ];
230 +
231 + return apply_filters('fluent_community/push_settings_api_response', $data, $request->all());
232 + }
233 +
234 + public function savePushSettings(Request $request)
235 + {
236 + $prevSettings = Utility::getPushNotificationSettings();
237 +
238 + $settings = Arr::only((array)$request->get('settings', []), array_keys($prevSettings));
239 + $settings = wp_parse_args($settings, $prevSettings);
240 +
241 + foreach ($settings as $key => $value) {
242 + if ($key === 'prompt_placements') {
243 + $settings[$key] = array_values(array_intersect(
244 + array_map('sanitize_text_field', (array)$value),
245 + PushNotificationModule::PROMPT_PLACEMENTS
246 + ));
247 + } else {
248 + $settings[$key] = $value === 'yes' ? 'yes' : 'no';
249 + }
250 + }
251 +
252 + Utility::updateOption('global_push_settings', $settings);
253 +
254 + return [
255 + 'push_settings' => $settings,
256 + 'message' => __('Push notification settings have been updated', 'fluent-community')
257 + ];
258 + }
259 +
203 260 public function getStorageSettings(Request $request)
204 261 {
205 262 if (!defined('FLUENT_COMMUNITY_PRO')) {
206 263 $config = [
@@ -228,9 +285,9 @@
228 285 'message' => __('You cannot update the storage settings as it is defined in the config file', 'fluent-community')
229 286 ]);
230 287 }
231 288
232 - $config = $request->get('config', []);
289 + $config = (array)$request->get('config', []);
233 290
234 291 $driver = Arr::get($config, 'driver', 'local');
235 292
236 293 $validation = [
@@ -339,18 +396,8 @@
339 396 public function updateWelcomeBannerSettings(Request $request)
340 397 {
341 398 $settings = $request->get('settings', []);
342 399
343 - if (!empty($settings['login']['description'])) {
344 - $description = wp_unslash($settings['login']['description']);
345 - $settings['login']['description'] = CustomSanitizer::unslashMarkdown($description);
346 - }
347 -
348 - if (!empty($settings['logout']['description'])) {
349 - $description = wp_unslash($settings['logout']['description']);
350 - $settings['logout']['description'] = CustomSanitizer::unslashMarkdown($description);
351 - }
352 -
353 400 $settings = CustomSanitizer::sanitizeWelcomeBannerSettings($settings);
354 401
355 402 if (Arr::get($settings, 'login.enabled') == 'yes') {
356 403 $settings['login']['description_rendered'] = wp_kses_post(FeedsHelper::mdToHtml(Arr::get($settings, 'login.description')));
@@ -444,9 +491,9 @@
444 491
445 492 if (Arr::get($inputs, 'slug') && empty($settings['is_slug_defined'])) {
446 493 $settings['slug'] = sanitize_title(Arr::get($inputs, 'slug'));
447 494 }
448 - update_option('fluent_community_settings', $settings, 'yes');
495 + update_option('fluent_community_settings', $settings, true);
449 496
450 497 // Email Subscription Settings
451 498 $subscriptionSettings = array_filter([
452 499 'user_id' => get_current_user_id(),