ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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}
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
Glossary actor class.
static getInstance(ilObjGlossary $a_glossary, ilObjUser $a_user)
Get instance.
__construct(ilObjGlossary $a_glossary, ilObjUser $a_user)
ilGlossaryAct constructor.
copyTerm(ilObjGlossary $a_source_glossary, $a_term_id)
Copy term.
referenceTerms(ilObjGlossary $a_source_glossary, $a_term_ids)
Reference a term of another glossary in current glossary.
static _lookGlossaryID($term_id)
get glossary id form term id
static _copyTerm($a_term_id, $a_glossary_id)
Copy a term to a glossary.
Class ilObjGlossary.
getRefId()
get reference id @access public
getId()
get object id @access public
global $DIC
Definition: saml.php:7