ILIAS  release_8 Revision v8.24
class.ilStudyProgrammeChangeDeadlineGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
25
27{
28 private const CMD_SHOW_DEADLINE_CONFIG = "showDeadlineConfig";
29 private const CMD_CHANGE_DEADLINE = "changeDeadline";
30 private const PROP_DEADLINE = "deadline";
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->showDeadlineConfig();
82 break;
84 $this->changeDeadline();
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 showDeadlineConfig(): 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_DEADLINE
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 $deadline_date = $prg->getSettings()->getDeadlineSettings()->getDeadlineDate();
135 $format = $this->data_factory->dateFormat()->germanShort();
136 $deadline_date_sub_form = $ff
137 ->dateTime('', $txt('prg_deadline_date_desc'))
138 ->withFormat($format)
139 ;
140
141 if ($deadline_date !== null) {
142 $deadline_date_sub_form = $deadline_date_sub_form->withValue(
143 $deadline_date->format($format->toString())
144 );
146 }
147
148 $sg = $ff->switchableGroup(
149 [
151 $ff->group([], $txt('prg_no_deadline')),
153 $ff->group([$deadline_date_sub_form], $txt('prg_deadline_date'))
154 ],
155 ''
156 );
157
158 return $sg->withValue($option);
159 }
160
161 protected function buildFormElements(
162 $ff,
163 Closure $txt,
165 ): array {
166 return [
167 $ff->section(
168 [
170 ],
171 $txt("prg_deadline_settings"),
172 ""
173 )
174 ];
175
176 return $return;
177 }
178
179 protected function changeDeadline(): void
180 {
181 $form = $this
182 ->buildForm($this->getObject(), $this->ctrl->getFormAction($this, "changeDeadline"))
183 ->withRequest($this->request);
184
185 $result = $form->getInputGroup()->getContent();
186
187 $msg_collection = $this->messages->getMessageCollection('msg_change_deadline_date');
188
189 if ($result->isOK()) {
190 $values = $result->value();
191 $programme = $this->getObject();
192 $acting_usr_id = $this->user->getId();
193
194 $deadline_data = $values[0][self::PROP_DEADLINE];
195 $deadline_type = $deadline_data[0];
196 $deadline = null;
198 $deadline = array_shift($deadline_data[1]);
199
200 if (!$deadline) {
201 $this->tpl->setOnScreenMessage("failure", $this->lng->txt('error_updating_deadline'), true);
202 $this->ctrl->setParameter($this, 'prgrs_ids', implode(',', $this->getProgressIds()));
203 $this->ctrl->redirectByClass(self::class, self::CMD_SHOW_DEADLINE_CONFIG);
204 }
205 }
206
207 foreach ($this->getProgressIds() as $progress_id) {
208 $assignment_id = $progress_id->getAssignmentId();
209 $programme->changeProgressDeadline($assignment_id, $acting_usr_id, $msg_collection, $deadline);
210 }
211
212 $this->messages->showMessages($msg_collection);
213 $this->ctrl->redirectByClass('ilObjStudyProgrammeMembersGUI', 'view');
214 }
215
216 $this->tpl->setOnScreenMessage("failure", $this->lng->txt('error_updating_deadline'), true);
217 $this->ctrl->setParameter($this, 'prgrs_ids', implode(',', $this->getProgressIds()));
218 $this->ctrl->redirectByClass(self::class, self::CMD_SHOW_DEADLINE_CONFIG);
219 }
220
221 protected function getBackTarget(): ?string
222 {
223 return $this->back_target;
224 }
225
226 public function setBackTarget(string $target): void
227 {
228 $this->back_target = $target;
229 }
230
231 protected function getProgressIds(): array
232 {
233 return $this->progress_ids;
234 }
235
236 public function setProgressIds(array $progress_ids): void
237 {
238 $this->progress_ids = $progress_ids;
239 }
240
241 protected function getRefId(): ?int
242 {
243 return $this->ref_id;
244 }
245
246 public function setRefId(int $ref_id): void
247 {
248 $this->ref_id = $ref_id;
249 }
250
251 protected function getObject(): ilObjStudyProgramme
252 {
253 $ref_id = $this->getRefId();
254 if (is_null($ref_id)) {
255 throw new LogicException("Can't create object. No ref_id given.");
256 }
257
258 if ($this->object === null) {
259 $this->object = ilObjStudyProgramme::getInstanceByRefId($ref_id);
260 }
261 return $this->object;
262 }
263
264 protected function redirectToParent(): void
265 {
266 $back_target = $this->getBackTarget();
267 if (is_null($back_target)) {
268 throw new LogicException("Can't redirect. No back target given.");
269 }
270
271 $this->ctrl->redirectToURL($back_target);
272 }
273}
$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...
__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)
buildFormElements( $ff, Closure $txt, ilObjStudyProgramme $prg)
buildForm(ilObjStudyProgramme $prg, string $submit_action)
Psr Http Message ServerRequestInterface $request
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
Class ChatMainBarProvider \MainMenu\Provider.