diff --git a/lam-packaging/debian/control b/lam-packaging/debian/control
index cc1983e9..23febc6e 100644
--- a/lam-packaging/debian/control
+++ b/lam-packaging/debian/control
@@ -8,9 +8,10 @@ Homepage: https://www.ldap-account-manager.org/
Package: ldap-account-manager
Architecture: all
-Depends: php5 (>= 5.4.26) | php (>= 7), php5-ldap | php-ldap, php5-gd | php-gd,
- php5-json | php-json, php5-imagick | php-imagick, php5-curl | php-curl,
- php5 | php-zip, php5 | php-xml, php5-imagick | php-imagick,
+Depends: php5 (>= 5.4.26) | php (>= 7), php5-ldap | php-ldap,
+ php5-gd | php-gd | php5-imagick | php-imagick,
+ php5-json | php-json, php5-curl | php-curl,
+ php5 | php-zip, php5 | php-xml,
libapache2-mod-php5 | libapache2-mod-php | php5-fpm | php-fpm,
php-tcpdf, php-phpseclib (>= 2.0),
apache2 (>= 2.4.0) | httpd, fonts-dejavu, debconf (>= 0.2.26) | debconf-2.0, ${misc:Depends}
diff --git a/lam/HISTORY b/lam/HISTORY
index 7f9e5e8c..63fce3a5 100644
--- a/lam/HISTORY
+++ b/lam/HISTORY
@@ -1,7 +1,8 @@
September 2018 6.5
- - Password change possible via LDAP EXOP operation (set LDAP_EXOP as password hash)
- - Dropped suppurt for Apache 2.2
+ - Password change possible via LDAP EXOP operation (set LDAP_EXOP as password hash, requires PHP 7.2)
+ - Dropped support for Apache 2.2
- Upload: allow to overwrite existing accounts
+ - Personal: photos can be printed in PDF export
- Kolab updates
- LAM Pro:
-> Auto deletion of entries with dynamic directory services support (requires PHP 7.2).
diff --git a/lam/docs/manual-sources/chapter-tools.xml b/lam/docs/manual-sources/chapter-tools.xml
index b2aaae30..a4a4195f 100644
--- a/lam/docs/manual-sources/chapter-tools.xml
+++ b/lam/docs/manual-sources/chapter-tools.xml
@@ -1,410 +1,407 @@
-
- Tools
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+
+ Tools
-
+
-
- Profile editor
+
+ Profile editor
- The account profiles are templates for your accounts. Here you can
- specify default values which can then be loaded when you create
- accounts. You may also load a template for an existing account to reset
- it to default values. When you create a new account then LAM will always
- load the profile named "default". This
- account profile can include default values for all your accounts.
+ The account profiles are templates for your accounts. Here you can
+ specify default values which can then be loaded when you create accounts.
+ You may also load a template for an existing account to reset it to
+ default values. When you create a new account then LAM will always load
+ the profile named "default". This account
+ profile can include default values for all your accounts.
-
-
-
-
-
-
-
+
+
+
+
+
+
+
- You can enter the LDAP suffix, RDN identifier and various other
- attributes depending on account type and activated modules.
+ You can enter the LDAP suffix, RDN identifier and various other
+ attributes depending on account type and activated modules.
-
-
-
-
-
-
-
+
+
+
+
+
+
+
- Import/export:
+ Import/export:
- Profiles can be exported to and imported from other server
- profiles.
+ Profiles can be exported to and imported from other server
+ profiles.
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
- There is a special export target called "*Global templates". All
- profiles exported here will be copied to all other server profiles
- (incl. new ones). But existing profiles with the same name are not
- overwritten. So a profile in global templates is treated as default
- profile for all server profiles.
+ There is a special export target called "*Global templates". All
+ profiles exported here will be copied to all other server profiles (incl.
+ new ones). But existing profiles with the same name are not overwritten.
+ So a profile in global templates is treated as default profile for all
+ server profiles.
- Use this if you would like to setup default profiles that are
- valid for all server profiles.
+ Use this if you would like to setup default profiles that are valid
+ for all server profiles.
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
- File upload
+
+ File upload
- When you need to create lots of accounts then you can use LAM's
- file upload to create them. LAM will read a CSV formatted file and
- create the related LDAP entries. Please check the data in you CSV file
- carefully. LAM will do less checks for the file upload than for single
- account creation.
+ When you need to create lots of accounts then you can use LAM's file
+ upload to create them. LAM will read a CSV formatted file and create the
+ related LDAP entries. Please check the data in you CSV file carefully. LAM
+ will do less checks for the file upload than for single account
+ creation.
- At the first page please select the account type and what
- extensions should be activated.
+ At the first page please select the account type and what extensions
+ should be activated.
-
-
-
-
-
-
-
+
+
+
+
+
+
+
- The next page shows all available options for the file upload. You
- will also find a sample CSV file which can be used as template for your
- CSV file. All red options are required columns in the file. You need to
- specify a value for each account.
+ The next page shows all available options for the file upload. You
+ will also find a sample CSV file which can be used as template for your
+ CSV file. All red options are required columns in the file. You need to
+ specify a value for each account.
- When you upload the CSV file then LAM first does some checks on
- this file. This includes syntax checks and if all required data was
- entered. No changes in the LDAP directory are done at this time.
+ When you upload the CSV file then LAM first does some checks on this
+ file. This includes syntax checks and if all required data was entered. No
+ changes in the LDAP directory are done at this time.
- If the checks were successful then LAM will ask again if you want
- to create the accounts. You will also have the chance to check the
- upload by viewing the changes in LDIF format.
+ If the checks were successful then LAM will ask again if you want to
+ create the accounts. You will also have the chance to check the upload by
+ viewing the changes in LDIF format.
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
- Multi edit
+
+ Multi edit
- This tool allows you to modify a large list of LDAP entries in
- batch mode. You can add new attributes/object classes, remove attributes
- and set attributes to a specific value.
+ This tool allows you to modify a large list of LDAP entries in batch
+ mode. You can add new attributes/object classes, remove attributes and set
+ attributes to a specific value.
- At the beginning, you need to specify where the entries are stored
- that should be changed. You can select an account suffix, the tree
- suffix or enter your own DN by selecting "Other".
+ At the beginning, you need to specify where the entries are stored
+ that should be changed. You can select an account suffix, the tree suffix
+ or enter your own DN by selecting "Other".
- Next, enter an additional LDAP filter to limit the entries that
- should be changed. E.g. use "(objectclass=inetOrgPerson)" to filter for
- users. You may also enter e.g. "(!(objectClass=passwordSelfReset))" to
- match all accounts that do not yet have the password self reset
- feature.
+ Next, enter an additional LDAP filter to limit the entries that
+ should be changed. E.g. use "(objectclass=inetOrgPerson)" to filter for
+ users. You may also enter e.g. "(!(objectClass=passwordSelfReset))" to
+ match all accounts that do not yet have the password self reset feature.
-
+
- Now, it is time to define the changes that should be done. The
- following operations are possible:
+ Now, it is time to define the changes that should be done. The
+ following operations are possible:
-
-
- Add: Adds an attribute value if not yet existing. Please do
- not use for single-value attributes that already have a
- value.
-
+
+
+ Add: Adds an attribute value if not yet existing. Please do not
+ use for single-value attributes that already have a value.
+
-
- Modify: Sets an attribute to the given value. If the attribute
- does not yet exist then it is added. If the attribute has multiple
- values then all other values are removed.
-
+
+ Modify: Sets an attribute to the given value. If the attribute
+ does not yet exist then it is added. If the attribute has multiple
+ values then all other values are removed.
+
-
- Delete: Deletes the specified value from this attribute. If
- you leave the value field blank then all attribute values are
- removed.
-
-
+
+ Delete: Deletes the specified value from this attribute. If you
+ leave the value field blank then all attribute values are
+ removed.
+
+
- Please note that all actions are run as separate LDAP commands.
- You cannot add an object class and a required attribute at the same
- time.
+ Please note that all actions are run as separate LDAP commands. You
+ cannot add an object class and a required attribute at the same
+ time.
-
-
-
-
-
-
-
+
+
+
+
+
+
+
- Dry run
+ Dry run
- You should always start with a dry run. It will not do any changes
- to your LDAP directory but print out all modifications that will be
- done. You will also be able to download the changes in LDIF format to
- use with ldapmodify. This is useful if you want to adjust some actions
- manually.
+ You should always start with a dry run. It will not do any changes
+ to your LDAP directory but print out all modifications that will be done.
+ You will also be able to download the changes in LDIF format to use with
+ ldapmodify. This is useful if you want to adjust some actions
+ manually.
-
-
-
-
-
-
-
+
+
+
+
+
+
+
- Apply changes
+ Apply changes
- This will run the actions against your LDAP directory. You will
- see which accounts are edited in the progress area and also if any
- errors occured.
+ This will run the actions against your LDAP directory. You will see
+ which accounts are edited in the progress area and also if any errors
+ occured.
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
- OU editor
+
+ OU editor
- This is a simple editor to add/delete organisational units in your
- LDAP tree. This way you can structure the accounts.
+ This is a simple editor to add/delete organisational units in your
+ LDAP tree. This way you can structure the accounts.
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
- PDF editor
+
+ PDF editor
- All accounts in LAM may be exported as PDF files. You can specify
- the page structure and displayed information by editing the PDF
- profiles.
+ All accounts in LAM may be exported as PDF files. You can specify
+ the page structure and displayed information by editing the PDF
+ profiles.
-
-
-
-
-
-
-
+
+
+
+
+
+
+
- When you export accounts to PDF then each account will get its own
- page inside the PDF. There is a headline on each page where you can show
- a page title. You may also add a logo to each page. To add more logos
- please use the logo management on the PDF editor main page.
+ When you export accounts to PDF then each account will get its own
+ page inside the PDF. There is a headline on each page where you can show a
+ page title. You may also add a logo to each page. To add more logos please
+ use the logo management on the PDF editor main page.
-
-
-
-
-
-
-
+
+
+
+
+
+
+
- The main part is structured into sections of information. Each
- section has a title. This can either be static text or the value of an
- attribute. You may also insert a static text block as section. Sections
- can be moved by using the arrows next to the section title.
+ The main part is structured into sections of information. Each
+ section has a title. This can either be static text or the value of an
+ attribute. You may also insert a static text block as section. Sections
+ can be moved by using the arrows next to the section title.
- Each section can contain multiple fields which usually represent
- LDAP attributes. You can simply add new fields by selecting the field
- name and its position. Then use the arrows to move the field inside the
- section.
+ Each section can contain multiple fields which usually represent
+ LDAP attributes. You can simply add new fields by selecting the field name
+ and its position. Then use the arrows to move the field inside the
+ section.
-
+
- Import/export:
+ Import/export:
- PDF structures can be exported to and imported from other server
- profiles.
+ PDF structures can be exported to and imported from other server
+ profiles.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ There is a special export target called "*Global templates". All PDF
+ structures exported here will be copied to all other server profiles
+ (incl. new ones). But existing PDF structures with the same name are not
+ overwritten. So a PDF structure in global templates is treated as default
+ structure for all server profiles.
+
+ Use this if you would like to setup default PDF structures that are
+ valid for all server profiles.
+
+
+
+
+
+
+
+
+
+ Logo management:
+
+ You can upload image files to put a custom logo on the PDF files.
+ The image file name must end with .png or .jpg.
+
+
+
+
+
+
+
+
+
+
+
+ Schema browser
+
+ Here you browse the schema of your LDAP server. You can view what
+ object classes, attributes, syntaxes and matching rules are available.
+ This is useful if you need to check if a certain object class is
+ available.
+
+
+
+
+
+
+
+
+
+
+
+ Server information
+
+ This shows information and statistics about your LDAP server. This
+ includes the suffixes, used overlays, connection data and operation
+ statistics. You will need "cn=monitor" setup to see all details. Some data
+ may not be available depending on your LDAP server software.
+
+ Please see the following links how to setup "cn=monitor":
+
+
+
+ OpenLDAP
+
+
+
+ 389
+ server
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Tests
+
+ This allows you to check if your LDAP schema is compatible with LAM
+ and to find possible problems.
+
+
+ Lamdaemon test
+
+ LAM provides an external script to manage home directories and
+ quotas. You can test here if everything is setup correctly.
+
+ If you get an error like "no tty present and no askpass program
+ specified" then the path to the lamdaemon.pl may be wrong. Please see
+ the lamdaemon installation
+ instructions for setup details.
-
-
-
-
-
-
-
-
-
-
-
-
-
- There is a special export target called "*Global templates". All
- PDF structures exported here will be copied to all other server profiles
- (incl. new ones). But existing PDF structures with the same name are not
- overwritten. So a PDF structure in global templates is treated as
- default structure for all server profiles.
-
- Use this if you would like to setup default PDF structures that
- are valid for all server profiles.
-
-
-
-
-
-
-
-
-
- Logo management:
-
- You can upload image files to put a custom logo on the PDF files.
- The image file name must end with .png or .jpg and the size must not
- exceed 2000x300px.
-
-
-
-
-
+
- Schema browser
+ Schema test
- Here you browse the schema of your LDAP server. You can view what
- object classes, attributes, syntaxes and matching rules are available.
- This is useful if you need to check if a certain object class is
- available.
+ This will test if your LDAP schema supports all object classes and
+ attributes of the active LAM modules. If you get a message that
+ something is missing please check that you installed all required schemas.
+
+ If you get error messages about object class violations then this
+ test can tell you what is missing.
-
+
-
-
- Server information
-
- This shows information and statistics about your LDAP server. This
- includes the suffixes, used overlays, connection data and operation
- statistics. You will need "cn=monitor" setup to see all details. Some
- data may not be available depending on your LDAP server software.
-
- Please see the following links how to setup "cn=monitor":
-
-
-
- OpenLDAP
-
-
-
- 389
- server
-
-
-
-
-
-
-
-
-
-
-
-
-
- Tests
-
- This allows you to check if your LDAP schema is compatible with
- LAM and to find possible problems.
-
-
- Lamdaemon test
-
- LAM provides an external script to manage home directories and
- quotas. You can test here if everything is setup correctly.
-
- If you get an error like "no tty present and no askpass program
- specified" then the path to the lamdaemon.pl may be wrong. Please see
- the lamdaemon installation
- instructions for setup details.
-
-
-
-
-
-
-
-
-
-
-
- Schema test
-
- This will test if your LDAP schema supports all object classes
- and attributes of the active LAM modules. If you get a message that
- something is missing please check that you installed all required schemas.
-
- If you get error messages about object class violations then
- this test can tell you what is missing.
-
-
-
-
-
-
-
-
-
-
-
+
+
diff --git a/lam/docs/manual-sources/images/pdfEditor.png b/lam/docs/manual-sources/images/pdfEditor.png
index 03b60527..043a2a66 100644
Binary files a/lam/docs/manual-sources/images/pdfEditor.png and b/lam/docs/manual-sources/images/pdfEditor.png differ
diff --git a/lam/docs/manual-sources/images/pdfEditor2.png b/lam/docs/manual-sources/images/pdfEditor2.png
index 1e52858d..fe2f43bd 100644
Binary files a/lam/docs/manual-sources/images/pdfEditor2.png and b/lam/docs/manual-sources/images/pdfEditor2.png differ
diff --git a/lam/docs/manual-sources/images/pdfEditor3.png b/lam/docs/manual-sources/images/pdfEditor3.png
index 0f264dca..1e2ac721 100644
Binary files a/lam/docs/manual-sources/images/pdfEditor3.png and b/lam/docs/manual-sources/images/pdfEditor3.png differ
diff --git a/lam/docs/manual-sources/images/pdfEditor4.png b/lam/docs/manual-sources/images/pdfEditor4.png
index acd0a7f2..2aaa8a4d 100644
Binary files a/lam/docs/manual-sources/images/pdfEditor4.png and b/lam/docs/manual-sources/images/pdfEditor4.png differ
diff --git a/lam/docs/manual-sources/images/pdfEditor5.png b/lam/docs/manual-sources/images/pdfEditor5.png
index c6938065..849503ce 100644
Binary files a/lam/docs/manual-sources/images/pdfEditor5.png and b/lam/docs/manual-sources/images/pdfEditor5.png differ
diff --git a/lam/docs/manual-sources/images/pdfEditor6.png b/lam/docs/manual-sources/images/pdfEditor6.png
index 95bf94b8..f7eb3075 100644
Binary files a/lam/docs/manual-sources/images/pdfEditor6.png and b/lam/docs/manual-sources/images/pdfEditor6.png differ
diff --git a/lam/lib/baseModule.inc b/lam/lib/baseModule.inc
index fdbc3bff..9b948af0 100644
--- a/lam/lib/baseModule.inc
+++ b/lam/lib/baseModule.inc
@@ -3,6 +3,7 @@ use \LAM\PDF\PDFLabelValue;
use \LAM\PDF\PDFTable;
use LAM\TYPES\ConfiguredType;
use function LAM\TYPES\getScopeFromTypeId;
+use LAM\PDF\PDFImage;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
@@ -846,6 +847,19 @@ abstract class baseModule {
$result[get_class($this) . '_' . $name][] = $table;
}
+ /**
+ * Adds an image to the PDF.
+ *
+ * @param array $result result array (entry will be added here)
+ * @param String $attrName attribute name
+ * @param PDFTable $table table
+ */
+ public function addPDFImage(&$result, $attrName) {
+ if (isset($this->attributes[$attrName]) && (sizeof($this->attributes[$attrName]) > 0)) {
+ $result[get_class($this) . '_' . $attrName][] = new PDFImage($this->attributes[$attrName][0]);
+ }
+ }
+
/**
* Returns an array containing all input columns for the file upload.
*
diff --git a/lam/lib/checkEnvironment.inc b/lam/lib/checkEnvironment.inc
index 34d2902f..d231d883 100644
--- a/lam/lib/checkEnvironment.inc
+++ b/lam/lib/checkEnvironment.inc
@@ -81,13 +81,9 @@ if (! function_exists('utf8_decode') || !extension_loaded('xml')) {
if (!extension_loaded('libxml')) {
$criticalErrors[] = array("ERROR", "Your PHP has no Lib XML support!", "Please install the Lib XML extension for PHP.");
}
-// imagick
-if (!extension_loaded('imagick')) {
- $criticalErrors[] = array("ERROR", "Your PHP has no imagick support.", "Please install the imagick extension for PHP.");
-}
-// check if PHP has GD support
-if (! function_exists('getimagesize')) {
- $criticalErrors[] = array("ERROR", "Your PHP has no GD support!", "Please install the GD extension for PHP.");
+// imagick/GD
+if (!extension_loaded('imagick') && !function_exists('getimagesize')) {
+ $criticalErrors[] = array("ERROR", "Your PHP has no imagick or GD support.", "Please install the imagick or GD extension for PHP.");
}
// check if PHP has JSON support
if (! function_exists('json_encode')) {
diff --git a/lam/lib/imageutils.inc b/lam/lib/imageutils.inc
index 00dc4a50..663bd3b3 100644
--- a/lam/lib/imageutils.inc
+++ b/lam/lib/imageutils.inc
@@ -44,6 +44,20 @@ class ImageManipulationFactory {
if (extension_loaded('imagick')) {
return new ImageManipulatorImagick($imageData);
}
+ return new ImageManipulatorGd($imageData);
+ }
+
+ /**
+ * Returns an image manipulator based on installed PHP modules.
+ *
+ * @param string $path path to image file
+ * @return ImageManipulator manipulator
+ */
+ public static function getImageManipulatorFromFile($path) {
+ $handle = fopen($path, "r");
+ $data = fread($handle, 100000000);
+ fclose($handle);
+ return ImageManipulationFactory::getImageManipulator($data);
}
}
@@ -130,7 +144,7 @@ class ImageManipulatorImagick implements ImageManipulator {
* @see \LAM\ImageUtils\ImageManipulator::getHeight()
*/
public function getHeight() {
- $this->image->getimageheight();
+ return $this->image->getimageheight();
}
/**
@@ -138,7 +152,7 @@ class ImageManipulatorImagick implements ImageManipulator {
* @see \LAM\ImageUtils\ImageManipulator::getWidth()
*/
public function getWidth() {
- $this->image->getimagewidth();
+ return $this->image->getimagewidth();
}
/**
@@ -157,15 +171,19 @@ class ImageManipulatorImagick implements ImageManipulator {
public function crop($x, $y, $width, $height) {
$this->image->cropimage($width, $height, $x, $y);
}
+
/**
* {@inheritDoc}
* @see \LAM\ImageUtils\ImageManipulator::resize()
*/
public function thumbnail($width, $height) {
+ if (($this->getWidth() <= $width) && ($this->getHeight() <= $height)) {
+ // skip if smaller than target size
+ return;
+ }
$this->image->thumbnailimage($width, $height, true);
}
-
/**
* {@inheritDoc}
* @see \LAM\ImageUtils\ImageManipulator::getImageData()
@@ -176,5 +194,134 @@ class ImageManipulatorImagick implements ImageManipulator {
}
+/**
+ * Manipulates images using gd library.
+ *
+ * @author Roland Gruber
+ */
+class ImageManipulatorGd implements ImageManipulator {
+
+ /**
+ * Image
+ *
+ * @var resource image
+ */
+ private $image;
+
+ /**
+ * GD image type
+ *
+ * @var int image type
+ */
+ private $type;
+
+ /**
+ * Constructor.
+ *
+ * @param string $imageData original image as binary string
+ */
+ public function __construct($imageData) {
+ $this->image = imagecreatefromstring($imageData);
+ $info = getimagesizefromstring($imageData);
+ $this->type = $info[2];
+ }
+
+ /**
+ * Destructor
+ */
+ public function __destruct() {
+ if ($this->image != null) {
+ imagedestroy($this->image);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ * @see \LAM\ImageUtils\ImageManipulator::getHeight()
+ */
+ public function getHeight() {
+ return imagesy($this->image);
+ }
+
+ /**
+ * {@inheritDoc}
+ * @see \LAM\ImageUtils\ImageManipulator::getWidth()
+ */
+ public function getWidth() {
+ return imagesx($this->image);
+ }
+
+ /**
+ * {@inheritDoc}
+ * @see \LAM\ImageUtils\ImageManipulator::getAsJpeg()
+ */
+ public function convertToJpeg() {
+ $this->type = IMAGETYPE_JPEG;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @see \LAM\ImageUtils\ImageManipulator::crop()
+ */
+ public function crop($x, $y, $width, $height) {
+ $this->image = imagecrop($this->image, array(
+ 'x' => $x,
+ 'y' => $y,
+ 'width' => $width,
+ 'height' => $height
+ ));
+ }
+ /**
+ * {@inheritDoc}
+ * @see \LAM\ImageUtils\ImageManipulator::resize()
+ */
+ public function thumbnail($width, $height) {
+ if (($this->getWidth() <= $width) && ($this->getHeight() <= $height)) {
+ // skip if smaller than target size
+ return;
+ }
+ $thumbWidth = $this->getWidth();
+ $thumbHeight = $this->getHeight();
+ if ($thumbWidth > $width) {
+ $factor = $width / $thumbWidth;
+ $thumbWidth = $thumbWidth * $factor;
+ $thumbHeight = $thumbHeight * $factor;
+ }
+ if ($thumbHeight > $height) {
+ $factor = $height / $thumbHeight;
+ $thumbWidth = $thumbWidth * $factor;
+ $thumbHeight = $thumbHeight * $factor;
+ }
+ $thumbnail = imagecreatetruecolor($thumbWidth, $thumbHeight);
+ imagecopyresampled(
+ $thumbnail,
+ $this->image,
+ 0, 0, 0, 0,
+ $thumbWidth,
+ $thumbHeight,
+ $this->getWidth(),
+ $this->getHeight());
+ $this->image = $thumbnail;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ * @see \LAM\ImageUtils\ImageManipulator::getImageData()
+ */
+ public function getImageData() {
+ ob_start();
+ if ($this->type == IMAGETYPE_JPEG) {
+ imagejpeg($this->image);
+ }
+ else if ($this->type == IMAGETYPE_PNG) {
+ imagepng($this->image);
+ }
+ $output = ob_get_contents();
+ ob_clean();
+ return $output;
+ }
+
+}
?>
diff --git a/lam/lib/lamtcpdf.inc b/lam/lib/lamtcpdf.inc
index ec167a38..6236f2df 100644
--- a/lam/lib/lamtcpdf.inc
+++ b/lam/lib/lamtcpdf.inc
@@ -2,7 +2,7 @@
namespace LAM\PDF;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
- Copyright (C) 2017 Roland Gruber
+ Copyright (C) 2017 - 2018 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
@@ -69,7 +69,6 @@ class LAMTCPDF extends \TCPDF {
$logoFile = $this->structure->getLogo();
if (!empty($logoFile) && ($logoFile !== 'none')) {
$logo = dirname(__FILE__) . "/../config/pdf/" . $_SESSION['config']->getName() . "/logos/" . $logoFile;
- $imgProperties = getimagesize($logo);
$this->Image($logo, 10, 10, '', 15, 'JPG', '', 'T', false, 300, '', false, false, 0, false, false, false);
}
else {
diff --git a/lam/lib/modules/inetOrgPerson.inc b/lam/lib/modules/inetOrgPerson.inc
index 8a4ff1aa..f4147c03 100644
--- a/lam/lib/modules/inetOrgPerson.inc
+++ b/lam/lib/modules/inetOrgPerson.inc
@@ -1,6 +1,7 @@
isBooleanConfigOptionSet('inetOrgPerson_hideInitials')) {
$return['PDF_fields']['initials'] = _('Initials');
}
+ if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidejpegPhoto')) {
+ $return['PDF_fields']['jpegPhoto'] = _('Photo');
+ }
// help Entries
$return['help'] = array (
'description' => array (
@@ -2014,6 +2018,7 @@ class inetOrgPerson extends baseModule implements passwordService {
else if (isset($this->attributes['INFO.userPasswordClearText'])) {
$this->addPDFKeyValue($return, 'userPassword', _('Password'), $this->attributes['INFO.userPasswordClearText']);
}
+ $this->addPDFImage($return, 'jpegPhoto');
return $return;
}
diff --git a/lam/lib/pdf.inc b/lam/lib/pdf.inc
index 5a694d8a..9d0bdbe0 100644
--- a/lam/lib/pdf.inc
+++ b/lam/lib/pdf.inc
@@ -1,5 +1,7 @@
Ln(LAMPDF_LINEHEIGHT);
}
+/**
+ * Prints a PDFLabelValue entry.
+ *
+ * @param LAMTCPDF $pdf PDF
+ * @param PDFImage $imageEntry entry
+ * @param string $fontName font name
+ */
+function printImage(&$pdf, $imageEntry, $fontName) {
+ include_once dirname(__FILE__) . '/imageutils.inc';
+ $imageManipulator = ImageManipulationFactory::getImageManipulator($imageEntry->getImageData());
+ $height = $imageManipulator->getHeight() / 2.9;
+ if ($height > 40) {
+ $height = 40;
+ }
+ $pdf->Image('@' . $imageManipulator->getImageData(), null, null, null, $height,
+ 'JPG', null, 'T', true, 300, 'R',
+ false, false, 0, false, false, false);
+ $pdf->Ln($height);
+ $pdf->Ln(LAMPDF_LINEHEIGHT);
+ $imageManipulator = null;
+}
+
/**
* Common interface for all PDF entries.
*
@@ -381,3 +408,41 @@ class PDFLabelValue implements PDFEntry {
}
}
+
+/**
+ * Adds an image to the PDF file.
+ *
+ * @package PDF
+ * @author Roland Gruber
+ */
+class PDFImage implements PDFEntry {
+
+ private $binaryData;
+
+ /**
+ * Constructor
+ *
+ * @param string $binaryData image data
+ */
+ public function __construct($binaryData) {
+ $this->binaryData = $binaryData;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @see \LAM\PDF\PDFEntry::getHeadline()
+ */
+ public function getHeadline() {
+ return '';
+ }
+
+ /**
+ * Returns the image data.
+ *
+ * @return string image data
+ */
+ public function getImageData() {
+ return $this->binaryData;
+ }
+
+}
diff --git a/lam/lib/pdfstruct.inc b/lam/lib/pdfstruct.inc
index 3d58322e..ad92ea58 100644
--- a/lam/lib/pdfstruct.inc
+++ b/lam/lib/pdfstruct.inc
@@ -3,6 +3,7 @@ namespace LAM\PDF;
use \htmlStatusMessage;
use \LAMException;
+use \LAM\ImageUtils\ImageManipulationFactory;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2003 - 2006 Michael Duergner
@@ -102,10 +103,11 @@ function getAvailableLogos() {
$dirHandle = opendir($dirPath);
while($file = readdir($dirHandle)) {
if(!is_dir($file) && $file != '.' && $file != '..' && preg_match('/\\.(jpg|png)$/i',$file)) {
- $infos = getimagesize($dirPath . $file);
- if($infos[0] <= 2000 && $infos[1] <= 300) {
- array_push($return, array('filename' => $file, 'infos' => $infos));
- }
+ include_once dirname(__FILE__) . '/imageutils.inc';
+ $imageManipulator = ImageManipulationFactory::getImageManipulatorFromFile($dirPath . $file);
+ $infos = array($imageManipulator->getWidth(), $imageManipulator->getHeight());
+ $imageManipulator = null;
+ array_push($return, array('filename' => $file, 'infos' => $infos));
}
}
sort($return);
@@ -169,18 +171,14 @@ function uploadPDFLogo($file, $name) {
if (!preg_match('/[a-zA-Z0-9_-]+\\.(png)|(jpg)/i', $name)) {
return new htmlStatusMessage('ERROR', _('Unable to upload logo file.'), _('The file name must end with ".png" or ".jpg".'));
}
- $infos = getimagesize($file);
- if ($infos[0] <= 2000 && $infos[1] <= 300) {
- $dirPath = dirname(__FILE__) . '/../config/pdf/' . $_SESSION['config']->getName() . '/logos/';
- $success = copy($file, $dirPath . '/' . $name);
- if ($success) {
- return new htmlStatusMessage('INFO', _('Uploaded logo file.'), $name);
- }
- else {
- return new htmlStatusMessage('ERROR', _('Unable to upload logo file.'), $name);
- }
+ $dirPath = dirname(__FILE__) . '/../config/pdf/' . $_SESSION['config']->getName() . '/logos/';
+ $success = copy($file, $dirPath . '/' . $name);
+ if ($success) {
+ return new htmlStatusMessage('INFO', _('Uploaded logo file.'), $name);
+ }
+ else {
+ return new htmlStatusMessage('ERROR', _('Unable to upload logo file.'), $name);
}
- return new htmlStatusMessage('ERROR', _('Unable to upload logo file.'), _('The file must not exeed 2000x300px.'));
}
/**
diff --git a/lam/lib/types/user.inc b/lam/lib/types/user.inc
index fc98ef09..3079c86e 100644
--- a/lam/lib/types/user.inc
+++ b/lam/lib/types/user.inc
@@ -1,4 +1,6 @@
getHeight();
+ $imageManipulator = null;
$minSize = 64;
- if ($imgSize[0] < 64) {
- $minSize = $imgSize[0];
+ if ($imgHeight < 64) {
+ $minSize = $imgHeight;
}
$imgTitle = _('Click to switch between thumbnail and original size.');
echo "";
echo '';
}
elseif (($attribute == 'mail') || ($attribute == 'rfc822Mailbox')) {