ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilObjCourseReferenceAccess.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
24include_once("./Services/ContainerReference/classes/class.ilContainerReferenceAccess.php");
25
37{
41 public function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
42 {
43 global $DIC;
44
45 switch ($a_permission) {
46 case 'visible':
47 case 'read':
48 include_once './Modules/CourseReference/classes/class.ilObjCourseReference.php';
49 $target_ref_id = ilObjCourseReference::_lookupTargetRefId($a_obj_id);
50
51 if (!$DIC->access()->checkAccessOfUser($a_user_id, $a_permission, $a_cmd, $target_ref_id)) {
52 return false;
53 }
54 break;
55 }
56
57 return true;
58 }
59
63 public static function _preloadData($a_obj_ids, $a_ref_ids)
64 {
65 global $DIC;
66
67 $repository = new ilUserCertificateRepository();
68 $coursePreload = new ilCertificateObjectsForUserPreloader($repository);
69 $coursePreload->preLoad($DIC->user()->getId(), array_map(function ($objId) {
70 return (int) \ilObjCourseReference::_lookupTargetId($objId);
71 }, $a_obj_ids));
72 }
73
77 public static function _getCommands($a_ref_id = 0)
78 {
79 global $DIC;
80
81 if ($DIC->access()->checkAccess('write', '', $a_ref_id)) {
82 // Only local (reference specific commands)
83 $commands = array(
84 array("permission" => "visible", "cmd" => "", "lang_var" => "show","default" => true),
85 array("permission" => "write", "cmd" => "editReference", "lang_var" => "edit")
86 );
87 } else {
88 include_once('./Modules/Course/classes/class.ilObjCourseAccess.php');
90 }
91 return $commands;
92 }
93}
An exception for terminatinating execution or to throw for unit testing.
static _lookupTargetId($a_obj_id)
lookup target id
static _lookupTargetRefId($a_obj_id)
Lookup target ref_id.
static _getCommands()
get commands
static _preloadData($a_obj_ids, $a_ref_ids)
Preload data.
_checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id="")
checks wether a user may invoke a command or not (this method is called by ilAccessHandler::checkAcce...
global $DIC
Definition: saml.php:7