ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilLMMenuEditor Class Reference

class for editing lm menu More...

+ Collaboration diagram for ilLMMenuEditor:

Public Member Functions

 __construct ()
 
 setObjId ($a_obj_id)
 
 getObjId ()
 
 setEntryId ($a_id)
 
 getEntryId ()
 
 setLinkType ($a_link_type)
 
 getLinkType ()
 
 setTitle ($a_title)
 
 getTitle ()
 
 setTarget ($a_target)
 
 getTarget ()
 
 setLinkRefId ($a_link_ref_id)
 
 getLinkRefId ()
 
 setActive ($a_val)
 Set active. More...
 
 getActive ()
 Get active. More...
 
 create ()
 
 getMenuEntries ($a_only_active=false)
 
 delete ($a_id)
 delete menu entry More...
 
 update ()
 update menu entry More...
 
 readEntry ($a_id)
 
 updateActiveStatus ($a_entries)
 update active status of all menu entries of lm More...
 

Static Public Member Functions

static fixImportMenuItems (int $new_lm_id, array $ref_mapping)
 Fix ref ids on import. More...
 
static writeActive ($entry_id, $active)
 Write status for entry id. More...
 

Protected Attributes

 $active = "n"
 
 $db
 

Detailed Description

class for editing lm menu

Author
Sascha Hofmann sasch.nosp@m.ahof.nosp@m.mann@.nosp@m.gmx..nosp@m.de
Version
$Id$

Definition at line 32 of file class.ilLMMenuEditor.php.

Constructor & Destructor Documentation

◆ __construct()

ilLMMenuEditor::__construct ( )

Definition at line 41 of file class.ilLMMenuEditor.php.

42 {
43 global $DIC;
44
45 $ilDB = $DIC->database();
46
47 $this->db = $ilDB;
48 $this->link_type = "extern";
49 $this->link_ref_id = null;
50 }
global $DIC
Definition: saml.php:7
global $ilDB

References $DIC, and $ilDB.

Member Function Documentation

◆ create()

ilLMMenuEditor::create ( )

Definition at line 133 of file class.ilLMMenuEditor.php.

134 {
136
137 $id = $ilDB->nextId("lm_menu");
138 $q = "INSERT INTO lm_menu (id, lm_id,link_type,title,target,link_ref_id, active) " .
139 "VALUES " .
140 "(" .
141 $ilDB->quote($id, "integer") . "," .
142 $ilDB->quote((int) $this->getObjId(), "integer") . "," .
143 $ilDB->quote($this->getLinkType(), "text") . "," .
144 $ilDB->quote($this->getTitle(), "text") . "," .
145 $ilDB->quote($this->getTarget(), "text") . "," .
146 $ilDB->quote((int) $this->getLinkRefId(), "integer") . "," .
147 $ilDB->quote($this->getActive(), "text") .
148 ")";
149 $r = $ilDB->manipulate($q);
150
151 $this->entry_id = $id;
152
153 return true;
154 }
$r
Definition: example_031.php:79
if(!array_key_exists('StateId', $_REQUEST)) $id

References $db, $id, $ilDB, $r, getActive(), getLinkRefId(), getLinkType(), getObjId(), getTarget(), and getTitle().

+ Here is the call graph for this function:

◆ delete()

ilLMMenuEditor::delete (   $a_id)

delete menu entry

Definition at line 189 of file class.ilLMMenuEditor.php.

190 {
192
193 if (!$a_id) {
194 return false;
195 }
196
197 $q = "DELETE FROM lm_menu WHERE id = " .
198 $ilDB->quote($a_id, "integer");
199 $ilDB->manipulate($q);
200
201 return true;
202 }

References $db, and $ilDB.

◆ fixImportMenuItems()

static ilLMMenuEditor::fixImportMenuItems ( int  $new_lm_id,
array  $ref_mapping 
)
static

Fix ref ids on import.

Parameters
int$new_lm_id
array$ref_mapping

Definition at line 272 of file class.ilLMMenuEditor.php.

273 {
274 global $DIC;
275
276 $db = $DIC->database();
277
278 $set = $db->queryF(
279 "SELECT * FROM lm_menu " .
280 " WHERE lm_id = %s ",
281 array("integer"),
282 array($new_lm_id)
283 );
284 while ($rec = $db->fetchAssoc($set)) {
285 // ... only check internal links
286 if ($rec["link_type"] == "intern") {
287 $link = explode("_", $rec["link_ref_id"]);
288 $ref_id = (int) $link[count($link) - 1];
289 $new_ref_id = $ref_mapping[$ref_id];
290 // if ref id has been imported, update it
291 if ($new_ref_id > 0) {
292 $new_target = str_replace((string) $ref_id, (string) $new_ref_id, $rec["target"]);
293 $db->update("lm_menu", array(
294 "link_ref_id" => array("integer", $new_ref_id),
295 "target" => array("text", $new_target)
296 ), array( // where
297 "id" => array("integer", $rec["id"])
298 ));
299 } else { // if not, delete the menu item
300 $db->manipulateF(
301 "DELETE FROM lm_menu WHERE " .
302 " id = %s",
303 array("integer"),
304 array($rec["id"])
305 );
306 }
307 }
308 }
309 }

References $db, and $DIC.

Referenced by ilLearningModuleImporter\finalProcessing().

+ Here is the caller graph for this function:

◆ getActive()

ilLMMenuEditor::getActive ( )

Get active.

Returns
string

Definition at line 127 of file class.ilLMMenuEditor.php.

128 {
129 return $this->active;
130 }

References $active.

Referenced by create().

+ Here is the caller graph for this function:

◆ getEntryId()

ilLMMenuEditor::getEntryId ( )

Definition at line 67 of file class.ilLMMenuEditor.php.

68 {
69 return $this->entry_id;
70 }

Referenced by update().

+ Here is the caller graph for this function:

◆ getLinkRefId()

ilLMMenuEditor::getLinkRefId ( )

Definition at line 107 of file class.ilLMMenuEditor.php.

108 {
109 return $this->link_ref_id;
110 }

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getLinkType()

ilLMMenuEditor::getLinkType ( )

Definition at line 77 of file class.ilLMMenuEditor.php.

78 {
79 return $this->link_type;
80 }

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getMenuEntries()

ilLMMenuEditor::getMenuEntries (   $a_only_active = false)

Definition at line 156 of file class.ilLMMenuEditor.php.

157 {
159
160 $entries = array();
161
162 if ($a_only_active === true) {
163 $and = " AND active = " . $ilDB->quote("y", "text");
164 }
165
166 $q = "SELECT * FROM lm_menu " .
167 "WHERE lm_id = " . $ilDB->quote($this->lm_id, "integer") .
168 $and;
169
170 $r = $ilDB->query($q);
171
172 while ($row = $ilDB->fetchObject($r)) {
173 $entries[] = array('id' => $row->id,
174 'title' => $row->title,
175 'link' => $row->target,
176 'type' => $row->link_type,
177 'ref_id' => $row->link_ref_id,
178 'active' => $row->active
179 );
180 }
181
182 return $entries;
183 }
$row

References $db, $ilDB, $r, and $row.

◆ getObjId()

ilLMMenuEditor::getObjId ( )

Definition at line 57 of file class.ilLMMenuEditor.php.

58 {
59 return $this->lm_id;
60 }

Referenced by create().

+ Here is the caller graph for this function:

◆ getTarget()

ilLMMenuEditor::getTarget ( )

Definition at line 97 of file class.ilLMMenuEditor.php.

98 {
99 return $this->target;
100 }
$target
Definition: test.php:19

References $target.

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getTitle()

ilLMMenuEditor::getTitle ( )

Definition at line 87 of file class.ilLMMenuEditor.php.

88 {
89 return $this->title;
90 }

References $title.

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ readEntry()

ilLMMenuEditor::readEntry (   $a_id)

Definition at line 223 of file class.ilLMMenuEditor.php.

224 {
226
227 if (!$a_id) {
228 return false;
229 }
230
231 $q = "SELECT * FROM lm_menu WHERE id = " .
232 $ilDB->quote($a_id, "integer");
233 $r = $ilDB->query($q);
234
235 $row = $ilDB->fetchObject($r);
236
237 $this->setTitle($row->title);
238 $this->setTarget($row->target);
239 $this->setLinkType($row->link_type);
240 $this->setLinkRefId($row->link_ref_id);
241 $this->setEntryid($a_id);
242 $this->setActive($row->active);
243 }
setLinkType($a_link_type)
setActive($a_val)
Set active.
setLinkRefId($a_link_ref_id)

References $db, $ilDB, $r, $row, setActive(), setLinkRefId(), setLinkType(), setTarget(), and setTitle().

+ Here is the call graph for this function:

◆ setActive()

ilLMMenuEditor::setActive (   $a_val)

Set active.

Parameters
string$a_val

Definition at line 117 of file class.ilLMMenuEditor.php.

118 {
119 $this->active = $a_val;
120 }

Referenced by readEntry().

+ Here is the caller graph for this function:

◆ setEntryId()

ilLMMenuEditor::setEntryId (   $a_id)

Definition at line 62 of file class.ilLMMenuEditor.php.

63 {
64 $this->entry_id = $a_id;
65 }

◆ setLinkRefId()

ilLMMenuEditor::setLinkRefId (   $a_link_ref_id)

Definition at line 102 of file class.ilLMMenuEditor.php.

103 {
104 $this->link_ref_id = $a_link_ref_id;
105 }

Referenced by readEntry().

+ Here is the caller graph for this function:

◆ setLinkType()

ilLMMenuEditor::setLinkType (   $a_link_type)

Definition at line 72 of file class.ilLMMenuEditor.php.

73 {
74 $this->link_type = $a_link_type;
75 }

Referenced by readEntry().

+ Here is the caller graph for this function:

◆ setObjId()

ilLMMenuEditor::setObjId (   $a_obj_id)

Definition at line 52 of file class.ilLMMenuEditor.php.

53 {
54 $this->lm_id = $a_obj_id;
55 }

◆ setTarget()

ilLMMenuEditor::setTarget (   $a_target)

Definition at line 92 of file class.ilLMMenuEditor.php.

93 {
94 $this->target = $a_target;
95 }

Referenced by readEntry().

+ Here is the caller graph for this function:

◆ setTitle()

ilLMMenuEditor::setTitle (   $a_title)

Definition at line 82 of file class.ilLMMenuEditor.php.

83 {
84 $this->title = $a_title;
85 }

Referenced by readEntry().

+ Here is the caller graph for this function:

◆ update()

ilLMMenuEditor::update ( )

update menu entry

Definition at line 208 of file class.ilLMMenuEditor.php.

209 {
211
212 $q = "UPDATE lm_menu SET " .
213 " link_type = " . $ilDB->quote($this->getLinkType(), "text") . "," .
214 " title = " . $ilDB->quote($this->getTitle(), "text") . "," .
215 " target = " . $ilDB->quote($this->getTarget(), "text") . "," .
216 " link_ref_id = " . $ilDB->quote((int) $this->getLinkRefId(), "integer") .
217 " WHERE id = " . $ilDB->quote($this->getEntryId(), "integer");
218 $r = $ilDB->manipulate($q);
219
220 return true;
221 }

References $db, $ilDB, $r, getEntryId(), getLinkRefId(), getLinkType(), getTarget(), and getTitle().

+ Here is the call graph for this function:

◆ updateActiveStatus()

ilLMMenuEditor::updateActiveStatus (   $a_entries)

update active status of all menu entries of lm

Parameters
arrayentry ids

Definition at line 250 of file class.ilLMMenuEditor.php.

251 {
253
254 // update active status
255 $q = "UPDATE lm_menu SET " .
256 "active = CASE " .
257 "WHEN " . $ilDB->in("id", $a_entries, false, "integer") . " " .
258 "THEN " . $ilDB->quote("y", "text") . " " .
259 "ELSE " . $ilDB->quote("n", "text") . " " .
260 "END " .
261 "WHERE lm_id = " . $ilDB->quote($this->lm_id, "integer");
262
263 $ilDB->manipulate($q);
264 }

References $db, and $ilDB.

◆ writeActive()

static ilLMMenuEditor::writeActive (   $entry_id,
  $active 
)
static

Write status for entry id.

Parameters
$entry_id
$active

Definition at line 317 of file class.ilLMMenuEditor.php.

318 {
319 global $DIC;
320
321 $db = $DIC->database();
322
323 $db->update("lm_menu", array(
324 "active" => array("text", ($active ? "y" : "n"))
325 ), array( // where
326 "id" => array("", $entry_id)
327 ));
328 }

References $active, $db, and $DIC.

Referenced by ilObjContentObject\cloneObject().

+ Here is the caller graph for this function:

Field Documentation

◆ $active

ilLMMenuEditor::$active = "n"
protected

Definition at line 34 of file class.ilLMMenuEditor.php.

Referenced by getActive(), and writeActive().

◆ $db

ilLMMenuEditor::$db
protected

The documentation for this class was generated from the following file: