ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ModuleManager.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Help\Module;
22
25
27{
28 protected \ilObjUser $user;
29 protected \ILIAS\Help\Tooltips\TooltipsManager $tooltips;
30 protected \ILIAS\Help\Map\MapManager $help_map;
31 protected \ilAppEventHandler $event;
33 protected \ilSetting $settings;
34
35 public function __construct(
38 ) {
39 $this->repo = $repo;
40 $this->settings = $domain->settings();
41 $this->help_map = $domain->map();
42 $this->tooltips = $domain->tooltips();
43 $this->event = $domain->event();
44 $this->user = $domain->user();
45 }
46
47 public function upload(
48 array $file
49 ): void {
50 $id = $this->repo->create();
51
52 try {
53 $imp = new \ilImport();
54 $conf = $imp->getConfig("components/ILIAS/Help");
55 $conf->setModuleId($id);
56 $new_id = $imp->importObject(null, $file["tmp_name"], $file["name"], "lm", "components/ILIAS/LearningModule"); //
57 $newObj = new \ilObjLearningModule($new_id, false);
58
59 $this->repo->writeHelpModuleLmId($id, $newObj->getId());
61 throw new \ilLMOldExportFileException("This file seems to be from ILIAS version 5.0.x or lower. Import is not supported anymore.");
62 }
63
64 $this->event->raise(
65 'components/ILIAS/Help',
66 'create',
67 array(
68 'obj_id' => $id,
69 'obj_type' => 'lm'
70 )
71 );
72 }
73 public function getHelpModules(): array
74 {
75 return $this->repo->getHelpModules();
76 }
77
81 public function getActiveModules(): array
82 {
83 $ids = [];
84 foreach ($this->getHelpModules() as $m) {
85 if ($m["active"]) {
86 $ids[] = (int) $m["id"];
87 }
88 }
89 return $ids;
90 }
91
92 public function isHelpActive(): bool
93 {
94 if ($this->user->getLanguage() !== "de") {
95 return false;
96 }
97 if ($this->isAuthoringMode()) {
98 return true;
99 }
100 return (count($this->getActiveModules()) > 0);
101 }
102
103 public function areTooltipsActive(): bool
104 {
105 if ($this->settings->get("help_mode") === "1") {
106 return false;
107 }
108 return $this->isHelpActive();
109 }
110
111 public function isAuthoringMode(): bool
112 {
113 return ($this->getAuthoringLMId() > 0);
114 }
115 public function getAuthoringLMId(): int
116 {
117 $lm_id = 0;
118 if (defined('OH_REF_ID') && (int) OH_REF_ID > 0) {
119 $lm_id = \ilObject::_lookupObjId((int) OH_REF_ID);
120 }
121 return $lm_id;
122 }
123
124 public function lookupModuleTitle(
125 int $id
126 ): string {
127 return $this->repo->lookupModuleTitle($id);
128 }
129
130 public function lookupModuleLmId(
131 int $id
132 ): int {
133 return $this->repo->lookupModuleLmId($id);
134 }
135
136 public function activate(int $module_id): void
137 {
138 $this->repo->writeActive($module_id, true);
139 }
140
141 public function deactivate(int $module_id): void
142 {
143 $this->repo->writeActive($module_id, false);
144 }
145
146 public function deleteModule(
147 int $id
148 ): void {
149 $lm_id = $this->repo->lookupModuleLmId($id);
150
151 // delete learning module
152 if (\ilObject::_lookupType($lm_id) === "lm") {
153 $lm = new \ilObjLearningModule($lm_id, false);
154 $lm->delete();
155 }
156
157 // delete mappings
158 $this->help_map->deleteEntriesOfModule($id);
159
160 // delete tooltips
161 $this->tooltips->deleteTooltipsOfModule($id);
162
163 $this->repo->deleteModule($id);
164 }
165
166 public function isHelpLM(
167 int $lm_id
168 ): bool {
169 return $this->repo->isHelpLM($lm_id);
170 }
171
172 public function saveOrder(array $order): void
173 {
174 $this->repo->saveOrder($order);
175 }
176}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
ILIAS Help Tooltips TooltipsManager $tooltips
__construct(ModuleDBRepository $repo, InternalDomainService $domain)
ILIAS Help Map MapManager $help_map
manifest.xml file not found-exception for import
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...