PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / 2.6.01
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses v2.6.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
fluent-community / app / Http / Controllers / SettingController.php

SettingController.php in FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses 2.6.01, at app/Http/Controllers/SettingController.php

631 lines 26.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCommunity\App\Http\Controllers;
4
5 use FluentCommunity\App\Functions\Utility;
6 use FluentCommunity\App\Models\Space;
7 use FluentCommunity\App\Models\SpaceGroup;
8 use FluentCommunity\App\Services\Helper;
9 use FluentCommunity\Framework\Http\Request\Request;
10 use FluentCommunity\Framework\Support\Arr;
11 use FluentCommunity\Framework\Support\Sanitizer;
12 use FluentCommunity\Modules\Course\Model\Course;
13
14 class SettingController extends Controller
15 {
16 public function getFeatures()
17 {
18 $data = [
19 'features' => Utility::getFeaturesConfig(),
20 'addOns' => $this->getAddons()
21 ];
22 return apply_filters('fluent_community/features_api_response', $data, $this->request->all());
23 }
24
25 public function setFeatures(Request $request)
26 {
27 $request->validate([
28 'features.giphy_api_key' => 'required_if:features.giphy_module,yes|string',
29 ]);
30
31 $data = $request->get('features', []);
32
33 $data = Sanitizer::sanitize($data, [
34 'leader_board_module' => 'sanitize_text_field',
35 'course_module' => 'sanitize_text_field',
36 'giphy_module' => 'sanitize_text_field',
37 'giphy_api_key' => 'sanitize_text_field',
38 'cloud_storage' => 'sanitize_text_field',
39 'emoji_module' => 'sanitize_text_field',
40 'user_badge' => 'sanitize_text_field',
41 'has_crm_sync' => 'sanitize_text_field',
42 'followers_module' => 'sanitize_text_field',
43 'custom_profile_fields' => 'sanitize_text_field',
44 ]);
45
46 $prevConfig = Utility::getFeaturesConfig();
47
48 $data = wp_parse_args($data, $prevConfig);
49
50 Utility::updateOption('fluent_community_features', $data);
51
52 return [
53 'message' => __('Features saved successfully.', 'fluent-community')
54 ];
55 }
56
57 public function getMenuSettings(Request $request)
58 {
59 $menuGroups = Helper::getMenuItemsGroup('edit');
60 $formattedGroups = [];
61
62 foreach ($menuGroups as $indexName => $menuGroup) {
63 if (is_array($menuGroup)) {
64 $formattedGroups[$indexName] = array_values($menuGroup);
65 } else {
66 $formattedGroups[$indexName] = [];
67 }
68 }
69
70 $afterCommunityLinkGroups = Arr::get($formattedGroups, 'afterCommunityLinkGroups', []);
71 $formattedAfterCommunityGroups = [];
72
73 if (is_array($afterCommunityLinkGroups)) {
74 foreach ($afterCommunityLinkGroups as $group) {
75 if (!is_array($group)) continue;
76
77 $title = Arr::get($group, 'title', '');
78 if (empty($title)) continue;
79
80 $items = Arr::get($group, 'items', []);
81 $items = is_array($items) ? array_values($items) : [];
82
83 $formattedAfterCommunityGroups[] = [
84 'title' => $title,
85 'slug' => Arr::get($group, 'slug', ''),
86 'items' => $items,
87 ];
88 }
89 }
90
91 $formattedGroups['afterCommunityLinkGroups'] = $formattedAfterCommunityGroups;
92
93 $data = [
94 'menuSettings' => $formattedGroups
95 ];
96 return apply_filters('fluent_community/menu_settings_api_response', $data, $request->all());
97 }
98
99 public function saveMenuSettings(Request $request)
100 {
101 $menuSettings = $request->get('menuSettings', []);
102
103 $mainMenuItems = $menuSettings['mainMenuItems'] ?? [];
104 $profileDropdownItems = $menuSettings['profileDropdownItems'] ?? [];
105 $beforeCommunityMenuItems = $menuSettings['beforeCommunityMenuItems'] ?? [];
106 $afterCommunityLinkGroups = $menuSettings['afterCommunityLinkGroups'] ?? [];
107
108 $previousSettings = Helper::getMenuItemsGroup('edit');
109
110 $menuSettings['mainMenuItems'] = $this->formatMenuGroup($mainMenuItems, $previousSettings['mainMenuItems']);
111 $menuSettings['profileDropdownItems'] = $this->formatMenuGroup($profileDropdownItems, $previousSettings['profileDropdownItems']);
112 $menuSettings['beforeCommunityMenuItems'] = $this->formatMenuGroup($beforeCommunityMenuItems, $previousSettings['beforeCommunityMenuItems']);
113
114 $formattedAfterCommunityGroups = [];
115 foreach ($afterCommunityLinkGroups as $afterCommunityLinkGroup) {
116 if (empty($afterCommunityLinkGroup['title'])) continue;
117
118 $formattedAfterCommunityGroups[] = [
119 'title' => sanitize_text_field($afterCommunityLinkGroup['title']),
120 'slug' => !empty($afterCommunityLinkGroup['slug']) ? $afterCommunityLinkGroup['slug'] : 'custom_footer_group_' . time(),
121 'items' => $this->formatMenuGroup($afterCommunityLinkGroup['items'], [])
122 ];
123 }
124
125 $menuSettings['afterCommunityLinkGroups'] = $formattedAfterCommunityGroups;
126 $menuSettings = Arr::only($menuSettings, ['mainMenuItems', 'profileDropdownItems', 'beforeCommunityMenuItems', 'afterCommunityLinkGroups']);
127
128 Utility::updateOption('fluent_community_menu_groups', $menuSettings);
129
130 return [
131 'message' => __('Menu settings saved successfully.', 'fluent-community')
132 ];
133 }
134
135 private function formatMenuGroup($mainMenuItems, $savedMenuItems)
136 {
137 $formattedMainMenuItems = [];
138 foreach ($mainMenuItems as $item) {
139 $slug = (string)Arr::get($item, 'slug');
140 if (!Arr::get($item, 'title') || !Arr::get($item, 'permalink')) {
141 continue;
142 }
143
144 if (!$slug) {
145 $slug = 'custom_' . sanitize_title(Arr::get($item, 'title')) . time();
146 $item['slug'] = $slug;
147 $item['is_custom'] = 'yes';
148 }
149
150 $defaultItem = Arr::get($savedMenuItems, $slug, []);
151 if ($defaultItem) {
152 $preservedKeys = ['is_system', 'is_locked', 'is_unavailable', 'slug'];
153 foreach ($preservedKeys as $key) {
154 if (isset($defaultItem[$key])) {
155 $item[$key] = Arr::get($defaultItem, $key);
156 }
157 }
158 }
159
160 $item = \FluentCommunity\App\Services\CustomSanitizer::sanitizeMenuLink($item);
161
162 $formattedMainMenuItems[$slug] = $item;
163 }
164
165 return $formattedMainMenuItems;
166 }
167
168 public function getAddons()
169 {
170 $addons = [
171 'fluent-messaging' => [
172 'is_repo' => false,
173 'title' => __('FluentCommunity Chat', 'fluent-community'),
174 'logo' => Helper::assetUrl('images/brands/fluent-messages.svg'),
175 'is_installed' => defined('FLUENT_MESSAGING_CHAT_VERSION'),
176 'learn_more_url' => 'https://fluentcommunity.co',
177 'settings_url' => Helper::baseUrl('chat'),
178 'action_text' => $this->isPluginInstalled('fluent-messaging/fluent-messaging.php') ? __('Active FluentCommunity Chat', 'fluent-community') : __('Install FluentCommunity Chat', 'fluent-community'),
179 'description' => __('FluentCommunity Chat is a real-time chat plugin for WordPress. It allows you to create a chat room for your community members.', 'fluent-community')
180 ],
181 'fluent-player' => [
182 'is_repo' => false,
183 'title' => __('FluentPlayer', 'fluent-community'),
184 'logo' => Helper::assetUrl('images/brands/fluent-player.svg'),
185 'is_installed' => defined('FLUENT_PLAYER_VERSION'),
186 'learn_more_url' => 'https://wordpress.org/plugins/fluent-player/',
187 'action_text' => $this->isPluginInstalled('fluent-player/fluent-player.php') ? __('Active FluentPlayer', 'fluent-community') : __('Install FluentPlayer', 'fluent-community'),
188 'description' => __('Advanced video player with support for YouTube, Vimeo, HLS and more.', 'fluent-community')
189 ],
190 'fluent-cart' => [
191 'is_repo' => true,
192 'title' => __('FluentCart', 'fluent-community'),
193 'logo' => Helper::assetUrl('images/brands/fluent-cart.svg'),
194 'is_installed' => defined('FLUENTCART_VERSION'),
195 'learn_more_url' => 'https://wordpress.org/plugins/fluent-cart/',
196 'settings_url' => defined('FLUENTCART_VERSION') ? admin_url('admin.php?page=fluent-cart#/') : '',
197 'action_text' => $this->isPluginInstalled('fluent-cart/fluent-cart.php') ? __('Active FluentCart', 'fluent-community') : __('Install Fluent Cart', 'fluent-community'),
198 'description' => __('The easiest way to sell digital and physical products in WordPress. Create, manage, and sell products with ease.', 'fluent-community')
199 ],
200 'fluent-crm' => [
201 'is_repo' => true,
202 'title' => __('FluentCRM', 'fluent-community'),
203 'logo' => Helper::assetUrl('images/brands/fluentcrm.svg'),
204 'is_installed' => defined('FLUENTCRM'),
205 'learn_more_url' => 'https://fluentcrm.com',
206 'settings_url' => defined('FLUENTCRM') ? admin_url('admin.php?page=fluentcrm-admin#/') : '',
207 'action_text' => $this->isPluginInstalled('fluent-crm/fluent-crm.php') ? __('Active FluentCRM', 'fluent-community') : __('Install FluentCRM', 'fluent-community'),
208 'description' => __('The Best Email Marketing Automation Plugin for WordPress. Capture, Segment and Automate your Marketing.', 'fluent-community')
209 ],
210 'fluentform' => [
211 'is_repo' => true,
212 'title' => __('Fluent Forms', 'fluent-community'),
213 'logo' => Helper::assetUrl('images/brands/fluentform.png'),
214 'is_installed' => defined('FLUENTFORM'),
215 'learn_more_url' => 'https://wordpress.org/plugins/fluentform/',
216 'settings_url' => defined('FLUENTFORM') ? admin_url('admin.php?page=fluent_forms') : '',
217 'action_text' => $this->isPluginInstalled('fluentform/fluentform.php') ? __('Active Fluent Forms', 'fluent-community') : __('Install Fluent Forms', 'fluent-community'),
218 'description' => __('Collect leads and build any type of forms, accept payments, connect with your CRM with the Fastest Contact Form Builder Plugin for WordPress', 'fluent-community')
219 ],
220 'fluent-smtp' => [
221 'is_repo' => true,
222 'title' => __('Fluent SMTP', 'fluent-community'),
223 'logo' => Helper::assetUrl('images/brands/fluent-smtp.svg'),
224 'is_installed' => defined('FLUENTMAIL'),
225 'learn_more_url' => 'https://wordpress.org/plugins/fluent-smtp/',
226 'settings_url' => defined('FLUENTMAIL') ? admin_url('options-general.php?page=fluent-mail#/') : '',
227 'action_text' => $this->isPluginInstalled('fluent-smtp/fluent-smtp.php') ? __('Active Fluent SMTP', 'fluent-community') : __('Install Fluent SMTP', 'fluent-community'),
228 'description' => __('Fluent SMTP is the ultimate SMTP and SES plugin for WordPress. Connect with any SMTP service, including SendGrid, Mailgun, SES, Sendinblue, PepiPost, Google, Microsoft, and more.', 'fluent-community')
229 ],
230 'fluent-support' => [
231 'is_repo' => true,
232 'title' => __('Fluent Support', 'fluent-community'),
233 'logo' => Helper::assetUrl('images/brands/fluent-support.svg'),
234 'is_installed' => defined('FLUENT_SUPPORT_VERSION'),
235 'learn_more_url' => 'https://wordpress.org/plugins/fluent-support/',
236 'settings_url' => defined('FLUENT_SUPPORT_VERSION') ? admin_url('admin.php?page=fluent-support#/') : '',
237 'action_text' => $this->isPluginInstalled('fluent-support/fluent-support.php') ? __('Active Fluent Support', 'fluent-community') : __('Install Fluent Support', 'fluent-community'),
238 'description' => __('WordPress Helpdesk and Customer Support Ticket Plugin. Provide awesome support and manage customer queries right from your WordPress dashboard.', 'fluent-community')
239 ]
240 ];
241
242 if (defined('FLUENT_COMMUNITY_PRO')) {
243 $addons['wp-payment-form'] = [
244 'is_repo' => true,
245 'title' => __('Paymattic', 'fluent-community'),
246 'logo' => Helper::assetUrl('images/brands/paymattic.png'),
247 'is_installed' => defined('WPPAYFORM_VERSION'),
248 'learn_more_url' => 'https://wordpress.org/plugins/wp-payment-form/',
249 'settings_url' => defined('WPPAYFORM_VERSION') ? admin_url('admin.php?page=wppayform.php#/integrations/fluent_community') : '',
250 'action_text' => $this->isPluginInstalled('wp-payment-form/wp-payment-form.php') ? __('Active Paymattic', 'fluent-community') : __('Install Paymattic', 'fluent-community'),
251 'description' => __('Paymattic – Secure, Simple Payment & Donation with Subscription Payments, Recurring Donations, Customer Management', 'fluent-community')
252 ];
253 }
254
255 return $addons;
256 }
257
258 private function isPluginInstalled($plugin)
259 {
260 return file_exists(WP_PLUGIN_DIR . '/' . $plugin);
261 }
262
263 public function installPlugin(Request $request)
264 {
265 if (!current_user_can('install_plugins')) {
266 return $this->sendError([
267 'message' => __('You do not have permission to install plugins', 'fluent-community')
268 ]);
269 }
270
271 $pluginSlug = $request->get('plugin');
272
273 $addons = $this->getAddons();
274
275 if (!isset($addons[$pluginSlug])) {
276 return $this->sendError(__('Invalid Plugin', 'fluent-community'));
277 }
278
279 $details = $addons[$pluginSlug];
280
281 if ($details['is_repo']) {
282 $plugin = [
283 'name' => $details['title'],
284 'repo-slug' => $pluginSlug,
285 'file' => $pluginSlug . '.php',
286 ];
287 $this->backgroundInstaller($plugin, $pluginSlug);
288 } else {
289 if ($pluginSlug == 'fluent-messaging') {
290 if (!defined('FLUENT_COMMUNITY_PRO')) {
291 return $this->sendError(__('FluentMessaging is a Pro Plugin. Please install FluentCommunity Pro first.', 'fluent-community'));
292 }
293 do_action('fluent_community/install_messaging_plugin');
294 } else if ($pluginSlug == 'fluent-player') {
295
296 if (!defined('FLUENT_COMMUNITY_PRO')) {
297 return $this->sendError(__('FluentPlayer is required pro version of FluentCommunity. Please install FluentCommunity Pro first.', 'fluent-community'));
298 }
299
300 do_action('fluent_community/install_fluent_player_plugin');
301 }
302 }
303
304 return [
305 'message' => __('Plugin has been installed Successfully', 'fluent-community'),
306 'is_installed' => true
307 ];
308 }
309
310 private function backgroundInstaller($plugin_to_install, $plugin_id)
311 {
312 if (!empty($plugin_to_install['repo-slug'])) {
313 require_once ABSPATH . 'wp-admin/includes/file.php';
314 require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
315 require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
316 require_once ABSPATH . 'wp-admin/includes/plugin.php';
317
318 WP_Filesystem();
319
320 $skin = new \Automatic_Upgrader_Skin();
321 $upgrader = new \WP_Upgrader($skin);
322 $installed_plugins = array_reduce(array_keys(\get_plugins()), array($this, 'associate_plugin_file'),
323 array());
324 $plugin_slug = $plugin_to_install['repo-slug'];
325 $plugin_file = isset($plugin_to_install['file']) ? $plugin_to_install['file'] : $plugin_slug . '.php';
326 $installed = false;
327 $activate = false;
328
329 // See if the plugin is installed already.
330 if (isset($installed_plugins[$plugin_file])) {
331 $installed = true;
332 $activate = !is_plugin_active($installed_plugins[$plugin_file]);
333 }
334
335 // Install this thing!
336 if (!$installed) {
337 // Suppress feedback.
338 ob_start();
339
340 try {
341 $plugin_information = plugins_api(
342 'plugin_information',
343 array(
344 'slug' => $plugin_slug,
345 'fields' => array(
346 'short_description' => false,
347 'sections' => false,
348 'requires' => false,
349 'rating' => false,
350 'ratings' => false,
351 'downloaded' => false,
352 'last_updated' => false,
353 'added' => false,
354 'tags' => false,
355 'homepage' => false,
356 'donate_link' => false,
357 'author_profile' => false,
358 'author' => false,
359 ),
360 )
361 );
362
363 if (is_wp_error($plugin_information)) {
364 throw new \Exception($plugin_information->get_error_message());
365 }
366
367 $package = $plugin_information->download_link;
368 $download = $upgrader->download_package($package);
369
370 if (is_wp_error($download)) {
371 throw new \Exception($download->get_error_message());
372 }
373
374 $working_dir = $upgrader->unpack_package($download, true);
375
376 if (is_wp_error($working_dir)) {
377 throw new \Exception($working_dir->get_error_message());
378 }
379
380 $result = $upgrader->install_package(
381 array(
382 'source' => $working_dir,
383 'destination' => WP_PLUGIN_DIR,
384 'clear_destination' => false,
385 'abort_if_destination_exists' => false,
386 'clear_working' => true,
387 'hook_extra' => array(
388 'type' => 'plugin',
389 'action' => 'install',
390 ),
391 )
392 );
393
394 if (is_wp_error($result)) {
395 throw new \Exception($result->get_error_message());
396 }
397
398 $activate = true;
399 } catch (\Exception $e) {
400 }
401
402 // Discard feedback.
403 ob_end_clean();
404 }
405
406 wp_clean_plugins_cache();
407
408 // Activate this thing.
409 if ($activate) {
410 try {
411 $result = activate_plugin($installed ? $installed_plugins[$plugin_file] : $plugin_slug . '/' . $plugin_file);
412
413 if (is_wp_error($result)) {
414 throw new \Exception($result->get_error_message());
415 }
416 } catch (\Exception $e) {
417 throw new \Exception(esc_html($e->getMessage()));
418 }
419 }
420 }
421 }
422
423 private function associate_plugin_file($plugins, $key)
424 {
425 $path = explode('/', $key);
426 $filename = end($path);
427 $plugins[$filename] = $key;
428 return $plugins;
429 }
430
431 public function getCustomizationSettings(Request $request)
432 {
433 $data = [
434 'settings' => Utility::getCustomizationSettings()
435 ];
436
437 return apply_filters('fluent_community/customization_settings_api_response', $data, $request->all());
438 }
439
440 public function updateCustomizationSettings(Request $request)
441 {
442 $settings = $request->get('settings', []);
443
444 $yesNoFields = [
445 'dark_mode', 'fixed_page_header', 'show_powered_by', 'show_post_modal', 'feed_link_on_sidebar', 'fixed_sidebar', 'icon_on_header_menu', 'disable_feed_layout', 'collapse_sidebar_groups', 'hide_header_on_scroll'
446 ];
447
448 foreach ($settings as $key => $value) {
449 if (in_array($key, $yesNoFields)) {
450 $settings[$key] = $value == 'yes' ? 'yes' : 'no';
451 } else if ($key == 'affiliate_id') {
452 $settings[$key] = (int)$value;
453 if (!$settings[$key]) {
454 $settings[$key] = '';
455 }
456 } else {
457 $settings[$key] = sanitize_text_field($value);
458 }
459 }
460
461 Utility::updateCustomizationSettings($settings);
462
463 return [
464 'message' => __('Customization settings have been saved successfully.', 'fluent-community')
465 ];
466 }
467
468 public function getFluentPlayerSettings(Request $request)
469 {
470 return [
471 'settings' => \FluentCommunity\Modules\Integrations\FluentPlayer\Bootstrap::getSettings()
472 ];
473 }
474
475 public function updateFluentPlayerSettings(Request $request)
476 {
477 $settings = $request->get('settings', []);
478
479 $updatedSettings = \FluentCommunity\Modules\Integrations\FluentPlayer\Bootstrap::updateSettings($settings);
480
481 return [
482 'message' => __('FluentPlayer settings have been saved successfully.', 'fluent-community'),
483 'settings' => $updatedSettings
484 ];
485 }
486
487 public function getPrivacySettings(Request $request)
488 {
489 $data = [
490 'settings' => Utility::getPrivacySettings()
491 ];
492
493 return apply_filters('fluent_community/privacy_settings_api_response', $data, $request->all());
494 }
495
496 public function updatePrivacySettings(Request $request)
497 {
498 $settings = $request->get('settings', []);
499 Utility::updatePrivacySettings($settings);
500
501 return [
502 'message' => __('Privacy settings have been saved successfully.', 'fluent-community')
503 ];
504 }
505
506 public function getColorConfig(Request $request)
507 {
508 $config = Utility::getColorConfig('edit');
509 $schemas = Utility::getColorSchemas();
510
511 $data = [
512 'config' => $config,
513 'schemas' => $schemas
514 ];
515
516 return apply_filters('fluent_community/color_config_api_response', $data, $request->all());
517 }
518
519 public function getCrmTaggingConfig(Request $request)
520 {
521 $defaults = [
522 'is_enabled' => 'no',
523 'tagging_maps' => [],
524 'linked_maps' => [],
525 'create_crm_contact' => 'yes',
526 'create_user' => 'no',
527 'send_welcome_email' => 'yes',
528 'has_space_tagging' => 'no',
529 'has_space_sync' => 'no',
530 'has_course_tagging' => 'no',
531 'has_course_sync' => 'no',
532 ];
533
534 $settings = get_option('_fcom_crm_tagging', []);
535 $settings = wp_parse_args($settings, $defaults);
536
537 $spaceGroups = SpaceGroup::with(['spaces' => function ($query) {
538 $query->where('type', 'community');
539 }])
540 ->orderBy('serial', 'ASC')
541 ->get();
542
543 $formattedSpaceGroups = [];
544 foreach ($spaceGroups as $spaceGroup) {
545 $spaces = $spaceGroup->spaces->map(function ($space) {
546 return [
547 'id' => $space->id,
548 'title' => $space->title,
549 'privacy' => $space->privacy,
550 'slug' => $space->slug,
551 'icon' => $space->getIconMark(),
552 'type' => $space->type,
553 ];
554 });
555
556 if (!$spaces) {
557 continue;
558 }
559
560 $formattedSpaceGroups[] = [
561 'id' => $spaceGroup->id,
562 'title' => $spaceGroup->title,
563 'spaces' => $spaces
564 ];
565 }
566
567 $otherSpaces = Space::whereNull('parent_id')
568 ->orderBy('title', 'ASC')
569 ->get();
570
571 if (!$otherSpaces->isEmpty()) {
572 $formattedSpaceGroups[] = [
573 'id' => 'other',
574 'title' => __('Other Spaces', 'fluent-community'),
575 'spaces' => $otherSpaces->map(function ($space) {
576 return [
577 'id' => $space->id,
578 'type' => $space->type,
579 'title' => $space->title,
580 'privacy' => $space->privacy,
581 'slug' => $space->slug,
582 'icon' => $space->getIconMark(),
583 ];
584 })
585 ];
586 }
587
588 $courses = Course::orderBy('title', 'ASC')->get();
589
590 if (!$courses->isEmpty()) {
591 $formattedSpaceGroups[] = [
592 'id' => 'courses',
593 'title' => __('All Courses', 'fluent-community'),
594 'spaces' => $courses->map(function ($course) {
595 return [
596 'id' => $course->id,
597 'title' => $course->title,
598 'privacy' => $course->privacy,
599 'slug' => $course->slug,
600 'icon' => $course->getIconMark(),
601 'type' => $course->type,
602 ];
603 })
604 ];
605 }
606
607 if (empty($settings['tagging_maps'])) {
608 $settings['tagging_maps'] = (object)[];
609 }
610
611 if (empty($settings['linked_maps'])) {
612 $settings['linked_maps'] = (object)[];
613 }
614
615 if (defined('FLUENTCRM')) {
616 $fluentCrmTags = \FluentCrm\App\Models\Tag::select(['id', 'title'])->orderBy('title', 'ASC')->get();
617 } else {
618 $fluentCrmTags = [];
619 }
620
621
622 $data = [
623 'settings' => $settings,
624 'spaceGroups' => $formattedSpaceGroups,
625 'crm_tags' => $fluentCrmTags,
626 'has_fluentcrm' => defined('FLUENTCRM')
627 ];
628 return apply_filters('fluent_community/crm_tagging_config_api_response', $data, $request->all());
629 }
630 }
631