ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 
30  $target_ref_id = ilContainerReference::_lookupTargetRefId($a_obj_id);
31  if (!$ilAccess->checkAccessOfUser($a_user_id, $a_permission, $a_cmd, $target_ref_id)) {
32  return false;
33  }
34  break;
35  case "delete":
36 
37  if (!$ilAccess->checkAccessOfUser($a_user_id, $a_permission, $a_cmd, $a_ref_id)) {
38  return false;
39  }
40  $tree = $DIC['tree'];
41  $assignment_ids = [];
42  $target_ref_id = ilContainerReference::_lookupTargetRefId($a_obj_id);
43  $prg = ilObjStudyProgramme::getInstanceByRefId($target_ref_id);
44  $target_id = $prg->getId();
45  $progress_db = ilStudyProgrammeDIC::dic()['ilStudyProgrammeUserProgressDB'];
46  $parent = $tree->getParentNodeData($a_ref_id);
47  if ($parent["type"] === "prg" && !$parent["deleted"]) {
48  $parent = ilObjStudyProgramme::getInstanceByRefId($parent["ref_id"]);
49  foreach ($parent->getProgresses() as $parent_progress
50  ) {
51  try {
52  $progress =
53  $progress_db->getInstanceForAssignment(
54  $target_id,
55  $parent_progress->getAssignmentId()
56  );
58  continue;
59  }
60  if ($progress->isRelevant()) {
61  return false;
62  }
63  }
64  }
65 
66  break;
67  }
68 
69  return true;
70  }
71 
72  public static function _getCommands($a_ref_id = null)
73  {
74  global $DIC;
75 
76  $ilAccess = $DIC->access();
77 
78  if ($ilAccess->checkAccess('write', '', $a_ref_id)) {
79  // Only local (reference specific commands)
80  $commands = [
81  ["permission" => "read", "cmd" => "view", "lang_var" => "show", "default" => true]
82  ,["permission" => "write", "cmd" => "view", "lang_var" => "edit_content"]
83  ,["permission" => "write", "cmd" => "edit", "lang_var" => "settings"]
84  ,["permission" => "write", "cmd" => "editReference", "lang_var" => "edit"]
85  ];
86  } else {
88  }
89  return $commands;
90  }
91 }
_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...
$target_id
Definition: goto.php:49
Exception is thrown when a progress for some programme node and assignment is missing.
static getInstanceByRefId($a_ref_id)
$DIC
Definition: xapitoken.php:46
static _lookupTargetRefId($a_obj_id)
Lookup target ref_id.