ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilGlossaryTermPermission.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */
4
13{
17 protected $user;
18
22 protected $access;
23
27 protected $glossary_id = array();
28
32 protected $permission = array();
33
37 protected $log;
38
42 private function __construct()
43 {
44 global $DIC;
45
46 $this->user = $DIC->user();
47 $this->access = $DIC->access();
48
49 $this->log = ilLoggerFactory::getLogger('glo');
50 }
51
56 public static function getInstance()
57 {
58 return new self();
59 }
60
68 public function checkPermission($a_perm, $a_term_id)
69 {
70 $this->log->debug("check permission " . $a_perm . " for " . $a_term_id . ".");
71 $glo_id = $this->getGlossaryIdForTerm($a_term_id);
72 if (!isset($this->permission[$a_perm][$glo_id])) {
73 $this->permission[$a_perm][$glo_id] = false;
74 $this->log->debug("...checking references");
75 foreach (ilObject::_getAllReferences($glo_id) as $ref_id) {
76 $this->log->debug("..." . $ref_id);
77 if ($this->permission[$a_perm][$glo_id] == true) {
78 continue;
79 }
80 if ($this->access->checkAccess($a_perm, "", $ref_id)) {
81 $this->permission[$a_perm][$glo_id] = true;
82 }
83 }
84 }
85 $this->log->debug("...return " . ((int) $this->permission[$a_perm][$glo_id]));
86 return $this->permission[$a_perm][$glo_id];
87 }
88
95 protected function getGlossaryIdForTerm($a_term_id)
96 {
97 if (!isset($this->glossary_id[$a_term_id])) {
98 include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
99 $this->glossary_id[$a_term_id] = ilGlossaryTerm::_lookGlossaryID($a_term_id);
100 }
101 return $this->glossary_id[$a_term_id];
102 }
103}
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
Permission checker for terms.
__construct()
ilGlossaryTermPermission constructor.
getGlossaryIdForTerm($a_term_id)
Get glossary for term.
checkPermission($a_perm, $a_term_id)
Check permission.
static _lookGlossaryID($term_id)
get glossary id form term id
static getLogger($a_component_id)
Get component logger.
static _getAllReferences($a_id)
get all reference ids of object
global $DIC
Definition: saml.php:7