ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilSkillTreeNodeGUI.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
5include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
6
16{
18 var $in_use = false;
19 var $use_checked = false;
28
34 function __construct($a_node_id = 0)
35 {
36 global $ilAccess;
37
38 $this->node_object = null;
39 $this->access = $ilAccess;
40 $this->ref_id = (int) $_GET["ref_id"];
41
42 if ($a_node_id > 0 &&
43 $this->getType() == ilSkillTreeNode::_lookupType($a_node_id))
44 {
45 $this->readNodeObject((int) $a_node_id);
46 }
47 }
48
55 function isInUse()
56 {
57 if (!is_object($this->node_object))
58 {
59 return false;
60 }
61 if ($this->use_checked)
62 {
63 return $this->in_use;
64 }
65 $cskill_ids = ilSkillTreeNode::getAllCSkillIdsForNodeIds(array($this->node_object->getId()));
66 include_once("./Services/Skill/classes/class.ilSkillUsage.php");
67 $u = new ilSkillUsage();
68 $usages = $u->getAllUsagesInfoOfSubtrees($cskill_ids);
69 if (count($usages) > 0)
70 {
71 $this->in_use = true;
72 } else
73 {
74 $this->in_use = false;
75 }
76 return $this->in_use;
77 }
78
85 function checkPermissionBool($a_perm)
86 {
87 return $this->access->checkAccess($a_perm, "", $this->ref_id);
88 }
89
90
96 function setParentGUI($a_parentgui)
97 {
98 $this->parentgui = $a_parentgui;
99 }
100
106 function getParentGUI()
107 {
108 return $this->parentgui;
109 }
110
114 function readNodeObject($a_node_id)
115 {
116 include_once("./Services/Skill/classes/class.ilSkillTreeNodeFactory.php");
117 $this->node_object = ilSkillTreeNodeFactory::getInstance($a_node_id);
118 }
119
123 function saveAllTitles()
124 {
125 global $ilCtrl;
126
127 $this->getParentGUI()->saveAllTitles(false);
128 $ilCtrl->redirect($this, "showOrganization");
129 }
130
134 function deleteNodes()
135 {
136 global $ilCtrl;
137
138 $ilCtrl->setParameter($this, "backcmd", $_GET["backcmd"]);
139 $this->getParentGUI()->deleteNodes($this);
140 }
141
145 function cutItems()
146 {
147 global $ilCtrl, $lng;
148
149 include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
150
151 if (!is_array($_POST["id"]) || count($_POST["id"]) == 0)
152 {
153 $this->redirectToParent();
154 }
155
156 $items = ilUtil::stripSlashesArray($_POST["id"]);
157 $todel = array(); // delete IDs < 0 (needed for non-js editing)
158 foreach($items as $k => $item)
159 {
160 if ($item < 0)
161 {
162 $todel[] = $k;
163 }
164 }
165 foreach($todel as $k)
166 {
167 unset($items[$k]);
168 }
169
171 {
172 ilUtil::sendInfo($lng->txt("skmg_insert_please_choose_one_type_only"), true);
173 $this->redirectToParent();
174 }
175
177
178 include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
180
181 ilUtil::sendInfo($lng->txt("skmg_selected_items_have_been_cut"), true);
182
183 ilSkillTreeNode::saveChildsOrder((int) $_GET["obj_id"], array(),
184 $_GET["tmpmode"]);
185
186 $this->redirectToParent();
187 }
188
192 function copyItems()
193 {
194 global $ilCtrl, $lng;
195
196 if (!is_array($_POST["id"]) || count($_POST["id"]) == 0)
197 {
198 $this->redirectToParent();
199 }
200
201 include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
202
203 $items = ilUtil::stripSlashesArray($_POST["id"]);
204 $todel = array(); // delete IDs < 0 (needed for non-js editing)
205 foreach($items as $k => $item)
206 {
207 if ($item < 0)
208 {
209 $todel[] = $k;
210 }
211 }
212 foreach($todel as $k)
213 {
214 unset($items[$k]);
215 }
217 {
218 ilUtil::sendInfo($lng->txt("skmg_insert_please_choose_one_type_only"), true);
219 $this->redirectToParent();
220 }
222
223 // @todo: move this to a service since it can be used here, too
224 include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
226 ilUtil::sendInfo($lng->txt("skmg_selected_items_have_been_copied"), true);
227
228 $this->redirectToParent();
229 }
230
234 function cancelDelete()
235 {
236 global $ilCtrl;
237
238 $this->redirectToParent();
239 }
240
245 {
246 global $ilCtrl;
247
248 if (!$this->checkPermissionBool("write"))
249 {
250 return;
251 }
252
253 $this->getParentGUI()->confirmedDelete(false);
254 ilSkillTreeNode::saveChildsOrder((int) $_GET["obj_id"], array(),
255 $_GET["tmpmode"]);
256
257 $this->redirectToParent();
258 }
259
263 function setLocator()
264 {
265 global $ilLocator, $tpl, $ilCtrl;
266
267 $ilLocator->addRepositoryItems($_GET["ref_id"]);
268 $this->getParentGUI()->addLocatorItems();
269
270 if ($_GET["obj_id"] > 0)
271 {
272 include_once("./Services/Skill/classes/class.ilSkillTree.php");
273 $tree = new ilSkillTree();
274 $path = $tree->getPathFull($_GET["obj_id"]);
275 for( $i = 1; $i < count($path); $i++)
276 {
277 switch($path[$i]["type"])
278 {
279 case "scat":
280 $ilCtrl->setParameterByClass("ilskillcategorygui", "obj_id",
281 $path[$i]["child"]);
282 $ilLocator->addItem($path[$i]["title"],
283 $ilCtrl->getLinkTargetByClass("ilskillmanagementgui",
284 "ilskillcategorygui"), "", 0, $path[$i]["type"],
285 ilUtil::getImagePath("icon_skmg.svg"));
286 break;
287
288 case "skll":
289 $ilCtrl->setParameterByClass("ilbasicskillgui", "obj_id",
290 $path[$i]["child"]);
291 $ilLocator->addItem($path[$i]["title"],
292 $ilCtrl->getLinkTargetByClass("ilskillmanagementgui",
293 "ilbasicskillgui"), "", 0, $path[$i]["type"],
294 ilUtil::getImagePath("icon_skmg.svg"));
295 break;
296
297 }
298 }
299 }
300 $ilCtrl->setParameter($this, "obj_id", $_GET["obj_id"]);
301
302 $tpl->setLocator();
303 }
304
309 {
310 global $tpl;
311
312 if (is_object($this->node_object))
313 {
314 include_once("./Services/Skill/classes/class.ilSkillTree.php");
315 $tree = new ilSkillTree();
316 $path = $this->node_object->skill_tree->getSkillTreePath($this->node_object->getId(),
317 $this->tref_id);
318 $desc = "";
319 foreach ($path as $p)
320 {
321 if (in_array($p["type"], array("scat", "skll", "sktr")))
322 {
323 $desc.= $sep.$p["title"];
324 $sep = " > ";
325 }
326 }
327 }
328 $tpl->setDescription($desc);
329 }
330
334 function create()
335 {
336 global $tpl;
337
338 $this->initForm("create");
339 $tpl->setContent($this->form->getHTML());
340 }
341
348 {
349 global $lng;
350
351 // status
352 $radg = new ilRadioGroupInputGUI($lng->txt("skmg_status"), "status");
353 foreach (ilSkillTreeNode::getAllStatus() as $k => $op)
354 {
355 $op = new ilRadioOption($op, $k, ilSkillTreeNode::getStatusInfo($k));
356 $radg->addOption($op);
357 }
358 $a_form->addItem($radg);
359 }
360
364 function editProperties()
365 {
366 global $tpl, $lng;
367
368 if ($this->isInUse())
369 {
370 ilUtil::sendInfo($lng->txt("skmg_skill_in_use"));
371 }
372
373 $this->initForm("edit");
374 $this->getPropertyValues();
375 $tpl->setContent($this->form->getHTML());
376 }
377
382 {
383 $values = array();
384
385 $values["title"] = $this->node_object->getTitle();
386 $values["order_nr"] = $this->node_object->getOrderNr();
387 $values["self_eval"] = $this->node_object->getSelfEvaluation();
388 $values["status"] = $this->node_object->getStatus();
389
390 $this->form->setValuesByArray($values);
391 }
392
397 public function save()
398 {
399 global $tpl, $lng, $ilCtrl;
400
401 if (!$this->checkPermissionBool("write"))
402 {
403 return;
404 }
405
406 $this->initForm("create");
407 if ($this->form->checkInput())
408 {
409 $this->saveItem();
410 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
411 ilSkillTreeNode::saveChildsOrder((int) $_GET["obj_id"], array(),
412 in_array($this->getType(), array("sktp", "sctp")));
413 $this->afterSave();
414 }
415 else
416 {
417 $this->form->setValuesByPost();
418 $tpl->setContent($this->form->getHtml());
419 }
420 }
421
425 function afterSave()
426 {
427 $this->redirectToParent();
428 }
429
430
435 public function update()
436 {
437 global $tpl, $lng, $ilCtrl;
438
439 if (!$this->checkPermissionBool("write"))
440 {
441 return;
442 }
443
444 $this->initForm("edit");
445 if ($this->form->checkInput())
446 {
447 $this->updateItem();
448 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
449 $this->afterUpdate();
450 }
451 else
452 {
453 $this->form->setValuesByPost();
454 $tpl->setContent($this->form->getHtml());
455 }
456 }
457
461 function afterUpdate()
462 {
463 global $ilCtrl;
464
465 $ilCtrl->redirect($this, "editProperties");
466 }
467
473 public function initForm($a_mode = "edit")
474 {
475 global $lng, $ilCtrl;
476
477 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
478 $this->form = new ilPropertyFormGUI();
479
480 // title
481 $ti = new ilTextInputGUI($lng->txt("title"), "title");
482 $ti->setMaxLength(200);
483 $ti->setSize(50);
484 $ti->setRequired(true);
485 $this->form->addItem($ti);
486
487 // order nr
488 $ni = new ilNumberInputGUI($lng->txt("skmg_order_nr"), "order_nr");
489 $ni->setMaxLength(6);
490 $ni->setSize(6);
491 $ni->setRequired(true);
492 $this->form->addItem($ni);
493
494 // save and cancel commands
495 if ($this->checkPermissionBool("write"))
496 {
497 if ($a_mode == "create")
498 {
499 $this->form->addCommandButton("save", $lng->txt("save"));
500 $this->form->addCommandButton("cancelSave", $lng->txt("cancel"));
501 $this->form->setTitle($lng->txt("skmg_create_" . $this->getType()));
502 } else
503 {
504 $this->form->addCommandButton("update", $lng->txt("save"));
505 $this->form->setTitle($lng->txt("skmg_edit_" . $this->getType()));
506 }
507 }
508
509 $ilCtrl->setParameter($this, "obj_id", $_GET["obj_id"]);
510 $this->form->setFormAction($ilCtrl->getFormAction($this));
511
512 }
513
520 function cancelSave()
521 {
522 $this->redirectToParent();
523 }
524
531 function redirectToParent($a_tmp_mode = false)
532 {
533 global $ilCtrl;
534
535 if ($_GET["tmpmode"])
536 {
537 $a_tmp_mode = true;
538 }
539
540 $t = ilSkillTreeNode::_lookupType((int) $_GET["obj_id"]);
541
542 switch ($t)
543 {
544 case "skrt":
545 $ilCtrl->setParameterByClass("ilskillrootgui", "obj_id", (int) $_GET["obj_id"]);
546 if ($a_tmp_mode)
547 {
548 $ilCtrl->redirectByClass("ilskillrootgui", "listTemplates");
549 }
550 else
551 {
552 $ilCtrl->redirectByClass("ilskillrootgui", "listSkills");
553 }
554 break;
555
556 case "sctp":
557 $ilCtrl->setParameterByClass("ilskilltemplatecategorygui", "obj_id", (int) $_GET["obj_id"]);
558 $ilCtrl->redirectByClass("ilskilltemplatecategorygui", "listItems");
559 break;
560
561 case "scat":
562 $ilCtrl->setParameterByClass("ilskillcategorygui", "obj_id", (int) $_GET["obj_id"]);
563 $ilCtrl->redirectByClass("ilskillcategorygui", "listItems");
564 break;
565 }
566
567 }
568
572 function saveOrder()
573 {
574 global $ilCtrl, $lng;
575
576 if (!$this->checkPermissionBool("write"))
577 {
578 return;
579 }
580
581 ilSkillTreeNode::saveChildsOrder((int) $_GET["obj_id"], $_POST["order"],
582 (int) $_GET["tmpmode"]);
583 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
584 $this->redirectToParent((int) $_GET["tmpmode"]);
585 }
586
591 {
592 global $ilCtrl, $ilUser;
593
594 include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
595 $nodes = ilSkillTreeNode::insertItemsFromClip("skll", (int) $_GET["obj_id"]);
596 $this->redirectToParent();
597 }
598
603 {
604 global $ilCtrl, $ilUser;
605
606 include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
607 $nodes = ilSkillTreeNode::insertItemsFromClip("scat", (int) $_GET["obj_id"]);
608 $this->redirectToParent();
609 }
610
615 {
616 global $ilCtrl, $ilUser;
617
618 include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
619 $nodes = ilSkillTreeNode::insertItemsFromClip("sktr", (int) $_GET["obj_id"]);
620 $this->redirectToParent();
621 }
622
627 {
628 global $ilCtrl, $ilUser;
629
630 include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
631 $nodes = ilSkillTreeNode::insertItemsFromClip("sktp", (int) $_GET["obj_id"]);
632 $this->redirectToParent();
633 }
634
639 {
640 global $ilCtrl, $ilUser;
641
642 include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
643 $nodes = ilSkillTreeNode::insertItemsFromClip("sctp", (int) $_GET["obj_id"]);
644 $this->redirectToParent();
645 }
646
650 function setTitleIcon()
651 {
652 global $tpl;
653
654 $obj_id = (is_object($this->node_object))
655 ? $this->node_object->getId()
656 :0;
657 $tpl->setTitleIcon(
659 $obj_id, $this->getType(), "",
661 }
662
666
673 function addUsageTab($a_tabs)
674 {
675 global $lng, $ilCtrl;
676
677 $a_tabs->addTab("usage",
678 $lng->txt("skmg_usage"),
679 $ilCtrl->getLinkTarget($this, "showUsage"));
680 }
681
682
686 function showUsage()
687 {
688 global $tpl;
689
690 $this->setTabs("usage");
691
692 include_once("./Services/Skill/classes/class.ilSkillUsage.php");
693 $usage_info = new ilSkillUsage();
694 $base_skill_id = ($this->base_skill_id > 0)
695 ? $this->base_skill_id
696 : $this->node_object->getId();
697 $usages = $usage_info->getAllUsagesInfoOfSubtree($base_skill_id.":".$this->tref_id);
698
699 $html = "";
700 include_once("./Services/Skill/classes/class.ilSkillUsageTableGUI.php");
701 foreach ($usages as $k => $usage)
702 {
703 $tab = new ilSkillUsageTableGUI($this, "showUsage", $k, $usage);
704 $html.= $tab->getHTML()."<br/><br/>";
705 }
706
707 $tpl->setContent($html);
708 }
709
714 {
715 global $ilCtrl;
716
717 if (!is_array($_POST["id"]) || count($_POST["id"]) == 0)
718 {
719 $this->redirectToParent();
720 }
721
722 include_once("./Services/Export/classes/class.ilExport.php");
723 $exp = new ilExport();
724 $conf = $exp->getConfig("Services/Skill");
725 $conf->setSelectedNodes($_POST["id"]);
726 $exp->exportObject("skmg", ilObject::_lookupObjId((int) $_GET["ref_id"]));
727
728 $ilCtrl->redirectByClass(array("iladministrationgui", "ilobjskillmanagementgui", "ilexportgui"), "");
729 }
730
731
732}
733?>
global $tpl
Definition: ilias.php:8
$path
Definition: aliased.php:25
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
static setAction($a_action)
This class represents a number property in a property form.
static _lookupObjId($a_id)
This class represents a property form user interface.
addItem($a_item)
Add Item (Property, SectionHeader).
This class represents a property in a property form.
This class represents an option in a radio group.
Basic GUI class for skill tree nodes.
redirectToParent($a_tmp_mode=false)
Redirect to parent (identified by current obj_id)
exportSelectedNodes()
Export seleced nodes.
insertSkillTemplateClip()
Insert skill template from clipboard.
showUsage()
Show skill usage.
save()
Save skill tree node.
insertBasicSkillClip()
Insert basic skills from clipboard.
confirmedDelete()
confirmed delete
deleteNodes()
Delete nodes in the hierarchy.
__construct($a_node_id=0)
constructor
getPropertyValues()
Get property values for edit form.
setSkillNodeDescription()
Set skill node description.
create()
Create skill tree node.
readNodeObject($a_node_id)
Get node object instance.
getParentGUI()
Get Parent GUI class (ilObjSCORM2004LearningModuleGUI).
setParentGUI($a_parentgui)
Set Parent GUI class.
editProperties()
Edit properties form.
insertTemplateReferenceClip()
Insert skill template references from clipboard.
addUsageTab($a_tabs)
Add usage tab.
update()
Update skill tree node.
insertTemplateCategoryClip()
Insert skill template category from clipboard.
addStatusInput(ilPropertyFormGUI $a_form)
Add status input.
checkPermissionBool($a_perm)
Check permission pool.
setLocator()
Set Locator Items.
cutItems()
Copy items to clipboard, then cut them from the current tree.
insertSkillCategoryClip()
Insert skill categories from clipboard.
copyItems()
Copy items to clipboard.
initForm($a_mode="edit")
Init form.
static getIconPath($a_obj_id, $a_type, $a_size="", $a_status=0)
Get icon path.
static uniqueTypesCheck($a_items)
Check for unique types.
static getStatusInfo($a_status)
Get status info.
static _lookupStatus($a_obj_id)
Lookup Status.
static saveChildsOrder($a_par_id, $a_childs_order, $a_templates=false)
Save childs order.
static insertItemsFromClip($a_type, $a_obj_id)
Insert basic skills from clipboard.
static getAllStatus()
Get all status.
static clipboardCopy($a_tree_id, $a_ids)
Copy a set of skills/skill categories into the clipboard.
static clipboardCut($a_tree_id, $a_ids)
Cut and copy a set of skills/skill categories into the clipboard.
static getAllCSkillIdsForNodeIds(array $a_node_ids)
Get all possible common skill IDs for node IDs.
static _lookupType($a_obj_id)
Lookup Type.
TableGUI class for skill usages.
This class represents a text property in a property form.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static stripSlashesArray($a_arr, $a_strip_html=true, $a_allow="")
Strip slashes from array.
$html
Definition: example_001.php:87
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17
$ilUser
Definition: imgupload.php:18