PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / trunk
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses vtrunk
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 / OptionController.php

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

79 lines 2.7 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\Hooks\Handlers\PortalHandler;
7 use FluentCommunity\App\Models\BaseSpace;
8 use FluentCommunity\App\Services\FeedsHelper;
9 use FluentCommunity\App\Services\LockscreenService;
10 use FluentCommunity\Framework\Http\Request\Request;
11
12 class OptionController extends Controller
13 {
14
15 public function getAppVars()
16 {
17 $appVars = (new PortalHandler())->appVars();
18 unset($appVars['rest']);
19
20 $data = [
21 'appVars' => $appVars,
22 'menu_links_groups' => Utility::getPortalSidebarData('sidebar')
23 ];
24
25 return apply_filters('fluent_community/app_vars_api_response', $data, $this->request->all());
26 }
27
28 public function getMenuItems()
29 {
30 $data = Utility::getPortalSidebarData('sidebar');
31 return apply_filters('fluent_community/menu_items_api_response', $data, $this->request->all());
32 }
33
34 public function getSidebarMenuHtml(Request $request)
35 {
36 ob_start();
37 do_action('fluent_community/portal_sidebar', 'ajax');
38
39 $html = ob_get_clean();
40
41 $userModel = $this->getUser();
42 $userSpaces = [];
43 if ($userModel) {
44 if ($userModel->isCommunityModerator()) {
45 $userSpaces = BaseSpace::orderBy('title', 'ASC')
46 ->get();
47 } else {
48 $userSpaces = BaseSpace::orderBy('title', 'ASC')
49 ->whereHas('members', function ($q) {
50 $q->where('user_id', get_current_user_id())
51 ->where('status', 'active');
52 })
53 ->get();
54 }
55
56 BaseSpace::preloadMemberships($userSpaces, $userModel->ID);
57
58 $userSpaces->each(function ($space) use ($userModel) {
59 $space->permissions = $userModel->getSpacePermissions($space);
60 $space->membership = $space->getMembership($userModel->ID);
61 $space->description_rendered = wp_kses_post(FeedsHelper::mdToHtml($space->description));
62 if ($space->privacy == 'private' && !$space->membership) {
63 $space->lockscreen_config = LockscreenService::getLockscreenConfig($space);
64 }
65 $space->topics = Utility::getTopicsBySpaceId($space->id);
66 });
67 $userSpaces = $userSpaces->keyBy('slug');
68 } else {
69 $userSpaces = (object)[];
70 }
71
72 $data = [
73 'sidebar_html' => $html,
74 'auth_spaces' => $userSpaces
75 ];
76 return apply_filters('fluent_community/sidebar_menu_html_api_response', $data, $request->all());
77 }
78 }
79