ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilWebDAVMountInstructionsUploadGUI.php
Go to the documentation of this file.
1<?php
2
8
14{
15 const ACTION_SAVE_ADD_DOCUMENT_FORM = 'saveAddDocumentForm';
16 const ACTION_SAVE_EDIT_DOCUMENT_FORM = 'saveEditDocumentForm';
17
18 public function __construct(
19 ilObjWebDAV $webdav_settings,
21 ilObjUser $user,
22 ilCtrl $ctrl,
24 ilRbacSystem $rbacsystem,
25 ilErrorHandling $error,
27 ilToolbarGUI $toolbar,
28 GlobalHttpState $http_state,
29 Factory $ui_factory,
30 Renderer $ui_renderer,
31 Filesystems $file_systems,
32 FileUpload $file_upload,
33 ilWebDAVMountInstructionsRepository $mount_instructions_repository
34 ) {
35 $this->webdav_settings = $webdav_settings;
36 $this->tpl = $tpl;
37 $this->ctrl = $ctrl;
38 $this->lng = $lng;
39 $this->rbacsystem = $rbacsystem;
40 $this->error = $error;
41 $this->user = $user;
42 $this->log = $log;
43 $this->toolbar = $toolbar;
44 $this->http_state = $http_state;
45 $this->ui_factory = $ui_factory;
46 $this->ui_renderer = $ui_renderer;
47 $this->file_systems = $file_systems;
48 $this->file_upload = $file_upload;
49 $this->mount_instructions_repository = $mount_instructions_repository;
50 }
51
55 public function executeCommand() : void
56 {
57 $cmd = $this->ctrl->getCmd();
58
59 if (!$this->rbacsystem->checkAccess('read', $this->webdav_settings->getRefId())) {
60 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
61 }
62
63 if ($cmd == 'delete') {
64 $cmd .= 'Document';
65 }
66 if ($cmd == '' || !method_exists($this, $cmd)) {
67 $cmd = 'showDocuments';
68 }
69 $this->$cmd();
70 }
71
75 protected function showDocuments() : void
76 {
77 if ($this->rbacsystem->checkAccess('write', $this->webdav_settings->getRefId())) {
78 $addDocumentBtn = ilLinkButton::getInstance();
79 $addDocumentBtn->setPrimary(true);
80 $addDocumentBtn->setUrl($this->ctrl->getLinkTarget($this, 'showAddDocumentForm'));
81 $addDocumentBtn->setCaption('webdav_add_instructions_btn_label');
82 $this->toolbar->addStickyItem($addDocumentBtn);
83 }
84
85 $uri_builder = new ilWebDAVUriBuilder($this->http_state->request());
86
87 $document_tbl_gui = new ilWebDAVMountInstructionsDocumentTableGUI(
88 $this,
89 $uri_builder,
90 'showDocuments',
91 $this->ui_factory,
92 $this->ui_renderer,
93 $this->rbacsystem->checkAccess('write', $this->webdav_settings->getRefId())
94 );
95 $document_tbl_gui->setProvider(new ilWebDAVMountInstructionsTableDataProvider($this->mount_instructions_repository));
96 $document_tbl_gui->populate();
97
98 $this->tpl->setContent($document_tbl_gui->getHTML());
99 }
100
106 {
107 if ($a_document->getId() > 0) {
108 $this->ctrl->setParameter($this, 'doc_id', $a_document->getId());
109
110 $form_action = $this->ctrl->getFormAction($this, self::ACTION_SAVE_EDIT_DOCUMENT_FORM);
112 } else {
113 $form_action = $this->ctrl->getFormAction($this, self::ACTION_SAVE_ADD_DOCUMENT_FORM);
115 }
116
118 $a_document,
119 $this->mount_instructions_repository,
121 $this->user,
122 $this->file_systems->temp(),
123 $this->file_upload,
124 $form_action,
125 $save_command,
126 'showDocuments',
127 $this->rbacsystem->checkAccess('write', $this->webdav_settings->getRefId())
128 );
129
130 return $form;
131 }
132
133 protected function showAddDocumentForm()
134 {
135 if (!$this->rbacsystem->checkAccess('write', $this->webdav_settings->getRefId())) {
136 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
137 }
138
140 $this->tpl->setContent($form->getHTML());
141 }
142
143 protected function showEditDocumentForm()
144 {
145 if (!$this->rbacsystem->checkAccess('write', $this->webdav_settings->getRefId())) {
146 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
147 }
148
149 $document_id = $_REQUEST['webdav_id'];
150 $document = $this->mount_instructions_repository->getMountInstructionsDocumentById($document_id);
151 $form = $this->getDocumentForm($document);
152 $this->tpl->setContent($form->getHTML());
153 }
154
158 protected function saveAddDocumentForm()
159 {
160 if (!$this->rbacsystem->checkAccess('write', $this->webdav_settings->getRefId())) {
161 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
162 }
163
165 if ($form->saveObject()) {
166 ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
167 if ($form->hasTranslatedInfo()) {
168 ilUtil::sendInfo($form->getTranslatedInfo(), true);
169 }
170 $this->ctrl->redirect($this, 'showDocuments');
171 } elseif ($form->hasTranslatedError()) {
172 ilUtil::sendFailure($form->getTranslatedError(), true);
173 }
174
175 $html = $form->getHTML();
176 $this->tpl->setContent($html);
177 }
178
182 protected function saveEditDocumentForm()
183 {
184 if (!$this->rbacsystem->checkAccess('write', $this->webdav_settings->getRefId())) {
185 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
186 }
187
188 $form = $this->getDocumentForm(new ilWebDAVMountInstructionsDocument((int) $_REQUEST['webdav_id']));
189 if ($form->updateObject()) {
190 ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
191 if ($form->hasTranslatedInfo()) {
192 ilUtil::sendInfo($form->getTranslatedInfo(), true);
193 }
194 $this->ctrl->redirect($this, 'showDocuments');
195 } elseif ($form->hasTranslatedError()) {
196 ilUtil::sendFailure($form->getTranslatedError(), true);
197 }
198
199 $html = $form->getHTML();
200 $this->tpl->setContent($html);
201 }
202
203 protected function getDocumentByServerRequest()
204 {
205 return $this->httpState->request() - getParsedBody()['instructions_id'] ?? [];
206 }
207
208 protected function deleteDocument()
209 {
210 if (!$this->rbacsystem->checkAccess('delete', $this->webdav_settings->getRefId())) {
211 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
212 } else {
213 $webdav_id = $_REQUEST['webdav_id'];
214 $this->mount_instructions_repository->deleteMountInstructionsById($webdav_id);
215 ilUtil::sendSuccess($this->lng->txt('deleted_successfully'), true);
216 $this->ctrl->redirect($this, 'showDocuments');
217 }
218 }
219
220 public function saveDocumentSorting()
221 {
222 if (!$this->rbacsystem->checkAccess('write', $this->webdav_settings->getRefId())) {
223 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
224 }
225
226 $sorting = $this->http_state->request()->getParsedBody()['sorting'] ?? [];
227 if (!is_array($sorting) || 0 === count($sorting)) {
228 $this->showDocuments();
229 return;
230 }
231
232 // Sort array by give sort value
233 asort($sorting, SORT_NUMERIC);
234
235 $position = 0;
236 foreach ($sorting as $document_id => $ignored_sort_value) {
237
238 // Only accept numbers
239 if (!is_numeric($document_id)) {
240 continue;
241 }
242
243 $this->mount_instructions_repository->updateSortingValueById((int) $document_id, ++$position);
244 }
245
246 ilUtil::sendSuccess($this->lng->txt('webdav_saved_sorting'), true);
247 $this->ctrl->redirect($this);
248 }
249}
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
error($a_errmsg)
set error message @access public
This class provides processing control methods.
Class ilGlobalPageTemplate.
language handling
static getInstance()
Factory.
Component logger with individual log levels by component id.
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
__construct(ilObjWebDAV $webdav_settings, ilGlobalPageTemplate $tpl, ilObjUser $user, ilCtrl $ctrl, ilLanguage $lng, ilRbacSystem $rbacsystem, ilErrorHandling $error, ilLogger $log, ilToolbarGUI $toolbar, GlobalHttpState $http_state, Factory $ui_factory, Renderer $ui_renderer, Filesystems $file_systems, FileUpload $file_upload, ilWebDAVMountInstructionsRepository $mount_instructions_repository)
getDocumentForm(ilWebDAVMountInstructionsDocument $a_document)
Class Filesystems The Filesystems interface defines the access methods which can be used to fetch the...
Definition: Filesystems.php:15
Interface GlobalHttpState.
This is how the factory for UI elements looks.
Definition: Factory.php:18
An entity that renders components to a string output.
Definition: Renderer.php:15
Interface ilWebDAVMountInstructionsRepository.
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
$log
Definition: result.php:15
$lng