ILIAS  release_8 Revision v8.24
class.TermManager.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
22
24
30{
33 protected \ilObjGlossary $glossary;
34 protected int $user_id;
35
36 public function __construct(
37 InternalDomainService $domain_service,
40 int $user_id
41 ) {
42 $this->session_repo = $session_repo;
43 $this->glossary = $glossary;
44 $this->user_id = $user_id;
45 $this->domain = $domain_service;
46 }
47
48 public function setSessionLang(string $lang): void
49 {
50 $this->session_repo->setLang($this->glossary->getRefId(), $lang);
51 }
52
53 public function getSessionLang(): string
54 {
55 return $this->session_repo->getLang($this->glossary->getRefId());
56 }
57
59 int $other_glossary_ref_id,
60 int $term_id
61 ): void {
62 $access = $this->domain->access();
63
64 if (!$access->checkAccessOfUser(
65 $this->user_id,
66 "write",
67 "",
68 $this->glossary->getRefId()
69 )
70 ) {
71 return;
72 }
73
74 if (!$access->checkAccessOfUser(
75 $this->user_id,
76 "read",
77 "",
78 $other_glossary_ref_id
79 )) {
80 return;
81 }
82
83 if (\ilGlossaryTerm::_lookGlossaryID($term_id) !=
84 \ilObject::_lookupObjectId($other_glossary_ref_id)) {
85 return;
86 }
87
88 \ilGlossaryTerm::_copyTerm($term_id, $this->glossary->getId());
89 }
90
95 int $other_glossary_ref_id,
96 array $term_ids
97 ): void {
98 $access = $this->domain->access();
99
100 if (!$access->checkAccessOfUser(
101 $this->user_id,
102 "write",
103 "",
104 $this->glossary->getRefId()
105 )) {
106 return;
107 }
108
109 if (!$access->checkAccessOfUser(
110 $this->user_id,
111 "read",
112 "",
113 $other_glossary_ref_id
114 )) {
115 return;
116 }
117
118 $other_glossary_obj_id = \ilObject::_lookupObjectId($other_glossary_ref_id);
119 $refs = new \ilGlossaryTermReferences($this->glossary->getId());
120 foreach ($term_ids as $term_id) {
121 if (\ilGlossaryTerm::_lookGlossaryID($term_id) != $other_glossary_obj_id) {
122 continue;
123 }
124
125 if ($this->glossary->getId() == $other_glossary_obj_id) {
126 continue;
127 }
128 $refs->addTerm($term_id);
129 }
130 $refs->update();
131 }
132}
TermSessionRepository $session_repo
referenceTermsFromOtherGlossary(int $other_glossary_ref_id, array $term_ids)
Reference terms of another glossary in current glossary.
copyTermFromOtherGlossary(int $other_glossary_ref_id, int $term_id)
__construct(InternalDomainService $domain_service, TermSessionRepository $session_repo, \ilObjGlossary $glossary, int $user_id)
static _lookGlossaryID(int $term_id)
get glossary id form term id
static _copyTerm(int $a_term_id, int $a_glossary_id)
Copy a term to a glossary.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupObjectId(int $ref_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$lang
Definition: xapiexit.php:26