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/Controllers/SpaceController.php +54 -0 2.10.02.11.0 View file →
@@ -8,8 +8,9 @@
8 8 use FluentCommunity\App\Models\SpaceGroup;
9 9 use FluentCommunity\App\Models\User;
10 10 use FluentCommunity\App\Services\CustomSanitizer;
11 11 use FluentCommunity\App\Services\Helper;
12 +use FluentCommunity\App\Services\SpaceMenuService;
12 13 use FluentCommunity\App\Functions\Utility;
13 14 use FluentCommunity\App\Services\ProfileHelper;
14 15 use FluentCommunity\Framework\Http\Request\Request;
15 16 use FluentCommunity\App\Models\Comment;
@@ -791,8 +792,61 @@
791 792
792 793 return [
793 794 'message' => __('Links have been updated for the space', 'fluent-community'),
794 795 'links' => $links
796 + ];
797 + }
798 +
799 + public function getPrimaryMenu(Request $request, $slug)
800 + {
801 + $space = Space::where('slug', $slug)->first();
802 +
803 + if (!$space) {
804 + return $this->sendError([
805 + 'message' => __('Space not found', 'fluent-community'),
806 + ]);
807 + }
808 +
809 + // Lighter than formatSpaceData(), but listeners like fcom-chat need membership too.
810 + $user = $this->getUser();
811 + $space->permissions = $space->getUserPermissions($user);
812 + $space->membership = $space->getMembership($user ? $user->ID : null);
813 +
814 + return [
815 + 'menu_items' => SpaceMenuService::getManagerItems($space),
816 + ];
817 + }
818 +
819 + public function updatePrimaryMenu(Request $request, $slug)
820 + {
821 + $space = Space::where('slug', $slug)->first();
822 +
823 + if (!$space) {
824 + return $this->sendError([
825 + 'message' => __('Space not found', 'fluent-community'),
826 + ]);
827 + }
828 +
829 + $incoming = $request->get('menu_items', []);
830 +
831 + if (!is_array($incoming)) {
832 + return $this->sendError([
833 + 'message' => __('Menu items must be a list.', 'fluent-community'),
834 + ], 422);
835 + }
836 +
837 + $menuItems = CustomSanitizer::sanitizeSpaceMenuItems($incoming);
838 +
839 + SpaceMenuService::storeMenu($space, $menuItems);
840 +
841 + // No re-fetch needed — unlike formatSpaceData(), this doesn't make $space unsaveable.
842 + $user = $this->getUser();
843 + $space->permissions = $space->getUserPermissions($user);
844 + $space->membership = $space->getMembership($user ? $user->ID : null);
845 +
846 + return [
847 + 'message' => __('Menu has been updated for the space', 'fluent-community'),
848 + 'menu_items' => SpaceMenuService::getManagerItems($space),
795 849 ];
796 850 }
797 851
798 852 public function getSpaceGroups(Request $request)