ILIAS  release_8 Revision v8.24
class.ilStudyProgrammeChangeExpireDateGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
25
27{
28 private const CMD_SHOW_EXPIRE_DATE_CONFIG = "showExpireDateConfig";
29 private const CMD_CHANGE_EXPIRE_DATE = "changeExpireDate";
30 private const PROP_VALIDITY_OF_QUALIFICATION = "validity_qualification";
31
32 protected ilCtrl $ctrl;
34 protected ilLanguage $lng;
35 protected ilAccess $access;
36 protected ilObjUser $user;
39 protected Psr\Http\Message\ServerRequestInterface $request;
43
44 protected ?string $back_target = null;
45 protected array $progress_ids = [];
46 protected ?int $ref_id = null;
47 protected ?ilObjStudyProgramme $object = null;
48
49 public function __construct(
57 Psr\Http\Message\ServerRequestInterface $request,
61 ) {
62 $this->ctrl = $ctrl;
63 $this->tpl = $tpl;
64 $this->lng = $lng;
65 $this->access = $access;
66 $this->user = $user;
67 $this->input_factory = $input_factory;
68 $this->renderer = $renderer;
69 $this->request = $request;
70 $this->refinery_factory = $refinery_factory;
71 $this->data_factory = $data_factory;
72 $this->messages = $messages;
73 }
74
75 public function executeCommand(): void
76 {
77 $cmd = $this->ctrl->getCmd();
78
79 switch ($cmd) {
81 $this->showExpireDateConfig();
82 break;
84 $this->changeExpireDate();
85 break;
86 case 'cancel':
87 $this->redirectToParent();
88 break;
89 default:
90 throw new Exception('Unknown command ' . $cmd);
91 }
92 }
93
94 protected function showExpireDateConfig(): void
95 {
96 $this->tpl->loadStandardTemplate();
97 $this->ctrl->setParameter($this, 'prgrs_ids', implode(',', $this->getProgressIds()));
98 $action = $this->ctrl->getFormAction(
99 $this,
100 self::CMD_CHANGE_EXPIRE_DATE
101 );
102 $this->ctrl->clearParameters($this);
103
104 $form = $this->buildForm($this->getObject(), $action);
105
106 $this->tpl->setContent($this->renderer->render($form));
107 }
108
109 protected function buildForm(ilObjStudyProgramme $prg, string $submit_action): Standard
110 {
111 $ff = $this->input_factory->field();
112 $txt = function ($id) {
113 return $this->lng->txt($id);
114 };
115
116 return $this->input_factory->container()->form()->standard(
117 $submit_action,
118 $this->buildFormElements(
119 $ff,
120 $txt,
121 $prg
122 )
123 );
124 }
125
127 {
128 $ff = $this->input_factory->field();
129 $txt = function ($id) {
130 return $this->lng->txt($id);
131 };
132
134 $format = $this->data_factory->dateFormat()->germanShort();
135 $vq_date_sub_form = $ff
136 ->dateTime('', $txt('validity_qualification_date_desc'))
137 ->withFormat($format);
138 $date = $prg->getSettings()->getValidityOfQualificationSettings()->getQualificationDate();
139 if ($date !== null) {
140 $vq_date_sub_form = $vq_date_sub_form->withValue($date->format($format->toString()));
142 }
143
144 $sg = $ff->switchableGroup(
145 [
147 $ff->group([], $txt('prg_no_validity_qualification')),
149 $ff->group([$vq_date_sub_form], $txt('validity_qualification_date'))
150 ],
151 ''
152 );
153 return $sg->withValue($option);
154 }
155
156 protected function buildFormElements(
157 ILIAS\UI\Component\Input\Field\Factory $ff,
158 Closure $txt,
160 ): array {
161 return [
162 $ff->section(
163 [
165 ],
166 $txt("prg_validity_of_qualification"),
167 ""
168 )
169 ];
170 }
171
172 protected function changeExpireDate(): void
173 {
174 $form = $this
175 ->buildForm($this->getObject(), $this->ctrl->getFormAction($this, "changeExpireDate"))
176 ->withRequest($this->request);
177
178 $result = $form->getInputGroup()->getContent();
179
180 $msg_collection = $this->messages->getMessageCollection('msg_change_expire_date');
181
182 if ($result->isOK()) {
183 $values = $result->value();
184 $programme = $this->getObject();
185 $acting_usr_id = $this->user->getId();
186
187 $vq_data = $values[0][self::PROP_VALIDITY_OF_QUALIFICATION];
188 $vq_type = $vq_data[0];
189 $validity = null;
191 $validity = array_shift($vq_data[1]);
192 if (!$validity) {
193 $this->tpl->setOnScreenMessage("failure", $this->lng->txt('error_updating_expire_date'), true);
194 $this->ctrl->setParameter($this, 'prgrs_ids', implode(',', $this->getProgressIds()));
195 $this->ctrl->redirectByClass(self::class, self::CMD_SHOW_EXPIRE_DATE_CONFIG);
196 }
197 }
198 foreach ($this->getProgressIds() as $progress_id) {
199 $assignment_id = $progress_id->getAssignmentId();
200 $programme->changeProgressValidityDate($assignment_id, $acting_usr_id, $msg_collection, $validity, );
201 }
202
203 $this->messages->showMessages($msg_collection);
204 $this->ctrl->redirectByClass('ilObjStudyProgrammeMembersGUI', 'view');
205 }
206 $this->tpl->setOnScreenMessage("failure", $this->lng->txt('error_updating_expire_date'), true);
207 $this->ctrl->setParameter($this, 'prgrs_ids', implode(',', $this->getProgressIds()));
208 $this->ctrl->redirectByClass(self::class, self::CMD_SHOW_EXPIRE_DATE_CONFIG);
209 }
210
211 protected function getBackTarget(): ?string
212 {
213 return $this->back_target;
214 }
215
216 public function setBackTarget(string $target): void
217 {
218 $this->back_target = $target;
219 }
220
221 protected function getProgressIds(): array
222 {
223 return $this->progress_ids;
224 }
225
226 public function setProgressIds(array $progress_ids): void
227 {
228 $this->progress_ids = $progress_ids;
229 }
230
231 protected function getRefId(): ?int
232 {
233 return $this->ref_id;
234 }
235
236 public function setRefId(int $ref_id): void
237 {
238 $this->ref_id = $ref_id;
239 }
240
241 protected function getObject(): ilObjStudyProgramme
242 {
243 $ref_id = $this->getRefId();
244 if (is_null($ref_id)) {
245 throw new LogicException("Can't create object. No ref_id given.");
246 }
247
248 if ($this->object === null) {
249 $this->object = ilObjStudyProgramme::getInstanceByRefId($ref_id);
250 }
251 return $this->object;
252 }
253
254 protected function redirectToParent(): void
255 {
256 $back_target = $this->getBackTarget();
257 if (is_null($back_target)) {
258 throw new LogicException("Can't redirect. No back target given.");
259 }
260
261 $this->ctrl->redirectToURL($back_target);
262 }
263}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Builds data types.
Definition: Factory.php:21
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilCtrl provides processing control methods.
language handling
@ilCtrl_Calls ilObjStudyProgrammeSettingsGUI: ilStudyProgrammeCommonSettingsGUI
User class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
buildForm(ilObjStudyProgramme $prg, string $submit_action)
buildFormElements(ILIAS\UI\Component\Input\Field\Factory $ff, Closure $txt, ilObjStudyProgramme $prg)
__construct(ilCtrl $ctrl, ilGlobalTemplateInterface $tpl, ilLanguage $lng, ilAccess $access, ilObjUser $user, Factory $input_factory, Renderer $renderer, Psr\Http\Message\ServerRequestInterface $request, ILIAS\Refinery\Factory $refinery_factory, ILIAS\Data\Factory $data_factory, ilPRGMessagePrinter $messages)
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
$txt
Definition: error.php:13
This describes a standard form.
Definition: Standard.php:27
This is how a factory for inputs looks like.
Definition: Factory.php:27
This is a legacy support of Component\Input\Field\Input that has been moved to Component\Input\Contai...
Definition: Input.php:32
An entity that renders components to a string output.
Definition: Renderer.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ref_id
Definition: ltiauth.php:67
$format
Definition: metadata.php:235
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.