ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilObjCourseReferenceAccess.php
Go to the documentation of this file.
1 <?php
2 
19 include_once("./Services/ContainerReference/classes/class.ilContainerReferenceAccess.php");
20 
32 {
36  public function _checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id = null): bool
37  {
38  global $DIC;
39 
40  switch ($permission) {
41  case 'visible':
42  case 'read':
43  case 'edit_learning_progress':
44  include_once './Modules/CourseReference/classes/class.ilObjCourseReference.php';
45  $target_ref_id = ilObjCourseReference::_lookupTargetRefId($obj_id);
46 
47  if (!$target_ref_id || !$DIC->access()->checkAccessOfUser($user_id, $permission, $cmd, $target_ref_id)) {
48  return false;
49  }
50  break;
51  }
52 
53  return true;
54  }
55 
59  public static function _preloadData(array $obj_ids, array $ref_ids): void
60  {
61  global $DIC;
62 
63  $repository = new ilUserCertificateRepository();
64  $coursePreload = new ilCertificateObjectsForUserPreloader($repository);
65  $coursePreload->preLoad($DIC->user()->getId(), array_map(function ($objId) {
67  }, $obj_ids));
68  }
69 
73  public static function _getCommands($a_ref_id = 0): array
74  {
75  global $DIC;
76 
77  if ($DIC->access()->checkAccess('write', '', $a_ref_id)) {
78  // Only local (reference specific commands)
79  $commands = array(
80  array("permission" => "visible", "cmd" => "", "lang_var" => "show","default" => true),
81  array("permission" => "write", "cmd" => "editReference", "lang_var" => "edit")
82  );
83  } else {
84  include_once('./Modules/Course/classes/class.ilObjCourseAccess.php');
85  $commands = ilObjCourseAccess::_getCommands();
86  }
87  return $commands;
88  }
89 }
$objId
Definition: xapitoken.php:57
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
_checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupTargetRefId(int $a_obj_id)
static _lookupTargetId(int $a_obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _preloadData(array $obj_ids, array $ref_ids)