diff --git a/lam/HISTORY b/lam/HISTORY index 55d6d950..f46493b0 100644 --- a/lam/HISTORY +++ b/lam/HISTORY @@ -1,7 +1,9 @@ March 2012 3.7 - Login: support bind user for login search - Personal: added labeledURI and cosmetic changes, description is now multi-valued (RFE 3446363) - - File upload: support custom scripts postCreate (LAM Pro) + - File upload: + -> support custom scripts postCreate (LAM Pro) + -> PDF export - New translation: Slovakian - removed phpGroupWare support (project no longer exists) - LAM Pro: diff --git a/lam/lib/checkEnvironment.inc b/lam/lib/checkEnvironment.inc index 614a15e5..0ce3ee31 100644 --- a/lam/lib/checkEnvironment.inc +++ b/lam/lib/checkEnvironment.inc @@ -103,6 +103,10 @@ if (isset($memLimit) && ($memLimit != '') && (substr(strtoupper($memLimit), strl if (!@preg_match('/^\p{L}+$/u', "abc")) { $criticalErrors[] = array("ERROR", "Your PCRE library has no complete Unicode support. Please upgrade libpcre or compile with \"--enable-unicode-properties\"."); } +// check ZIP support for PDF files in file upload +if (!extension_loaded('zip')) { + $criticalErrors[] = array("ERROR", "Your PHP has no ZIP support.", "Please install the ZIP extension for PHP."); +} // stop login if critical errors occured if (sizeof($criticalErrors) > 0) { echo "\n\n"; diff --git a/lam/lib/lamPDF.inc b/lam/lib/lamPDF.inc index 0a9b2558..36c241cf 100644 --- a/lam/lib/lamPDF.inc +++ b/lam/lib/lamPDF.inc @@ -4,7 +4,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) Copyright (C) 2003 - 2006 Michael Duergner - 2011 Roland Gruber + 2007 - 2012 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 @@ -27,6 +27,7 @@ $Id$ * and furthermore some helper functions. * * @author Michael Duergner + * @author Roland Gruber * @package PDF */ @@ -35,6 +36,7 @@ $Id$ * * @package PDF * @author Michael Duergner + * @author Roland Gruber */ class lamPDF extends UFPDF { @@ -64,7 +66,9 @@ class lamPDF extends UFPDF { */ function __construct($page_definitions = array(),$fontName) { $this->fontName = $fontName; - define('FPDF_FONTPATH', dirname(__FILE__) . '/font/'); + if (!defined('FPDF_FONTPATH')) { + define('FPDF_FONTPATH', dirname(__FILE__) . '/font/'); + } // Call constructor of superclass $this->FPDF('P','mm','A4'); diff --git a/lam/lib/ldap.inc b/lam/lib/ldap.inc index 997bd6d9..13215fa7 100644 --- a/lam/lib/ldap.inc +++ b/lam/lib/ldap.inc @@ -122,7 +122,9 @@ class Ldap{ /** Closes connection to server */ function close() { - @ldap_close($this->server); + if ($this->server != null) { + @ldap_close($this->server); + } } /** @@ -158,7 +160,7 @@ class Ldap{ $dir = @opendir($tmpDir); $file = @readdir($dir); while ($file) { - if ((substr($file, -4) == '.pdf') || (substr($file, -4) == '.jpg')) { + if ((substr($file, -4) == '.pdf') || (substr($file, -4) == '.jpg') || (substr($file, -4) == '.zip')) { $path = $tmpDir . $file; if ($time - filemtime($path) > 600) { @unlink($path); diff --git a/lam/lib/lists.inc b/lam/lib/lists.inc index b69ca9fb..6ebba0b7 100644 --- a/lam/lib/lists.inc +++ b/lam/lib/lists.inc @@ -923,6 +923,9 @@ class lamList { } elseif (isset($_GET['uploadAllOk'])) { StatusMessage('INFO', _("Upload has finished")); + if (isset($_SESSION['mass_pdf']['file'])) { + StatusMessage('INFO', sprintf(_('You can download your PDF files {link=%s}here{endlink}.'), '../' . $_SESSION['mass_pdf']['file'])); + } } elseif (isset($_SESSION['listRedirectMessages'])) { for ($i = 0; $i < sizeof($_SESSION['listRedirectMessages']); $i++) { diff --git a/lam/lib/pdf.inc b/lam/lib/pdf.inc index 634ccd2d..2fd7f53f 100644 --- a/lam/lib/pdf.inc +++ b/lam/lib/pdf.inc @@ -3,7 +3,8 @@ $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2003 - 2006 Michael Duergner + Copyright (C) 2003 - 2004 Michael Duergner + 2003 - 2012 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 @@ -26,6 +27,7 @@ $Id$ * and furthermore some helper functions. * * @author Michael Duergner + * @author Roland Gruber * @package PDF */ @@ -49,9 +51,10 @@ $line_width = LAMPDF_LINEWIDTH; * @param string $pdf_structure The filename of the structure definition that should be used * to create the PDF page. If not submitted the 'default.user' structure definition * for the appropriate account type. + * @param $returnAsString returns the PDF output as String value instead of writing it to a file * @return String PDF file name */ -function createModulePDF($accounts,$pdf_structure="default") { +function createModulePDF($accounts, $pdf_structure="default", $returnAsString = false) { /** PDF generator class */ include_once("fpdf.php"); @@ -142,12 +145,17 @@ function createModulePDF($accounts,$pdf_structure="default") { // Close PDF $pdf->Close(); - // use timestamp and random number from ldap.inc as filename so it should be unique. - $filename = '../../tmp/' . $_SESSION['ldap']->new_rand() . time() .'.pdf'; - // Save PDF - $pdf->Output($filename); - // return PDF file name - return $filename; + if (!$returnAsString) { + // use timestamp and random number from ldap.inc as filename so it should be unique. + $filename = '../../tmp/' . $_SESSION['ldap']->new_rand() . time() .'.pdf'; + // Save PDF + $pdf->Output($filename); + // return PDF file name + return $filename; + } + else { + return $pdf->Output('', 'S'); + } } /** diff --git a/lam/templates/massBuildAccounts.php b/lam/templates/massBuildAccounts.php index 33fab11a..13068133 100644 --- a/lam/templates/massBuildAccounts.php +++ b/lam/templates/massBuildAccounts.php @@ -3,7 +3,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2004 - 2011 Roland Gruber + Copyright (C) 2004 - 2012 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 @@ -195,6 +195,17 @@ if ($_FILES['inputfile'] && ($_FILES['inputfile']['size'] > 0)) { $_SESSION['mass_ids'] = $ids; $_SESSION['mass_scope'] = $_POST['scope']; $_SESSION['mass_selectedModules'] = $selectedModules; + if (isset($_SESSION['mass_pdf'])) { + unset($_SESSION['mass_pdf']); + } + if (isset($_POST['createPDF']) && ($_POST['createPDF'] == 'on')) { + $_SESSION['mass_pdf']['structure'] = $_POST['pdfStructure']; + $_SESSION['mass_pdf']['counter'] = 0; + $_SESSION['mass_pdf']['file'] = '../tmp/lam_pdf' . $_SESSION['ldap']->new_rand() . '.zip'; + } + else { + $_SESSION['mass_pdf']['structure'] = null; + } // show links for upload and LDIF export echo "