ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
class.ilObjSkillManagementGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26
35{
37 protected ilTabsGUI $tabs;
38 protected Factory $ui_fac;
39 protected Renderer $ui_ren;
42
49 public function __construct(
50 $a_data,
51 int $a_id,
52 bool $a_call_by_reference = true,
53 bool $a_prepare_output = true
54 ) {
55 global $DIC;
56
57 $this->ctrl = $DIC->ctrl();
58 $this->error = $DIC["ilErr"];
59 $this->access = $DIC->access();
60 $this->tabs = $DIC->tabs();
61 $this->lng = $DIC->language();
62 $this->settings = $DIC->settings();
63 $this->tpl = $DIC["tpl"];
64 $this->toolbar = $DIC->toolbar();
65 $this->user = $DIC->user();
66 $this->ui_fac = $DIC->ui()->factory();
67 $this->ui_ren = $DIC->ui()->renderer();
68 $ilCtrl = $DIC->ctrl();
69
70 $this->type = 'skmg';
71 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
72
73 $this->lng->loadLanguageModule('skmg');
74
75 $ilCtrl->saveParameter($this, "node_id");
76 $this->skill_manager = $DIC->skills()->internal()->manager();
77 $this->management_access_manager = $this->skill_manager->getManagementAccessManager($this->object->getRefId());
78 }
79
80 public function executeCommand(): void
81 {
83 $ilTabs = $this->tabs;
84
85 $next_class = $this->ctrl->getNextClass($this);
86 $cmd = $this->ctrl->getCmd();
87
88 if (!$this->management_access_manager->hasReadManagementPermission()) {
89 $ilErr->raiseError($this->lng->txt('no_permission'), $ilErr->WARNING);
90 }
91
92 switch ($next_class) {
93 case "ilskilltreeadmingui":
94 $this->prepareOutput();
95 $ilTabs->activateTab("skill_trees");
96 $gui = new ilSkillTreeAdminGUI($this->skill_manager);
97 $this->ctrl->forwardCommand($gui);
98 break;
99
100 case 'ilpermissiongui':
101 $this->prepareOutput();
102 $this->tabs_gui->activateTab('permissions');
103 $perm_gui = new ilPermissionGUI($this);
104 $ret = $this->ctrl->forwardCommand($perm_gui);
105 break;
106
107 default:
108 $this->prepareOutput();
109 if (!$cmd || $cmd == 'view') {
110 $cmd = "listTrees";
111 }
112
113 $this->$cmd();
114
115 break;
116 }
117 }
118
119 public function getAdminTabs(): void
120 {
121 $ilAccess = $this->access;
123
124 if ($this->management_access_manager->hasReadManagementPermission()) {
125 $this->tabs_gui->addTab(
126 "skill_trees",
127 $lng->txt("skmg_skill_trees"),
128 $this->ctrl->getLinkTargetByClass("ilskilltreeadmingui", "")
129 );
130
131 $this->tabs_gui->addTab(
132 "settings",
133 $lng->txt("settings"),
134 $this->ctrl->getLinkTarget($this, "editSettings")
135 );
136 }
137
138 if ($this->management_access_manager->hasEditManagementPermissionsPermission()) {
139 $this->tabs_gui->addTab(
140 "permissions",
141 $lng->txt("perm_settings"),
142 $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm")
143 );
144 }
145 }
146
147 public function editSettings(): void
148 {
149 $ilCtrl = $this->ctrl;
151 $ilTabs = $this->tabs;
152
153 $ilTabs->activateTab("settings");
154
155 $skmg_set = new ilSkillManagementSettings();
156
157 // Enable skill management
158 $check_enable = $this->ui_fac->input()->field()->checkbox($lng->txt("skmg_enable_skmg"))
159 ->withValue($skmg_set->isActivated());
160
161 // Hide Competence Profile Data before Self-Assessment
162 $check_hide_prof = $this->ui_fac->input()->field()->checkbox(
163 $lng->txt("skmg_hide_profile_self_eval"),
164 $lng->txt("skmg_hide_profile_self_eval_info")
165 )->withValue($skmg_set->getHideProfileBeforeSelfEval());
166
167 // Allow local assignment of global profiles
168 $check_loc_ass_prof = $this->ui_fac->input()->field()->checkbox($lng->txt("skmg_local_assignment_profiles"))
169 ->withValue($skmg_set->getLocalAssignmentOfProfiles());
170
171 // Allow creation of local profiles
172 $check_create_loc_prof = $this->ui_fac->input()->field()->checkbox(
173 $lng->txt("skmg_allow_local_profiles"),
174 $lng->txt("skmg_allow_local_profiles_info")
175 )->withValue($skmg_set->getAllowLocalProfiles());
176
177 //section
178 $section_settings = $this->ui_fac->input()->field()->section(
179 ["check_enable" => $check_enable,
180 "check_hide_prof" => $check_hide_prof,
181 "check_loc_ass_prof" => $check_loc_ass_prof,
182 "check_create_loc_prof" => $check_create_loc_prof],
183 $lng->txt("skmg_settings")
184 );
185
186 // form and form action handling
187 $ilCtrl->setParameterByClass(
188 'ilobjskillmanagementgui',
189 'skill_settings',
190 'skill_settings_config'
191 );
192
193 $form = $this->ui_fac->input()->container()->form()->standard(
194 $ilCtrl->getFormAction($this, "editSettings"),
195 ["section_settings" => $section_settings]
196 );
197
198 if ($this->request->getMethod() == "POST"
199 && $this->request->getQueryParams()["skill_settings"] == "skill_settings_config") {
200 if (!$this->management_access_manager->hasEditManagementSettingsPermission()) {
201 $this->tpl->setOnScreenMessage(
202 GlobalTemplate::MESSAGE_TYPE_FAILURE,
203 $this->lng->txt("no_permission"),
204 true
205 );
206 $this->tpl->setContent($this->ui_ren->render([$form]));
207 return;
208 }
209
210 $form = $form->withRequest($this->request);
211 $result = $form->getData();
212
213 $skmg_set->activate($result["section_settings"]["check_enable"]);
214 $skmg_set->setHideProfileBeforeSelfEval($result["section_settings"]["check_hide_prof"]);
215 $skmg_set->setLocalAssignmentOfProfiles($result["section_settings"]["check_loc_ass_prof"]);
216 $skmg_set->setAllowLocalProfiles($result["section_settings"]["check_create_loc_prof"]);
217
218 $this->tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"), true);
219 $ilCtrl->redirect($this, "editSettings");
220 }
221
222 $this->tpl->setContent($this->ui_ren->render([$form]));
223 }
224
225 public function listTrees(): void
226 {
227 $this->ctrl->clearParameterByClass(get_class($this), "node_id");
228 $this->ctrl->redirectByClass("ilskilltreeadmingui", "listTrees");
229 }
230}
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