ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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")))
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
149 include_once("./Services/Skill/classes/class.ilSkillProfileTableGUI.php");
150 $tab = new ilSkillProfileTableGUI($this, "listProfiles");
151
152 $tpl->setContent($tab->getHTML());
153 }
154
158 function create()
159 {
160 global $tpl;
161
162 $form = $this->initProfileForm("create");
163 $tpl->setContent($form->getHTML());
164 }
165
169 function edit()
170 {
171 global $tpl;
172
173 $this->setTabs("settings");
174 $form = $this->initProfileForm("edit");
175 $tpl->setContent($form->getHTML());
176 }
177
178
184 public function initProfileForm($a_mode = "edit")
185 {
186 global $lng, $ilCtrl;
187
188 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
189 $form = new ilPropertyFormGUI();
190
191 // title
192 $ti = new ilTextInputGUI($lng->txt("title"), "title");
193 $ti->setMaxLength(200);
194 $ti->setSize(40);
195 $ti->setRequired(true);
196 $form->addItem($ti);
197
198 // description
199 $desc = new ilTextAreaInputGUI($lng->txt("description"), "description");
200 $desc->setCols(40);
201 $desc->setRows(4);
202 $form->addItem($desc);
203
204 // save and cancel commands
205 if ($this->checkPermissionBool("write"))
206 {
207 if ($a_mode == "create")
208 {
209 $form->addCommandButton("save", $lng->txt("save"));
210 $form->addCommandButton("listProfiles", $lng->txt("cancel"));
211 $form->setTitle($lng->txt("skmg_add_profile"));
212 } else
213 {
214 // set values
215 $ti->setValue($this->profile->getTitle());
216 $desc->setValue($this->profile->getDescription());
217
218 $form->addCommandButton("update", $lng->txt("save"));
219 $form->addCommandButton("listProfiles", $lng->txt("cancel"));
220 $form->setTitle($lng->txt("skmg_edit_profile"));
221 }
222 }
223
224 $form->setFormAction($ilCtrl->getFormAction($this));
225
226 return $form;
227 }
228
232 public function save()
233 {
234 global $tpl, $lng, $ilCtrl;
235
236 if (!$this->checkPermissionBool("write"))
237 {
238 return;
239 }
240
241 $form = $this->initProfileForm("create");
242 if ($form->checkInput())
243 {
244 $prof = new ilSkillProfile();
245 $prof->setTitle($form->getInput("title"));
246 $prof->setDescription($form->getInput("description"));
247 $prof->create();
248 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
249 $ilCtrl->redirect($this, "listProfiles");
250 }
251 else
252 {
253 $form->setValuesByPost();
254 $tpl->setContent($form->getHtml());
255 }
256 }
257
261 function update()
262 {
263 global $lng, $ilCtrl, $tpl;
264
265 if (!$this->checkPermissionBool("write"))
266 {
267 return;
268 }
269
270 $form = $this->initProfileForm("edit");
271 if ($form->checkInput())
272 {
273 $this->profile->setTitle($form->getInput("title"));
274 $this->profile->setDescription($form->getInput("description"));
275 $this->profile->update();
276
277 ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
278 $ilCtrl->redirect($this, "listProfiles");
279 }
280 else
281 {
282 $form->setValuesByPost();
283 $tpl->setContent($form->getHtml());
284 }
285 }
286
291 {
292 global $ilCtrl, $tpl, $lng;
293
294 if (!is_array($_POST["id"]) || count($_POST["id"]) == 0)
295 {
296 ilUtil::sendInfo($lng->txt("no_checkbox"), true);
297 $ilCtrl->redirect($this, "listProfiles");
298 }
299 else
300 {
301 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
302 $cgui = new ilConfirmationGUI();
303 $cgui->setFormAction($ilCtrl->getFormAction($this));
304 $cgui->setHeaderText($lng->txt("skmg_delete_profiles"));
305 $cgui->setCancel($lng->txt("cancel"), "listProfiles");
306 $cgui->setConfirm($lng->txt("delete"), "deleteProfiles");
307
308 foreach ($_POST["id"] as $i)
309 {
310 $cgui->addItem("id[]", $i, ilSkillProfile::lookupTitle($i));
311 }
312
313 $tpl->setContent($cgui->getHTML());
314 }
315 }
316
320 function deleteProfiles()
321 {
322 global $ilCtrl, $tpl, $lng;
323
324 if (!$this->checkPermissionBool("write"))
325 {
326 return;
327 }
328
329 if (is_array($_POST["id"]))
330 {
331 foreach ($_POST["id"] as $i)
332 {
333 $prof = new ilSkillProfile($i);
334 $prof->delete();
335 }
336 ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
337 }
338
339 $ilCtrl->redirect($this, "listProfiles");
340 }
341
345
352 function showLevels()
353 {
354 global $tpl, $ilCtrl, $lng, $ilToolbar;
355
356 $this->setTabs("levels");
357
358 if ($this->checkPermissionBool("write"))
359 {
360 $ilToolbar->addButton($lng->txt("skmg_assign_level"),
361 $ilCtrl->getLinkTarget($this, "assignLevel")
362 );
363 }
364
365 include_once("./Services/Skill/classes/class.ilSkillProfileLevelsTableGUI.php");
366 $tab = new ilSkillProfileLevelsTableGUI($this, "showLevels", $this->profile);
367 $tpl->setContent($tab->getHTML());
368 }
369
373 function assignLevel()
374 {
375 global $lng, $ilTabs, $ilCtrl, $tpl;
376
377 $tpl->setTitle($lng->txt("skmg_profile").": ".
378 $this->profile->getTitle());
379 $tpl->setDescription("");
380
381 //$this->setTabs("levels");
382
383 ilUtil::sendInfo($lng->txt("skmg_select_skill_level_assign"));
384
385 $ilTabs->clearTargets();
386 $ilTabs->setBackTarget($lng->txt("back"),
387 $ilCtrl->getLinkTarget($this, "showLevels"));
388
389 include_once("./Services/Skill/classes/class.ilSkillSelectorGUI.php");
390 $exp = new ilSkillSelectorGUI($this, "assignLevel", $this, "assignLevelSelectSkill", "cskill_id");
391 if (!$exp->handleCommand())
392 {
393 $tpl->setContent($exp->getHTML());
394 }
395 }
396
401 {
402 global $tpl, $lng, $ilCtrl, $ilTabs;
403
404 $ilCtrl->saveParameter($this, "cskill_id");
405
406 $tpl->setTitle($lng->txt("skmg_profile").": ".
407 $this->profile->getTitle());
408 $tpl->setDescription("");
409
410 $ilTabs->clearTargets();
411 $ilTabs->setBackTarget($lng->txt("back"),
412 $ilCtrl->getLinkTarget($this, "showLevels"));
413
414 include_once("./Services/Skill/classes/class.ilSkillLevelProfileAssignmentTableGUI.php");
415 $tab = new ilSkillLevelProfileAssignmentTableGUI($this, "assignLevelSelectSkill",
416 $_GET["cskill_id"]);
417 $tpl->setContent($tab->getHTML());
418 }
419
424 {
425 global $ilCtrl, $lng;
426
427 if (!$this->checkPermissionBool("write"))
428 {
429 return;
430 }
431
432
433 $parts = explode(":", $_GET["cskill_id"]);
434
435 $this->profile->addSkillLevel((int) $parts[0],
436 (int) $parts[1], (int) $_GET["level_id"]);
437 $this->profile->update();
438
439 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
440 $ilCtrl->redirect($this, "showLevels");
441 }
442
447 {
448 global $ilCtrl, $tpl, $lng;
449
450 $this->setTabs("levels");
451
452 if (!is_array($_POST["ass_id"]) || count($_POST["ass_id"]) == 0)
453 {
454 ilUtil::sendInfo($lng->txt("no_checkbox"), true);
455 $ilCtrl->redirect($this, "showLevels");
456 }
457 else
458 {
459 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
460 $cgui = new ilConfirmationGUI();
461 $cgui->setFormAction($ilCtrl->getFormAction($this));
462 $cgui->setHeaderText($lng->txt("skmg_confirm_remove_level_ass"));
463 $cgui->setCancel($lng->txt("cancel"), "showLevels");
464 $cgui->setConfirm($lng->txt("remove"), "removeLevelAssignments");
465
466 include_once("./Services/Skill/classes/class.ilBasicSkill.php");
467 foreach ($_POST["ass_id"] as $i)
468 {
469 $id_arr = explode(":", $i);
470 $cgui->addItem("ass_id[]", $i,
471 ilBasicSkill::_lookupTitle($id_arr[0]).": ".
473 }
474
475 $tpl->setContent($cgui->getHTML());
476 }
477 }
478
486 {
487 global $ilCtrl;
488
489 if (!$this->checkPermissionBool("write"))
490 {
491 return;
492 }
493
494 if (is_array($_POST["ass_id"]))
495 {
496 foreach ($_POST["ass_id"] as $i)
497 {
498 $id_arr = explode(":", $i);
499 $this->profile->removeSkillLevel($id_arr[0], $id_arr[1], $id_arr[2]);
500 }
501 $this->profile->update();
502 }
503
504 $ilCtrl->redirect($this, "showLevels");
505 }
506
510 function showUsers()
511 {
512 global $lng, $tpl, $ilToolbar;
513
514 // add member
515 include_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
517 $this,
518 $ilToolbar,
519 array(
520 'auto_complete_name' => $lng->txt('user'),
521 'submit_name' => $lng->txt('skmg_assign_user')
522 )
523 );
524
525 $this->setTabs("users");
526
527 include_once("./Services/Skill/classes/class.ilSkillProfileUserTableGUI.php");
528 $tab = new ilSkillProfileUserTableGUI($this, "showUsers",
529 $this->profile);
530 $tpl->setContent($tab->getHTML());
531 }
532
539 function assignUser()
540 {
541 global $ilCtrl, $lng;
542
543 if (!$this->checkPermissionBool("write"))
544 {
545 return;
546 }
547
548 $user_id = ilObjUser::_lookupId(ilUtil::stripSlashes($_POST["user_login"]));
549 if ($user_id > 0)
550 {
551 $this->profile->addUserToProfile($user_id);
552 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
553 }
554
555 $ilCtrl->redirect($this, "showUsers");
556 }
557
562 {
563 global $ilCtrl, $tpl, $lng;
564
565 if (!$this->checkPermissionBool("write"))
566 {
567 return;
568 }
569
570 $this->setTabs("users");
571
572 if (!is_array($_POST["id"]) || count($_POST["id"]) == 0)
573 {
574 ilUtil::sendInfo($lng->txt("no_checkbox"), true);
575 $ilCtrl->redirect($this, "showUsers");
576 }
577 else
578 {
579 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
580 $cgui = new ilConfirmationGUI();
581 $cgui->setFormAction($ilCtrl->getFormAction($this));
582 $cgui->setHeaderText($lng->txt("skmg_confirm_user_removal"));
583 $cgui->setCancel($lng->txt("cancel"), "showUsers");
584 $cgui->setConfirm($lng->txt("remove"), "removeUsers");
585
586 foreach ($_POST["id"] as $i)
587 {
588 $name = ilObjUser::_lookupName($i);
589 $cgui->addItem("id[]", $i,
590 $name["lastname"].", ".$name["firstname"].
591 " [".$name["login"]."]");
592 }
593
594 $tpl->setContent($cgui->getHTML());
595 }
596 }
597
601 function removeUsers()
602 {
603 global $ilCtrl, $lng;
604
605 if (!$this->checkPermissionBool("write"))
606 {
607 return;
608 }
609
610 if (is_array($_POST["id"]))
611 {
612 foreach ($_POST["id"] as $i)
613 {
614 $this->profile->removeUserFromProfile((int) $i);
615 }
616 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
617 }
618 $ilCtrl->redirect($this, "showUsers");
619 }
620}
621
622?>
global $tpl
Definition: ilias.php:8
$_GET["client_id"]
static lookupLevelTitle($a_id)
Lookup level title.
Confirmation screen class.
static _lookupId($a_user_str)
Lookup id by login.
static _lookupName($a_user_id)
lookup user name
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.
deleteProfiles()
Delete profiles.
executeCommand()
Execute command.
save()
Save profile form.
assignLevelToProfile()
Assign level to profile.
removeLevelAssignments()
Remove level assignment.
checkPermissionBool($a_perm)
Check permission pool.
confirmDeleteProfiles()
Confirm profile deletion.
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.
$_POST['username']
Definition: cron.php:12
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
$cmd
Definition: sahs_server.php:35