PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / 2.11.0
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses v2.11.0
2.11.0 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 All 78 releases
← All changes | app/Http/Policies/SpacePolicy.php +38 -5 2.7.02.11.0 View file →
@@ -3,8 +3,9 @@
3 3 namespace FluentCommunity\App\Http\Policies;
4 4
5 5 use FluentCommunity\App\Models\User;
6 6 use FluentCommunity\App\Models\Space;
7 +use FluentCommunity\App\Models\BaseSpace;
7 8 use FluentCommunity\App\Services\Helper;
8 9 use FluentCommunity\Framework\Http\Request\Request;
9 10
10 11 class SpacePolicy extends BasePolicy
@@ -35,14 +36,18 @@
35 36 }
36 37
37 38 public function join(Request $request)
38 39 {
39 - return !!get_current_user_id();
40 + $xProfile = Helper::getCurrentProfile(true);
41 +
42 + return $xProfile && $xProfile->status == 'active';
40 43 }
41 44
42 45 public function leave(Request $request)
43 46 {
44 - return !!get_current_user_id();
47 + $xProfile = Helper::getCurrentProfile(true);
48 +
49 + return $xProfile && $xProfile->status == 'active';
45 50 }
46 51
47 52 public function create(Request $request)
48 53 {
@@ -48,8 +53,13 @@
48 53 {
49 54 return $this->canManageCommunity($request, null);
50 55 }
51 56
57 + public function searchProduct(Request $request)
58 + {
59 + return $this->canManageCommunity($request);
60 + }
61 +
52 62 public function patchBySlug(Request $request, $slug)
53 63 {
54 64 return $this->canManageCommunity($request, Space::where('slug', $slug)->first());
55 65 }
@@ -63,8 +73,21 @@
63 73 {
64 74 return $this->canManageCommunity($request, Space::where('slug', $slug)->first());
65 75 }
66 76
77 + /**
78 + * The manager listing exposes disabled and hidden rows, so it is not a plain portal read.
79 + */
80 + public function getPrimaryMenu(Request $request, $slug)
81 + {
82 + return $this->canManageCommunity($request, Space::where('slug', $slug)->first());
83 + }
84 +
85 + public function updatePrimaryMenu(Request $request, $slug)
86 + {
87 + return $this->canManageCommunity($request, Space::where('slug', $slug)->first());
88 + }
89 +
67 90 public function deleteBySlug(Request $request, $slug)
68 91 {
69 92 return $this->canManageCommunity($request, Space::where('slug', $slug)->first());
70 93 }
@@ -94,9 +117,9 @@
94 117
95 118 public function getSpaceGroups(Request $request)
96 119 {
97 120 if ($request->get('options_only')) {
98 - return true;
121 + return !!Helper::canAccessPortal(get_current_user_id());
99 122 }
100 123
101 124 return $this->canManageSpace($request, null);
102 125 }
@@ -135,8 +158,18 @@
135 158 {
136 159 return $this->canManageSpace($request, Space::where('slug', $spaceSlug)->first());
137 160 }
138 161
162 + public function addPaywall(Request $request, $spaceId)
163 + {
164 + return $this->canManageCommunity($request, BaseSpace::withoutGlobalScopes()->find((int) $spaceId));
165 + }
166 +
167 + public function removePaywall(Request $request, $spaceId)
168 + {
169 + return $this->canManageCommunity($request, BaseSpace::withoutGlobalScopes()->find((int) $spaceId));
170 + }
171 +
139 172 protected function canManageCommunity(Request $request, $space = false)
140 173 {
141 174 $user = User::find(get_current_user_id());
142 175
@@ -148,9 +181,9 @@
148 181 return true;
149 182 }
150 183
151 184 if ($space === false) {
152 - $space = Space::find($request->get('space_id'));
185 + $space = Space::find((int) $request->get('space_id'));
153 186 }
154 187
155 188 return $space && $user->getSpaceRole($space) === 'admin';
156 189 }
@@ -167,9 +200,9 @@
167 200 return true;
168 201 }
169 202
170 203 if ($space === false) {
171 - $space = Space::find($request->get('space_id'));
204 + $space = Space::find((int) $request->get('space_id'));
172 205 }
173 206
174 207 return $space && $user->getSpaceRole($space) === 'admin';
175 208 }