ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilObjSkillManagement.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2020 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
11 {
12 
19  public function __construct($a_id = 0, $a_call_by_reference = true)
20  {
21  global $DIC;
22 
23  $this->db = $DIC->database();
24  $this->type = "skmg";
25  parent::__construct($a_id, $a_call_by_reference);
26  }
27 
34  public function update()
35  {
36  $ilDB = $this->db;
37 
38  if (!parent::update()) {
39  return false;
40  }
41 
42  return true;
43  }
44 
48  public function read()
49  {
50  $ilDB = $this->db;
51 
52  parent::read();
53  }
54 
61  public function delete()
62  {
63  // always call parent delete function first!!
64  if (!parent::delete()) {
65  return false;
66  }
67 
68  //put here your module specific stuff
69 
70  return true;
71  }
72 
81  public function executeDragDrop($source_id, $target_id, $first_child, $as_subitem = false, $movecopy = "move")
82  {
83  $tree = new ilSkillTree();
84 
85  $source_obj = ilSkillTreeNodeFactory::getInstance($source_id);
86 
87  if (!$first_child) {
89  $target_parent = $tree->getParentId($target_id);
90  }
91  // handle skills
92  if ($source_obj->getType() == "skll") {
93  if ($tree->isInTree($source_obj->getId())) {
94  $node_data = $tree->getNodeData($source_obj->getId());
95 
96  // cut on move
97  if ($movecopy == "move") {
98  $parent_id = $tree->getParentId($source_obj->getId());
99  $tree->deleteTree($node_data);
100  }
101 
102  // paste page
103  if (!$tree->isInTree($source_obj->getId())) {
104  if ($first_child) { // as first child
105  $target_pos = IL_FIRST_NODE;
106  $parent = $target_id;
107  } elseif ($as_subitem) { // as last child
108  $parent = $target_id;
109  $target_pos = IL_FIRST_NODE;
110  $childs = $tree->getChildsByType($parent, array("skll", "scat"));
111  if (count($childs) != 0) {
112  $target_pos = $childs[count($childs) - 1]["obj_id"];
113  }
114  } else { // at position
115  $target_pos = $target_id;
116  $parent = $target_parent;
117  }
118  // insert skill into tree
119  $tree->insertNode(
120  $source_obj->getId(),
121  $parent,
122  $target_pos
123  );
124  }
125  }
126  }
127 
128  // handle skil categories
129  if ($source_obj->getType() == "scat") {
130  $source_node = $tree->getNodeData($source_id);
131  $subnodes = $tree->getSubtree($source_node);
132 
133  // check, if target is within subtree
134  foreach ($subnodes as $subnode) {
135  if ($subnode["obj_id"] == $target_id) {
136  return;
137  }
138  }
139 
140  $target_pos = $target_id;
141 
142  if ($first_child) { // as first node
143  $target_pos = IL_FIRST_NODE;
144  $target_parent = $target_id;
145  } elseif ($as_subitem) { // as last node
146  $target_parent = $target_id;
147  $target_pos = IL_FIRST_NODE;
148  $childs = $tree->getChilds($target_parent);
149  if (count($childs) != 0) {
150  $target_pos = $childs[count($childs) - 1]["obj_id"];
151  }
152  }
153 
154  // delete source tree
155  if ($movecopy == "move") {
156  $tree->deleteTree($source_node);
157  }
158 
159  if (!$tree->isInTree($source_id)) {
160  $tree->insertNode($source_id, $target_parent, $target_pos);
161 
162  // insert moved tree
163  if ($movecopy == "move") {
164  foreach ($subnodes as $node) {
165  if ($node["obj_id"] != $source_id) {
166  $tree->insertNode($node["obj_id"], $node["parent"]);
167  }
168  }
169  }
170  }
171  }
172  }
173 }
read()
read style folder data
Skill tree.
executeDragDrop($source_id, $target_id, $first_child, $as_subitem=false, $movecopy="move")
Execute Drag Drop Action.
$target_id
Definition: goto.php:51
const IL_FIRST_NODE
Definition: class.ilTree.php:5
global $DIC
Definition: goto.php:24
Skill management main application class.
__construct(Container $dic, ilPlugin $plugin)
__construct($a_id=0, $a_call_by_reference=true)
Constructor public.
global $ilDB