| @@ -2,10 +2,10 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace FluentCommunity\App\Http\Controllers; |
| 4 | 4 | |
| 5 | 5 | use FluentCommunity\App\Functions\Utility; |
| 6 | +use FluentCommunity\App\Hooks\Handlers\PortalHandler; | |
| 6 | 7 | use FluentCommunity\App\Models\BaseSpace; |
| 7 | -use FluentCommunity\App\Models\SpaceGroup; | |
| 8 | 8 | use FluentCommunity\App\Services\FeedsHelper; |
| 9 | 9 | use FluentCommunity\App\Services\LockscreenService; |
| 10 | 10 | use FluentCommunity\Framework\Http\Request\Request; |
| 11 | 11 | |
| @@ -10,8 +10,28 @@ | ||
| 10 | 10 | use FluentCommunity\Framework\Http\Request\Request; |
| 11 | 11 | |
| 12 | 12 | class OptionController extends Controller |
| 13 | 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 | + | |
| 14 | 34 | public function getSidebarMenuHtml(Request $request) |
| 15 | 35 | { |
| 16 | 36 | ob_start(); |
| 17 | 37 | do_action('fluent_community/portal_sidebar', 'ajax'); |
| @@ -32,12 +52,14 @@ | ||
| 32 | 52 | }) |
| 33 | 53 | ->get(); |
| 34 | 54 | } |
| 35 | 55 | |
| 56 | + BaseSpace::preloadMemberships($userSpaces, $userModel->ID); | |
| 57 | + | |
| 36 | 58 | $userSpaces->each(function ($space) use ($userModel) { |
| 37 | 59 | $space->permissions = $userModel->getSpacePermissions($space); |
| 38 | 60 | $space->membership = $space->getMembership($userModel->ID); |
| 39 | - $space->description_rendered = FeedsHelper::mdToHtml($space->description); | |
| 61 | + $space->description_rendered = wp_kses_post(FeedsHelper::mdToHtml($space->description)); | |
| 40 | 62 | if ($space->privacy == 'private' && !$space->membership) { |
| 41 | 63 | $space->lockscreen_config = LockscreenService::getLockscreenConfig($space); |
| 42 | 64 | } |
| 43 | 65 | $space->topics = Utility::getTopicsBySpaceId($space->id); |
| @@ -46,10 +68,11 @@ | ||
| 46 | 68 | } else { |
| 47 | 69 | $userSpaces = (object)[]; |
| 48 | 70 | } |
| 49 | 71 | |
| 50 | - return [ | |
| 72 | + $data = [ | |
| 51 | 73 | 'sidebar_html' => $html, |
| 52 | 74 | 'auth_spaces' => $userSpaces |
| 53 | 75 | ]; |
| 76 | + return apply_filters('fluent_community/sidebar_menu_html_api_response', $data, $request->all()); | |
| 54 | 77 | } |
| 55 | 78 | } |