From 936fb60b422326bf9b269245b184bf474a83a836 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sun, 22 Jan 2017 18:00:47 +0100 Subject: [PATCH] fixed template copy --- lam/lib/pdfstruct.inc | 24 ++++++++++++++++++++++-- lam/lib/profiles.inc | 9 ++++++--- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/lam/lib/pdfstruct.inc b/lam/lib/pdfstruct.inc index 7a28c1b9..63864973 100644 --- a/lam/lib/pdfstruct.inc +++ b/lam/lib/pdfstruct.inc @@ -345,14 +345,17 @@ function installPDFTemplates() { $entry = $templateDir->read(); } } - $basePath = dirname(__FILE__) . '/../config/pdf/' . $_SESSION['config']->getName() . '/'; + $basePath = dirname(__FILE__) . '/../config/pdf/' . $_SESSION['config']->getName(); + if (!file_exists($basePath)) { + mkdir($basePath); + } $typeManager = new \LAM\TYPES\TypeManager(); foreach ($typeManager->getConfiguredTypes() as $type) { if (empty($allTemplates[$type->getScope()])) { continue; } foreach ($allTemplates[$type->getScope()] as $templateName) { - $path = $basePath . $templateName . '.' . $type->getId() . '.xml'; + $path = $basePath . '/' . $templateName . '.' . $type->getId() . '.xml'; if (!is_file($path)) { $template = $templatePath . '/' . $templateName . '.' . $type->getScope() . '.xml'; logNewMessage(LOG_DEBUG, 'Copy template ' . $template . ' to ' . $path); @@ -360,6 +363,23 @@ function installPDFTemplates() { } } } + if (!file_exists($basePath . '/logos')) { + mkdir($basePath . '/logos'); + } + $templatePath = dirname(__FILE__) . '/../config/templates/pdf/logos'; + $templateDir = @dir($templatePath); + if ($templateDir) { + $entry = $templateDir->read(); + while ($entry){ + $path = $basePath . '/logos/' . $entry; + if ((strpos($entry, '.') !== 1) && !is_file($path)) { + $template = $templatePath . '/' . $entry; + logNewMessage(LOG_DEBUG, 'Copy template ' . $template . ' to ' . $path); + @copy($template, $path); + } + $entry = $templateDir->read(); + } + } } ?> diff --git a/lam/lib/profiles.inc b/lam/lib/profiles.inc index 9db4065b..82aaa543 100644 --- a/lam/lib/profiles.inc +++ b/lam/lib/profiles.inc @@ -5,7 +5,7 @@ use \LAMException; $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2003 - 2016 Roland Gruber + Copyright (C) 2003 - 2017 Roland Gruber 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 @@ -251,14 +251,17 @@ function installProfileTemplates() { $entry = $templateDir->read(); } } - $basePath = dirname(__FILE__) . '/../config/profiles/' . $_SESSION['config']->getName() . '/'; + $basePath = dirname(__FILE__) . '/../config/profiles/' . $_SESSION['config']->getName(); + if (!file_exists($basePath)) { + mkdir($basePath); + } $typeManager = new \LAM\TYPES\TypeManager(); foreach ($typeManager->getConfiguredTypes() as $type) { if (empty($allTemplates[$type->getScope()])) { continue; } foreach ($allTemplates[$type->getScope()] as $templateName) { - $path = $basePath . $templateName . '.' . $type->getId(); + $path = $basePath . '/' . $templateName . '.' . $type->getId(); if (!is_file($path)) { $template = $templatePath . '/' . $templateName . '.' . $type->getScope(); logNewMessage(LOG_DEBUG, 'Copy template ' . $template . ' to ' . $path);