← All changes
|
Modules/Integrations/FluentCart/Http/Controllers/PaywallController.php
+10
-3
2.7.7
→
2.10.0
View file →
| @@ -4,9 +4,9 @@ | ||
| 4 | 4 | |
| 5 | 5 | use FluentCart\App\Models\Product; |
| 6 | 6 | use FluentCart\App\Models\ProductDetail; |
| 7 | 7 | use FluentCart\App\Models\ProductVariation; |
| 8 | -use FluentCart\App\Services\Permission\PermissionManager; | |
| 8 | +use FluentCart\App\Services\Permission\PermissionManager as CartPermissionManager; | |
| 9 | 9 | use FluentCommunity\App\Models\BaseSpace; |
| 10 | 10 | use FluentCommunity\Framework\Support\Arr; |
| 11 | 11 | use FluentCommunity\App\Services\Helper; |
| 12 | 12 | use FluentCart\App\Helpers\Helper as CartHelper; |
| @@ -18,8 +18,15 @@ | ||
| 18 | 18 | public function getPaywalls(Request $request, $spaceId) |
| 19 | 19 | { |
| 20 | 20 | $space = BaseSpace::withoutGlobalScopes()->findOrFail($spaceId); |
| 21 | 21 | |
| 22 | + $userId = get_current_user_id(); | |
| 23 | + if ($space->privacy === 'secret' && !$space->getMembership($userId) && !$space->isAdmin($userId, true)) { | |
| 24 | + return $this->sendError([ | |
| 25 | + 'message' => __('The space could not be found', 'fluent-community') | |
| 26 | + ], 404); | |
| 27 | + } | |
| 28 | + | |
| 22 | 29 | $paywallIds = array_map('intval', $request->get('paywall_ids', [])); |
| 23 | 30 | $productIds = Arr::get($space->settings, 'cart_product_ids', []); |
| 24 | 31 | |
| 25 | 32 | $paywallQuery = Product::whereIn('ID', $productIds) |
| @@ -133,9 +140,9 @@ | ||
| 133 | 140 | } |
| 134 | 141 | |
| 135 | 142 | public function searchProduct(Request $request) |
| 136 | 143 | { |
| 137 | - $search = trim($request->getSafe('search')); | |
| 144 | + $search = trim((string) $request->getSafe('search', 'sanitize_text_field', '')); | |
| 138 | 145 | |
| 139 | 146 | $products = Product::query() |
| 140 | 147 | ->select('ID', 'post_title') |
| 141 | 148 | ->when($search !== '', function ($query) use ($search) { |
| @@ -165,9 +172,9 @@ | ||
| 165 | 172 | } |
| 166 | 173 | |
| 167 | 174 | public function createProduct(Request $request) |
| 168 | 175 | { |
| 169 | - if (!PermissionManager::hasPermission('products/create')) { | |
| 176 | + if (!CartPermissionManager::hasPermission('products/create')) { | |
| 170 | 177 | return $this->sendError([ |
| 171 | 178 | 'message' => __('You do not have permission to create products', 'fluent-community') |
| 172 | 179 | ], 422); |
| 173 | 180 | } |