ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilLearningProgressAccess.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
34 {
38  public static function checkPermission($a_permission, $a_ref_id , $a_user_id = null)
39  {
40  if(is_null($a_user_id))
41  {
42  $a_user_id = $GLOBALS['ilUser']->getId();
43  }
44 
45  // workaround for missing permission definitions in file object
46  $type = ilObject::_lookupType($a_ref_id, true);
47  if(
48  $type == 'file' && (
49  $a_permission == 'read_learning_progress' ||
50  $a_permission == 'edit_learning_progress'
51  )
52  ) {
53  return $GLOBALS['ilAccess']->checkAccessOfUser($a_user_id, 'write','', $a_ref_id);
54  }
55  return $GLOBALS['ilAccess']->checkAccessOfUser($a_user_id, $a_permission,'', $a_ref_id);
56  }
57 
58 
67  public static function checkAccess($a_ref_id, $a_allow_only_read = true)
68  {
69  global $ilUser,$ilAccess;
70 
71  if($ilUser->getId() == ANONYMOUS_USER_ID)
72  {
73  return false;
74  }
75 
76  include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
78  {
79  return false;
80  }
81 
82  // workaround for missing file object permissions
83  if(ilObject::_lookupType($a_ref_id, true) == 'file' &&
84  $ilAccess->checkAccess('write','',$a_ref_id)
85  )
86  {
87  return true;
88  }
89 
90  if($ilAccess->checkAccess('read_learning_progress','',$a_ref_id) ||
91  $ilAccess->checkAccess('edit_learning_progress','',$a_ref_id))
92  {
93  return true;
94  }
95 
97  {
98  return false;
99  }
100 
101  include_once './Services/Object/classes/class.ilObjectLP.php';
103  if(!$olp->isActive())
104  {
105  return false;
106  }
107 
108  if(!$ilAccess->checkAccess('read','',$a_ref_id))
109  {
110  return false;
111  }
112 
113  if($a_allow_only_read)
114  {
115  return true;
116  }
117 
118  return false;
119  }
120 }
121 ?>
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
static checkPermission($a_permission, $a_ref_id, $a_user_id=null)
wrapper for rbac access checks
Learning progress access checks.
static checkAccess($a_ref_id, $a_allow_only_read=true)
check access to learning progress
static _enabledLearningProgress()
check wether learing progress is enabled or not
static _lookupObjId($a_id)
$ilUser
Definition: imgupload.php:18
static _lookupType($a_id, $a_reference=false)
lookup object type
static getInstance($a_obj_id)