# fluent-community/trunk/Modules/Course/CourseModule.php

FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS &amp; Online Courses, version trunk. 42 lines.

- Page: https://pluginprobe.com/plugins/fluent-community/trunk/code/Modules/Course/CourseModule.php
- Raw: https://pluginprobe.com/plugins/fluent-community/trunk/raw/Modules/Course/CourseModule.php
- Modified: 2025-10-01T13:51:42+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/fluent-community/trunk/code/Modules/Course/CourseModule.php#L10-L20`.

```php
<?php

namespace FluentCommunity\Modules\Course;


use FluentCommunity\App\Services\Helper;
use FluentCommunity\Modules\Course\Model\Course;

class CourseModule
{
    public function register($app)
    {
        /*
         * register the routes
         */
        $app->router->group(function ($router) {
            require_once __DIR__ . '/Http/course_api.php';
        });

        // Add to Menu
        add_filter('fluent_community/main_menu_items', [$this, 'maybeRemoveCourseMenu']);
    }

    public function maybeRemoveCourseMenu($items)
    {

        if(!isset($items['all_courses'])) {
            return $items;
        }

        $userModel = Helper::getCurrentUser();

        $isModerator = $userModel && $userModel->isCommunityModerator();

        if (!$isModerator && !Course::where('status', 'published')->exists()) {
            unset($items['all_courses']);
        }

        return $items;
    }
}

```
