ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLearningProgressAccess.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=0);
26{
30 public static function checkPermission(
31 string $a_permission,
32 int $a_ref_id,
33 ?int $a_user_id = null
34 ): bool {
35 global $DIC;
36
37 if ($a_user_id === null) {
38 $a_user_id = $DIC->user()->getId();
39 }
40
41 // position access
42 if ($a_permission === 'read_learning_progress') {
43 return $DIC->access()->checkRbacOrPositionPermissionAccess(
46 $a_ref_id
47 );
48 }
49 return $DIC->access()->checkAccessOfUser(
50 $a_user_id,
51 $a_permission,
52 '',
53 $a_ref_id
54 );
55 }
56
60 public static function checkAccess(
61 int $a_ref_id,
62 bool $a_allow_only_read = true
63 ): bool {
64 global $DIC;
65
66 if ($DIC->user()->getId() == ANONYMOUS_USER_ID) {
67 return false;
68 }
69
71 return false;
72 }
73
75 if (
76 $olp->isActive() && (
77 $DIC->access()->checkAccess(
78 'read_learning_progress',
79 '',
80 $a_ref_id
81 ) ||
82 $DIC->access()->checkRbacOrPositionPermissionAccess(
85 $a_ref_id
86 )
87 )
88 ) {
89 return true;
90 }
91
92 if (!$DIC->access()->checkAccess('read', '', $a_ref_id)) {
93 return false;
94 }
95 // edit learning progress is sufficient: #0029313
96 if ($DIC->access()->checkAccess(
97 'edit_learning_progress',
98 '',
99 $a_ref_id
100 )) {
101 return true;
102 }
103
105 return false;
106 }
107
108 if (!$olp->isActive()) {
109 return false;
110 }
111
112 if ($a_allow_only_read) {
113 return true;
114 }
115 return false;
116 }
117}
Learning progress access checks.
static checkPermission(string $a_permission, int $a_ref_id, ?int $a_user_id=null)
wrapper for rbac access checks
static checkAccess(int $a_ref_id, bool $a_allow_only_read=true)
check access to learning progress
static getInstance(int $obj_id)
static _lookupObjId(int $ref_id)
const ANONYMOUS_USER_ID
Definition: constants.php:27
global $DIC
Definition: shib_login.php:26