ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilObjCourseReferenceAccess.php
Go to the documentation of this file.
1 <?php
2 
30 {
34  public function _checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id = null): bool
35  {
36  global $DIC;
37 
38  switch ($permission) {
39  case 'visible':
40  case 'read':
41  $target_ref_id = ilObjCourseReference::_lookupTargetRefId($obj_id);
42 
43  if (!$target_ref_id || !$DIC->access()->checkAccessOfUser($user_id, $permission, $cmd, $target_ref_id)) {
44  return false;
45  }
46  break;
47  }
48 
49  return true;
50  }
51 
55  public static function _preloadData(array $obj_ids, array $ref_ids): void
56  {
57  global $DIC;
58 
59  $repository = new ilUserCertificateRepository();
60  $coursePreload = new ilCertificateObjectsForUserPreloader($repository);
61  $coursePreload->preLoad($DIC->user()->getId(), array_map(function ($objId) {
63  }, $obj_ids));
64  }
65 
69  public static function _getCommands($a_ref_id = 0): array
70  {
71  global $DIC;
72 
73  if ($DIC->access()->checkAccess('write', '', $a_ref_id)) {
74  // Only local (reference specific commands)
75  $commands = array(
76  array("permission" => "visible", "cmd" => "", "lang_var" => "show","default" => true),
77  array("permission" => "write", "cmd" => "editReference", "lang_var" => "edit")
78  );
79  } else {
80  $commands = ilObjCourseAccess::_getCommands();
81  }
82  return $commands;
83  }
84 }
$objId
Definition: xapitoken.php:55
$ref_id
Definition: ltiauth.php:66
_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...
global $DIC
Definition: shib_login.php:25
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)