ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilLMMenuEditor Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilLMMenuEditor:

Public Member Functions

 __construct ()
 
 setObjId (int $a_obj_id)
 
 getObjId ()
 
 setEntryId (int $a_id)
 
 getEntryId ()
 
 setLinkType (string $a_link_type)
 
 getLinkType ()
 
 setTitle (string $a_title)
 
 getTitle ()
 
 setTarget (string $a_target)
 
 getTarget ()
 
 setLinkRefId (int $a_link_ref_id)
 
 getLinkRefId ()
 
 setActive (string $a_val)
 
 getActive ()
 
 create ()
 
 getMenuEntries (bool $a_only_active=false)
 
 delete (int $a_id)
 
 update ()
 
 readEntry (int $a_id)
 
 updateActiveStatus (array $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)
 
static writeActive (int $entry_id, bool $active)
 

Protected Attributes

string $target = ""
 
string $title = ""
 
int $entry_id = 0
 
int $lm_id = 0
 
int $link_ref_id
 
string $link_type
 
string $active = "n"
 
ilDBInterface $db
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning class for editing lm menu

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

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

Constructor & Destructor Documentation

◆ __construct()

ilLMMenuEditor::__construct ( )

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

References $DIC, and $ilDB.

36  {
37  global $DIC;
38 
39  $ilDB = $DIC->database();
40 
41  $this->db = $ilDB;
42  $this->link_type = "extern";
43  $this->link_ref_id = null;
44  }
global $DIC
Definition: feed.php:28

Member Function Documentation

◆ create()

ilLMMenuEditor::create ( )

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

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

117  : void
118  {
119  $ilDB = $this->db;
120 
121  $id = $ilDB->nextId("lm_menu");
122  $q = "INSERT INTO lm_menu (id, lm_id,link_type,title,target,link_ref_id, active) " .
123  "VALUES " .
124  "(" .
125  $ilDB->quote($id, "integer") . "," .
126  $ilDB->quote($this->getObjId(), "integer") . "," .
127  $ilDB->quote($this->getLinkType(), "text") . "," .
128  $ilDB->quote($this->getTitle(), "text") . "," .
129  $ilDB->quote($this->getTarget(), "text") . "," .
130  $ilDB->quote($this->getLinkRefId(), "integer") . "," .
131  $ilDB->quote($this->getActive(), "text") .
132  ")";
133  $ilDB->manipulate($q);
134  $this->entry_id = $id;
135  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ delete()

ilLMMenuEditor::delete ( int  $a_id)

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

References $db, and $ilDB.

169  : void
170  {
171  $ilDB = $this->db;
172 
173  $q = "DELETE FROM lm_menu WHERE id = " .
174  $ilDB->quote($a_id, "integer");
175  $ilDB->manipulate($q);
176  }

◆ fixImportMenuItems()

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

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

References $DIC, $ref_id, ilDBInterface\fetchAssoc(), ILIAS\Repository\int(), ilDBInterface\manipulateF(), ilDBInterface\queryF(), and ilDBInterface\update().

Referenced by ilLearningModuleImporter\finalProcessing().

235  : void {
236  global $DIC;
237 
238  $db = $DIC->database();
239 
240  $set = $db->queryF(
241  "SELECT * FROM lm_menu " .
242  " WHERE lm_id = %s ",
243  array("integer"),
244  array($new_lm_id)
245  );
246  while ($rec = $db->fetchAssoc($set)) {
247  // ... only check internal links
248  if ($rec["link_type"] == "intern") {
249  $link = explode("_", $rec["link_ref_id"]);
250  $ref_id = (int) $link[count($link) - 1];
251  $new_ref_id = $ref_mapping[$ref_id] ?? 0;
252  // if ref id has been imported, update it
253  if ($new_ref_id > 0) {
254  $new_target = str_replace((string) $ref_id, (string) $new_ref_id, $rec["target"]);
255  $db->update("lm_menu", array(
256  "link_ref_id" => array("integer", $new_ref_id),
257  "target" => array("text", $new_target)
258  ), array( // where
259  "id" => array("integer", $rec["id"])
260  ));
261  } else { // if not, delete the menu item
262  $db->manipulateF(
263  "DELETE FROM lm_menu WHERE " .
264  " id = %s",
265  array("integer"),
266  array($rec["id"])
267  );
268  }
269  }
270  }
271  }
manipulateF(string $query, array $types, array $values)
fetchAssoc(ilDBStatement $statement)
update(string $table_name, array $values, array $where)
$where MUST contain existing columns only.
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
queryF(string $query, array $types, array $values)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActive()

ilLMMenuEditor::getActive ( )

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

References $active.

Referenced by create().

111  : string
112  {
113  return $this->active;
114  }
+ Here is the caller graph for this function:

◆ getEntryId()

ilLMMenuEditor::getEntryId ( )

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

References $entry_id.

Referenced by update().

61  : int
62  {
63  return $this->entry_id;
64  }
+ Here is the caller graph for this function:

◆ getLinkRefId()

ilLMMenuEditor::getLinkRefId ( )

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

References $link_ref_id.

Referenced by create(), and update().

101  : int
102  {
103  return $this->link_ref_id;
104  }
+ Here is the caller graph for this function:

◆ getLinkType()

ilLMMenuEditor::getLinkType ( )

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

References $link_type.

Referenced by create(), and update().

71  : string
72  {
73  return $this->link_type;
74  }
+ Here is the caller graph for this function:

◆ getMenuEntries()

ilLMMenuEditor::getMenuEntries ( bool  $a_only_active = false)

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

References $db, and $ilDB.

Referenced by ilLMMenuItemsTableGUI\__construct().

139  : array {
140  $ilDB = $this->db;
141 
142  $and = "";
143 
144  $entries = array();
145 
146  if ($a_only_active === true) {
147  $and = " AND active = " . $ilDB->quote("y", "text");
148  }
149 
150  $q = "SELECT * FROM lm_menu " .
151  "WHERE lm_id = " . $ilDB->quote($this->lm_id, "integer") .
152  $and;
153 
154  $r = $ilDB->query($q);
155 
156  while ($row = $ilDB->fetchObject($r)) {
157  $entries[] = array('id' => $row->id,
158  'title' => $row->title,
159  'link' => $row->target,
160  'type' => $row->link_type,
161  'ref_id' => $row->link_ref_id,
162  'active' => $row->active
163  );
164  }
165 
166  return $entries;
167  }
+ Here is the caller graph for this function:

◆ getObjId()

ilLMMenuEditor::getObjId ( )

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

References $lm_id.

Referenced by create().

51  : int
52  {
53  return $this->lm_id;
54  }
+ Here is the caller graph for this function:

◆ getTarget()

ilLMMenuEditor::getTarget ( )

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

References $target.

Referenced by create(), and update().

91  : string
92  {
93  return $this->target;
94  }
+ Here is the caller graph for this function:

◆ getTitle()

ilLMMenuEditor::getTitle ( )

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

References $title.

Referenced by create(), and update().

81  : string
82  {
83  return $this->title;
84  }
+ Here is the caller graph for this function:

◆ readEntry()

ilLMMenuEditor::readEntry ( int  $a_id)

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

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

191  : void
192  {
193  $ilDB = $this->db;
194 
195  if (!$a_id) {
196  return;
197  }
198 
199  $q = "SELECT * FROM lm_menu WHERE id = " .
200  $ilDB->quote($a_id, "integer");
201  $r = $ilDB->query($q);
202 
203  $row = $ilDB->fetchObject($r);
204 
205  $this->setTitle($row->title);
206  $this->setTarget($row->target);
207  $this->setLinkType($row->link_type);
208  $this->setLinkRefId($row->link_ref_id);
209  $this->setEntryId($a_id);
210  $this->setActive($row->active);
211  }
setTitle(string $a_title)
setLinkRefId(int $a_link_ref_id)
setLinkType(string $a_link_type)
setTarget(string $a_target)
setActive(string $a_val)
+ Here is the call graph for this function:

◆ setActive()

ilLMMenuEditor::setActive ( string  $a_val)

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

Referenced by readEntry().

106  : void
107  {
108  $this->active = $a_val;
109  }
+ Here is the caller graph for this function:

◆ setEntryId()

ilLMMenuEditor::setEntryId ( int  $a_id)

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

Referenced by readEntry().

56  : void
57  {
58  $this->entry_id = $a_id;
59  }
+ Here is the caller graph for this function:

◆ setLinkRefId()

ilLMMenuEditor::setLinkRefId ( int  $a_link_ref_id)

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

Referenced by readEntry().

96  : void
97  {
98  $this->link_ref_id = $a_link_ref_id;
99  }
+ Here is the caller graph for this function:

◆ setLinkType()

ilLMMenuEditor::setLinkType ( string  $a_link_type)

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

Referenced by readEntry().

66  : void
67  {
68  $this->link_type = $a_link_type;
69  }
+ Here is the caller graph for this function:

◆ setObjId()

ilLMMenuEditor::setObjId ( int  $a_obj_id)

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

46  : void
47  {
48  $this->lm_id = $a_obj_id;
49  }

◆ setTarget()

ilLMMenuEditor::setTarget ( string  $a_target)

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

Referenced by readEntry().

86  : void
87  {
88  $this->target = $a_target;
89  }
+ Here is the caller graph for this function:

◆ setTitle()

ilLMMenuEditor::setTitle ( string  $a_title)

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

Referenced by readEntry().

76  : void
77  {
78  $this->title = $a_title;
79  }
+ Here is the caller graph for this function:

◆ update()

ilLMMenuEditor::update ( )

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

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

178  : void
179  {
180  $ilDB = $this->db;
181 
182  $q = "UPDATE lm_menu SET " .
183  " link_type = " . $ilDB->quote($this->getLinkType(), "text") . "," .
184  " title = " . $ilDB->quote($this->getTitle(), "text") . "," .
185  " target = " . $ilDB->quote($this->getTarget(), "text") . "," .
186  " link_ref_id = " . $ilDB->quote($this->getLinkRefId(), "integer") .
187  " WHERE id = " . $ilDB->quote($this->getEntryId(), "integer");
188  $ilDB->manipulate($q);
189  }
+ Here is the call graph for this function:

◆ updateActiveStatus()

ilLMMenuEditor::updateActiveStatus ( array  $a_entries)

update active status of all menu entries of lm

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

References $db, and $ilDB.

216  : void
217  {
218  $ilDB = $this->db;
219 
220  // update active status
221  $q = "UPDATE lm_menu SET " .
222  "active = CASE " .
223  "WHEN " . $ilDB->in("id", $a_entries, false, "integer") . " " .
224  "THEN " . $ilDB->quote("y", "text") . " " .
225  "ELSE " . $ilDB->quote("n", "text") . " " .
226  "END " .
227  "WHERE lm_id = " . $ilDB->quote($this->lm_id, "integer");
228 
229  $ilDB->manipulate($q);
230  }

◆ writeActive()

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

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

References $DIC, and ilDBInterface\update().

Referenced by ilObjContentObject\validatePages().

276  : void {
277  global $DIC;
278 
279  $db = $DIC->database();
280 
281  $db->update("lm_menu", array(
282  "active" => array("text", ($active ? "y" : "n"))
283  ), array( // where
284  "id" => array("", $entry_id)
285  ));
286  }
update(string $table_name, array $values, array $where)
$where MUST contain existing columns only.
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $active

string ilLMMenuEditor::$active = "n"
protected

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

Referenced by getActive().

◆ $db

ilDBInterface ilLMMenuEditor::$db
protected

◆ $entry_id

int ilLMMenuEditor::$entry_id = 0
protected

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

Referenced by getEntryId().

◆ $link_ref_id

int ilLMMenuEditor::$link_ref_id
protected

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

Referenced by getLinkRefId().

◆ $link_type

string ilLMMenuEditor::$link_type
protected

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

Referenced by getLinkType().

◆ $lm_id

int ilLMMenuEditor::$lm_id = 0
protected

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

Referenced by getObjId().

◆ $target

string ilLMMenuEditor::$target = ""
protected

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

Referenced by getTarget().

◆ $title

string ilLMMenuEditor::$title = ""
protected

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

Referenced by getTitle().


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