|
13 | 13 | use \htmlResponsiveInputTextarea; |
14 | 14 | use \htmlHiddenInput; |
15 | 15 | use \htmlSpacer; |
| 16 | +use LAM\PDF\PdfLogo; |
16 | 17 | use LAM\PDF\PdfStructurePersistenceManager; |
17 | 18 | use LAM\PDF\PDFTextSection; |
18 | 19 | use LAM\PDF\PDFEntrySection; |
|
23 | 24 | /* |
24 | 25 | This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) |
25 | 26 | Copyright (C) 2003 - 2006 Michael Duergner |
26 | | - 2007 - 2021 Roland Gruber |
| 27 | + 2007 - 2022 Roland Gruber |
27 | 28 |
|
28 | 29 | This program is free software; you can redistribute it and/or modify |
29 | 30 | it under the terms of the GNU General Public License as published by |
|
132 | 133 | } |
133 | 134 | } |
134 | 135 |
|
| 136 | +$logoFiles = $pdfStructurePersistenceManager->getPdfLogos($_SESSION['config']->getName(), true); |
135 | 137 | if (!empty($_POST['form_submit'])) { |
136 | | - updateBasicSettings($_SESSION['currentPDFStructure']); |
| 138 | + updateBasicSettings($_SESSION['currentPDFStructure'], $logoFiles); |
137 | 139 | updateSectionTitles($_SESSION['currentPDFStructure']); |
138 | 140 | addSection($_SESSION['currentPDFStructure']); |
139 | 141 | addSectionEntry($_SESSION['currentPDFStructure']); |
|
228 | 230 | // headline |
229 | 231 | $headline = $_SESSION['currentPDFStructure']->getTitle(); |
230 | 232 | // logo |
231 | | -$logoFiles = $pdfStructurePersistenceManager->getPdfLogos($_SESSION['config']->getName(), true); |
232 | 233 | $logos = array(_('No logo') => 'none'); |
233 | 234 | foreach($logoFiles as $logoFile) { |
234 | 235 | $logos[$logoFile->getName() . ' (' . $logoFile->getWidth() . ' x ' . $logoFile->getHeight() . ")"] = $logoFile->getName(); |
@@ -516,16 +517,28 @@ function translateFieldIDToName($id, $scope, $availablePDFFields) { |
516 | 517 | /** |
517 | 518 | * Updates basic settings such as logo and head line. |
518 | 519 | * |
519 | | - * @param PDFStructure $structure |
| 520 | + * @param PDFStructure $structure PDF structure |
| 521 | + * @param PdfLogo[] $logoFiles logos |
520 | 522 | */ |
521 | | -function updateBasicSettings(PDFStructure &$structure) { |
| 523 | +function updateBasicSettings(PDFStructure &$structure, array $logoFiles) { |
522 | 524 | // set headline |
523 | 525 | if (isset($_POST['headline'])) { |
524 | 526 | $structure->setTitle(str_replace('<', '', str_replace('>', '', $_POST['headline']))); |
525 | 527 | } |
526 | 528 | // set logo |
527 | 529 | if (isset($_POST['logoFile'])) { |
528 | | - $structure->setLogo($_POST['logoFile']); |
| 530 | + $fileName = $_POST['logoFile']; |
| 531 | + $found = false; |
| 532 | + foreach ($logoFiles as $logoFile) { |
| 533 | + if ($logoFile->getName() === $fileName) { |
| 534 | + $found = true; |
| 535 | + } |
| 536 | + } |
| 537 | + if (!$found) { |
| 538 | + logNewMessage(LOG_ERR, 'Invalid PDF logo file: ' . $fileName); |
| 539 | + return; |
| 540 | + } |
| 541 | + $structure->setLogo($fileName); |
529 | 542 | } |
530 | 543 | // set folding marks |
531 | 544 | if (isset($_POST['foldingmarks'])) { |
|
0 commit comments