ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilGlossaryAct.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 $glossary;
18 
22  protected $user;
23 
27  protected $access;
28 
34  protected function __construct(ilObjGlossary $a_glossary, ilObjUser $a_user)
35  {
36  global $DIC;
37 
38  $this->access = $DIC->access();
39  $this->glossary = $a_glossary;
40  $this->user = $a_user;
41  }
42 
49  public static function getInstance(ilObjGlossary $a_glossary, ilObjUser $a_user)
50  {
51  return new self($a_glossary, $a_user);
52  }
53 
60  public function copyTerm(ilObjGlossary $a_source_glossary, $a_term_id)
61  {
62  if (!$this->access->checkAccessOfUser($this->user->getId(), "write", "", $this->glossary->getRefId())) {
63  return;
64  }
65 
66  if (!$this->access->checkAccessOfUser($this->user->getId(), "read", "", $a_source_glossary->getRefId())) {
67  return;
68  }
69 
70  include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
71  if (ilGlossaryTerm::_lookGlossaryID($a_term_id) != $a_source_glossary->getId()) {
72  return;
73  }
74 
75  ilGlossaryTerm::_copyTerm($a_term_id, $this->glossary->getId());
76  }
77 
78 
85  public function referenceTerms(ilObjGlossary $a_source_glossary, $a_term_ids)
86  {
87  if (!$this->access->checkAccessOfUser($this->user->getId(), "write", "", $this->glossary->getRefId())) {
88  return;
89  }
90 
91  if (!$this->access->checkAccessOfUser($this->user->getId(), "read", "", $a_source_glossary->getRefId())) {
92  return;
93  }
94 
95  include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
96  include_once("./Modules/Glossary/classes/class.ilGlossaryTermReferences.php");
97  $refs = new ilGlossaryTermReferences($this->glossary->getId());
98  foreach ($a_term_ids as $term_id) {
99  if (ilGlossaryTerm::_lookGlossaryID($term_id) != $a_source_glossary->getId()) {
100  continue;
101  }
102 
103  if ($this->glossary->getId() == $a_source_glossary->getId()) {
104  continue;
105  }
106  $refs->addTerm($term_id);
107  }
108  $refs->update();
109  }
110 }
__construct(ilObjGlossary $a_glossary, ilObjUser $a_user)
ilGlossaryAct constructor.
global $DIC
Definition: saml.php:7
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
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