diff --git a/lam/lib/pdfstruct.inc b/lam/lib/pdfstruct.inc index db46732b..69270f2e 100644 --- a/lam/lib/pdfstruct.inc +++ b/lam/lib/pdfstruct.inc @@ -422,6 +422,17 @@ class PDFStructureReader { */ class PDFStructureWriter { + private $serverProfileName; + + /** + * Constructor. + * + * @param $serverProfileName server profile name + */ + public function __construct($serverProfileName) { + $this->serverProfileName = $serverProfileName; + } + /** * Writes the PDF structure to disk. * @@ -447,10 +458,10 @@ class PDFStructureWriter { throw new \LAMException(_('PDF structure name not valid'), _('The name for that PDF-structure you submitted is not valid. A valid name must consist of the following characters: \'a-z\',\'A-Z\',\'0-9\',\'_\',\'-\'.')); } - if(!is_writable(dirname(__FILE__) . '/../config/pdf/' . $_SESSION['config']->getName())) { + if(!is_writable(dirname(__FILE__) . '/../config/pdf/' . $this->serverProfileName)) { throw new \LAMException(_('Could not save PDF structure, access denied.')); } - return dirname(__FILE__) . '/../config/pdf/' . $_SESSION['config']->getName() . '/' . $name . '.' . $typeId . '.xml'; + return dirname(__FILE__) . '/../config/pdf/' . $this->serverProfileName . '/' . $name . '.' . $typeId . '.xml'; } /** diff --git a/lam/templates/pdfedit/pdfpage.php b/lam/templates/pdfedit/pdfpage.php index 061fb726..f9e17dbd 100644 --- a/lam/templates/pdfedit/pdfpage.php +++ b/lam/templates/pdfedit/pdfpage.php @@ -135,7 +135,7 @@ if (!empty($_POST['form_submit'])) { // main pdf structure page $saveErrors = array(); if(isset($_GET['submit'])) { - $writer = new PDFStructureWriter(); + $writer = new PDFStructureWriter($_SESSION['config']->getName()); try { $writer->write($type->getId(), $_POST['pdfname'], $_SESSION['currentPDFStructure']); unset($_SESSION['currentPDFStructure']); diff --git a/lam/tests/lib/pdfstructTest.php b/lam/tests/lib/pdfstructTest.php index c7906b72..0f0d73ae 100644 --- a/lam/tests/lib/pdfstructTest.php +++ b/lam/tests/lib/pdfstructTest.php @@ -106,7 +106,7 @@ class ReadStructureTest extends TestCase { $reader->method('getFileName')->willReturn($file); $structure = $reader->read('type', 'name'); // create writer and get output XML - $writer = new PDFStructureWriter(); + $writer = new PDFStructureWriter('test'); $xml = $writer->getXML($structure); // compare $this->assertEquals($originalXML, $xml);