ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  function __construct($a_id = 0,$a_call_by_reference = true)
25  {
26  $this->type = "skmg";
27  parent::__construct($a_id,$a_call_by_reference);
28  }
29 
36  function update()
37  {
38  global $ilDB;
39 
40  if (!parent::update())
41  {
42  return false;
43  }
44 
45  return true;
46  }
47 
51  function read()
52  {
53  global $ilDB;
54 
55  parent::read();
56 
57  }
58 
65  function delete()
66  {
67  // always call parent delete function first!!
68  if (!parent::delete())
69  {
70  return false;
71  }
72 
73  //put here your module specific stuff
74 
75  return true;
76  }
77 
86  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)
96  {
98  $target_parent = $tree->getParentId($target_id);
99  }
100  // handle skills
101  if ($source_obj->getType() == "skll")
102  {
103  if ($tree->isInTree($source_obj->getId()))
104  {
105  $node_data = $tree->getNodeData($source_obj->getId());
106 
107  // cut on move
108  if ($movecopy == "move")
109  {
110  $parent_id = $tree->getParentId($source_obj->getId());
111  $tree->deleteTree($node_data);
112 
113  }
114 
115  // paste page
116  if(!$tree->isInTree($source_obj->getId()))
117  {
118  if ($first_child) // as first child
119  {
120  $target_pos = IL_FIRST_NODE;
121  $parent = $target_id;
122  }
123  else if ($as_subitem) // as last child
124  {
125  $parent = $target_id;
126  $target_pos = IL_FIRST_NODE;
127  $childs = $tree->getChildsByType($parent, array("skll", "scat"));
128  if (count($childs) != 0)
129  {
130  $target_pos = $childs[count($childs) - 1]["obj_id"];
131  }
132  }
133  else // at position
134  {
135  $target_pos = $target_id;
136  $parent = $target_parent;
137  }
138  // insert skill into tree
139  $tree->insertNode($source_obj->getId(),
140  $parent, $target_pos);
141  }
142  }
143  }
144 
145  // handle skil categories
146  if ($source_obj->getType() == "scat")
147  {
148  $source_node = $tree->getNodeData($source_id);
149  $subnodes = $tree->getSubtree($source_node);
150 
151  // check, if target is within subtree
152  foreach ($subnodes as $subnode)
153  {
154  if($subnode["obj_id"] == $target_id)
155  {
156  return;
157  }
158  }
159 
160  $target_pos = $target_id;
161 
162  if ($first_child) // as first node
163  {
164  $target_pos = IL_FIRST_NODE;
165  $target_parent = $target_id;
166  }
167  else if ($as_subitem) // as last node
168  {
169  $target_parent = $target_id;
170  $target_pos = IL_FIRST_NODE;
171  $childs = $tree->getChilds($target_parent);
172  if (count($childs) != 0)
173  {
174  $target_pos = $childs[count($childs) - 1]["obj_id"];
175  }
176  }
177 
178  // delete source tree
179  if ($movecopy == "move")
180  {
181  $tree->deleteTree($source_node);
182  }
183 
184  if (!$tree->isInTree($source_id))
185  {
186  $tree->insertNode($source_id, $target_parent, $target_pos);
187 
188  // insert moved tree
189  if ($movecopy == "move")
190  {
191  foreach ($subnodes as $node)
192  {
193  if($node["obj_id"] != $source_id)
194  {
195  $tree->insertNode($node["obj_id"], $node["parent"]);
196  }
197  }
198  }
199  }
200  }
201 
202  }
203 }
204 ?>
read()
read style folder data
Skill tree.
executeDragDrop($source_id, $target_id, $first_child, $as_subitem=false, $movecopy="move")
Execute Drag Drop Action.
Class ilObject Basic functions for all objects.
$target_id
Definition: goto.php:51
const IL_FIRST_NODE
Definition: class.ilTree.php:5
Skill management main application class.
Create styles array
The data for the language used.
__construct($a_id=0, $a_call_by_reference=true)
Constructor public.
global $ilDB