From 4230f78268ff062ec5f1ce044d23a0930a078380 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 4 May 2013 18:22:07 +0000 Subject: [PATCH] reduced PDF code --- lam/lib/modules/account.inc | 8 +- lam/lib/modules/inetOrgPerson.inc | 176 ++++++------------------------ 2 files changed, 33 insertions(+), 151 deletions(-) diff --git a/lam/lib/modules/account.inc b/lam/lib/modules/account.inc index 8194525f..b4f39fc6 100644 --- a/lam/lib/modules/account.inc +++ b/lam/lib/modules/account.inc @@ -229,12 +229,8 @@ class account extends baseModule { */ function get_pdfEntries() { $return = array(); - $description = ''; - if (isset($this->attributes['description'][0])) { - $description = $this->attributes['description'][0]; - } - $return['account_description'] = array('' . _('Description') . '' . $description . ''); - $return['account_uid'] = array('' . _('User name') . '' . $this->attributes['uid'][0] . ''); + $this->addSimplePDFField($return, 'description', _('Description')); + $this->addSimplePDFField($return, 'uid', _('User name')); return $return; } diff --git a/lam/lib/modules/inetOrgPerson.inc b/lam/lib/modules/inetOrgPerson.inc index 28a2d02e..85108d37 100644 --- a/lam/lib/modules/inetOrgPerson.inc +++ b/lam/lib/modules/inetOrgPerson.inc @@ -2344,151 +2344,37 @@ class inetOrgPerson extends baseModule implements passwordService { * @return array list of possible PDF entries */ function get_pdfEntries() { - $description = ''; - if (isset($this->attributes['description'][0])) $description = implode(', ', $this->attributes['description']); - $title = ''; - if (isset($this->attributes['title'][0])) { - $title = implode(', ', $this->attributes['title']); - } - $givenName = ''; - if (isset($this->attributes['givenName'][0])) $givenName = $this->attributes['givenName'][0]; - $lastName = ''; - if (isset($this->attributes['sn'][0])) { - $lastName = $this->attributes['sn'][0]; - } - $manager = ''; - if (isset($this->attributes['manager'][0])) { - $manager = $this->attributes['manager'][0]; - } - $street = ''; - if (isset($this->attributes['street'][0])) { - $street = implode(', ', $this->attributes['street']); - } - $postOfficeBox = ''; - if (isset($this->attributes['postOfficeBox'][0])) { - $postOfficeBox = implode(', ', $this->attributes['postOfficeBox']); - } - $postalCode = ''; - if (isset($this->attributes['postalCode'][0])) { - $postalCode = implode(', ', $this->attributes['postalCode']); - } - $postalAddress = ''; - if (isset($this->attributes['postalAddress'][0])) { - $postalAddress = implode(', ', $this->attributes['postalAddress']); - } - $registeredAddress = ''; - if (isset($this->attributes['registeredAddress'][0])) { - $registeredAddress = implode(', ', $this->attributes['registeredAddress']); - } - $telephoneNumber = ''; - if (isset($this->attributes['telephoneNumber'][0])) { - $telephoneNumber = implode(', ', $this->attributes['telephoneNumber']); - } - $homePhone = ''; - if (isset($this->attributes['homePhone'][0])) { - $homePhone = implode(', ', $this->attributes['homePhone']); - } - $mobile = ''; - if (isset($this->attributes['mobile'][0])) { - $mobile = implode(', ', $this->attributes['mobile']); - } - $mail = ''; - if (isset($this->attributes['mail'][0])) { - $mail = implode(', ', $this->attributes['mail']); - } - $cn = ''; - if (isset($this->attributes['cn'][0])) { - $cn = $this->attributes['cn'][0]; - } - $roomNumber = ''; - if (isset($this->attributes['roomNumber'][0])) { - $roomNumber = $this->attributes['roomNumber'][0]; - } - $facsimileTelephoneNumber = ''; - if (isset($this->attributes['facsimileTelephoneNumber'][0])) { - $facsimileTelephoneNumber = implode(', ', $this->attributes['facsimileTelephoneNumber']); - } - $businessCategory = ''; - if (isset($this->attributes['businessCategory'][0])) { - $businessCategory = implode(', ', $this->attributes['businessCategory']); - } - $uid = ''; - if (isset($this->attributes['uid'][0])) { - $uid = $this->attributes['uid'][0]; - } - $carLicense = ''; - if (isset($this->attributes['carLicense'][0])) { - $carLicense = $this->attributes['carLicense'][0]; - } - $st = ''; - if (isset($this->attributes['st'][0])) { - $st = implode(', ', $this->attributes['st']); - } - $physicalDeliveryOfficeName = ''; - if (isset($this->attributes['physicalDeliveryOfficeName'][0])) { - $physicalDeliveryOfficeName = implode(', ', $this->attributes['physicalDeliveryOfficeName']); - } - $employeeType = ''; - if (isset($this->attributes['employeeType'][0])) $employeeType = $this->attributes['employeeType'][0]; - $l = ''; - if (isset($this->attributes['l'][0])) { - $l = implode(', ', $this->attributes['l']); - } - $employeeNumber = ''; - if (isset($this->attributes['employeeNumber'][0])) { - $employeeNumber = $this->attributes['employeeNumber'][0]; - } - $ou = ''; - if (isset($this->attributes['ou'][0])) { - $ou = implode(', ', $this->attributes['ou']); - } - $o = ''; - if (isset($this->attributes['o'][0])) { - $o = implode(', ', $this->attributes['o']); - } - $initials = ''; - if (isset($this->attributes['initials'][0])) { - $initials = implode(', ', $this->attributes['initials']); - } - $labeledURI = ''; - if (isset($this->attributes['labeledURI'][0])) { - $labeledURI = implode(', ', $this->attributes['labeledURI']); - } - - $return = array( - get_class($this) . '_description' => array('' . _('Description') . '' . $description . ''), - get_class($this) . '_title' => array('' . _('Job title') . '' . $title . ''), - get_class($this) . '_givenName' => array('' . _('First name') . '' . $givenName . ''), - get_class($this) . '_sn' => array('' . _('Last name') . '' . $lastName . ''), - get_class($this) . '_employeeType' => array('' . _('Employee type') . '' . $employeeType . ''), - get_class($this) . '_manager' => array('' . _('Manager') . '' . $manager . ''), - get_class($this) . '_street' => array('' . _('Street') . '' . $street . ''), - get_class($this) . '_postOfficeBox' => array('' . _('Post office box') . '' . $postOfficeBox . ''), - get_class($this) . '_postalCode' => array('' . _('Postal code') . '' . $postalCode . ''), - get_class($this) . '_postalAddress' => array('' . _('Postal address') . '' . $postalAddress . ''), - get_class($this) . '_registeredAddress' => array('' . _('Registered address') . '' . $registeredAddress . ''), - get_class($this) . '_telephoneNumber' => array('' . _('Telephone number') . '' . $telephoneNumber . ''), - get_class($this) . '_homePhone' => array('' . _('Home telephone number') . '' . $homePhone . ''), - get_class($this) . '_mobileTelephoneNumber' => array('' . _('Mobile number') . '' . $mobile . ''), - get_class($this) . '_facsimileTelephoneNumber' => array('' . _('Fax number') . '' . $facsimileTelephoneNumber . ''), - get_class($this) . '_mail' => array('' . _('Email address') . '' . $mail . ''), - get_class($this) . '_cn' => array('' . _('Common name') . '' . $cn . ''), - get_class($this) . '_roomNumber' => array('' . _('Room number') . '' . $roomNumber . ''), - get_class($this) . '_businessCategory' => array('' . _('Business category') . '' . $businessCategory . ''), - get_class($this) . '_uid' => array('' . _('User name') . '' . $uid . ''), - get_class($this) . '_carLicense' => array('' . _('Car license') . '' . $carLicense . ''), - get_class($this) . '_location' => array('' . _('Location') . '' . $l . ''), - get_class($this) . '_state' => array('' . _('State') . '' . $st . ''), - get_class($this) . '_officeName' => array('' . _('Office name') . '' . $physicalDeliveryOfficeName . ''), - get_class($this) . '_ou' => array('' . _('Organisational unit') . '' . $ou . ''), - get_class($this) . '_o' => array('' . _('Organisation') . '' . $o . ''), - get_class($this) . '_employeeNumber' => array('' . _('Employee number') . '' . $employeeNumber . ''), - get_class($this) . '_initials' => array('' . _('Initials') . '' . $initials . ''), - get_class($this) . '_labeledURI' => array('' . _('Web site') . '' . $labeledURI . ''), - ); - if (isset($this->attributes['departmentNumber'])) { - $return[get_class($this) . '_departmentNumber'] = array('' . _('Department') . '' . implode(', ', $this->attributes['departmentNumber']) . ''); - } + $return = array(); + $this->addSimplePDFField($return, 'description', _('Description')); + $this->addSimplePDFField($return, 'title', _('Job title')); + $this->addSimplePDFField($return, 'givenName', _('First name')); + $this->addSimplePDFField($return, 'sn', _('Last name')); + $this->addSimplePDFField($return, 'manager', _('Manager')); + $this->addSimplePDFField($return, 'street', _('Street')); + $this->addSimplePDFField($return, 'postOfficeBox', _('Post office box')); + $this->addSimplePDFField($return, 'postalCode', _('Postal code')); + $this->addSimplePDFField($return, 'postalAddress', _('Postal address')); + $this->addSimplePDFField($return, 'registeredAddress', _('Registered address')); + $this->addSimplePDFField($return, 'telephoneNumber', _('Telephone number')); + $this->addSimplePDFField($return, 'homePhone', _('Home telephone number')); + $this->addSimplePDFField($return, 'mobileTelephoneNumber', _('Mobile number'), 'mobile'); + $this->addSimplePDFField($return, 'mail', _('Email address')); + $this->addSimplePDFField($return, 'cn', _('Common name')); + $this->addSimplePDFField($return, 'facsimileTelephoneNumber', _('Fax number')); + $this->addSimplePDFField($return, 'roomNumber', _('Room number')); + $this->addSimplePDFField($return, 'businessCategory', _('Business category')); + $this->addSimplePDFField($return, 'uid', _('User name')); + $this->addSimplePDFField($return, 'carLicense', _('Car license')); + $this->addSimplePDFField($return, 'state', _('State'), 'st'); + $this->addSimplePDFField($return, 'officeName', _('Office name'), 'physicalDeliveryOfficeName'); + $this->addSimplePDFField($return, 'employeeType', _('Employee type')); + $this->addSimplePDFField($return, 'location', _('Location'), 'l'); + $this->addSimplePDFField($return, 'employeeNumber', _('Employee number')); + $this->addSimplePDFField($return, 'ou', _('Organisational unit')); + $this->addSimplePDFField($return, 'o', _('Organisation')); + $this->addSimplePDFField($return, 'initials', _('Initials')); + $this->addSimplePDFField($return, 'labeledURI', _('Web site')); + $this->addSimplePDFField($return, 'departmentNumber', _('Department')); return $return; }