PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / 2.10.0
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses v2.10.0
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
← All changes | Modules/Course/Http/Policies/CourseAdminPolicy.php +34 -3 1.0.952.10.0 View file →
@@ -2,10 +2,11 @@
2 2
3 3 namespace FluentCommunity\Modules\Course\Http\Policies;
4 4
5 5 use FluentCommunity\App\Http\Policies\BasePolicy;
6 +use FluentCommunity\Framework\Http\Request\Request;
7 +use FluentCommunity\Modules\Course\Model\Course;
6 8 use FluentCommunity\App\Services\Helper;
7 -use FluentCommunity\Framework\Http\Request\Request;
8 9
9 10 class CourseAdminPolicy extends BasePolicy
10 11 {
11 12 /**
@@ -14,11 +15,41 @@
14 15 * @return Boolean
15 16 */
16 17 public function verifyRequest(Request $request)
17 18 {
18 - if (Helper::isSiteAdmin()) {
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()) {
19 39 return true;
20 40 }
21 41
22 - return false;
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();
23 54 }
24 55 }