PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / 2.10.01
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses v2.10.01
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 / Modules / Course / Http / Policies / CourseAdminPolicy.php

CourseAdminPolicy.php in FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses 2.10.01, at Modules/Course/Http/Policies/CourseAdminPolicy.php

56 lines 1.3 KB
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\Http\Policies;
4
5 use FluentCommunity\App\Http\Policies\BasePolicy;
6 use FluentCommunity\Framework\Http\Request\Request;
7 use FluentCommunity\Modules\Course\Model\Course;
8 use FluentCommunity\App\Services\Helper;
9
10 class CourseAdminPolicy extends BasePolicy
11 {
12 /**
13 * Check user permission for any method
14 * @param \FluentCommunity\Framework\Http\Request\Request $request
15 * @return Boolean
16 */
17 public function verifyRequest(Request $request)
18 {
19 $user = Helper::getCurrentUser(true);
20
21 if (!$user) {
22 return false;
23 }
24
25 if (!$user->hasCourseCreatorAccess()) {
26 return false;
27 }
28
29 if ($this->getRouteParam($request, 'course_id')) {
30 return $this->canManageCourse($request);
31 }
32
33 return true;
34 }
35
36 protected function canManageCourse(Request $request)
37 {
38 if (Helper::isSuperAdmin()) {
39 return true;
40 }
41
42 $user = Helper::getCurrentUser(true);
43
44 if ($courseId = $this->getRouteParam($request, 'course_id')) {
45 $course = Course::find($courseId);
46 if (!$course) {
47 return false;
48 }
49
50 return $course->isCourseAdmin($user);
51 }
52
53 return $user->hasSpaceManageAccess();
54 }
55 }
56