ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilObjStudyProgrammeReferenceAccess.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 {
40  public function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = ""): bool
41  {
42  global $DIC;
43  $ilAccess = $DIC['ilAccess'];
44  switch ($a_permission) {
45  case 'visible':
46  case 'read':
47  $target_ref_id = ilContainerReference::_lookupTargetRefId($a_obj_id);
48  if (!$target_ref_id || !$ilAccess->checkAccessOfUser($a_user_id, $a_permission, $a_cmd, $target_ref_id)) {
49  return false;
50  }
51  break;
52  case "delete":
53 
54  if (!$ilAccess->checkAccessOfUser($a_user_id, $a_permission, $a_cmd, $a_ref_id)) {
55  return false;
56  }
57  $tree = $DIC['tree'];
58  $target_ref_id = ilContainerReference::_lookupTargetRefId($a_obj_id);
59  $prg = ilObjStudyProgramme::getInstanceByRefId($target_ref_id);
60  $target_id = $prg->getId();
61  $parent = $tree->getParentNodeData($a_ref_id);
62  if ($parent["type"] === "prg" && !$parent["deleted"]) {
63  $parent = ilObjStudyProgramme::getInstanceByRefId($parent["ref_id"]);
64  if (! $parent->canBeRemoved()) {
65  return false;
66  }
67  }
68 
69  break;
70  }
71 
72  return true;
73  }
74 
75  public static function _getCommands(int $a_ref_id = null): array
76  {
77  global $DIC;
78  $ilAccess = $DIC->access();
79  $prgr_obj_id = ilObject::_lookupObjId($a_ref_id);
80  $target_ref_id = ilContainerReference::_lookupTargetRefId($prgr_obj_id);
81 
82  $commands = [];
83 
84  if ($ilAccess->checkAccess('write', '', $a_ref_id)) {
85  $commands[] = ["permission" => "write", "cmd" => "editReference", "lang_var" => "edit"];
86  }
87  if ($ilAccess->checkAccess('read', '', $target_ref_id)) {
88  $commands[] = array('permission' => 'visible', 'cmd' => 'view', 'lang_var' => 'show', 'default' => true);
89  }
90 
91  return $commands;
92  }
93 }
_checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id="")
Checks whether a user may invoke a command or not (this method is called by ilAccessHandler::checkAcc...
$target_id
Definition: goto.php:52
static _lookupObjId(int $ref_id)
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupTargetRefId(int $a_obj_id)