ILIAS  release_8 Revision v8.24
class.ilLearningProgressAccess.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=0);
4/*
5 +-----------------------------------------------------------------------------+
6 | ILIAS open source |
7 +-----------------------------------------------------------------------------+
8 | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
9 | |
10 | This program is free software; you can redistribute it and/or |
11 | modify it under the terms of the GNU General Public License |
12 | as published by the Free Software Foundation; either version 2 |
13 | of the License, or (at your option) any later version. |
14 | |
15 | This program is distributed in the hope that it will be useful, |
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 | GNU General Public License for more details. |
19 | |
20 | You should have received a copy of the GNU General Public License |
21 | along with this program; if not, write to the Free Software |
22 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
23 +-----------------------------------------------------------------------------+
24*/
25
32{
36 public static function checkPermission(
37 string $a_permission,
38 int $a_ref_id,
39 ?int $a_user_id = null
40 ): bool {
41 global $DIC;
42
43 if ($a_user_id === null) {
44 $a_user_id = $DIC->user()->getId();
45 }
46
47 // position access
48 if ($a_permission === 'read_learning_progress') {
49 return $DIC->access()->checkRbacOrPositionPermissionAccess(
52 $a_ref_id
53 );
54 }
55 return $DIC->access()->checkAccessOfUser(
56 $a_user_id,
57 $a_permission,
58 '',
59 $a_ref_id
60 );
61 }
62
66 public static function checkAccess(
67 int $a_ref_id,
68 bool $a_allow_only_read = true
69 ): bool {
70 global $DIC;
71
72 if ($DIC->user()->getId() == ANONYMOUS_USER_ID) {
73 return false;
74 }
75
77 return false;
78 }
79
81 if ($DIC->access()->checkAccess(
82 'read_learning_progress',
83 '',
84 $a_ref_id
85 ) ||
86 (
87 $DIC->access()->checkRbacOrPositionPermissionAccess(
90 $a_ref_id
91 ) && $olp->isActive()
92 )
93 ) {
94 return true;
95 }
96
97 if (!$DIC->access()->checkAccess('read', '', $a_ref_id)) {
98 return false;
99 }
100 // edit learning progress is sufficient: #0029313
101 if ($DIC->access()->checkAccess(
102 'edit_learning_progress',
103 '',
104 $a_ref_id
105 )) {
106 return true;
107 }
108
110 return false;
111 }
112
113 if (!$olp->isActive()) {
114 return false;
115 }
116
117 if ($a_allow_only_read) {
118 return true;
119 }
120 return false;
121 }
122}
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: feed.php:28