ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 static function getInstance(ilObjGlossary $a_glossary, ilObjUser $a_user)
50 {
51 return new self($a_glossary, $a_user);
52 }
53
60 function copyTerm(ilObjGlossary $a_source_glossary, $a_term_id)
61 {
62 if (!$this->access->checkAccessOfUser($this->user->getId(), "write", "", $this->glossary->getRefId()))
63 {
64 return;
65 }
66
67 if (!$this->access->checkAccessOfUser($this->user->getId(), "read", "", $a_source_glossary->getRefId()))
68 {
69 return;
70 }
71
72 include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
73 if (ilGlossaryTerm::_lookGlossaryID($a_term_id) != $a_source_glossary->getId())
74 {
75 return;
76 }
77
78 ilGlossaryTerm::_copyTerm($a_term_id, $this->glossary->getId());
79 }
80
81
88 function referenceTerms(ilObjGlossary $a_source_glossary, $a_term_ids)
89 {
90 if (!$this->access->checkAccessOfUser($this->user->getId(), "write", "", $this->glossary->getRefId()))
91 {
92 return;
93 }
94
95 if (!$this->access->checkAccessOfUser($this->user->getId(), "read", "", $a_source_glossary->getRefId()))
96 {
97 return;
98 }
99
100 include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
101 include_once("./Modules/Glossary/classes/class.ilGlossaryTermReferences.php");
102 $refs = new ilGlossaryTermReferences($this->glossary->getId());
103 foreach ($a_term_ids as $term_id)
104 {
105 if (ilGlossaryTerm::_lookGlossaryID($term_id) != $a_source_glossary->getId())
106 {
107 continue;
108 }
109
110 if ($this->glossary->getId() == $a_source_glossary->getId())
111 {
112 continue;
113 }
114 $refs->addTerm($term_id);
115 }
116 $refs->update();
117 }
118
119
120}
121
122?>
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