ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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.

References $DIC, and $ilDB.

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

Member Function Documentation

◆ create()

ilLMMenuEditor::create ( )

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

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

134  {
135  $ilDB = $this->db;
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  }
getActive()
Get active.
if(!array_key_exists('StateId', $_REQUEST)) $id
$r
Definition: example_031.php:79
global $ilDB
+ 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.

References $db, and $ilDB.

190  {
191  $ilDB = $this->db;
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  }
global $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.

References $db, $DIC, and array.

Referenced by ilLearningModuleImporter\finalProcessing().

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  }
global $DIC
Definition: saml.php:7
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getActive()

ilLMMenuEditor::getActive ( )

Get active.

Returns
string

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

References $active.

Referenced by create().

128  {
129  return $this->active;
130  }
+ Here is the caller graph for this function:

◆ getEntryId()

ilLMMenuEditor::getEntryId ( )

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

Referenced by update().

68  {
69  return $this->entry_id;
70  }
+ Here is the caller graph for this function:

◆ getLinkRefId()

ilLMMenuEditor::getLinkRefId ( )

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

Referenced by create(), and update().

108  {
109  return $this->link_ref_id;
110  }
+ Here is the caller graph for this function:

◆ getLinkType()

ilLMMenuEditor::getLinkType ( )

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

Referenced by create(), and update().

78  {
79  return $this->link_type;
80  }
+ Here is the caller graph for this function:

◆ getMenuEntries()

ilLMMenuEditor::getMenuEntries (   $a_only_active = false)

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

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

157  {
158  $ilDB = $this->db;
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  }
$r
Definition: example_031.php:79
Create styles array
The data for the language used.
global $ilDB

◆ getObjId()

ilLMMenuEditor::getObjId ( )

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

Referenced by create().

58  {
59  return $this->lm_id;
60  }
+ Here is the caller graph for this function:

◆ getTarget()

ilLMMenuEditor::getTarget ( )

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

References $target.

Referenced by create(), and update().

98  {
99  return $this->target;
100  }
+ Here is the caller graph for this function:

◆ getTitle()

ilLMMenuEditor::getTitle ( )

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

References $title.

Referenced by create(), and update().

88  {
89  return $this->title;
90  }
+ Here is the caller graph for this function:

◆ readEntry()

ilLMMenuEditor::readEntry (   $a_id)

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

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

224  {
225  $ilDB = $this->db;
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  }
setActive($a_val)
Set active.
$r
Definition: example_031.php:79
setLinkRefId($a_link_ref_id)
global $ilDB
setLinkType($a_link_type)
+ 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.

Referenced by readEntry().

118  {
119  $this->active = $a_val;
120  }
+ 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.

Referenced by readEntry().

103  {
104  $this->link_ref_id = $a_link_ref_id;
105  }
+ Here is the caller graph for this function:

◆ setLinkType()

ilLMMenuEditor::setLinkType (   $a_link_type)

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

Referenced by readEntry().

73  {
74  $this->link_type = $a_link_type;
75  }
+ 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.

Referenced by readEntry().

93  {
94  $this->target = $a_target;
95  }
+ Here is the caller graph for this function:

◆ setTitle()

ilLMMenuEditor::setTitle (   $a_title)

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

Referenced by readEntry().

83  {
84  $this->title = $a_title;
85  }
+ Here is the caller graph for this function:

◆ update()

ilLMMenuEditor::update ( )

update menu entry

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

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

209  {
210  $ilDB = $this->db;
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  }
$r
Definition: example_031.php:79
global $ilDB
+ 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.

References $db, and $ilDB.

251  {
252  $ilDB = $this->db;
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  }
global $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.

References $active, $db, $DIC, and array.

Referenced by ilObjContentObject\cloneObject().

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  }
global $DIC
Definition: saml.php:7
Create styles array
The data for the language used.
+ 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: