ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilSkillProfileGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5include_once("./Services/Skill/classes/class.ilSkillProfile.php");
6
16{
17 protected $profile = null;
26
30 function __construct()
31 {
32 global $ilCtrl, $ilAccess;
33
34 $ilCtrl->saveParameter($this, "sprof_id");
35 $this->access = $ilAccess;
36 $this->ref_id = (int) $_GET["ref_id"];
37
38 if ((int) $_GET["sprof_id"] > 0)
39 {
40 $this->id = (int) $_GET["sprof_id"];
41 }
42
43 if ($this->id > 0)
44 {
45 $this->profile = new ilSkillProfile($this->id);
46 }
47 }
48
55 function checkPermissionBool($a_perm)
56 {
57 return $this->access->checkAccess($a_perm, "", $this->ref_id);
58 }
59
63 function executeCommand()
64 {
65 global $ilCtrl, $lng;
66
67 $cmd = $ilCtrl->getCmd("listProfiles");
68 $next_class = $ilCtrl->getNextClass();
69 switch($next_class)
70 {
71 case 'ilrepositorysearchgui':
72 include_once('./Services/Search/classes/class.ilRepositorySearchGUI.php');
73 $user_search = new ilRepositorySearchGUI();
74 $user_search->setTitle($lng->txt('skmg_add_user_to_profile'));
75 $user_search->setCallback($this, 'assignUser');
76
77 // Set tabs
78 //$this->tabs_gui->setTabActive('user_assignment');
79 $ilCtrl->setReturn($this, 'listUsers');
80 $ret = $ilCtrl->forwardCommand($user_search);
81 break;
82
83 default:
84 if (in_array($cmd, array("listProfiles", "create", "edit", "save", "update",
85 "confirmDeleteProfiles", "deleteProfiles", "showLevels", "assignLevel",
86 "assignLevelSelectSkill", "assignLevelToProfile",
87 "confirmLevelAssignmentRemoval", "removeLevelAssignments",
88 "showUsers", "assignUser",
89 "confirmUserRemoval", "removeUsers", "exportProfiles", "showImportForm", "importProfiles")))
90 {
91 $this->$cmd();
92 }
93 break;
94 }
95 }
96
103 function setTabs($a_active)
104 {
105 global $ilTabs, $lng, $ilCtrl, $tpl, $ilHelp;
106
107 $tpl->setTitle($lng->txt("skmg_profile").": ".
108 $this->profile->getTitle());
109 $tpl->setDescription("");
110
111 $ilTabs->clearTargets();
112 $ilHelp->setScreenIdComponent("skmg_prof");
113
114 $ilTabs->setBackTarget($lng->txt("back"),
115 $ilCtrl->getLinkTarget($this, ""));
116
117 // users
118 $ilTabs->addTab("users",
119 $lng->txt("skmg_assigned_users"),
120 $ilCtrl->getLinkTarget($this, "showUsers"));
121
122 // levels
123 $ilTabs->addTab("levels",
124 $lng->txt("skmg_assigned_skill_levels"),
125 $ilCtrl->getLinkTarget($this, "showLevels"));
126
127 // settings
128 $ilTabs->addTab("settings",
129 $lng->txt("settings"),
130 $ilCtrl->getLinkTarget($this, "edit"));
131
132 $ilTabs->activateTab($a_active);
133 }
134
135
139 function listProfiles()
140 {
141 global $tpl, $ilToolbar, $lng, $ilCtrl;
142
143 if ($this->checkPermissionBool("write"))
144 {
145 $ilToolbar->addButton($lng->txt("skmg_add_profile"),
146 $ilCtrl->getLinkTarget($this, "create"));
147
148 $ilToolbar->addButton($lng->txt("import"),
149 $ilCtrl->getLinkTarget($this, "showImportForm"));
150 }
151
152 include_once("./Services/Skill/classes/class.ilSkillProfileTableGUI.php");
153 $tab = new ilSkillProfileTableGUI($this, "listProfiles");
154
155 $tpl->setContent($tab->getHTML());
156 }
157
161 function create()
162 {
163 global $tpl;
164
165 $form = $this->initProfileForm("create");
166 $tpl->setContent($form->getHTML());
167 }
168
172 function edit()
173 {
174 global $tpl;
175
176 $this->setTabs("settings");
177 $form = $this->initProfileForm("edit");
178 $tpl->setContent($form->getHTML());
179 }
180
181
187 public function initProfileForm($a_mode = "edit")
188 {
189 global $lng, $ilCtrl;
190
191 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
192 $form = new ilPropertyFormGUI();
193
194 // title
195 $ti = new ilTextInputGUI($lng->txt("title"), "title");
196 $ti->setMaxLength(200);
197 $ti->setSize(40);
198 $ti->setRequired(true);
199 $form->addItem($ti);
200
201 // description
202 $desc = new ilTextAreaInputGUI($lng->txt("description"), "description");
203 $desc->setCols(40);
204 $desc->setRows(4);
205 $form->addItem($desc);
206
207 // save and cancel commands
208 if ($this->checkPermissionBool("write"))
209 {
210 if ($a_mode == "create")
211 {
212 $form->addCommandButton("save", $lng->txt("save"));
213 $form->addCommandButton("listProfiles", $lng->txt("cancel"));
214 $form->setTitle($lng->txt("skmg_add_profile"));
215 } else
216 {
217 // set values
218 $ti->setValue($this->profile->getTitle());
219 $desc->setValue($this->profile->getDescription());
220
221 $form->addCommandButton("update", $lng->txt("save"));
222 $form->addCommandButton("listProfiles", $lng->txt("cancel"));
223 $form->setTitle($lng->txt("skmg_edit_profile"));
224 }
225 }
226
227 $form->setFormAction($ilCtrl->getFormAction($this));
228
229 return $form;
230 }
231
235 public function save()
236 {
237 global $tpl, $lng, $ilCtrl;
238
239 if (!$this->checkPermissionBool("write"))
240 {
241 return;
242 }
243
244 $form = $this->initProfileForm("create");
245 if ($form->checkInput())
246 {
247 $prof = new ilSkillProfile();
248 $prof->setTitle($form->getInput("title"));
249 $prof->setDescription($form->getInput("description"));
250 $prof->create();
251 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
252 $ilCtrl->redirect($this, "listProfiles");
253 }
254 else
255 {
256 $form->setValuesByPost();
257 $tpl->setContent($form->getHtml());
258 }
259 }
260
264 function update()
265 {
266 global $lng, $ilCtrl, $tpl;
267
268 if (!$this->checkPermissionBool("write"))
269 {
270 return;
271 }
272
273 $form = $this->initProfileForm("edit");
274 if ($form->checkInput())
275 {
276 $this->profile->setTitle($form->getInput("title"));
277 $this->profile->setDescription($form->getInput("description"));
278 $this->profile->update();
279
280 ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
281 $ilCtrl->redirect($this, "listProfiles");
282 }
283 else
284 {
285 $form->setValuesByPost();
286 $tpl->setContent($form->getHtml());
287 }
288 }
289
294 {
295 global $ilCtrl, $tpl, $lng;
296
297 if (!is_array($_POST["id"]) || count($_POST["id"]) == 0)
298 {
299 ilUtil::sendInfo($lng->txt("no_checkbox"), true);
300 $ilCtrl->redirect($this, "listProfiles");
301 }
302 else
303 {
304 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
305 $cgui = new ilConfirmationGUI();
306 $cgui->setFormAction($ilCtrl->getFormAction($this));
307 $cgui->setHeaderText($lng->txt("skmg_delete_profiles"));
308 $cgui->setCancel($lng->txt("cancel"), "listProfiles");
309 $cgui->setConfirm($lng->txt("delete"), "deleteProfiles");
310
311 foreach ($_POST["id"] as $i)
312 {
313 $cgui->addItem("id[]", $i, ilSkillProfile::lookupTitle($i));
314 }
315
316 $tpl->setContent($cgui->getHTML());
317 }
318 }
319
323 function deleteProfiles()
324 {
325 global $ilCtrl, $tpl, $lng;
326
327 if (!$this->checkPermissionBool("write"))
328 {
329 return;
330 }
331
332 if (is_array($_POST["id"]))
333 {
334 foreach ($_POST["id"] as $i)
335 {
336 $prof = new ilSkillProfile($i);
337 $prof->delete();
338 }
339 ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
340 }
341
342 $ilCtrl->redirect($this, "listProfiles");
343 }
344
348
355 function showLevels()
356 {
357 global $tpl, $ilCtrl, $lng, $ilToolbar;
358
359 $this->setTabs("levels");
360
361 if ($this->checkPermissionBool("write"))
362 {
363 $ilToolbar->addButton($lng->txt("skmg_assign_level"),
364 $ilCtrl->getLinkTarget($this, "assignLevel")
365 );
366 }
367
368 include_once("./Services/Skill/classes/class.ilSkillProfileLevelsTableGUI.php");
369 $tab = new ilSkillProfileLevelsTableGUI($this, "showLevels", $this->profile);
370 $tpl->setContent($tab->getHTML());
371 }
372
376 function assignLevel()
377 {
378 global $lng, $ilTabs, $ilCtrl, $tpl;
379
380 $tpl->setTitle($lng->txt("skmg_profile").": ".
381 $this->profile->getTitle());
382 $tpl->setDescription("");
383
384 //$this->setTabs("levels");
385
386 ilUtil::sendInfo($lng->txt("skmg_select_skill_level_assign"));
387
388 $ilTabs->clearTargets();
389 $ilTabs->setBackTarget($lng->txt("back"),
390 $ilCtrl->getLinkTarget($this, "showLevels"));
391
392 include_once("./Services/Skill/classes/class.ilSkillSelectorGUI.php");
393 $exp = new ilSkillSelectorGUI($this, "assignLevel", $this, "assignLevelSelectSkill", "cskill_id");
394 if (!$exp->handleCommand())
395 {
396 $tpl->setContent($exp->getHTML());
397 }
398 }
399
404 {
405 global $tpl, $lng, $ilCtrl, $ilTabs;
406
407 $ilCtrl->saveParameter($this, "cskill_id");
408
409 $tpl->setTitle($lng->txt("skmg_profile").": ".
410 $this->profile->getTitle());
411 $tpl->setDescription("");
412
413 $ilTabs->clearTargets();
414 $ilTabs->setBackTarget($lng->txt("back"),
415 $ilCtrl->getLinkTarget($this, "showLevels"));
416
417 include_once("./Services/Skill/classes/class.ilSkillLevelProfileAssignmentTableGUI.php");
418 $tab = new ilSkillLevelProfileAssignmentTableGUI($this, "assignLevelSelectSkill",
419 $_GET["cskill_id"]);
420 $tpl->setContent($tab->getHTML());
421 }
422
427 {
428 global $ilCtrl, $lng;
429
430 if (!$this->checkPermissionBool("write"))
431 {
432 return;
433 }
434
435
436 $parts = explode(":", $_GET["cskill_id"]);
437
438 $this->profile->addSkillLevel((int) $parts[0],
439 (int) $parts[1], (int) $_GET["level_id"]);
440 $this->profile->update();
441
442 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
443 $ilCtrl->redirect($this, "showLevels");
444 }
445
450 {
451 global $ilCtrl, $tpl, $lng;
452
453 $this->setTabs("levels");
454
455 if (!is_array($_POST["ass_id"]) || count($_POST["ass_id"]) == 0)
456 {
457 ilUtil::sendInfo($lng->txt("no_checkbox"), true);
458 $ilCtrl->redirect($this, "showLevels");
459 }
460 else
461 {
462 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
463 $cgui = new ilConfirmationGUI();
464 $cgui->setFormAction($ilCtrl->getFormAction($this));
465 $cgui->setHeaderText($lng->txt("skmg_confirm_remove_level_ass"));
466 $cgui->setCancel($lng->txt("cancel"), "showLevels");
467 $cgui->setConfirm($lng->txt("remove"), "removeLevelAssignments");
468
469 include_once("./Services/Skill/classes/class.ilBasicSkill.php");
470 foreach ($_POST["ass_id"] as $i)
471 {
472 $id_arr = explode(":", $i);
473 $cgui->addItem("ass_id[]", $i,
474 ilBasicSkill::_lookupTitle($id_arr[0]).": ".
476 }
477
478 $tpl->setContent($cgui->getHTML());
479 }
480 }
481
489 {
490 global $ilCtrl;
491
492 if (!$this->checkPermissionBool("write"))
493 {
494 return;
495 }
496
497 if (is_array($_POST["ass_id"]))
498 {
499 foreach ($_POST["ass_id"] as $i)
500 {
501 $id_arr = explode(":", $i);
502 $this->profile->removeSkillLevel($id_arr[0], $id_arr[1], $id_arr[2]);
503 }
504 $this->profile->update();
505 }
506
507 $ilCtrl->redirect($this, "showLevels");
508 }
509
513 function showUsers()
514 {
515 global $lng, $tpl, $ilToolbar;
516
517 // add member
518 include_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
520 $this,
521 $ilToolbar,
522 array(
523 'auto_complete_name' => $lng->txt('user'),
524 'submit_name' => $lng->txt('skmg_assign_user')
525 )
526 );
527
528 $this->setTabs("users");
529
530 include_once("./Services/Skill/classes/class.ilSkillProfileUserTableGUI.php");
531 $tab = new ilSkillProfileUserTableGUI($this, "showUsers",
532 $this->profile);
533 $tpl->setContent($tab->getHTML());
534 }
535
542 function assignUser()
543 {
544 global $ilCtrl, $lng;
545
546 if (!$this->checkPermissionBool("write"))
547 {
548 return;
549 }
550
551 $user_id = ilObjUser::_lookupId(ilUtil::stripSlashes($_POST["user_login"]));
552 if ($user_id > 0)
553 {
554 $this->profile->addUserToProfile($user_id);
555 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
556 }
557
558 $ilCtrl->redirect($this, "showUsers");
559 }
560
565 {
566 global $ilCtrl, $tpl, $lng;
567
568 if (!$this->checkPermissionBool("write"))
569 {
570 return;
571 }
572
573 $this->setTabs("users");
574
575 if (!is_array($_POST["id"]) || count($_POST["id"]) == 0)
576 {
577 ilUtil::sendInfo($lng->txt("no_checkbox"), true);
578 $ilCtrl->redirect($this, "showUsers");
579 }
580 else
581 {
582 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
583 $cgui = new ilConfirmationGUI();
584 $cgui->setFormAction($ilCtrl->getFormAction($this));
585 $cgui->setHeaderText($lng->txt("skmg_confirm_user_removal"));
586 $cgui->setCancel($lng->txt("cancel"), "showUsers");
587 $cgui->setConfirm($lng->txt("remove"), "removeUsers");
588
589 foreach ($_POST["id"] as $i)
590 {
591 $name = ilObjUser::_lookupName($i);
592 $cgui->addItem("id[]", $i,
593 $name["lastname"].", ".$name["firstname"].
594 " [".$name["login"]."]");
595 }
596
597 $tpl->setContent($cgui->getHTML());
598 }
599 }
600
604 function removeUsers()
605 {
606 global $ilCtrl, $lng;
607
608 if (!$this->checkPermissionBool("write"))
609 {
610 return;
611 }
612
613 if (is_array($_POST["id"]))
614 {
615 foreach ($_POST["id"] as $i)
616 {
617 $this->profile->removeUserFromProfile((int) $i);
618 }
619 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
620 }
621 $ilCtrl->redirect($this, "showUsers");
622 }
623
630 function exportProfiles()
631 {
632 global $ilCtrl;
633
634 if (!is_array($_POST["id"]) || count($_POST["id"]) == 0)
635 {
636 $ilCtrl->redirect($this, "");
637 }
638
639 include_once("./Services/Export/classes/class.ilExport.php");
640 $exp = new ilExport();
641 $conf = $exp->getConfig("Services/Skill");
643 $conf->setSelectedProfiles($_POST["id"]);
644 $exp->exportObject("skmg", ilObject::_lookupObjId((int) $_GET["ref_id"]));
645
646 //ilExport::_createExportDirectory(0, "xml", "");
647 //$export_dir = ilExport::_getExportDirectory($a_id, "xml", $a_type);
648 //$exp->exportEntity("skprof", $_POST["id"], "", "Services/Skill", $a_title, $a_export_dir, "skprof");
649
650 $ilCtrl->redirectByClass(array("iladministrationgui", "ilobjskillmanagementgui", "ilexportgui"), "");
651 }
652
656 function showImportForm()
657 {
658 global $tpl, $ilTabs;
659
660 $tpl->setContent($this->initInputForm()->getHTML());
661 }
662
666 public function initInputForm()
667 {
668 global $lng, $ilCtrl;
669
670 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
671 $form = new ilPropertyFormGUI();
672
673 include_once("./Services/Form/classes/class.ilFileInputGUI.php");
674 $fi = new ilFileInputGUI($lng->txt("skmg_input_file"), "import_file");
675 $fi->setSuffixes(array("zip"));
676 $fi->setRequired(true);
677 $form->addItem($fi);
678
679 // save and cancel commands
680 $form->addCommandButton("importProfiles", $lng->txt("import"));
681 $form->addCommandButton("", $lng->txt("cancel"));
682
683 $form->setTitle($lng->txt("import"));
684 $form->setFormAction($ilCtrl->getFormAction($this));
685
686 return $form;
687 }
688
692 public function importProfiles()
693 {
694 global $tpl, $lng, $ilCtrl, $ilTabs;
695
696 $form = $this->initInputForm();
697 if ($form->checkInput())
698 {
699 include_once("./Services/Export/classes/class.ilImport.php");
700 $imp = new ilImport();
701 $imp->importEntity($_FILES["import_file"]["tmp_name"], $_FILES["import_file"]["name"], "skmg", "Services/Skill");
702
703 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
704 $ilCtrl->redirect($this, "");
705 }
706 else
707 {
708 $form->setValuesByPost();
709 $tpl->setContent($form->getHtml());
710 }
711 }
712
713
714}
715
716?>
global $tpl
Definition: ilias.php:8
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
static lookupLevelTitle($a_id)
Lookup level title.
Confirmation screen class.
This class represents a file property in a property form.
Import class.
static _lookupId($a_user_str)
Lookup id by login.
static _lookupName($a_user_id)
lookup user name
static _lookupObjId($a_id)
This class represents a property form user interface.
static fillAutoCompleteToolbar($parent_object, ilToolbarGUI $toolbar=null, $a_options=array(), $a_sticky=false)
fill toolbar with
TableGUI class for skill profile skill level assignment.
Skill profile GUI class.
confirmLevelAssignmentRemoval()
Confirm level assignment removal.
importProfiles()
Import profiles.
deleteProfiles()
Delete profiles.
executeCommand()
Execute command.
showImportForm()
Show import form.
save()
Save profile form.
initInputForm()
Init input form.
assignLevelToProfile()
Assign level to profile.
removeLevelAssignments()
Remove level assignment.
checkPermissionBool($a_perm)
Check permission pool.
confirmDeleteProfiles()
Confirm profile deletion.
exportProfiles()
Export profiles.
assignLevelSelectSkill()
Output level table for profile assignment.
confirmUserRemoval()
Confirm user removal.
showLevels()
Show skill levels.
initProfileForm($a_mode="edit")
Init profile form.
setTabs($a_active)
Set tabs.
TableGUI class for skill profile levels.
TableGUI class for skill profiles.
TableGUI class for skill profile user assignment.
static lookupTitle($a_id)
Lookup title.
Explorer class that works on tree objects (Services/Tree)
static _lookupTitle($a_obj_id, $a_tref_id=0)
Lookup Title.
This class represents a text area property in a property form.
This class represents a text property in a property form.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
global $ilCtrl
Definition: ilias.php:18
$ret
Definition: parser.php:6
global $lng
Definition: privfeed.php:17
$cmd
Definition: sahs_server.php:35