From 103ee7fc0c6620d256890a416c130bfeea3aed12 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Tue, 7 May 2013 19:18:21 +0000 Subject: [PATCH] reduced PDF code --- lam/lib/modules/posixAccount.inc | 16 +++++++--------- lam/lib/modules/posixGroup.inc | 9 +++++---- lam/lib/modules/puppetClient.inc | 33 +++++++++++++++----------------- 3 files changed, 27 insertions(+), 31 deletions(-) diff --git a/lam/lib/modules/posixAccount.inc b/lam/lib/modules/posixAccount.inc index 59ea6559..1538aeff 100644 --- a/lam/lib/modules/posixAccount.inc +++ b/lam/lib/modules/posixAccount.inc @@ -1616,18 +1616,16 @@ class posixAccount extends baseModule implements passwordService { $uidLabel = _('Host name'); } $return = array( - 'posixAccount_uid' => array('' . $uidLabel . '' . $this->attributes['uid'][0] . ''), - 'posixAccount_cn' => array('' . _('Common name') . '' . $this->attributes['cn'][0] . ''), - 'posixAccount_uidNumber' => array('' . _('UID number') . '' . $this->attributes['uidNumber'][0] . ''), - 'posixAccount_gidNumber' => array('' . _('GID number') . '' . $this->attributes['gidNumber'][0] . ''), 'posixAccount_primaryGroup' => array('' . _('Primary group') . '' . $this->getGroupName($this->attributes['gidNumber'][0]) . ''), 'posixAccount_additionalGroups' => array('' . _('Additional groups') . '' . implode(", ", $this->groups) . ''), - 'posixAccount_homeDirectory' => array('' . _('Home directory') . '' . $this->attributes['homeDirectory'][0] . ''), - 'posixAccount_loginShell' => array('' . _('Login shell') . '' . $this->attributes['loginShell'][0] . ''), ); - if (isset($this->attributes['gecos'][0])) { - $return['posixAccount_gecos'] = array('' . _('Gecos') . '' . $this->attributes['gecos'][0] . ''); - } + $this->addSimplePDFField($return, 'uid', $uidLabel); + $this->addSimplePDFField($return, 'cn', _('Common name')); + $this->addSimplePDFField($return, 'uidNumber', _('UID number')); + $this->addSimplePDFField($return, 'gidNumber', _('GID number')); + $this->addSimplePDFField($return, 'homeDirectory', _('Home directory')); + $this->addSimplePDFField($return, 'loginShell', _('Login shell')); + $this->addSimplePDFField($return, 'gecos', _('Gecos')); if (self::areGroupOfNamesActive()) { $allGons = $this->findGroupOfNames(); $gons = array(); diff --git a/lam/lib/modules/posixGroup.inc b/lam/lib/modules/posixGroup.inc index a3503385..f72efec7 100644 --- a/lam/lib/modules/posixGroup.inc +++ b/lam/lib/modules/posixGroup.inc @@ -500,12 +500,13 @@ class posixGroup extends baseModule implements passwordService { if (isset($this->attributes['memberUid'][0])) { $members = implode(', ', $this->attributes['memberUid']); } - return array( - get_class($this) . '_cn' => array('' . _('Group name') . '' . $this->attributes['cn'][0] . ''), - get_class($this) . '_gidNumber' => array('' . _('GID number') . '' . $this->attributes['gidNumber'][0] . ''), + $return = array( get_class($this) . '_memberUid' => array('' . _('Group members') . '' . $members . ''), - get_class($this) . '_description' => array('' . _('Description') . '' . $this->attributes['description'][0] . '') ); + $this->addSimplePDFField($return, 'cn', _('Group name')); + $this->addSimplePDFField($return, 'gidNumber', _('GID number')); + $this->addSimplePDFField($return, 'description', _('Description')); + return $return; } diff --git a/lam/lib/modules/puppetClient.inc b/lam/lib/modules/puppetClient.inc index 33c51d1c..f9eae09e 100644 --- a/lam/lib/modules/puppetClient.inc +++ b/lam/lib/modules/puppetClient.inc @@ -3,7 +3,7 @@ $Id$ This code is not yet part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2012 Roland Gruber + Copyright (C) 2012 - 2013 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 @@ -417,24 +417,21 @@ class puppetClient extends baseModule { */ function get_pdfEntries() { $return = array(); - if (in_array('puppetClient', $this->attributes['objectClass'])) { - if (isset($this->attributes['environment'][0])) { - $return['puppetClient_environment'][0] = '' . _('Environment') . '' . implode(', ', $this->attributes['environment']) . ''; + if (!in_array('puppetClient', $this->attributes['objectClass'])) { + return $return; + } + $this->addSimplePDFField($return, 'environment', _('Environment')); + $this->addSimplePDFField($return, 'parentnode', _('Parent node')); + if (isset($this->attributes['puppetclass'][0])) { + $return['puppetClient_puppetclass'][0] = '' . _('Classes') . '' . $this->attributes['puppetclass'][0] . ''; + for ($i = 1; $i < sizeof($this->attributes['puppetclass']); $i++) { + $return['puppetClient_puppetclass'][] = '' . $this->attributes['puppetclass'][$i] . ''; } - if (isset($this->attributes['parentnode'][0])) { - $return['puppetClient_parentnode'][0] = '' . _('Parent node') . '' . $this->attributes['parentnode'][0] . ''; - } - if (isset($this->attributes['puppetclass'][0])) { - $return['puppetClient_puppetclass'][0] = '' . _('Classes') . '' . $this->attributes['puppetclass'][0] . ''; - for ($i = 1; $i < sizeof($this->attributes['puppetclass']); $i++) { - $return['puppetClient_puppetclass'][] = '' . $this->attributes['puppetclass'][$i] . ''; - } - } - if (isset($this->attributes['puppetvar'][0])) { - $return['puppetClient_puppetvar'][0] = '' . _('Variables') . '' . $this->attributes['puppetvar'][0] . ''; - for ($i = 1; $i < sizeof($this->attributes['puppetvar']); $i++) { - $return['puppetClient_puppetvar'][] = '' . $this->attributes['puppetvar'][$i] . ''; - } + } + if (isset($this->attributes['puppetvar'][0])) { + $return['puppetClient_puppetvar'][0] = '' . _('Variables') . '' . $this->attributes['puppetvar'][0] . ''; + for ($i = 1; $i < sizeof($this->attributes['puppetvar']); $i++) { + $return['puppetClient_puppetvar'][] = '' . $this->attributes['puppetvar'][$i] . ''; } } return $return;