ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilObjStudyProgrammeSettingsGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
5/* Copyright (c) 2015 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
6/* Copyright (c) 2020 Stefan Hecken <stefan.hecken@concepts-and-training.de> Extended GPL, see docs/LICENSE */
7
8use GuzzleHttp\Psr7\ServerRequest;
12
18{
19 const TAB_SETTINGS = 'settings';
20 const TAB_COMMON_SETTINGS = 'commonSettings';
21
22 const PROP_TITLE = "title";
23 const PROP_DESC = "desc";
24 const PROP_DEADLINE = "deadline";
25 const PROP_VALIDITY_OF_QUALIFICATION = "validity_qualification";
26 const PROP_ACCESS_CONTROL_BY_ORGU_POSITION = "access_ctr_by_orgu_position";
27
28 const OPT_NO_DEADLINE = 'opt_no_deadline';
29 const OPT_DEADLINE_PERIOD = "opt_deadline_period";
30 const OPT_DEADLINE_DATE = "opt_deadline_date";
31
32 const OPT_NO_VALIDITY_OF_QUALIFICATION = 'opt_no_validity_qualification';
33 const OPT_VALIDITY_OF_QUALIFICATION_PERIOD = "opt_validity_qualification_period";
34 const OPT_VALIDITY_OF_QUALIFICATION_DATE = "opt_validity_qualification_date";
35
36
40 public $ctrl;
41
45 public $tpl;
46
50 public $object;
51
55 public $lng;
56
60 protected $tmp_heading;
61
65 protected $input_factory;
66
70 protected $renderer;
71
75 protected $request;
76
81
85 protected $ref_id;
86
90 protected $data_factory;
91
96
101
105 protected $tabs;
106
107 public function __construct(
113 ServerRequest $request,
119 ) {
120 $this->tpl = $tpl;
121 $this->ctrl = $ilCtrl;
122 $this->lng = $lng;
123 $this->input_factory = $input_factory;
124 $this->renderer = $renderer;
125 $this->request = $request;
126 $this->refinery_factory = $refinery_factory;
127 $this->data_factory = $data_factory;
128 $this->type_repository = $type_repository;
129 $this->object = null;
130 $this->common_settings_gui = $common_settings_gui;
131 $this->tabs = $tabs;
132
133 $lng->loadLanguageModule("prg");
134 }
135
136 public function setRefId($a_ref_id)
137 {
138 $this->ref_id = $a_ref_id;
139 }
140
141 public function executeCommand()
142 {
143 $next_class = $this->ctrl->getNextClass();
144 switch ($next_class) {
145 case 'ilstudyprogrammecommonsettingsgui':
146 $this->tabs->activateSubTab(self::TAB_COMMON_SETTINGS);
147 $this->common_settings_gui->setObject($this->getObject());
148 $content = $this->ctrl->forwardCommand($this->common_settings_gui);
149 break;
150 default:
151 $cmd = $this->ctrl->getCmd();
152 if ($cmd == "") {
153 $cmd = "view";
154 }
155 switch ($cmd) {
156 case "view":
157 $content = $this->view();
158 break;
159 case "update":
160 $content = $this->$cmd();
161 break;
162 default:
163 throw new ilException(
164 "ilObjStudyProgrammeSettingsGUI: " . "Command not supported: $cmd"
165 );
166 }
167 }
168
169 if (!$this->ctrl->isAsynch()) {
170 $this->tpl->setContent($content);
171 } else {
172 $output_handler = new ilAsyncOutputHandler();
173 $heading = $this->lng->txt("prg_async_" . $this->ctrl->getCmd());
174 if (isset($this->tmp_heading)) {
175 $heading = $this->tmp_heading;
176 }
177 $output_handler->setHeading($heading);
178 $output_handler->setContent($content);
179 $output_handler->terminate();
180 }
181 }
182
183 protected function view()
184 {
185 $this->buildModalHeading($this->lng->txt('prg_async_settings'), isset($_GET["currentNode"]));
186
187 $form = $this->buildForm($this->getObject(), $this->ctrl->getFormAction($this, "update"));
188 return $this->renderer->render($form);
189 }
190
191 protected function update()
192 {
193 $form = $this
194 ->buildForm($this->getObject(), $this->ctrl->getFormAction($this, "update"))
195 ->withRequest($this->request);
196
197 $result = $form->getInputGroup()->getContent();
198
199 // This could further improved by providing a new container for asynch-forms in the
200 // UI-Framework.
201
202 if ($result->isOK()) {
203 $result->value()->update();
204 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
205
206 if ($this->ctrl->isAsynch()) {
208 array(
209 "success" => true,
210 "message" => $this->lng->txt("msg_obj_modified"))
211 );
212 return ilAsyncOutputHandler::handleAsyncOutput($form->getHTML(), $response, false);
213 } else {
214 $this->ctrl->redirect($this);
215 }
216 } else {
217 ilUtil::sendFailure($this->lng->txt("msg_form_save_error"));
218
219 if ($this->ctrl->isAsynch()) {
221 array(
222 "success" => false,
223 "errors" => $form->getErrors())
224 );
225 return ilAsyncOutputHandler::handleAsyncOutput($form->getHTML(), $response, false);
226 } else {
227 return $this->renderer->render($form);
228 }
229 }
230 }
231
232 protected function buildModalHeading($label, $current_node)
233 {
234 if (!$current_node) {
235 $this->ctrl->saveParameterByClass('ilobjstudyprogrammesettingsgui', 'ref_id');
236 $heading_button = ilLinkButton::getInstance();
237 $heading_button->setCaption('prg_open_node');
238 $heading_button->setUrl(
239 $this->ctrl->getLinkTargetByClass(
240 'ilobjstudyprogrammetreegui',
241 'view'
242 )
243 );
244
245 $heading =
246 "<div class=''>" .
247 $label .
248 "<div class='pull-right'>" .
249 $heading_button->render() .
250 "</div></div>"
251 ;
252 $this->tmp_heading = $heading;
253 } else {
254 $this->tmp_heading = "<div class=''>" . $label . "</div>";
255 }
256 }
257
258 protected function buildForm(
260 string $submit_action
261 ) : ILIAS\UI\Component\Input\Container\Form\Form {
262 $trans = $prg->getObjectTranslation();
263 $ff = $this->input_factory->field();
264 $sp_types = $this->type_repository->readAllTypesArray();
265
266 return $this->input_factory->container()->form()->standard(
267 $submit_action,
268 $this->buildFormElements(
269 $ff,
270 $trans,
271 $sp_types,
272 $prg
273 )
274 )->withAdditionalTransformation(
275 $this->refinery_factory->custom()->transformation(
276 function ($values) use ($prg) {
277 // to the section they originated from.
278 $object_data = $values[0];
279 $prg->setTitle($object_data[self::PROP_TITLE]);
280 $prg->setDescription($object_data[self::PROP_DESC]);
281
282 $type_settings = $values['prg_type'];
283 $type = $type_settings->getTypeId();
284 if ($prg->getTypeSettings()->getTypeId() != $type) {
285 $prg->setTypeSettings($type_settings);
286 $prg->updateCustomIcon();
287 }
288
289 $prg->setAssessmentSettings($values['prg_assessment']);
290 $prg->setDeadlineSettings($values['prg_deadline']);
292 $values['prg_validity_of_qualification']
293 );
294
295 $prg->setAutoMailSettings($values["automail_settings"]);
296
297 return $prg;
298 }
299 )
300 );
301 }
302
303 protected function buildFormElements(
304 InputFieldFactory $ff,
305 ilObjectTranslation $trans,
306 array $sp_types,
308 ) : array {
309 global $DIC;
310 $ilLng = $DIC->language();
311 $refinery = $DIC["refinery"];
312
313 $return = [
314 $this->getEditSection($ff, $trans),
315 "prg_type" => $prg
317 ->toFormInput($ff, $ilLng, $refinery, $sp_types)
318 ,
319 "prg_assessment" => $prg
321 ->toFormInput($ff, $ilLng, $refinery)
322 ,
323 "prg_deadline" => $prg
325 ->toFormInput($ff, $ilLng, $refinery, $this->data_factory)
326 ,
327 "prg_validity_of_qualification" => $prg
329 ->toFormInput($ff, $ilLng, $refinery, $this->data_factory)
330 ,
331 "automail_settings" => $prg
333 ->toFormInput($ff, $ilLng, $refinery)
334 ];
335
336 return $return;
337 }
338
339 protected function getEditSection(
340 InputFieldFactory $ff,
342 ) {
343 $languages = ilMDLanguageItem::_getLanguages();
344 return $ff->section(
345 [
346 self::PROP_TITLE =>
347 $ff->text($this->txt("title"))
348 ->withValue($trans->getDefaultTitle())
349 ->withRequired(true),
350 self::PROP_DESC =>
351 $ff->textarea($this->txt("description"))
352 ->withValue($trans->getDefaultDescription() ?? "")
353 ],
354 $this->txt("prg_edit"),
355 $this->txt("language") . ": " . $languages[$trans->getDefaultLanguage()] .
356 ' <a href="' . $this->ctrl->getLinkTargetByClass("ilobjecttranslationgui", "") .
357 '">&raquo; ' . $this->txt("obj_more_translations") . '</a>'
358 );
359 }
360
361 protected function getObject() : ilObjStudyProgramme
362 {
363 if ($this->object === null) {
364 $this->object = ilObjStudyProgramme::getInstanceByRefId($this->ref_id);
365 }
366 return $this->object;
367 }
368
369 protected function txt(string $code) : string
370 {
371 return $this->lng->txt($code);
372 }
373}
$result
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
Builds data types.
Definition: Factory.php:20
Class ilAsyncOutputHandler Handles the output for async-requests.
static handleAsyncOutput($normal_content, $async_content=null, $apply_to_tpl=true)
Handles async output.
static encodeAsyncResponse(array $data=array())
Encode data as json for async output.
This class provides processing control methods.
Base class for ILIAS Exception handling.
language handling
static getInstance()
Factory.
@ilCtrl_Calls ilObjStudyProgrammeSettingsGUI: ilStudyProgrammeCommonSettingsGUI
__construct(\ilGlobalTemplateInterface $tpl, \ilCtrl $ilCtrl, \ilLanguage $lng, Factory $input_factory, Renderer $renderer, ServerRequest $request, \ILIAS\Refinery\Factory $refinery_factory, \ILIAS\Data\Factory $data_factory, ilStudyProgrammeTypeRepository $type_repository, ilStudyProgrammeCommonSettingsGUI $common_settings_gui, ilTabsGUI $tabs)
buildFormElements(InputFieldFactory $ff, ilObjectTranslation $trans, array $sp_types, ilObjStudyProgramme $prg)
buildForm(\ilObjStudyProgramme $prg, string $submit_action)
getEditSection(InputFieldFactory $ff, ilObjectTranslation $trans)
setValidityOfQualificationSettings(\ilStudyProgrammeValidityOfAchievedQualificationSettings $validity_of_qualification_settings)
setAssessmentSettings(\ilStudyProgrammeAssessmentSettings $assessment_settings)
setAutoMailSettings(\ilStudyProgrammeAutoMailSettings $automail_settings)
static getInstanceByRefId($a_ref_id)
setDeadlineSettings(\ilStudyProgrammeDeadlineSettings $deadline_settings)
Class handles translation mode for an object.
getDefaultTitle()
Get default title.
getDefaultDescription()
Get default description.
getDefaultLanguage()
Get default language.
setTitle($a_title)
set object title
setDescription($a_desc)
set object description
Tabs GUI.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $ilCtrl
Definition: ilias.php:18
This is how a factory for inputs looks like.
Definition: Factory.php:11
An entity that renders components to a string output.
Definition: Renderer.php:15
Covers the persistence of sp-type related information.
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.
$type
$response
$DIC
Definition: xapitoken.php:46