PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / 1.0.96
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses v1.0.96
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 / Services / LockscreenService.php

LockscreenService.php in FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses 1.0.96, at app/Services/LockscreenService.php

129 lines 4.4 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\Services;
4
5 use FluentCommunity\App\Models\BaseSpace;
6 use FluentCommunity\Framework\Support\Arr;
7
8 class LockscreenService
9 {
10 public static function getLockscreenSettings(BaseSpace $space)
11 {
12 $defaultSettings = [
13 [
14 'hidden' => false,
15 'type' => 'image',
16 'label' => 'Banner',
17 'name' => 'banner',
18 'heading' => 'Banner Heading',
19 'heading_color' => '#FFFFFF',
20 'description' => 'Banner Description',
21 'text_color' => '#FFFFFF',
22 'button_text' => 'Buy Now',
23 'button_link' => '',
24 'button_color' => '#2B2E33',
25 'button_text_color' => '#FFFFFF',
26 'background_image' => '',
27 'overlay_color' => '#798398'
28 ],
29 [
30 'hidden' => false,
31 'type' => 'block',
32 'label' => 'Description',
33 'name' => 'description',
34 'content' => 'Description Test'
35 ]
36 ];
37
38 if ($space->isCourseSpace()) {
39 $defaultSettings[] = [
40 'hidden' => true,
41 'type' => 'lesson',
42 'label' => 'Lessons',
43 'name' => 'lesson'
44 ];
45 }
46
47 $defaultSettings[] = [
48 'hidden' => false,
49 'type' => 'image',
50 'label' => 'Call to action',
51 'name' => 'action',
52 'heading' => 'Call to Action Heading',
53 'heading_color' => '#FFFFFF',
54 'description' => 'Call to Action Description',
55 'text_color' => '#FFFFFF',
56 'button_text' => 'Buy Now',
57 'button_link' => '',
58 'button_color' => '#2B2E33',
59 'button_text_color' => '#FFFFFF',
60 'background_image' => '',
61 'overlay_color' => '#798398'
62 ];
63
64 $settings = $space->getCustomMeta('lockscreen_settings', $defaultSettings);
65
66 foreach ($settings as &$setting) {
67 if ($setting['type'] === 'block' && !empty($setting['content'])) {
68 $setting['content'] = do_blocks($setting['content']);
69 }
70 }
71
72 return $settings;
73 }
74
75 public static function formatLockscreenFields($settingFields)
76 {
77 $textFields = ['type', 'name', 'label', 'heading', 'description', 'button_text', 'el_icon'];
78 $colorFields = ['heading_color', 'text_color', 'button_color', 'button_text_color', 'overlay_color'];
79 $urlFields = ['button_link', 'background_image'];
80
81 $formattedFields = [];
82
83 foreach ($settingFields as $value) {
84 $textValues = array_map('sanitize_text_field', Arr::only($value, $textFields));
85 $colorValues = array_map('sanitize_hex_color', Arr::only($value, $colorFields));
86 $urlValues = array_map('sanitize_url', Arr::only($value, $urlFields));
87
88 $formattedField = array_merge($textValues, $colorValues, $urlValues);
89
90 $formattedField['hidden'] = Arr::isTrue($value, 'hidden');
91
92 if ($value['type'] == 'block') {
93 $formattedField['content'] = wp_kses_post(Arr::get($value, 'content'));
94 }
95
96 $formattedFields[] = $formattedField;
97 }
98
99 return $formattedFields;
100 }
101
102 public static function getLockscreenConfig(BaseSpace $space, $membership = null)
103 {
104 if ($space->privacy != 'private') {
105 return null;
106 }
107
108 if($membership) {
109 if($membership->pivot->status) {
110 if($membership->pivot->status == 'pending') {
111 return [
112 'is_pending' => true
113 ];
114 }
115 return null;
116 }
117 }
118
119 $showCustom = Arr::get($space->settings, 'custom_lock_screen', 'no') === 'yes';
120 $canSendRequest = Arr::get($space->settings, 'can_request_join', 'no') === 'yes';
121
122 return [
123 'showCustom' => $showCustom,
124 'canSendRequest' => $canSendRequest,
125 'lockScreen' => $showCustom ? self::getLockscreenSettings($space) : null
126 ];
127 }
128 }
129