hide fields that are not managed by a module

This commit is contained in:
Roland Gruber 2019-05-12 18:11:39 +02:00
parent 54b68e7765
commit 3b35aa29da
1 changed files with 14 additions and 5 deletions

View File

@ -22,7 +22,7 @@ use LAM\PDF\PDFStructureWriter;
/* /*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2003 - 2006 Michael Duergner Copyright (C) 2003 - 2006 Michael Duergner
2007 - 2018 Roland Gruber 2007 - 2019 Roland Gruber
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -65,7 +65,9 @@ startSecureSession();
enforceUserIsLoggedIn(); enforceUserIsLoggedIn();
// die if no write access // die if no write access
if (!checkIfWriteAccessIsAllowed()) die(); if (!checkIfWriteAccessIsAllowed()) {
die();
}
checkIfToolIsActive('toolPDFEditor'); checkIfToolIsActive('toolPDFEditor');
@ -271,6 +273,9 @@ foreach ($sections as $key => $section) {
if($section instanceof PDFEntrySection) { if($section instanceof PDFEntrySection) {
if($section->isAttributeTitle()) { if($section->isAttributeTitle()) {
$section_headline = translateFieldIDToName($section->getPdfKey(), $type->getScope(), $availablePDFFields); $section_headline = translateFieldIDToName($section->getPdfKey(), $type->getScope(), $availablePDFFields);
if ($section_headline === null) {
continue;
}
} }
else { else {
$section_headline = $section->getTitle(); $section_headline = $section->getTitle();
@ -312,8 +317,12 @@ foreach ($sections as $key => $section) {
// add section entries // add section entries
$sectionEntries = $section->getEntries(); $sectionEntries = $section->getEntries();
foreach ($sectionEntries as $e => $sectionEntry) { foreach ($sectionEntries as $e => $sectionEntry) {
$fieldLabel = translateFieldIDToName($sectionEntry->getKey(), $type->getScope(), $availablePDFFields);
if ($fieldLabel === null) {
continue;
}
$structureContent->addVerticalSpacer('1rem'); $structureContent->addVerticalSpacer('1rem');
$fieldOutput = new htmlOutputText(translateFieldIDToName($sectionEntry->getKey(), $type->getScope(), $availablePDFFields)); $fieldOutput = new htmlOutputText($fieldLabel);
$structureContent->addLabel($fieldOutput); $structureContent->addLabel($fieldOutput);
$actionGroup = new htmlGroup(); $actionGroup = new htmlGroup();
if ($e != 0) { if ($e != 0) {
@ -474,6 +483,7 @@ include __DIR__ . '/../../lib/adminFooter.inc';
* @param String $id field ID * @param String $id field ID
* @param String $scope account type * @param String $scope account type
* @param array $availablePDFFields available PDF fields * @param array $availablePDFFields available PDF fields
* @return string|null field label or null if no matching module found
*/ */
function translateFieldIDToName($id, $scope, $availablePDFFields) { function translateFieldIDToName($id, $scope, $availablePDFFields) {
foreach ($availablePDFFields as $module => $fields) { foreach ($availablePDFFields as $module => $fields) {
@ -491,7 +501,7 @@ function translateFieldIDToName($id, $scope, $availablePDFFields) {
} }
} }
} }
return $id; return null;
} }
/** /**
@ -670,7 +680,6 @@ function moveDown(PDFStructure &$structure) {
$sectionPos = $parts[0]; $sectionPos = $parts[0];
$entryPos = $parts[1]; $entryPos = $parts[1];
$entries = $sections[$sectionPos]->getEntries(); $entries = $sections[$sectionPos]->getEntries();
$entries = $sections[$sectionPos]->getEntries();
$entryTmp = $entries[$entryPos + 1]; $entryTmp = $entries[$entryPos + 1];
$entries[$entryPos + 1] = $entries[$entryPos]; $entries[$entryPos + 1] = $entries[$entryPos];
$entries[$entryPos] = $entryTmp; $entries[$entryPos] = $entryTmp;