ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
5require_once "./Services/Object/classes/class.ilObject.php";
6
16{
17
24 function ilObjSkillManagement($a_id = 0,$a_call_by_reference = true)
25 {
26 $this->type = "skmg";
27 $this->ilObject($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
78
92 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
93 {
94 global $tree;
95
96 switch ($a_event)
97 {
98 case "link":
99
100 //var_dump("<pre>",$a_params,"</pre>");
101 //echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
102 //exit;
103 break;
104
105 case "cut":
106
107 //echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
108 //exit;
109 break;
110
111 case "copy":
112
113 //var_dump("<pre>",$a_params,"</pre>");
114 //echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
115 //exit;
116 break;
117
118 case "paste":
119
120 //echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
121 //exit;
122 break;
123
124 case "new":
125
126 //echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
127 //exit;
128 break;
129 }
130
131 // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
132 if ($a_node_id==$_GET["ref_id"])
133 {
134 $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
135 $parent_type = $parent_obj->getType();
136 if($parent_type == $this->getType())
137 {
138 $a_node_id = (int) $tree->getParentId($a_node_id);
139 }
140 }
141
142 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
143 }
144
153 function executeDragDrop($source_id, $target_id, $first_child, $as_subitem = false, $movecopy = "move")
154 {
155 include_once("./Services/Skill/classes/class.ilSkillTree.php");
156 $tree = new ilSkillTree();
157
158 include_once("./Services/Skill/classes/class.ilSkillTreeNodeFactory.php");
159
160 $source_obj = ilSkillTreeNodeFactory::getInstance($source_id);
161
162 if (!$first_child)
163 {
165 $target_parent = $tree->getParentId($target_id);
166 }
167 // handle skills
168 if ($source_obj->getType() == "skll")
169 {
170 if ($tree->isInTree($source_obj->getId()))
171 {
172 $node_data = $tree->getNodeData($source_obj->getId());
173
174 // cut on move
175 if ($movecopy == "move")
176 {
177 $parent_id = $tree->getParentId($source_obj->getId());
178 $tree->deleteTree($node_data);
179
180 }
181
182 // paste page
183 if(!$tree->isInTree($source_obj->getId()))
184 {
185 if ($first_child) // as first child
186 {
187 $target_pos = IL_FIRST_NODE;
188 $parent = $target_id;
189 }
190 else if ($as_subitem) // as last child
191 {
192 $parent = $target_id;
193 $target_pos = IL_FIRST_NODE;
194 $childs = $tree->getChildsByType($parent, array("skll", "scat"));
195 if (count($childs) != 0)
196 {
197 $target_pos = $childs[count($childs) - 1]["obj_id"];
198 }
199 }
200 else // at position
201 {
202 $target_pos = $target_id;
203 $parent = $target_parent;
204 }
205 // insert skill into tree
206 $tree->insertNode($source_obj->getId(),
207 $parent, $target_pos);
208 }
209 }
210 }
211
212 // handle skil categories
213 if ($source_obj->getType() == "scat")
214 {
215 $source_node = $tree->getNodeData($source_id);
216 $subnodes = $tree->getSubtree($source_node);
217
218 // check, if target is within subtree
219 foreach ($subnodes as $subnode)
220 {
221 if($subnode["obj_id"] == $target_id)
222 {
223 return;
224 }
225 }
226
227 $target_pos = $target_id;
228
229 if ($first_child) // as first node
230 {
231 $target_pos = IL_FIRST_NODE;
232 $target_parent = $target_id;
233 }
234 else if ($as_subitem) // as last node
235 {
236 $target_parent = $target_id;
237 $target_pos = IL_FIRST_NODE;
238 $childs = $tree->getChilds($target_parent);
239 if (count($childs) != 0)
240 {
241 $target_pos = $childs[count($childs) - 1]["obj_id"];
242 }
243 }
244
245 // delete source tree
246 if ($movecopy == "move")
247 {
248 $tree->deleteTree($source_node);
249 }
250
251 if (!$tree->isInTree($source_id))
252 {
253 $tree->insertNode($source_id, $target_parent, $target_pos);
254
255 // insert moved tree
256 if ($movecopy == "move")
257 {
258 foreach ($subnodes as $node)
259 {
260 if($node["obj_id"] != $source_id)
261 {
262 $tree->insertNode($node["obj_id"], $node["parent"]);
263 }
264 }
265 }
266 }
267 }
268
269 }
270}
271?>
$_GET["client_id"]
const IL_FIRST_NODE
Definition: class.ilTree.php:5
Skill management main application class.
notify($a_event, $a_ref_id, $a_parent_non_rbac_id, $a_node_id, $a_params=0)
notifys an object about an event occured Based on the event happend, each object may decide how it re...
executeDragDrop($source_id, $target_id, $first_child, $as_subitem=false, $movecopy="move")
Execute Drag Drop Action.
ilObjSkillManagement($a_id=0, $a_call_by_reference=true)
Constructor @access public.
read()
read style folder data
Class ilObject Basic functions for all objects.
getType()
get object type @access public
ilObject($a_id=0, $a_reference=true)
Constructor @access public.
$target_id
Definition: goto.php:88
redirection script todo: (a better solution should control the processing via a xml file)
global $ilDB