ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
5 require_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  self::writeHelpModuleLmId($id, $newObj->getId());
93 
94  // import help learning module
95  $mess = $newObj->importFromZipFile($a_file["tmp_name"], $a_file["name"],
96  false, $id);
97  }
98 
105  function getHelpModules()
106  {
107  global $ilDB;
108 
109  $set = $ilDB->query("SELECT * FROM help_module");
110 
111  $mods = array();
112  while ($rec = $ilDB->fetchAssoc($set))
113  {
114  if (ilObject::_lookupType($rec["lm_id"]) == "lm")
115  {
116  $rec["title"] = ilObject::_lookupTitle($rec["lm_id"]);
117  $rec["create_date"] = ilObject::_lookupCreationDate($rec["lm_id"]);
118  }
119 
120  $mods[] = $rec;
121  }
122 
123  return $mods;
124  }
125 
132  function lookupModuleTitle($a_id)
133  {
134  global $ilDB;
135 
136  $set = $ilDB->query("SELECT * FROM help_module ".
137  " WHERE id = ".$ilDB->quote($a_id, "integer")
138  );
139  $rec = $ilDB->fetchAssoc($set);
140  if (ilObject::_lookupType($rec["lm_id"]) == "lm")
141  {
142  return ilObject::_lookupTitle($rec["lm_id"]);
143  }
144  return "";
145  }
146 
153  function lookupModuleLmId($a_id)
154  {
155  global $ilDB;
156 
157  $set = $ilDB->query("SELECT lm_id FROM help_module ".
158  " WHERE id = ".$ilDB->quote($a_id, "integer")
159  );
160  $rec = $ilDB->fetchAssoc($set);
161  return $rec["lm_id"];
162  }
163 
170  function deleteModule($a_id)
171  {
172  global $ilDB, $ilSetting;
173 
174  // if this is the currently activated one, deactivate it first
175  if ($a_id == (int) $ilSetting->get("help_module"))
176  {
177  $ilSetting->set("help_module", "");
178  }
179 
180  $set = $ilDB->query("SELECT * FROM help_module ".
181  " WHERE id = ".$ilDB->quote($a_id, "integer")
182  );
183  $rec = $ilDB->fetchAssoc($set);
184 
185  // delete learning module
186  if (ilObject::_lookupType($rec["lm_id"]) == "lm")
187  {
188  include_once("./Modules/LearningModule/classes/class.ilObjLearningModule.php");
189  $lm = new ilObjLearningModule($rec["lm_id"], false);
190  $lm->delete();
191  }
192 
193  // delete mappings
194  include_once("./Services/Help/classes/class.ilHelpMapping.php");
196 
197  // delete tooltips
198  include_once("./Services/Help/classes/class.ilHelp.php");
200 
201  // delete help module record
202  $ilDB->manipulate("DELETE FROM help_module WHERE ".
203  " id = ".$ilDB->quote($a_id, "integer"));
204 
205  }
206 
207 }
208 ?>