ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilGlossaryAct.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
11 {
15  protected $glossary;
16 
20  protected $user;
21 
25  protected $access;
26 
32  protected function __construct(ilObjGlossary $a_glossary, ilObjUser $a_user)
33  {
34  global $DIC;
35 
36  $this->access = $DIC->access();
37  $this->glossary = $a_glossary;
38  $this->user = $a_user;
39  }
40 
47  public static function getInstance(ilObjGlossary $a_glossary, ilObjUser $a_user)
48  {
49  return new self($a_glossary, $a_user);
50  }
51 
58  public function copyTerm(ilObjGlossary $a_source_glossary, $a_term_id)
59  {
60  if (!$this->access->checkAccessOfUser($this->user->getId(), "write", "", $this->glossary->getRefId())) {
61  return;
62  }
63 
64  if (!$this->access->checkAccessOfUser($this->user->getId(), "read", "", $a_source_glossary->getRefId())) {
65  return;
66  }
67 
68  if (ilGlossaryTerm::_lookGlossaryID($a_term_id) != $a_source_glossary->getId()) {
69  return;
70  }
71 
72  ilGlossaryTerm::_copyTerm($a_term_id, $this->glossary->getId());
73  }
74 
75 
82  public function referenceTerms(ilObjGlossary $a_source_glossary, $a_term_ids)
83  {
84  if (!$this->access->checkAccessOfUser($this->user->getId(), "write", "", $this->glossary->getRefId())) {
85  return;
86  }
87 
88  if (!$this->access->checkAccessOfUser($this->user->getId(), "read", "", $a_source_glossary->getRefId())) {
89  return;
90  }
91 
92  $refs = new ilGlossaryTermReferences($this->glossary->getId());
93  foreach ($a_term_ids as $term_id) {
94  if (ilGlossaryTerm::_lookGlossaryID($term_id) != $a_source_glossary->getId()) {
95  continue;
96  }
97 
98  if ($this->glossary->getId() == $a_source_glossary->getId()) {
99  continue;
100  }
101  $refs->addTerm($term_id);
102  }
103  $refs->update();
104  }
105 }
__construct(ilObjGlossary $a_glossary, ilObjUser $a_user)
ilGlossaryAct constructor.
Class ilObjGlossary.
referenceTerms(ilObjGlossary $a_source_glossary, $a_term_ids)
Reference a term of another glossary in current glossary.
static getInstance(ilObjGlossary $a_glossary, ilObjUser $a_user)
Get instance.
user()
Definition: user.php:4
getId()
get object id public
global $DIC
Definition: goto.php:24
copyTerm(ilObjGlossary $a_source_glossary, $a_term_id)
Copy term.
Glossary actor class.
static _lookGlossaryID($term_id)
get glossary id form term id
static _copyTerm($a_term_id, $a_glossary_id)
Copy a term to a glossary.
getRefId()
get reference id public