ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  static public 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  {
74  $this->permission[$a_perm][$glo_id] = false;
75  $this->log->debug("...checking references");
76  foreach (ilObject::_getAllReferences($glo_id) as $ref_id)
77  {
78  $this->log->debug("...".$ref_id);
79  if ($this->permission[$a_perm][$glo_id] == true)
80  {
81  continue;
82  }
83  if ($this->access->checkAccess($a_perm, "", $ref_id))
84  {
85  $this->permission[$a_perm][$glo_id] = true;
86  }
87  }
88  }
89  $this->log->debug("...return ".((int) $this->permission[$a_perm][$glo_id]));
90  return $this->permission[$a_perm][$glo_id];
91  }
92 
99  protected function getGlossaryIdForTerm($a_term_id)
100  {
101  if (!isset($this->glossary_id[$a_term_id]))
102  {
103  include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
104  $this->glossary_id[$a_term_id] = ilGlossaryTerm::_lookGlossaryID($a_term_id);
105  }
106  return $this->glossary_id[$a_term_id];
107  }
108 
109 
110 }
111 
112 ?>
user()
Definition: user.php:4
static _getAllReferences($a_id)
get all reference ids of object
checkPermission($a_perm, $a_term_id)
Check permission.
__construct()
ilGlossaryTermPermission constructor.
Create styles array
The data for the language used.
Permission checker for terms.
static _lookGlossaryID($term_id)
get glossary id form term id
$ref_id
Definition: sahs_server.php:39
global $DIC
static getLogger($a_component_id)
Get component logger.
getGlossaryIdForTerm($a_term_id)
Get glossary for term.