ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjSkillManagementGUI.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/Object/classes/class.ilObjectGUI.php");
6 
19 {
20  protected $skill_tree;
21 
27  public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
28  {
29  global $ilCtrl;
30 
31  $this->type = 'skmg';
32  parent::ilObjectGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
33 
34  $this->lng->loadLanguageModule('skmg');
35 
36  include_once("./Services/Skill/classes/class.ilSkillTree.php");
37  $this->skill_tree = new ilSkillTree();
38 
39  $ilCtrl->saveParameter($this, "obj_id");
40  }
41 
48  public function executeCommand()
49  {
50  global $rbacsystem, $ilErr, $ilAccess, $ilTabs;
51 
52  $next_class = $this->ctrl->getNextClass($this);
53  $cmd = $this->ctrl->getCmd();
54 
55  $this->prepareOutput();
56 
57  if(!$ilAccess->checkAccess('read','',$this->object->getRefId()))
58  {
59  $ilErr->raiseError($this->lng->txt('no_permission'),$ilErr->WARNING);
60  }
61 
62  switch($next_class)
63  {
64  case 'ilskillrootgui':
65  include_once("./Services/Skill/classes/class.ilSkillRootGUI.php");
66  $skrt_gui = new ilSkillRootGUI((int) $_GET["obj_id"], $this);
67  $skrt_gui->setParentGUI($this);
68  $ret = $this->ctrl->forwardCommand($skrt_gui);
69  break;
70 
71  case 'ilskillcategorygui':
72  $this->tabs_gui->activateTab("skills");
73  include_once("./Services/Skill/classes/class.ilSkillCategoryGUI.php");
74  $scat_gui = new ilSkillCategoryGUI((int) $_GET["obj_id"]);
75  $scat_gui->setParentGUI($this);
76  $this->showTree(false, $scat_gui, "listItems");
77  $ret = $this->ctrl->forwardCommand($scat_gui);
78  break;
79 
80  case 'ilbasicskillgui':
81  $this->tabs_gui->activateTab("skills");
82  include_once("./Services/Skill/classes/class.ilBasicSkillGUI.php");
83  $skill_gui = new ilBasicSkillGUI((int) $_GET["obj_id"]);
84  $skill_gui->setParentGUI($this);
85  $this->showTree(false, $skill_gui, "edit");
86  $ret = $this->ctrl->forwardCommand($skill_gui);
87  break;
88 
89  case 'ilskilltemplatecategorygui':
90  $this->tabs_gui->activateTab("skill_templates");
91  include_once("./Services/Skill/classes/class.ilSkillTemplateCategoryGUI.php");
92  $sctp_gui = new ilSkillTemplateCategoryGUI((int) $_GET["obj_id"]);
93  $sctp_gui->setParentGUI($this);
94  $this->showTree(true, $sctp_gui, "listItems");
95  $ret = $this->ctrl->forwardCommand($sctp_gui);
96  break;
97 
98  case 'ilbasicskilltemplategui':
99  $this->tabs_gui->activateTab("skill_templates");
100  include_once("./Services/Skill/classes/class.ilBasicSkillTemplateGUI.php");
101  $sktp_gui = new ilBasicSkillTemplateGUI((int) $_GET["obj_id"]);
102  $sktp_gui->setParentGUI($this);
103  $this->showTree(true, $sktp_gui, "edit");
104  $ret = $this->ctrl->forwardCommand($sktp_gui);
105  break;
106 
107  case 'ilskilltemplatereferencegui':
108  $this->tabs_gui->activateTab("skills");
109  include_once("./Services/Skill/classes/class.ilSkillTemplateReferenceGUI.php");
110  $sktr_gui = new ilSkillTemplateReferenceGUI((int) $_GET["obj_id"]);
111  $sktr_gui->setParentGUI($this);
112  $this->showTree(false, $sktr_gui, "listItems");
113  $ret = $this->ctrl->forwardCommand($sktr_gui);
114  break;
115 
116  case 'ilpermissiongui':
117  $this->tabs_gui->activateTab('permissions');
118  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
119  $perm_gui =& new ilPermissionGUI($this);
120  $ret = $this->ctrl->forwardCommand($perm_gui);
121  break;
122 
123  default:
124  if(!$cmd || $cmd == 'view')
125  {
126  $cmd = "editSkills";
127  }
128 
129  $this->$cmd();
130  break;
131  }
132  return true;
133  }
134 
141  public function getAdminTabs()
142  {
143  global $rbacsystem, $ilAccess, $lng;
144 
145  if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
146  {
147  $this->tabs_gui->addTab("skills",
148  $lng->txt("skmg_skills"),
149  $this->ctrl->getLinkTarget($this, "editSkills"));
150 
151  $this->tabs_gui->addTab("skill_templates",
152  $lng->txt("skmg_skill_templates"),
153  $this->ctrl->getLinkTarget($this, "editSkillTemplates"));
154 
155  $this->tabs_gui->addTab("settings",
156  $lng->txt("settings"),
157  $this->ctrl->getLinkTarget($this, "editSettings"));
158 
159  if (DEVMODE == 1)
160  {
161  $this->tabs_gui->addTab("test",
162  "Test (DEVMODE)",
163  $this->ctrl->getLinkTarget($this, "test"));
164  }
165  }
166 
167  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
168  {
169  $this->tabs_gui->addTab("permissions",
170  $lng->txt("perm_settings"),
171  $this->ctrl->getLinkTargetByClass('ilpermissiongui',"perm"));
172  }
173  }
174 
178  public function editSettings()
179  {
180  global $ilCtrl, $lng, $ilSetting, $ilTabs;
181 
182  $ilTabs->activateTab("settings");
183 
184  $skmg_set = new ilSetting("skmg");
185  $enable_skmg = $skmg_set->get("enable_skmg");
186 
187  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
188  $form = new ilPropertyFormGUI();
189  $form->setFormAction($ilCtrl->getFormAction($this));
190  $form->setTitle($lng->txt("skmg_settings"));
191 
192  // Enable skill management
193  $cb_prop = new ilCheckboxInputGUI($lng->txt("skmg_enable_skmg"),
194  "enable_skmg");
195  $cb_prop->setValue("1");
196  $cb_prop->setChecked($enable_skmg);
197  $form->addItem($cb_prop);
198 
199  // command buttons
200  $form->addCommandButton("saveSettings", $lng->txt("save"));
201 
202  $this->tpl->setContent($form->getHTML());
203  }
204 
208  public function saveSettings()
209  {
210  global $ilCtrl, $ilSetting;
211 
212  $skmg_set = new ilSetting("skmg");
213  $skmg_set->set("enable_skmg", $_POST["enable_skmg"]);
214 
215  ilUtil::sendSuccess($this->lng->txt("settings_saved"),true);
216 
217  $ilCtrl->redirect($this, "editSettings");
218  }
219 
226  function editSkills()
227  {
228  global $tpl, $ilTabs, $lng, $ilCtrl;
229 
230  $ilTabs->activateTab("skills");
231 
232 $ilCtrl->setParameterByClass("ilobjskillmanagementgui", "obj_id", $this->skill_tree->getRootId());
233 $ilCtrl->redirectByClass("ilskillrootgui", "listSkills");
234 
235  $a_form_action = $ilCtrl->getFormAction($this);
236  $a_top_node = $this->skill_tree->getRootId();
237 
238  $a_gui_obj = $this;
239  $a_gui_cmd = "editSkills";
240 
241 
242 
243  include_once("./Services/Skill/classes/class.ilSkillHFormGUI.php");
244  $form_gui = new ilSkillHFormGUI();
245  $form_gui->setParentCommand($a_gui_obj, $a_gui_cmd);
246  $form_gui->setFormAction($a_form_action);
247  $form_gui->setTitle($lng->txt("skmg_skill_hierarchie"));
248  $form_gui->setTree($this->skill_tree);
249  $form_gui->setCurrentTopNodeId($a_top_node);
250  $form_gui->addMultiCommand($lng->txt("delete"), "deleteNodes");
251  $form_gui->addMultiCommand($lng->txt("cut"), "cutItems");
252  $form_gui->addMultiCommand($lng->txt("copy"), "copyItems");
253  $form_gui->addCommand($lng->txt("skmg_save_all_titles"), "saveAllTitles");
254  $form_gui->addCommand($lng->txt("expand_all"), "expandAll");
255  $form_gui->addCommand($lng->txt("collapse_all"), "collapseAll");
256  $form_gui->setTriggeredUpdateCommand("saveAllTitles");
257 
258  // highlighted nodes
259  if ($_GET["highlight"] != "")
260  {
261  $hl = explode(":", $_GET["highlight"]);
262  $form_gui->setHighlightedNodes($hl);
263  $form_gui->setFocusId($hl[0]);
264  }
265 
266  $tpl->setContent($form_gui->getHTML());
267 
268  // show left handed tree
269  $this->showTree();
270  }
271 
278  function insertBasicSkill()
279  {
280  global $ilCtrl, $lng;
281 
282  include_once("./Services/Skill/classes/class.ilSkillHFormGUI.php");
283  include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
284 
286  $node_id = ilSkillHFormGUI::getPostNodeId();
287 
288  if (!ilSkillHFormGUI::getPostFirstChild()) // insert after node id
289  {
290  $parent_id = $this->skill_tree->getParentId($node_id);
291  $target = $node_id;
292  }
293  else // insert as first child
294  {
295  $parent_id = $node_id;
296  $target = IL_FIRST_NODE;
297  }
298  include_once("./Services/Skill/classes/class.ilBasicSkill.php");
299 
300  $skill_ids = array();
301  for ($i = 1; $i <= $num; $i++)
302  {
303  $skill = new ilBasicSkill();
304  $skill->setTitle($lng->txt("skmg_new_skill"));
305  $skill->create();
306  ilSkillTreeNode::putInTree($skill, $parent_id, $target);
307  $skill_ids[] = $skill->getId();
308  }
309  $skill_ids = array_reverse($skill_ids);
310  $skill_ids = implode($skill_ids, ":");
311 
312  $ilCtrl->setParameter($this, "highlight", $skill_ids);
313  $ilCtrl->redirect($this, "editSkills", "node_".$node_id);
314  }
315 
323  {
324  global $ilCtrl, $lng;
325 
326  include_once("./Services/Skill/classes/class.ilSkillHFormGUI.php");
327  include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
328 
330  $node_id = ilSkillHFormGUI::getPostNodeId();
331 
332  if (!ilSkillHFormGUI::getPostFirstChild()) // insert after node id
333  {
334  $parent_id = $this->skill_tree->getParentId($node_id);
335  $target = $node_id;
336  }
337  else // insert as first child
338  {
339  $parent_id = $node_id;
340  $target = IL_FIRST_NODE;
341  }
342  include_once("./Services/Skill/classes/class.ilBasicSkillTemplate.php");
343 
344  $skill_ids = array();
345  for ($i = 1; $i <= $num; $i++)
346  {
347  $skill = new ilBasicSkillTemplate();
348  $skill->setTitle($lng->txt("skmg_new_skill_template"));
349  $skill->create();
350  ilSkillTreeNode::putInTree($skill, $parent_id, $target);
351  $skill_ids[] = $skill->getId();
352  }
353  $skill_ids = array_reverse($skill_ids);
354  $skill_ids = implode($skill_ids, ":");
355 
356  $ilCtrl->setParameter($this, "highlight", $skill_ids);
357  $ilCtrl->redirect($this, "editSkillTemplates", "node_".$node_id);
358  }
359 
367  {
368  global $ilCtrl, $lng;
369 
370  include_once("./Services/Skill/classes/class.ilSkillHFormGUI.php");
371  include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
372 
374  $node_id = ilSkillHFormGUI::getPostNodeId();
375 
376  if (!ilSkillHFormGUI::getPostFirstChild()) // insert after node id
377  {
378  $parent_id = $this->skill_tree->getParentId($node_id);
379  $target = $node_id;
380  }
381  else // insert as first child
382  {
383  $parent_id = $node_id;
384  $target = IL_FIRST_NODE;
385  }
386  include_once("./Services/Skill/classes/class.ilSkillCategory.php");
387 
388  $skill_ids = array();
389  for ($i = 1; $i <= $num; $i++)
390  {
391  $skill = new ilSkillCategory();
392  $skill->setTitle($lng->txt("skmg_new_skill_category"));
393  $skill->create();
394  ilSkillTreeNode::putInTree($skill, $parent_id, $target);
395  $skill_ids[] = $skill->getId();
396  }
397  $skill_ids = array_reverse($skill_ids);
398  $skill_ids = implode($skill_ids, ":");
399 
400  $ilCtrl->setParameter($this, "highlight", $skill_ids);
401  $ilCtrl->redirect($this, "editSkills", "node_".$node_id);
402  }
403 
408  {
409  global $ilCtrl, $lng;
410 
411  include_once("./Services/Skill/classes/class.ilSkillHFormGUI.php");
412  include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
413 
415  $node_id = ilSkillHFormGUI::getPostNodeId();
416 
417  if (!ilSkillHFormGUI::getPostFirstChild()) // insert after node id
418  {
419  $parent_id = $this->skill_tree->getParentId($node_id);
420  $target = $node_id;
421  }
422  else // insert as first child
423  {
424  $parent_id = $node_id;
425  $target = IL_FIRST_NODE;
426  }
427  include_once("./Services/Skill/classes/class.ilSkillTemplateCategory.php");
428 
429  $skill_ids = array();
430  for ($i = 1; $i <= $num; $i++)
431  {
432  $skill = new ilSkillTemplateCategory();
433  $skill->setTitle($lng->txt("skmg_new_skill_template_category"));
434  $skill->create();
435  ilSkillTreeNode::putInTree($skill, $parent_id, $target);
436  $skill_ids[] = $skill->getId();
437  }
438  $skill_ids = array_reverse($skill_ids);
439  $skill_ids = implode($skill_ids, ":");
440 
441  $ilCtrl->setParameter($this, "highlight", $skill_ids);
442  $ilCtrl->redirect($this, "editSkillTemplates", "node_".$node_id);
443  }
444 
448  function saveAllTitles($a_succ_mess = true)
449  {
450  global $ilCtrl, $lng;
451 
452  if (is_array($_POST["title"]))
453  {
454  include_once("./Services/Skill/classes/class.ilSkillTreeNodeFactory.php");
455  foreach($_POST["title"] as $id => $title)
456  {
457  $node_obj = ilSkillTreeNodeFactory::getInstance($id);
458  if (is_object($node_obj))
459  {
460  // update title
462  }
463  }
464  if ($a_succ_mess)
465  {
466  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
467  }
468  }
469  $ilCtrl->redirect($this, "editSkills");
470  }
471 
475  function saveAllTemplateTitles($a_succ_mess = true)
476  {
477  global $ilCtrl, $lng;
478 
479  if (is_array($_POST["title"]))
480  {
481  include_once("./Services/Skill/classes/class.ilSkillTreeNodeFactory.php");
482  foreach($_POST["title"] as $id => $title)
483  {
484  $node_obj = ilSkillTreeNodeFactory::getInstance($id);
485  if (is_object($node_obj))
486  {
487  // update title
489  }
490  }
491  if ($a_succ_mess)
492  {
493  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
494  }
495  }
496  $ilCtrl->redirect($this, "editSkillTemplates");
497  }
498 
499 
503  function expandAll($a_redirect = true)
504  {
505  $_GET["skexpand"] = "";
506  $n_id = ($_GET["obj_id"] > 0)
507  ? $_GET["obj_id"]
508  : $this->skill_tree->readRootId();
509  $stree = $this->skill_tree->getSubTree($this->skill_tree->getNodeData($n_id));
510  $n_arr = array();
511  foreach ($stree as $n)
512  {
513  $n_arr[] = $n["child"];
514  $_SESSION["skexpand"] = $n_arr;
515  }
516  $this->saveAllTitles(false);
517  }
518 
522  function collapseAll($a_redirect = true)
523  {
524  $_GET["skexpand"] = "";
525  $n_id = ($_GET["obj_id"] > 0)
526  ? $_GET["obj_id"]
527  : $this->skill_tree->readRootId();
528  $stree = $this->skill_tree->getSubTree($this->skill_tree->getNodeData($n_id));
529  $old = $_SESSION["skexpand"];
530  foreach ($stree as $n)
531  {
532  if (in_array($n["child"], $old) && $n["child"] != $n_id)
533  {
534  $k = array_search($n["child"], $old);
535  unset($old[$k]);
536  }
537  }
538  $_SESSION["skexpand"] = $old;
539  $this->saveAllTitles(false);
540  }
541 
545  function deleteNodes($a_gui)
546  {
547  global $lng, $tpl, $ilCtrl, $ilTabs;
548 
549  if(!isset($_POST["id"]))
550  {
551  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
552  }
553 
554  $ilTabs->clearTargets();
555 
556  // SAVE POST VALUES
557  $_SESSION["saved_post"] = $_POST["id"];
558 
559  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
560  $confirmation_gui = new ilConfirmationGUI();
561 
562  $ilCtrl->setParameter($a_gui, "tmpmode", $_GET["tmpmode"]);
563  $a_form_action = $this->ctrl->getFormAction($a_gui);
564  $confirmation_gui->setFormAction($a_form_action);
565  $confirmation_gui->setHeaderText($this->lng->txt("info_delete_sure"));
566 
567  // Add items to delete
568  include_once("./Services/Skill/classes/class.ilSkillTreeNodeFactory.php");
569  foreach($_POST["id"] as $id)
570  {
571  if ($id != IL_FIRST_NODE)
572  {
573  $node_obj = ilSkillTreeNodeFactory::getInstance($id);
574  $confirmation_gui->addItem("id[]", $node_obj->getId(),
575  $node_obj->getTitle(), ilUtil::getImagePath("icon_".$node_obj->getType().".png"));
576  }
577  }
578 
579  $confirmation_gui->setCancel($lng->txt("cancel"), "cancelDelete");
580  $confirmation_gui->setConfirm($lng->txt("confirm"), "confirmedDelete");
581 
582  $tpl->setContent($confirmation_gui->getHTML());
583  }
584 
588  function cancelDelete()
589  {
590  $this->ctrl->redirect($this, "editSkills");
591  }
592 
596  function confirmedDelete()
597  {
598  global $ilCtrl;
599 
600  // delete all selected objects
601  include_once("./Services/Skill/classes/class.ilSkillTreeNodeFactory.php");
602  foreach ($_POST["id"] as $id)
603  {
604  if ($id != IL_FIRST_NODE)
605  {
607  $node_data = $this->skill_tree->getNodeData($id);
608  if (is_object($obj))
609  {
610  $obj->delete();
611  }
612  if($this->skill_tree->isInTree($id))
613  {
614  $this->skill_tree->deleteTree($node_data);
615  }
616  }
617  }
618 
619  // feedback
620  ilUtil::sendInfo($this->lng->txt("info_deleted"),true);
621  }
622 
623  //
624  //
625  // Test
626  //
627  //
628 
635  function test()
636  {
637  global $tpl, $lng, $ilCtrl, $ilTabs;
638 
639  $this->setTestSubTabs("test");
640 
641  $ilTabs->activateTab("test");
642 
643  include_once("./Services/Skill/classes/class.ilBasicSkill.php");
644 
645  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
646  $this->form = new ilPropertyFormGUI();
647 
648  $this->form->addCommandButton("test", $lng->txt("execute"));
649 
650  $this->form->setTitle("getCompletionDateForTriggerRefId()");
651  $this->form->setFormAction($ilCtrl->getFormAction($this));
652 
653  // user id
654  $ti = new ilTextInputGUI("User ID(s)", "user_id");
655  $ti->setMaxLength(200);
656  $ti->setInfo("Separate multiple IDs by :");
657  $ti->setValue($_POST["user_id"]);
658  $this->form->addItem($ti);
659 
660  // ref id
661  $ti = new ilTextInputGUI("Ref ID(s)", "ref_id");
662  $ti->setMaxLength(200);
663  $ti->setInfo("Separate multiple IDs by :");
664  $ti->setValue($_POST["ref_id"]);
665  $this->form->addItem($ti);
666 
667  $result = "";
668  if (isset($_POST["user_id"]))
669  {
670  $user_ids = explode(":", $_POST["user_id"]);
671  $ref_ids = explode(":", $_POST["ref_id"]);
672  if (count($user_ids) <= 1)
673  {
674  $user_ids = $user_ids[0];
675  }
676  if (count($ref_ids) == 1)
677  {
678  $ref_ids = $ref_ids[0];
679  }
680  else if (count($ref_ids) == 0)
681  {
682  $ref_ids = null;
683  }
684 
686  $result = "<br />Result:<br />".var_export($result, true);
687  }
688 
689  $tpl->setContent($this->form->getHTML().$result);
690 
691  }
692 
699  function testCert()
700  {
701  global $tpl, $lng, $ilCtrl, $ilTabs;
702 
703  $this->setTestSubTabs("cert");
704  $ilTabs->activateTab("test");
705 
706  include_once("./Services/Skill/classes/class.ilBasicSkill.php");
707 
708  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
709  $this->form = new ilPropertyFormGUI();
710 
711  $this->form->addCommandButton("testCert", $lng->txt("execute"));
712 
713  $this->form->setTitle("checkUserCertificateForTriggerRefId()");
714  $this->form->setFormAction($ilCtrl->getFormAction($this));
715 
716  // user id
717  $ti = new ilTextInputGUI("User ID(s)", "user_id");
718  $ti->setMaxLength(200);
719  $ti->setInfo("Separate multiple IDs by :");
720  $ti->setValue($_POST["user_id"]);
721  $this->form->addItem($ti);
722 
723  // ref id
724  $ti = new ilTextInputGUI("Ref ID(s)", "ref_id");
725  $ti->setMaxLength(200);
726  $ti->setInfo("Separate multiple IDs by :");
727  $ti->setValue($_POST["ref_id"]);
728  $this->form->addItem($ti);
729 
730  $result = "";
731  if (isset($_POST["user_id"]))
732  {
733  $user_ids = explode(":", $_POST["user_id"]);
734  $ref_ids = explode(":", $_POST["ref_id"]);
735  if (count($user_ids) <= 1)
736  {
737  $user_ids = $user_ids[0];
738  }
739  if (count($ref_ids) == 1)
740  {
741  $ref_ids = $ref_ids[0];
742  }
743  else if (count($ref_ids) == 0)
744  {
745  $ref_ids = null;
746  }
747 
749  $result = "<br />Result:<br />".var_export($result, true);
750  }
751 
752  $tpl->setContent($this->form->getHTML().$result);
753 
754  }
755 
762  function testAllCert()
763  {
764  global $tpl, $lng, $ilCtrl, $ilTabs;
765 
766  $this->setTestSubTabs("all_cert");
767  $ilTabs->activateTab("test");
768 
769  include_once("./Services/Skill/classes/class.ilBasicSkill.php");
770 
771  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
772  $this->form = new ilPropertyFormGUI();
773 
774  $this->form->addCommandButton("testAllCert", $lng->txt("execute"));
775 
776  $this->form->setTitle("getTriggerOfAllCertificates()");
777  $this->form->setFormAction($ilCtrl->getFormAction($this));
778 
779  // user id
780  $ti = new ilTextInputGUI("User ID(s)", "user_id");
781  $ti->setMaxLength(200);
782  $ti->setInfo("Separate multiple IDs by :");
783  $ti->setValue($_POST["user_id"]);
784  $this->form->addItem($ti);
785 
786  $result = "";
787  if (isset($_POST["user_id"]))
788  {
789  $user_ids = explode(":", $_POST["user_id"]);
790  $ref_ids = explode(":", $_POST["ref_id"]);
791  if (count($user_ids) <= 1)
792  {
793  $user_ids = $user_ids[0];
794  }
795 
797  $result = "<br />Result:<br />".var_export($result, true);
798  }
799 
800  $tpl->setContent($this->form->getHTML().$result);
801 
802  }
803 
810  function testLevels()
811  {
812  global $tpl, $lng, $ilCtrl, $ilTabs;
813 
814  $this->setTestSubTabs("levels");
815  $ilTabs->activateTab("test");
816 
817  include_once("./Services/Skill/classes/class.ilBasicSkill.php");
818 
819  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
820  $this->form = new ilPropertyFormGUI();
821 
822  $this->form->addCommandButton("testLevels", $lng->txt("execute"));
823 
824  $this->form->setTitle("getTriggerOfAllCertificates()");
825  $this->form->setFormAction($ilCtrl->getFormAction($this));
826 
827  // user id
828  $ti = new ilTextInputGUI("Ref ID", "ref_id");
829  $ti->setMaxLength(200);
830  $ti->setValue($_POST["ref_id"]);
831  $this->form->addItem($ti);
832 
833  $result = "";
834  if (isset($_POST["ref_id"]))
835  {
837  $result = "<br />Result:<br />".var_export($result, true);
838  }
839 
840  $tpl->setContent($this->form->getHTML().$result);
841 
842  }
843 
844 
851  function setTestSubtabs($a_act)
852  {
853  global $ilTabs, $ilCtrl;
854 
855  $ilTabs->addSubtab("test",
856  "getCompletionDateForTriggerRefId",
857  $ilCtrl->getLinkTarget($this, "test"));
858 
859  $ilTabs->addSubtab("cert",
860  "checkUserCertificateForTriggerRefId",
861  $ilCtrl->getLinkTarget($this, "testCert"));
862 
863  $ilTabs->addSubtab("all_cert",
864  "getTriggerOfAllCertificates",
865  $ilCtrl->getLinkTarget($this, "testAllCert"));
866 
867  $ilTabs->addSubtab("levels",
868  "getSkillLevelsForTrigger",
869  $ilCtrl->getLinkTarget($this, "testLevels"));
870 
871  $ilTabs->activateSubtab($a_act);
872 
873  }
874 
875  //
876  // Skill Templates
877  //
878 
883  {
884  global $tpl, $ilTabs, $lng, $ilCtrl;
885 
886  $ilTabs->activateTab("skill_templates");
887 
888 $ilCtrl->setParameterByClass("ilobjskillmanagementgui", "obj_id", $this->skill_tree->getRootId());
889 $ilCtrl->redirectByClass("ilskillrootgui", "listTemplates");
890 
891  $a_form_action = $ilCtrl->getFormAction($this);
892  $a_top_node = $this->skill_tree->getRootId();
893 
894  $a_gui_obj = $this;
895  $a_gui_cmd = "editSkillTemplates";
896 
897  include_once("./Services/Skill/classes/class.ilSkillTemplateHFormGUI.php");
898  $form_gui = new ilSkillTemplateHFormGUI();
899  $form_gui->setParentCommand($a_gui_obj, $a_gui_cmd);
900  $form_gui->setFormAction($a_form_action);
901  $form_gui->setTitle($lng->txt("skmg_skill_templates"));
902  $form_gui->setTree($this->skill_tree);
903  $form_gui->setCurrentTopNodeId($a_top_node);
904  $form_gui->addMultiCommand($lng->txt("delete"), "deleteNodes");
905  $form_gui->addMultiCommand($lng->txt("cut"), "cutItems");
906  $form_gui->addMultiCommand($lng->txt("copy"), "copyItems");
907  $form_gui->addCommand($lng->txt("skmg_save_all_titles"), "saveAllTemplateTitles");
908  $form_gui->addCommand($lng->txt("expand_all"), "expandAllTemplates");
909  $form_gui->addCommand($lng->txt("collapse_all"), "collapseAllTemplates");
910  $form_gui->setTriggeredUpdateCommand("saveAllTemplateTitles");
911 
912  // highlighted nodes
913  if ($_GET["highlight"] != "")
914  {
915  $hl = explode(":", $_GET["highlight"]);
916  $form_gui->setHighlightedNodes($hl);
917  $form_gui->setFocusId($hl[0]);
918  }
919 
920  $ilCtrl->setParameter($this, "active_node", $_GET["obj_id"]);
921 
922  $tpl->setContent($form_gui->getHTML());
923 
924  // show left handed tree
925  $this->showTree(true);
926  }
927 
935  {
936  global $ilCtrl, $lng;
937 
938  include_once("./Services/Skill/classes/class.ilSkillHFormGUI.php");
939  include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
940 
941  $node_id = ilSkillHFormGUI::getPostNodeId();
942 
943  if (!ilSkillHFormGUI::getPostFirstChild()) // insert after node id
944  {
945  $parent_id = $this->skill_tree->getParentId($node_id);
946  $target = $node_id;
947  }
948  else // insert as first child
949  {
950  $parent_id = $node_id;
951  $target = IL_FIRST_NODE;
952  }
953  include_once("./Services/Skill/classes/class.ilSkillTemplateReferenceGUI.php");
954  $ilCtrl->setParameterByClass("ilskilltemplatereferencegui", "parent_id", $parent_id);
955  $ilCtrl->setParameterByClass("ilskilltemplatereferencegui", "target", $target);
956  $ilCtrl->redirectByClass("ilskilltemplatereferencegui", "insert");
957  }
958 
959  //
960  // Tree
961  //
962 
966  function showTree($a_templates, $a_gui, $a_gui_cmd)
967  {
968  global $ilUser, $tpl, $ilCtrl, $lng;
969 
970 // $ilCtrl->setParameter($this, "active_node", $_GET["active_node"]);
971 
972 // $this->tpl->addBlockFile("CONTENT", "content", "tpl.explorer.html");
973 // $this->tpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.png", false));
974 
975  require_once ("./Services/Skill/classes/class.ilSkillExplorer.php");
976  $exp = new ilSkillExplorer($ilCtrl->getLinkTarget($a_gui, $a_gui_cmd),
977  $a_templates);
978 // $exp->setFrameUpdater("content", "ilHierarchyFormUpdater");
979  $exp->setTargetGet("obj_id");
980 
981  if ($a_templates)
982  {
983  $exp->setExpandTarget($this->ctrl->getLinkTarget($a_gui, $a_gui_cmd));
984  }
985  else
986  {
987  $exp->setExpandTarget($this->ctrl->getLinkTarget($a_gui, $a_gui_cmd));
988  }
989 
990  if ($_GET["skexpand"] == "")
991  {
992  $expanded = $this->skill_tree->readRootId();
993  }
994  else
995  {
996  $expanded = $_GET["skexpand"];
997  }
998 
999  if ($_GET["obj_id"] > 0)
1000  {
1001  $path = $this->skill_tree->getPathId($_GET["obj_id"]);
1002  $exp->setForceOpenPath($path);
1003  $exp->highlightNode($_GET["obj_id"]);
1004  }
1005  else
1006  {
1007  $exp->highlightNode($this->skill_tree->readRootId());
1008  }
1009  $exp->setExpand($expanded);
1010  // build html-output
1011  $exp->setOutput(0);
1012  $output = $exp->getOutput();
1013 
1014  // asynchronous output
1015  if ($ilCtrl->isAsynch())
1016  {
1017  echo $output; exit;
1018  }
1019 
1020 // $this->tpl->setCurrentBlock("content");
1021 // $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("sahs_organization"));
1022 // $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
1023 // $this->tpl->setVariable("EXPLORER",$output);
1024 
1025 // $this->ctrl->setParameter($this, "scexpand", $_GET["scexpand"]);
1026 // $this->tpl->setVariable("ACTION", $this->ctrl->getLinkTarget($this, "showTree"));
1027 // $this->tpl->parseCurrentBlock();
1028 // $this->tpl->show(false);
1029 
1030  $tpl->setLeftNavContent($output);
1031  }
1032 
1033 }
1034 ?>