ILIAS  release_8 Revision v8.24
class.ilObjHelpSettings.php
Go to the documentation of this file.
1<?php
2
25{
27
28 public function __construct()
29 {
31 global $DIC;
32
33 $this->db = $DIC->database();
34 $this->settings = $DIC->settings();
35 }
36
37 protected function initType(): void
38 {
39 $this->type = "hlps";
40 }
41
42 public static function createHelpModule(): int
43 {
44 global $DIC;
45
46 $ilDB = $DIC->database();
47
48 $id = $ilDB->nextId("help_module");
49
50 $ilDB->manipulate("INSERT INTO help_module " .
51 "(id) VALUES (" .
52 $ilDB->quote($id, "integer") .
53 ")");
54
55 return $id;
56 }
57
58 public static function writeHelpModuleLmId(
59 int $a_id,
60 int $a_lm_id
61 ): void {
62 global $DIC;
63
64 $ilDB = $DIC->database();
65
66 $ilDB->manipulate(
67 "UPDATE help_module SET " .
68 " lm_id = " . $ilDB->quote($a_lm_id, "integer") .
69 " WHERE id = " . $ilDB->quote($a_id, "integer")
70 );
71 }
72
73
74 public function uploadHelpModule(
75 array $a_file
76 ): void {
77 $id = self::createHelpModule();
78
79 try {
80 $imp = new ilImport();
81 $conf = $imp->getConfig("Services/Help");
82 $conf->setModuleId($id);
83 $new_id = $imp->importObject(null, $a_file["tmp_name"], $a_file["name"], "lm", "Modules/LearningModule"); //
84 $newObj = new ilObjLearningModule($new_id, false);
85
86 self::writeHelpModuleLmId($id, $newObj->getId());
88 throw new ilLMOldExportFileException("This file seems to be from ILIAS version 5.0.x or lower. Import is not supported anymore.");
89 }
90
91
92 $GLOBALS['ilAppEventHandler']->raise(
93 'Services/Help',
94 'create',
95 array(
96 'obj_id' => $id,
97 'obj_type' => 'lm'
98 )
99 );
100 }
101
102 public function getHelpModules(): array
103 {
104 $ilDB = $this->db;
105
106 $set = $ilDB->query("SELECT * FROM help_module");
107
108 $mods = array();
109 while ($rec = $ilDB->fetchAssoc($set)) {
110 if (ilObject::_lookupType((int) $rec["lm_id"]) === "lm") {
111 $rec["title"] = ilObject::_lookupTitle($rec["lm_id"]);
112 $rec["create_date"] = ilObject::_lookupCreationDate((int) $rec["lm_id"]);
113 }
114
115 $mods[] = $rec;
116 }
117
118 return $mods;
119 }
120
121 public static function lookupModuleTitle(
122 int $a_id
123 ): string {
124 global $DIC;
125
126 $ilDB = $DIC->database();
127
128 $set = $ilDB->query(
129 "SELECT * FROM help_module " .
130 " WHERE id = " . $ilDB->quote($a_id, "integer")
131 );
132 $rec = $ilDB->fetchAssoc($set);
133 if (ilObject::_lookupType((int) $rec["lm_id"]) === "lm") {
134 return ilObject::_lookupTitle((int) $rec["lm_id"]);
135 }
136 return "";
137 }
138
139 public static function lookupModuleLmId(
140 int $a_id
141 ): int {
142 global $DIC;
143
144 $ilDB = $DIC->database();
145
146 $set = $ilDB->query(
147 "SELECT lm_id FROM help_module " .
148 " WHERE id = " . $ilDB->quote($a_id, "integer")
149 );
150 $rec = $ilDB->fetchAssoc($set);
151 return (int) $rec["lm_id"];
152 }
153
154 public function deleteModule(
155 int $a_id
156 ): void {
157 $ilDB = $this->db;
159
160 // if this is the currently activated one, deactivate it first
161 if ($a_id === (int) $ilSetting->get("help_module")) {
162 $ilSetting->set("help_module", "");
163 }
164
165 $set = $ilDB->query(
166 "SELECT * FROM help_module " .
167 " WHERE id = " . $ilDB->quote($a_id, "integer")
168 );
169 $rec = $ilDB->fetchAssoc($set);
170
171 // delete learning module
172 if (ilObject::_lookupType($rec["lm_id"]) === "lm") {
173 $lm = new ilObjLearningModule((int) $rec["lm_id"], false);
174 $lm->delete();
175 }
176
177 // delete mappings
179
180 // delete tooltips
182
183 // delete help module record
184 $ilDB->manipulate("DELETE FROM help_module WHERE " .
185 " id = " . $ilDB->quote($a_id, "integer"));
186 }
187
191 public static function isHelpLM(
192 int $a_lm_id
193 ): bool {
194 global $DIC;
195
196 $ilDB = $DIC->database();
197
198 $set = $ilDB->query(
199 "SELECT id FROM help_module " .
200 " WHERE lm_id = " . $ilDB->quote($a_lm_id, "integer")
201 );
202 if ($rec = $ilDB->fetchAssoc($set)) {
203 return true;
204 }
205 return false;
206 }
207}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
static deleteEntriesOfModule(int $a_id)
static deleteTooltipsOfModule(int $a_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
uploadHelpModule(array $a_file)
static lookupModuleTitle(int $a_id)
static writeHelpModuleLmId(int $a_id, int $a_lm_id)
static lookupModuleLmId(int $a_id)
static isHelpLM(int $a_lm_id)
Check if LM is a help LM.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupType(int $id, bool $reference=false)
static _lookupCreationDate(int $obj_id)
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
global $ilSetting
Definition: privfeed.php:17