ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilGlossaryTermPermission.php
Go to the documentation of this file.
1<?php
2
27{
28 protected ilObjUser $user;
31 protected array $glossary_id = array();
32 protected array $permission = array();
33 protected ilLogger $log;
34
35 private function __construct()
36 {
37 global $DIC;
38
39 $this->user = $DIC->user();
40 $this->access = $DIC->access();
41
42 $this->log = ilLoggerFactory::getLogger('glo');
43 }
44
45 public static function getInstance(): self
46 {
47 return new self();
48 }
49
50 public function checkPermission(
51 string $a_perm,
52 int $a_term_id
53 ): bool {
54 $this->log->debug("check permission " . $a_perm . " for " . $a_term_id . ".");
55 $glo_id = $this->getGlossaryIdForTerm($a_term_id);
56 if (!isset($this->permission[$a_perm][$glo_id])) {
57 $this->permission[$a_perm][$glo_id] = false;
58 $this->log->debug("...checking references");
59 foreach (ilObject::_getAllReferences($glo_id) as $ref_id) {
60 $this->log->debug("..." . $ref_id);
61 if ($this->permission[$a_perm][$glo_id] == true) {
62 continue;
63 }
64 if ($this->access->checkAccess($a_perm, "", $ref_id)) {
65 $this->permission[$a_perm][$glo_id] = true;
66 }
67 }
68 }
69 $this->log->debug("...return " . ((int) $this->permission[$a_perm][$glo_id]));
70 return $this->permission[$a_perm][$glo_id];
71 }
72
73 protected function getGlossaryIdForTerm(int $a_term_id): int
74 {
75 if (!isset($this->glossary_id[$a_term_id])) {
76 $this->glossary_id[$a_term_id] = ilGlossaryTerm::_lookGlossaryID($a_term_id);
77 }
78 return $this->glossary_id[$a_term_id];
79 }
80}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
checkPermission(string $a_perm, int $a_term_id)
static _lookGlossaryID(int $term_id)
get glossary id form term id
static getLogger(string $a_component_id)
Get component logger.
Component logger with individual log levels by component id.
User class.
static _getAllReferences(int $id)
get all reference ids for object ID
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
$ref_id
Definition: ltiauth.php:66
global $DIC
Definition: shib_login.php:26