ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilObjSkillManagementGUI.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
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;
122  $lng = $this->lng;
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;
150  $lng = $this->lng;
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  return;
202  }
203 
204  $form = $form->withRequest($this->request);
205  $result = $form->getData();
206 
207  $skmg_set->activate($result["section_settings"]["check_enable"]);
208  $skmg_set->setHideProfileBeforeSelfEval($result["section_settings"]["check_hide_prof"]);
209  $skmg_set->setLocalAssignmentOfProfiles($result["section_settings"]["check_loc_ass_prof"]);
210  $skmg_set->setAllowLocalProfiles($result["section_settings"]["check_create_loc_prof"]);
211 
212  $this->tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"), true);
213  $ilCtrl->redirect($this, "editSettings");
214  }
215 
216  $this->tpl->setContent($this->ui_ren->render([$form]));
217  }
218 
219  public function listTrees(): void
220  {
221  $this->ctrl->clearParameterByClass(get_class($this), "node_id");
222  $this->ctrl->redirectByClass("ilskilltreeadmingui", "listTrees");
223  }
224 }
__construct( $a_data, int $a_id, bool $a_call_by_reference=true, bool $a_prepare_output=true)
Skill tree administration.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
prepareOutput(bool $show_sub_objects=true)
SkillManagementAccess $management_access_manager
SkillInternalManagerService $skill_manager
$ilErr
Definition: raiseError.php:17
ilLanguage $lng
This is how the factory for UI elements looks.
Definition: Factory.php:37
Class ilObjectGUI Basic methods of all Output classes.
global $DIC
Definition: shib_login.php:25
withValue($value)
Get an input like this with another value displayed on the client side.
Definition: Group.php:59
activateTab(string $a_id)
__construct(Container $dic, ilPlugin $plugin)
ilAccessHandler $access
Skill management main GUI class.