19 declare(strict_types=1);
50 string $formAction =
'',
51 string $saveCommand =
'saveDocument',
52 string $cancelCommand =
'showDocuments',
53 bool $isEditable =
false 72 $this->check_input_called = $status;
77 if ($this->document->getId() > 0) {
78 $this->
setTitle($this->
lng->txt(
'tos_form_edit_doc_head'));
80 $this->
setTitle($this->
lng->txt(
'tos_form_new_doc_head'));
86 $title->setInfo($this->
lng->txt(
'tos_form_document_title_info'));
88 $title->setDisabled(!$this->isEditable);
89 $title->setValue($this->document->getTitle());
93 $documentLabel = $this->
lng->txt(
'tos_form_document');
94 $documentByline = $this->
lng->txt(
'tos_form_document_info');
95 if ($this->document->getId() > 0) {
96 $documentLabel = $this->
lng->txt(
'tos_form_document_new');
97 $documentByline = $this->
lng->txt(
'tos_form_document_new_info');
101 $document->setInfo($documentByline);
102 if (!$this->document->getId()) {
103 $document->setRequired(
true);
105 $document->setDisabled(!$this->isEditable);
106 $document->setSuffixes([
'html',
'txt']);
109 if ($this->isEditable) {
118 return $this->translatedError !==
'';
128 return $this->translatedInfo !==
'';
138 if (!$this->fillObject()) {
143 $this->document->save();
148 protected function fillObject():
bool 154 if ($this->fileUpload->hasUploads() && !$this->fileUpload->hasBeenProcessed()) {
155 $this->fileUpload->process();
158 if ($this->fileUpload->hasUploads()) {
161 $uploadResult = array_values($this->fileUpload->getResults())[0];
167 if (!$this->document->getId() || $uploadResult->getName() !==
'') {
168 if (!$uploadResult->isOK()) {
169 $this->
getItemByPostVar(
'document')->setAlert($uploadResult->getStatus()->getMessage());
173 $this->fileUpload->moveOneFileTo(
181 $pathToFile =
'/agreements/' . $uploadResult->getName();
182 if (!$this->tmpFileSystem->has($pathToFile)) {
187 $originalContent = $content = $this->tmpFileSystem->read($pathToFile);
189 $purifiedHtmlContent = $this->documentPurifier->purify($content);
192 if (!$htmlValidator->isValid()) {
193 $purifiedHtmlContent = nl2br($purifiedHtmlContent);
196 if (trim($purifiedHtmlContent) !== trim($originalContent)) {
197 $this->translatedInfo = $this->
lng->txt(
'tos_form_document_content_changed');
200 $this->document->setText($purifiedHtmlContent);
201 $this->tmpFileSystem->delete($pathToFile);
204 $this->translatedError = $e->getMessage();
209 $this->document->setTitle($this->
getInput(
'title'));
211 if ($this->document->getId() > 0) {
212 $this->document->setLastModifiedUsrId($this->actor->getId());
214 $this->document->setOwnerUsrId($this->actor->getId());
218 $this->document->setSorting((
int) $documentWithMaxSorting->getSorting() + 1);
220 $this->document->setSorting(1);
static orderBy($orderBy, string $orderDirection='ASC')
Class ilTermsOfServiceDocumentsContainsHtmlValidator.
Interface for html sanitizing functionality.
Class ilTermsOfServiceDocument.
__construct(Container $dic, ilPlugin $plugin)
Class FlySystemFileAccessTest disabled disabled disabled.