From e8baa8d4fd0915e32e2a870beedaa020f84a85d2 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Tue, 3 Jan 2012 19:31:29 +0000 Subject: [PATCH] made description multi-valued (RFE 3446363) --- lam/HISTORY | 2 +- lam/lib/modules/inetOrgPerson.inc | 48 ++++++++++++++++++++++++++----- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/lam/HISTORY b/lam/HISTORY index 28145230..cd0539fc 100644 --- a/lam/HISTORY +++ b/lam/HISTORY @@ -1,6 +1,6 @@ March 2012 3.7 - Login: support bind user for login search - - Personal: added labeledURI and cosmetic changes + - Personal: added labeledURI and cosmetic changes, description is now multi-valued (RFE 3446363) - New translation: Slovakian - Fixed bugs: -> DHCP: error message not displayed properly (3441975) diff --git a/lam/lib/modules/inetOrgPerson.inc b/lam/lib/modules/inetOrgPerson.inc index d40a164e..1db8e3d3 100644 --- a/lam/lib/modules/inetOrgPerson.inc +++ b/lam/lib/modules/inetOrgPerson.inc @@ -4,7 +4,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) Copyright (C) 2003 - 2006 Tilo Lutz - 2005 - 2011 Roland Gruber + 2005 - 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 @@ -836,9 +836,21 @@ class inetOrgPerson extends baseModule implements passwordService { $this->attributes['objectClass'][] = 'person'; } } - // Load and check attributes + // load and check attributes + // description if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDescription')) { - $this->attributes['description'][0] = $_POST['description']; + $descriptionCounter = 0; + while (isset($_POST['description' . $descriptionCounter])) { + $this->attributes['description'][$descriptionCounter] = $_POST['description' . $descriptionCounter]; + if ($this->attributes['description'][$descriptionCounter] == '') { + unset($this->attributes['description'][$descriptionCounter]); + } + $descriptionCounter++; + } + if (isset($_POST['addDescription'])) { + $this->attributes['description'][] = ''; + } + $this->attributes['description'] = array_values($this->attributes['description']); } $this->attributes['sn'][0] = $_POST['sn']; if (!get_preg($this->attributes['sn'][0], 'realname')) $errors[] = $this->messages['lastname'][0]; @@ -1086,10 +1098,32 @@ class inetOrgPerson extends baseModule implements passwordService { $cnElement->setRequired(true); $fieldContainer->addElement($cnElement, true); } + // description if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDescription')) { - $description = ''; - if (isset($this->attributes['description'][0])) $description = $this->attributes['description'][0]; - $fieldContainer->addElement(new htmlTableExtendedInputField(_('Description'), 'description', $description, 'description'), true); + $descriptions = array(); + if (isset($this->attributes['description'][0])) { + $descriptions = $this->attributes['description']; + } + if (sizeof($descriptions) == 0) { + $descriptions[] = ''; + } + $descriptionLabel = new htmlOutputText(_('Description')); + $descriptionLabel->alignment = htmlElement::ALIGN_TOP; + $fieldContainer->addElement($descriptionLabel); + $descriptionContainer = new htmlGroup(); + for ($i = 0; $i < sizeof($descriptions); $i++) { + $descriptionContainer->addElement(new htmlInputField('description' . $i, $descriptions[$i])); + if ($i < (sizeof($descriptions) - 1)) { + $descriptionContainer->addElement(new htmlOutputText('
', false)); + } + else { + $descriptionContainer->addElement(new htmlButton('addDescription', 'add.png', true)); + } + } + $fieldContainer->addElement($descriptionContainer); + $descriptionHelp = new htmlHelpLink('description'); + $descriptionHelp->alignment = htmlElement::ALIGN_TOP; + $fieldContainer->addElement($descriptionHelp, true); } if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideStreet') || !$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostOfficeBox') @@ -1490,7 +1524,7 @@ class inetOrgPerson extends baseModule implements passwordService { */ function get_pdfEntries() { $description = ''; - if (isset($this->attributes['description'][0])) $description = $this->attributes['description'][0]; + if (isset($this->attributes['description'][0])) $description = implode(', ', $this->attributes['description']); $title = ''; if (isset($this->attributes['title'][0])) $title = $this->attributes['title'][0]; $givenName = '';