ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilObjHelpSettings.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5require_once "./Services/Object/classes/class.ilObject2.php";
6
16{
17
24 function ilObjHelpSettings($a_id = 0,$a_call_by_reference = true)
25 {
26 parent::__construct($a_id,$a_call_by_reference);
27 }
28
32 function initType()
33 {
34 $this->type = "hlps";
35 }
36
43 static function createHelpModule()
44 {
45 global $ilDB;
46
47 $id = $ilDB->nextId("help_module");
48
49 $ilDB->manipulate("INSERT INTO help_module ".
50 "(id) VALUES (".
51 $ilDB->quote($id, "integer").
52 ")");
53
54 return $id;
55 }
56
63 static function writeHelpModuleLmId($a_id, $a_lm_id)
64 {
65 global $ilDB;
66
67 $ilDB->manipulate("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
80 function uploadHelpModule($a_file)
81 {
82 $id = $this->createHelpModule();
83
84 // create and insert object in objecttree
85 /*include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
86 $newObj = new ilObjContentObject();
87 $newObj->setType("lm");
88 $newObj->setTitle("Help Module");
89 $newObj->create(true);
90 $newObj->createLMTree();*/
91
92 try
93 {
94 include_once("./Services/Export/classes/class.ilImport.php");
95 $imp = new ilImport();
96 $conf = $imp->getConfig("Services/Help");
97 $conf->setModuleId($id);
98 $new_id = $imp->importObject("", $a_file["tmp_name"], $a_file["name"], "lm", "Modules/LearningModule");
99 $newObj = new ilObjLearningModule($new_id, false);
100
101 self::writeHelpModuleLmId($id, $newObj->getId());
102 }
104 {
105 // old import
106 $t = $imp->getTemporaryImportDir();
107
108 // create and insert object in objecttree
109 include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
110 $newObj = new ilObjContentObject();
111 $newObj->setType("lm");
112 $newObj->setTitle("Help Module");
113 $newObj->create(true);
114 $newObj->createLMTree();
115
116 $mess = $newObj->importFromDirectory($t, false);
117
118 // this should only be true for help modules
119 // search the zip file
120 $dir = $t;
121 $files = ilUtil::getDir($dir);
122 foreach ($files as $file)
123 {
124 if (is_int(strpos($file["entry"], "__help_")) &&
125 is_int(strpos($file["entry"], ".zip")))
126 {
127 include_once("./Services/Export/classes/class.ilImport.php");
128 $imp = new ilImport();
129 $imp->getMapping()->addMapping('Services/Help', 'help_module', 0, $id);
130 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
131 $chaps = ilLMObject::getObjectList($newObj->getId(), "st");
132 foreach ($chaps as $chap)
133 {
134 $chap_arr = explode("_", $chap["import_id"]);
135 $imp->getMapping()->addMapping('Services/Help', 'help_chap',
136 $chap_arr[count($chap_arr) - 1], $chap["obj_id"]);
137 }
138 $imp->importEntity($dir."/".$file["entry"], $file["entry"],
139 "help", "Services/Help", true);
140 }
141 }
142
143 // delete import directory
145
146 self::writeHelpModuleLmId($id, $newObj->getId());
147 }
148
149
150 $GLOBALS['ilAppEventHandler']->raise(
151 'Services/Help',
152 'create',
153 array(
154 'obj_id' => $id,
155 'obj_type' => 'lm'
156 )
157 );
158 }
159
166 function getHelpModules()
167 {
168 global $ilDB;
169
170 $set = $ilDB->query("SELECT * FROM help_module");
171
172 $mods = array();
173 while ($rec = $ilDB->fetchAssoc($set))
174 {
175 if (ilObject::_lookupType($rec["lm_id"]) == "lm")
176 {
177 $rec["title"] = ilObject::_lookupTitle($rec["lm_id"]);
178 $rec["create_date"] = ilObject::_lookupCreationDate($rec["lm_id"]);
179 }
180
181 $mods[] = $rec;
182 }
183
184 return $mods;
185 }
186
193 function lookupModuleTitle($a_id)
194 {
195 global $ilDB;
196
197 $set = $ilDB->query("SELECT * FROM help_module ".
198 " WHERE id = ".$ilDB->quote($a_id, "integer")
199 );
200 $rec = $ilDB->fetchAssoc($set);
201 if (ilObject::_lookupType($rec["lm_id"]) == "lm")
202 {
203 return ilObject::_lookupTitle($rec["lm_id"]);
204 }
205 return "";
206 }
207
214 function lookupModuleLmId($a_id)
215 {
216 global $ilDB;
217
218 $set = $ilDB->query("SELECT lm_id FROM help_module ".
219 " WHERE id = ".$ilDB->quote($a_id, "integer")
220 );
221 $rec = $ilDB->fetchAssoc($set);
222 return $rec["lm_id"];
223 }
224
231 function deleteModule($a_id)
232 {
233 global $ilDB, $ilSetting;
234
235 // if this is the currently activated one, deactivate it first
236 if ($a_id == (int) $ilSetting->get("help_module"))
237 {
238 $ilSetting->set("help_module", "");
239 }
240
241 $set = $ilDB->query("SELECT * FROM help_module ".
242 " WHERE id = ".$ilDB->quote($a_id, "integer")
243 );
244 $rec = $ilDB->fetchAssoc($set);
245
246 // delete learning module
247 if (ilObject::_lookupType($rec["lm_id"]) == "lm")
248 {
249 include_once("./Modules/LearningModule/classes/class.ilObjLearningModule.php");
250 $lm = new ilObjLearningModule($rec["lm_id"], false);
251 $lm->delete();
252 }
253
254 // delete mappings
255 include_once("./Services/Help/classes/class.ilHelpMapping.php");
257
258 // delete tooltips
259 include_once("./Services/Help/classes/class.ilHelp.php");
261
262 // delete help module record
263 $ilDB->manipulate("DELETE FROM help_module WHERE ".
264 " id = ".$ilDB->quote($a_id, "integer"));
265
266 }
267
274 static function isHelpLM($a_lm_id)
275 {
276 global $ilDB;
277
278 $set = $ilDB->query("SELECT id FROM help_module ".
279 " WHERE lm_id = ".$ilDB->quote($a_lm_id, "integer")
280 );
281 if ($rec = $ilDB->fetchAssoc($set))
282 {
283 return true;
284 }
285 return false;
286 }
287
288}
289?>
print $file
static deleteEntriesOfModule($a_id)
Delete entries of module.
static deleteTooltipsOfModule($a_id)
Delete tooltips of module.
Import class.
getObjectList($lm_id, $type="")
static
manifest.xml file not found-exception for import
Class ilObjContentObject.
Help settings application class.
lookupModuleTitle($a_id)
lookup module title
lookupModuleLmId($a_id)
lookup module lm id
getHelpModules()
Get help modules.
ilObjHelpSettings($a_id=0, $a_call_by_reference=true)
Constructor.
deleteModule($a_id)
Delete module.
static createHelpModule()
Create help module.
uploadHelpModule($a_file)
Upload help file.
static writeHelpModuleLmId($a_id, $a_lm_id)
Write help module lm id.
static isHelpLM($a_lm_id)
Check if LM is a help LM.
Class ilObjLearningModule.
Class ilObject2 This is an intermediate progress of ilObject class.
static _lookupTitle($a_id)
lookup object title
_lookupCreationDate($a_id)
Lookup creation date.
static _lookupType($a_id, $a_reference=false)
lookup object type
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
global $ilSetting
Definition: privfeed.php:40
global $ilDB