ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 
5 include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
6 
16 {
21  var $access;
25  var $ref_id;
26 
32  function ilSkillTreeNodeGUI($a_node_id = 0)
33  {
34  global $ilAccess;
35 
36  $this->node_object = null;
37  $this->access = $ilAccess;
38  $this->ref_id = (int) $_GET["ref_id"];
39 
40  if ($a_node_id > 0 &&
41  $this->getType() == ilSkillTreeNode::_lookupType($a_node_id))
42  {
43  $this->readNodeObject((int) $a_node_id);
44  }
45  }
46 
53  function checkPermissionBool($a_perm)
54  {
55  return $this->access->checkAccess($a_perm, "", $this->ref_id);
56  }
57 
58 
64  function setParentGUI($a_parentgui)
65  {
66  $this->parentgui = $a_parentgui;
67  }
68 
74  function getParentGUI()
75  {
76  return $this->parentgui;
77  }
78 
82  function readNodeObject($a_node_id)
83  {
84  include_once("./Services/Skill/classes/class.ilSkillTreeNodeFactory.php");
85  $this->node_object = ilSkillTreeNodeFactory::getInstance($a_node_id);
86  }
87 
91  function saveAllTitles()
92  {
93  global $ilCtrl;
94 
95  $this->getParentGUI()->saveAllTitles(false);
96  $ilCtrl->redirect($this, "showOrganization");
97  }
98 
102  function deleteNodes()
103  {
104  global $ilCtrl;
105 
106  $ilCtrl->setParameter($this, "backcmd", $_GET["backcmd"]);
107  $this->getParentGUI()->deleteNodes($this);
108  }
109 
113  function cutItems()
114  {
115  global $ilCtrl, $lng;
116 
117  include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
118 
119  if (!is_array($_POST["id"]) || count($_POST["id"]) == 0)
120  {
121  $this->redirectToParent();
122  }
123 
124  $items = ilUtil::stripSlashesArray($_POST["id"]);
125  $todel = array(); // delete IDs < 0 (needed for non-js editing)
126  foreach($items as $k => $item)
127  {
128  if ($item < 0)
129  {
130  $todel[] = $k;
131  }
132  }
133  foreach($todel as $k)
134  {
135  unset($items[$k]);
136  }
137 
139  {
140  ilUtil::sendInfo($lng->txt("skmg_insert_please_choose_one_type_only"), true);
141  $this->redirectToParent();
142  }
143 
145 
146  include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
148 
149  ilUtil::sendInfo($lng->txt("skmg_selected_items_have_been_cut"), true);
150 
151  ilSkillTreeNode::saveChildsOrder((int) $_GET["obj_id"], array(),
152  $_GET["tmpmode"]);
153 
154  $this->redirectToParent();
155  }
156 
160  function copyItems()
161  {
162  global $ilCtrl, $lng;
163 
164  if (!is_array($_POST["id"]) || count($_POST["id"]) == 0)
165  {
166  $this->redirectToParent();
167  }
168 
169  include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
170 
171  $items = ilUtil::stripSlashesArray($_POST["id"]);
172  $todel = array(); // delete IDs < 0 (needed for non-js editing)
173  foreach($items as $k => $item)
174  {
175  if ($item < 0)
176  {
177  $todel[] = $k;
178  }
179  }
180  foreach($todel as $k)
181  {
182  unset($items[$k]);
183  }
185  {
186  ilUtil::sendInfo($lng->txt("skmg_insert_please_choose_one_type_only"), true);
187  $this->redirectToParent();
188  }
190 
191  // @todo: move this to a service since it can be used here, too
192  include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
194  ilUtil::sendInfo($lng->txt("skmg_selected_items_have_been_copied"), true);
195 
196  $this->redirectToParent();
197  }
198 
202  function cancelDelete()
203  {
204  global $ilCtrl;
205 
206  $this->redirectToParent();
207  }
208 
212  function confirmedDelete()
213  {
214  global $ilCtrl;
215 
216  if (!$this->checkPermissionBool("write"))
217  {
218  return;
219  }
220 
221  $this->getParentGUI()->confirmedDelete(false);
222  ilSkillTreeNode::saveChildsOrder((int) $_GET["obj_id"], array(),
223  $_GET["tmpmode"]);
224 
225  $this->redirectToParent();
226  }
227 
231  function setLocator()
232  {
233  global $ilLocator, $tpl, $ilCtrl;
234 
235  $ilLocator->addRepositoryItems($_GET["ref_id"]);
236  $this->getParentGUI()->addLocatorItems();
237 
238  if ($_GET["obj_id"] > 0)
239  {
240  include_once("./Services/Skill/classes/class.ilSkillTree.php");
241  $tree = new ilSkillTree();
242  $path = $tree->getPathFull($_GET["obj_id"]);
243  for( $i = 1; $i < count($path); $i++)
244  {
245  switch($path[$i]["type"])
246  {
247  case "scat":
248  $ilCtrl->setParameterByClass("ilskillcategorygui", "obj_id",
249  $path[$i]["child"]);
250  $ilLocator->addItem($path[$i]["title"],
251  $ilCtrl->getLinkTargetByClass("ilskillmanagementgui",
252  "ilskillcategorygui"), "", 0, $path[$i]["type"],
253  ilUtil::getImagePath("icon_skmg.svg"));
254  break;
255 
256  case "skll":
257  $ilCtrl->setParameterByClass("ilbasicskillgui", "obj_id",
258  $path[$i]["child"]);
259  $ilLocator->addItem($path[$i]["title"],
260  $ilCtrl->getLinkTargetByClass("ilskillmanagementgui",
261  "ilbasicskillgui"), "", 0, $path[$i]["type"],
262  ilUtil::getImagePath("icon_skmg.svg"));
263  break;
264 
265  }
266  }
267  }
268  $ilCtrl->setParameter($this, "obj_id", $_GET["obj_id"]);
269 
270  $tpl->setLocator();
271  }
272 
277  {
278  global $tpl;
279 
280  if (is_object($this->node_object))
281  {
282  include_once("./Services/Skill/classes/class.ilSkillTree.php");
283  $tree = new ilSkillTree();
284  $path = $this->node_object->skill_tree->getSkillTreePath($this->node_object->getId(),
285  $this->tref_id);
286  $desc = "";
287  foreach ($path as $p)
288  {
289  if (in_array($p["type"], array("scat", "skll", "sktr")))
290  {
291  $desc.= $sep.$p["title"];
292  $sep = " > ";
293  }
294  }
295  }
296  $tpl->setDescription($desc);
297  }
298 
302  function create()
303  {
304  global $tpl;
305 
306  $this->initForm("create");
307  $tpl->setContent($this->form->getHTML());
308  }
309 
316  {
317  global $lng;
318 
319  // status
320  $radg = new ilRadioGroupInputGUI($lng->txt("skmg_status"), "status");
321  foreach (ilSkillTreeNode::getAllStatus() as $k => $op)
322  {
323  $op = new ilRadioOption($op, $k, ilSkillTreeNode::getStatusInfo($k));
324  $radg->addOption($op);
325  }
326  $a_form->addItem($radg);
327  }
328 
332  function editProperties()
333  {
334  global $tpl;
335 
336  $this->initForm("edit");
337  $this->getPropertyValues();
338  $tpl->setContent($this->form->getHTML());
339  }
340 
344  function getPropertyValues()
345  {
346  $values = array();
347 
348  $values["title"] = $this->node_object->getTitle();
349  $values["order_nr"] = $this->node_object->getOrderNr();
350  $values["self_eval"] = $this->node_object->getSelfEvaluation();
351  $values["status"] = $this->node_object->getStatus();
352 
353  $this->form->setValuesByArray($values);
354  }
355 
360  public function save()
361  {
362  global $tpl, $lng, $ilCtrl;
363 
364  if (!$this->checkPermissionBool("write"))
365  {
366  return;
367  }
368 
369  $this->initForm("create");
370  if ($this->form->checkInput())
371  {
372  $this->saveItem();
373  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
374  ilSkillTreeNode::saveChildsOrder((int) $_GET["obj_id"], array(),
375  in_array($this->getType(), array("sktp", "sctp")));
376  $this->afterSave();
377  }
378  else
379  {
380  $this->form->setValuesByPost();
381  $tpl->setContent($this->form->getHtml());
382  }
383  }
384 
388  function afterSave()
389  {
390  $this->redirectToParent();
391  }
392 
393 
398  public function update()
399  {
400  global $tpl, $lng, $ilCtrl;
401 
402  if (!$this->checkPermissionBool("write"))
403  {
404  return;
405  }
406 
407  $this->initForm("edit");
408  if ($this->form->checkInput())
409  {
410  $this->updateItem();
411  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
412  $this->afterUpdate();
413  }
414  else
415  {
416  $this->form->setValuesByPost();
417  $tpl->setContent($this->form->getHtml());
418  }
419  }
420 
424  function afterUpdate()
425  {
426  global $ilCtrl;
427 
428  $ilCtrl->redirect($this, "editProperties");
429  }
430 
436  public function initForm($a_mode = "edit")
437  {
438  global $lng, $ilCtrl;
439 
440  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
441  $this->form = new ilPropertyFormGUI();
442 
443  // title
444  $ti = new ilTextInputGUI($lng->txt("title"), "title");
445  $ti->setMaxLength(200);
446  $ti->setSize(50);
447  $ti->setRequired(true);
448  $this->form->addItem($ti);
449 
450  // order nr
451  $ni = new ilNumberInputGUI($lng->txt("skmg_order_nr"), "order_nr");
452  $ni->setMaxLength(6);
453  $ni->setSize(6);
454  $ni->setRequired(true);
455  $this->form->addItem($ni);
456 
457  // save and cancel commands
458  if ($this->checkPermissionBool("write"))
459  {
460  if ($a_mode == "create")
461  {
462  $this->form->addCommandButton("save", $lng->txt("save"));
463  $this->form->addCommandButton("cancelSave", $lng->txt("cancel"));
464  $this->form->setTitle($lng->txt("skmg_create_" . $this->getType()));
465  } else
466  {
467  $this->form->addCommandButton("update", $lng->txt("save"));
468  $this->form->setTitle($lng->txt("skmg_edit_" . $this->getType()));
469  }
470  }
471 
472  $ilCtrl->setParameter($this, "obj_id", $_GET["obj_id"]);
473  $this->form->setFormAction($ilCtrl->getFormAction($this));
474 
475  }
476 
483  function cancelSave()
484  {
485  $this->redirectToParent();
486  }
487 
494  function redirectToParent($a_tmp_mode = false)
495  {
496  global $ilCtrl;
497 
498  if ($_GET["tmpmode"])
499  {
500  $a_tmp_mode = true;
501  }
502 
503  $t = ilSkillTreeNode::_lookupType((int) $_GET["obj_id"]);
504 
505  switch ($t)
506  {
507  case "skrt":
508  $ilCtrl->setParameterByClass("ilskillrootgui", "obj_id", (int) $_GET["obj_id"]);
509  if ($a_tmp_mode)
510  {
511  $ilCtrl->redirectByClass("ilskillrootgui", "listTemplates");
512  }
513  else
514  {
515  $ilCtrl->redirectByClass("ilskillrootgui", "listSkills");
516  }
517  break;
518 
519  case "sctp":
520  $ilCtrl->setParameterByClass("ilskilltemplatecategorygui", "obj_id", (int) $_GET["obj_id"]);
521  $ilCtrl->redirectByClass("ilskilltemplatecategorygui", "listItems");
522  break;
523 
524  case "scat":
525  $ilCtrl->setParameterByClass("ilskillcategorygui", "obj_id", (int) $_GET["obj_id"]);
526  $ilCtrl->redirectByClass("ilskillcategorygui", "listItems");
527  break;
528  }
529 
530  }
531 
535  function saveOrder()
536  {
537  global $ilCtrl, $lng;
538 
539  if (!$this->checkPermissionBool("write"))
540  {
541  return;
542  }
543 
544  ilSkillTreeNode::saveChildsOrder((int) $_GET["obj_id"], $_POST["order"],
545  (int) $_GET["tmpmode"]);
546  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
547  $this->redirectToParent((int) $_GET["tmpmode"]);
548  }
549 
554  {
555  global $ilCtrl, $ilUser;
556 
557  include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
558  $nodes = ilSkillTreeNode::insertItemsFromClip("skll", (int) $_GET["obj_id"]);
559  $this->redirectToParent();
560  }
561 
566  {
567  global $ilCtrl, $ilUser;
568 
569  include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
570  $nodes = ilSkillTreeNode::insertItemsFromClip("scat", (int) $_GET["obj_id"]);
571  $this->redirectToParent();
572  }
573 
578  {
579  global $ilCtrl, $ilUser;
580 
581  include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
582  $nodes = ilSkillTreeNode::insertItemsFromClip("sktr", (int) $_GET["obj_id"]);
583  $this->redirectToParent();
584  }
585 
590  {
591  global $ilCtrl, $ilUser;
592 
593  include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
594  $nodes = ilSkillTreeNode::insertItemsFromClip("sktp", (int) $_GET["obj_id"]);
595  $this->redirectToParent();
596  }
597 
602  {
603  global $ilCtrl, $ilUser;
604 
605  include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
606  $nodes = ilSkillTreeNode::insertItemsFromClip("sctp", (int) $_GET["obj_id"]);
607  $this->redirectToParent();
608  }
609 
613  function setTitleIcon()
614  {
615  global $tpl;
616 
617  $obj_id = (is_object($this->node_object))
618  ? $this->node_object->getId()
619  :0;
620  $tpl->setTitleIcon(
622  $obj_id, $this->getType(), "",
624  }
625 
629 
636  function addUsageTab($a_tabs)
637  {
638  global $lng, $ilCtrl;
639 
640  $a_tabs->addTab("usage",
641  $lng->txt("skmg_usage"),
642  $ilCtrl->getLinkTarget($this, "showUsage"));
643  }
644 
645 
649  function showUsage()
650  {
651  global $tpl;
652 
653  $this->setTabs("usage");
654 
655  include_once("./Services/Skill/classes/class.ilSkillUsage.php");
656  $usage_info = new ilSkillUsage();
657  $base_skill_id = ($this->base_skill_id > 0)
658  ? $this->base_skill_id
659  : $this->node_object->getId();
660  $usages = $usage_info->getAllUsagesInfoOfSubtree($base_skill_id.":".$this->tref_id);
661 
662  $html = "";
663  include_once("./Services/Skill/classes/class.ilSkillUsageTableGUI.php");
664  foreach ($usages as $k => $usage)
665  {
666  $tab = new ilSkillUsageTableGUI($this, "showUsage", $k, $usage);
667  $html.= $tab->getHTML()."<br/><br/>";
668  }
669 
670  $tpl->setContent($html);
671  }
672 
673 }
674 ?>
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
readNodeObject($a_node_id)
Get node object instance.
redirectToParent($a_tmp_mode=false)
Redirect to parent (identified by current obj_id)
cutItems()
Copy items to clipboard, then cut them from the current tree.
This class represents an option in a radio group.
insertTemplateReferenceClip()
Insert skill template references from clipboard.
addUsageTab($a_tabs)
Add usage tab.
$_POST['username']
Definition: cron.php:12
static getAllStatus()
Get all status.
This class represents a property form user interface.
setSkillNodeDescription()
Set skill node description.
Skill tree.
setLocator()
Set Locator Items.
$_GET["client_id"]
static getIconPath($a_obj_id, $a_type, $a_size="", $a_status=0)
Get icon path.
update()
Update skill tree node.
addItem($a_item)
Add Item (Property, SectionHeader).
static insertItemsFromClip($a_type, $a_obj_id)
Insert basic skills from clipboard.
showUsage()
Show skill usage.
getParentGUI()
Get Parent GUI class (ilObjSCORM2004LearningModuleGUI).
deleteNodes()
Delete nodes in the hierarchy.
setTitleIcon()
Set title icon.
getPropertyValues()
Get property values for edit form.
global $tpl
Definition: ilias.php:8
static _lookupType($a_obj_id)
Lookup Type.
checkPermissionBool($a_perm)
Check permission pool.
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
copyItems()
Copy items to clipboard.
This class represents a property in a property form.
create()
Create skill tree node.
static uniqueTypesCheck($a_items)
Check for unique types.
Basic GUI class for skill tree nodes.
confirmedDelete()
confirmed delete
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
This class represents a number property in a property form.
This class represents a text property in a property form.
static clipboardCopy($a_tree_id, $a_ids)
Copy a set of skills/skill categories into the clipboard.
setMaxLength($a_maxlength)
Set Max Length.
editProperties()
Edit properties form.
initForm($a_mode="edit")
Init form.
TableGUI class for skill usages.
ilSkillTreeNodeGUI($a_node_id=0)
constructor
save()
Save skill tree node.
static saveChildsOrder($a_par_id, $a_childs_order, $a_templates=false)
Save childs order.
static stripSlashesArray($a_arr, $a_strip_html=true, $a_allow="")
Strip slashes from array.
static getStatusInfo($a_status)
Get status info.
insertBasicSkillClip()
Insert basic skills from clipboard.
insertSkillCategoryClip()
Insert skill categories from clipboard.
setMaxLength($a_maxlength)
Set Max Length.
clipboardCut($a_tree_id, $a_ids)
Cut and copy a set of skills/skill categories into the clipboard.
global $ilUser
Definition: imgupload.php:15
global $lng
Definition: privfeed.php:40
$path
Definition: index.php:22
insertSkillTemplateClip()
Insert skill template from clipboard.
static _lookupStatus($a_obj_id)
Lookup Status.
setParentGUI($a_parentgui)
Set Parent GUI class.
Skill usage.
$html
Definition: example_001.php:87
addStatusInput(ilPropertyFormGUI $a_form)
Add status input.
insertTemplateCategoryClip()
Insert skill template category from clipboard.