ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjSkillManagementGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25
34{
36 protected ilTabsGUI $tabs;
37 protected Factory $ui_fac;
38 protected Renderer $ui_ren;
41
48 public function __construct(
49 $a_data,
50 int $a_id,
51 bool $a_call_by_reference = true,
52 bool $a_prepare_output = true
53 ) {
54 global $DIC;
55
56 $this->ctrl = $DIC->ctrl();
57 $this->error = $DIC["ilErr"];
58 $this->access = $DIC->access();
59 $this->tabs = $DIC->tabs();
60 $this->lng = $DIC->language();
61 $this->settings = $DIC->settings();
62 $this->tpl = $DIC["tpl"];
63 $this->toolbar = $DIC->toolbar();
64 $this->user = $DIC->user();
65 $this->ui_fac = $DIC->ui()->factory();
66 $this->ui_ren = $DIC->ui()->renderer();
67 $ilCtrl = $DIC->ctrl();
68
69 $this->type = 'skmg';
70 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
71
72 $this->lng->loadLanguageModule('skmg');
73
74 $ilCtrl->saveParameter($this, "node_id");
75 $this->skill_manager = $DIC->skills()->internal()->manager();
76 $this->management_access_manager = $this->skill_manager->getManagementAccessManager($this->object->getRefId());
77 }
78
79 public function executeCommand(): void
80 {
82 $ilTabs = $this->tabs;
83
84 $next_class = $this->ctrl->getNextClass($this);
85 $cmd = $this->ctrl->getCmd();
86
87 if (!$this->management_access_manager->hasReadManagementPermission()) {
88 $ilErr->raiseError($this->lng->txt('no_permission'), $ilErr->WARNING);
89 }
90
91 switch ($next_class) {
92 case "ilskilltreeadmingui":
93 $this->prepareOutput();
94 $ilTabs->activateTab("skill_trees");
95 $gui = new ilSkillTreeAdminGUI($this->skill_manager);
96 $this->ctrl->forwardCommand($gui);
97 break;
98
99 case 'ilpermissiongui':
100 $this->prepareOutput();
101 $this->tabs_gui->activateTab('permissions');
102 $perm_gui = new ilPermissionGUI($this);
103 $ret = $this->ctrl->forwardCommand($perm_gui);
104 break;
105
106 default:
107 $this->prepareOutput();
108 if (!$cmd || $cmd == 'view') {
109 $cmd = "listTrees";
110 }
111
112 $this->$cmd();
113
114 break;
115 }
116 }
117
118 public function getAdminTabs(): void
119 {
120 $ilAccess = $this->access;
122
123 if ($this->management_access_manager->hasReadManagementPermission()) {
124 $this->tabs_gui->addTab(
125 "skill_trees",
126 $lng->txt("skmg_skill_trees"),
127 $this->ctrl->getLinkTargetByClass("ilskilltreeadmingui", "")
128 );
129
130 $this->tabs_gui->addTab(
131 "settings",
132 $lng->txt("settings"),
133 $this->ctrl->getLinkTarget($this, "editSettings")
134 );
135 }
136
137 if ($this->management_access_manager->hasEditManagementPermissionsPermission()) {
138 $this->tabs_gui->addTab(
139 "permissions",
140 $lng->txt("perm_settings"),
141 $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm")
142 );
143 }
144 }
145
146 public function editSettings(): void
147 {
148 $ilCtrl = $this->ctrl;
150 $ilTabs = $this->tabs;
151
152 $ilTabs->activateTab("settings");
153
154 $skmg_set = new ilSkillManagementSettings();
155
156 // Enable skill management
157 $check_enable = $this->ui_fac->input()->field()->checkbox($lng->txt("skmg_enable_skmg"))
158 ->withValue($skmg_set->isActivated());
159
160 // Hide Competence Profile Data before Self-Assessment
161 $check_hide_prof = $this->ui_fac->input()->field()->checkbox(
162 $lng->txt("skmg_hide_profile_self_eval"),
163 $lng->txt("skmg_hide_profile_self_eval_info")
164 )->withValue($skmg_set->getHideProfileBeforeSelfEval());
165
166 // Allow local assignment of global profiles
167 $check_loc_ass_prof = $this->ui_fac->input()->field()->checkbox($lng->txt("skmg_local_assignment_profiles"))
168 ->withValue($skmg_set->getLocalAssignmentOfProfiles());
169
170 // Allow creation of local profiles
171 $check_create_loc_prof = $this->ui_fac->input()->field()->checkbox(
172 $lng->txt("skmg_allow_local_profiles"),
173 $lng->txt("skmg_allow_local_profiles_info")
174 )->withValue($skmg_set->getAllowLocalProfiles());
175
176 //section
177 $section_settings = $this->ui_fac->input()->field()->section(
178 ["check_enable" => $check_enable,
179 "check_hide_prof" => $check_hide_prof,
180 "check_loc_ass_prof" => $check_loc_ass_prof,
181 "check_create_loc_prof" => $check_create_loc_prof],
182 $lng->txt("skmg_settings")
183 );
184
185 // form and form action handling
186 $ilCtrl->setParameterByClass(
187 'ilobjskillmanagementgui',
188 'skill_settings',
189 'skill_settings_config'
190 );
191
192 $form = $this->ui_fac->input()->container()->form()->standard(
193 $ilCtrl->getFormAction($this, "editSettings"),
194 ["section_settings" => $section_settings]
195 );
196
197 if ($this->request->getMethod() == "POST"
198 && $this->request->getQueryParams()["skill_settings"] == "skill_settings_config") {
199 if (!$this->management_access_manager->hasEditManagementSettingsPermission()) {
200 return;
201 }
202
203 $form = $form->withRequest($this->request);
204 $result = $form->getData();
205
206 $skmg_set->activate($result["section_settings"]["check_enable"]);
207 $skmg_set->setHideProfileBeforeSelfEval($result["section_settings"]["check_hide_prof"]);
208 $skmg_set->setLocalAssignmentOfProfiles($result["section_settings"]["check_loc_ass_prof"]);
209 $skmg_set->setAllowLocalProfiles($result["section_settings"]["check_create_loc_prof"]);
210
211 $this->tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"), true);
212 $ilCtrl->redirect($this, "editSettings");
213 }
214
215 $this->tpl->setContent($this->ui_ren->render([$form]));
216 }
217
218 public function listTrees(): void
219 {
220 $this->ctrl->clearParameterByClass(get_class($this), "node_id");
221 $this->ctrl->redirectByClass("ilskilltreeadmingui", "listTrees");
222 }
223}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
error(string $a_errmsg)
Error Handling & global info handling.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
Skill management main GUI class.
getAdminTabs()
administration tabs show only permissions and trash folder
SkillInternalManagerService $skill_manager
SkillManagementAccess $management_access_manager
__construct( $a_data, int $a_id, bool $a_call_by_reference=true, bool $a_prepare_output=true)
Class ilObjectGUI Basic methods of all Output classes.
ilAccessHandler $access
prepareOutput(bool $show_sub_objects=true)
ilLanguage $lng
Skill tree administration.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
activateTab(string $a_id)
This is how the factory for UI elements looks.
Definition: Factory.php:38
An entity that renders components to a string output.
Definition: Renderer.php:31
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ilErr
Definition: raiseError.php:33
global $DIC
Definition: shib_login.php:26