ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilObjSkillManagement.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 require_once "./Services/Object/classes/class.ilObject.php";
6 
16 {
17 
24  public function __construct($a_id = 0, $a_call_by_reference = true)
25  {
26  global $DIC;
27 
28  $this->db = $DIC->database();
29  $this->type = "skmg";
30  parent::__construct($a_id, $a_call_by_reference);
31  }
32 
39  public function update()
40  {
41  $ilDB = $this->db;
42 
43  if (!parent::update()) {
44  return false;
45  }
46 
47  return true;
48  }
49 
53  public function read()
54  {
55  $ilDB = $this->db;
56 
57  parent::read();
58  }
59 
66  public function delete()
67  {
68  // always call parent delete function first!!
69  if (!parent::delete()) {
70  return false;
71  }
72 
73  //put here your module specific stuff
74 
75  return true;
76  }
77 
86  public function executeDragDrop($source_id, $target_id, $first_child, $as_subitem = false, $movecopy = "move")
87  {
88  include_once("./Services/Skill/classes/class.ilSkillTree.php");
89  $tree = new ilSkillTree();
90 
91  include_once("./Services/Skill/classes/class.ilSkillTreeNodeFactory.php");
92 
93  $source_obj = ilSkillTreeNodeFactory::getInstance($source_id);
94 
95  if (!$first_child) {
97  $target_parent = $tree->getParentId($target_id);
98  }
99  // handle skills
100  if ($source_obj->getType() == "skll") {
101  if ($tree->isInTree($source_obj->getId())) {
102  $node_data = $tree->getNodeData($source_obj->getId());
103 
104  // cut on move
105  if ($movecopy == "move") {
106  $parent_id = $tree->getParentId($source_obj->getId());
107  $tree->deleteTree($node_data);
108  }
109 
110  // paste page
111  if (!$tree->isInTree($source_obj->getId())) {
112  if ($first_child) { // as first child
113  $target_pos = IL_FIRST_NODE;
114  $parent = $target_id;
115  } elseif ($as_subitem) { // as last child
116  $parent = $target_id;
117  $target_pos = IL_FIRST_NODE;
118  $childs = $tree->getChildsByType($parent, array("skll", "scat"));
119  if (count($childs) != 0) {
120  $target_pos = $childs[count($childs) - 1]["obj_id"];
121  }
122  } else { // at position
123  $target_pos = $target_id;
124  $parent = $target_parent;
125  }
126  // insert skill into tree
127  $tree->insertNode(
128  $source_obj->getId(),
129  $parent,
130  $target_pos
131  );
132  }
133  }
134  }
135 
136  // handle skil categories
137  if ($source_obj->getType() == "scat") {
138  $source_node = $tree->getNodeData($source_id);
139  $subnodes = $tree->getSubtree($source_node);
140 
141  // check, if target is within subtree
142  foreach ($subnodes as $subnode) {
143  if ($subnode["obj_id"] == $target_id) {
144  return;
145  }
146  }
147 
148  $target_pos = $target_id;
149 
150  if ($first_child) { // as first node
151  $target_pos = IL_FIRST_NODE;
152  $target_parent = $target_id;
153  } elseif ($as_subitem) { // as last node
154  $target_parent = $target_id;
155  $target_pos = IL_FIRST_NODE;
156  $childs = $tree->getChilds($target_parent);
157  if (count($childs) != 0) {
158  $target_pos = $childs[count($childs) - 1]["obj_id"];
159  }
160  }
161 
162  // delete source tree
163  if ($movecopy == "move") {
164  $tree->deleteTree($source_node);
165  }
166 
167  if (!$tree->isInTree($source_id)) {
168  $tree->insertNode($source_id, $target_parent, $target_pos);
169 
170  // insert moved tree
171  if ($movecopy == "move") {
172  foreach ($subnodes as $node) {
173  if ($node["obj_id"] != $source_id) {
174  $tree->insertNode($node["obj_id"], $node["parent"]);
175  }
176  }
177  }
178  }
179  }
180  }
181 }
read()
read style folder data
global $DIC
Definition: saml.php:7
Skill tree.
executeDragDrop($source_id, $target_id, $first_child, $as_subitem=false, $movecopy="move")
Execute Drag Drop Action.
$target_id
Definition: goto.php:49
const IL_FIRST_NODE
Definition: class.ilTree.php:5
Skill management main application class.
Create styles array
The data for the language used.
update($pash, $contents, Config $config)
__construct($a_id=0, $a_call_by_reference=true)
Constructor public.
global $ilDB