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.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 1.1.10 1.1.11 All 75 releases
fluent-community / Modules / Course / CourseModule.php

CourseModule.php in FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses trunk, at Modules/Course/CourseModule.php

42 lines 924 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCommunity\Modules\Course;
4
5
6 use FluentCommunity\App\Services\Helper;
7 use FluentCommunity\Modules\Course\Model\Course;
8
9 class CourseModule
10 {
11 public function register($app)
12 {
13 /*
14 * register the routes
15 */
16 $app->router->group(function ($router) {
17 require_once __DIR__ . '/Http/course_api.php';
18 });
19
20 // Add to Menu
21 add_filter('fluent_community/main_menu_items', [$this, 'maybeRemoveCourseMenu']);
22 }
23
24 public function maybeRemoveCourseMenu($items)
25 {
26
27 if(!isset($items['all_courses'])) {
28 return $items;
29 }
30
31 $userModel = Helper::getCurrentUser();
32
33 $isModerator = $userModel && $userModel->isCommunityModerator();
34
35 if (!$isModerator && !Course::where('status', 'published')->exists()) {
36 unset($items['all_courses']);
37 }
38
39 return $items;
40 }
41 }
42