ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilObjStudyProgrammeReferenceAccess.php
Go to the documentation of this file.
1<?php
2
4{
22 public function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
23 {
24 global $DIC;
25 $ilAccess = $DIC['ilAccess'];
26 switch ($a_permission) {
27 case 'visible':
28 case 'read':
29 $target_ref_id = ilContainerReference::_lookupTargetRefId($a_obj_id);
30 if (!$ilAccess->checkAccessOfUser($a_user_id, $a_permission, $a_cmd, $target_ref_id)) {
31 return false;
32 }
33 break;
34 case "delete":
35
36 if (!$ilAccess->checkAccessOfUser($a_user_id, $a_permission, $a_cmd, $a_ref_id)) {
37 return false;
38 }
39 $tree = $DIC['tree'];
40 $assignment_ids = [];
41 $target_ref_id = ilContainerReference::_lookupTargetRefId($a_obj_id);
42 $prg = ilObjStudyProgramme::getInstanceByRefId($target_ref_id);
43 $target_id = $prg->getId();
44 $progress_db = ilStudyProgrammeDIC::dic()['ilStudyProgrammeUserProgressDB'];
45 $parent = $tree->getParentNodeData($a_ref_id);
46 if ($parent["type"] === "prg" && !$parent["deleted"]) {
47 $parent = ilObjStudyProgramme::getInstanceByRefId($parent["ref_id"]);
48 foreach ($parent->getProgresses() as $parent_progress
49 ) {
50 $progress = $progress_db->getByPrgIdAndAssignmentId(
52 $parent_progress->getAssignmentId()
53 );
54
55 if (!$progress) {
56 continue;
57 }
58 if ($progress->isRelevant()) {
59 return false;
60 }
61 }
62 }
63
64 break;
65 }
66
67 return true;
68 }
69
70 public static function _getCommands($a_ref_id = null)
71 {
72 global $DIC;
73 $ilAccess = $DIC->access();
74 $prgr_obj_id = ilObject::_lookupObjId($a_ref_id);
75 $target_ref_id = ilContainerReference::_lookupTargetRefId($prgr_obj_id);
76
77 $commands = [];
78
79 if ($ilAccess->checkAccess('write', '', $a_ref_id)) {
80 $commands[] = ["permission" => "write", "cmd" => "editReference", "lang_var" => "edit"];
81 }
82 if ($ilAccess->checkAccess('read', '', $target_ref_id)) {
83 $commands[] = array('permission' => 'visible', 'cmd' => 'view', 'lang_var' => 'show', 'default' => true);
84 }
85
86 return $commands;
87 }
88}
An exception for terminatinating execution or to throw for unit testing.
static _lookupTargetRefId($a_obj_id)
Lookup target ref_id.
_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...
static getInstanceByRefId($a_ref_id)
static _lookupObjId($a_id)
global $DIC
Definition: goto.php:24
$target_id
Definition: goto.php:51