implemented descriptive PDF fields
This commit is contained in:
parent
24f2b3bd6f
commit
f7fc93aedb
|
@ -1,11 +1,10 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Module HowTo - PDF output</title>
|
||||
<html><head><title>Module HowTo - PDF output</title>
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="style/layout.css">
|
||||
<link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico">
|
||||
</head>
|
||||
<body>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico"></head><body>
|
||||
<div style="text-align: center;">
|
||||
<h1>Module HowTo - PDF output<br>
|
||||
</h1>
|
||||
|
@ -21,15 +20,13 @@ not be able to select values from your module.<br>
|
|||
The PDF values are specified with <span style="font-weight: bold;">get_pdfFields()</span>
|
||||
or <span style="font-weight: bold;">meta['PDF_fields']</span>.<br>
|
||||
<br>
|
||||
<span style="font-weight: bold; text-decoration: underline;">Example:</span><br
|
||||
style="font-weight: bold; text-decoration: underline;">
|
||||
<span style="font-weight: bold; text-decoration: underline;">Example:</span><br style="font-weight: bold; text-decoration: underline;">
|
||||
<br>
|
||||
The <span style="font-style: italic;">ieee802Device</span>
|
||||
module has only one attribute and therefore one PDF value: the MAC
|
||||
address.<br>
|
||||
<br>
|
||||
<table style="width: 100%; text-align: left;" class="mod-code"
|
||||
border="0" cellpadding="2" cellspacing="2">
|
||||
<table style="width: 100%; text-align: left;" class="mod-code" border="0" cellpadding="2" cellspacing="2">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="vertical-align: top;"> /**<br>
|
||||
|
@ -44,11 +41,9 @@ get_metaData() {<br>
|
|||
[...]<br>
|
||||
// available PDF fields<br>
|
||||
<span style="color: rgb(255, 0, 0);">
|
||||
$return['PDF_fields'] = array(</span><br
|
||||
style="color: rgb(255, 0, 0);">
|
||||
$return['PDF_fields'] = array(</span><br style="color: rgb(255, 0, 0);">
|
||||
<span style="color: rgb(255, 0, 0);">
|
||||
'macAddress'</span><br
|
||||
style="color: rgb(255, 0, 0);">
|
||||
'macAddress' => _('MAC address')</span><br style="color: rgb(255, 0, 0);">
|
||||
<span style="color: rgb(255, 0, 0);">
|
||||
);</span><br style="color: rgb(255, 0, 0);">
|
||||
return $return;<br>
|
||||
|
@ -67,14 +62,12 @@ you module is asked for data to put into the PDF file.<br>
|
|||
<br>
|
||||
This is done with <span style="font-weight: bold;">get_pdfEntries()</span>.<br>
|
||||
<br>
|
||||
<span style="font-weight: bold; text-decoration: underline;">Example:</span><br
|
||||
style="font-weight: bold; text-decoration: underline;">
|
||||
<span style="font-weight: bold; text-decoration: underline;">Example:</span><br style="font-weight: bold; text-decoration: underline;">
|
||||
<br>
|
||||
The <span style="font-style: italic;">ieee802Device</span>
|
||||
module will return the MAC address list of the account.<br>
|
||||
<br>
|
||||
<table style="width: 100%; text-align: left;" class="mod-code"
|
||||
border="0" cellpadding="2" cellspacing="2">
|
||||
<table style="width: 100%; text-align: left;" class="mod-code" border="0" cellpadding="2" cellspacing="2">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="vertical-align: top;"> /**<br>
|
||||
|
@ -103,5 +96,4 @@ $this->attributes['macAddress']) . '</value></block>';<br>
|
|||
<h2><span style="font-weight: bold;"></span></h2>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</body></html>
|
|
@ -2,6 +2,7 @@
|
|||
<html><head>
|
||||
|
||||
|
||||
|
||||
|
||||
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-15"><title>Upgrade notes</title>
|
||||
|
||||
|
@ -19,8 +20,15 @@ This is a list of API changes for all LAM releases.
|
|||
|
||||
<br>
|
||||
|
||||
<h2>3.0.0 -> 3.1.0</h2>The PDF editor now supports descriptive PDF
|
||||
fields. You can use this by returning an associative array for the PDF
|
||||
fields (e.g. array('macAddress' => _('MAC address'))) in <span style="font-weight: bold;">get_pdfFields()</span> or the meta data.<br>
|
||||
The old format is still supported. LAM will continue to show the field name as label in this case.<br>
|
||||
<br>
|
||||
<br>
|
||||
<h2>2.9.0 -> 3.0.0</h2>
|
||||
|
||||
|
||||
You can now integrate JavaScript libraries by simply putting the files
|
||||
into templates/lib. All files with the name *.js are automatically
|
||||
included on all pages.<br>
|
||||
|
|
|
@ -358,14 +358,26 @@ function getHelp($module,$helpID,$scope='') {
|
|||
* Returns a list of available PDF entries.
|
||||
*
|
||||
* @param string $scope account type (user, group, host)
|
||||
* @return array PDF entries
|
||||
* @return array PDF entries (field ID => field label)
|
||||
*/
|
||||
function getAvailablePDFFields($scope) {
|
||||
$mods = $_SESSION['config']->get_AccountModules($scope);
|
||||
$return = array();
|
||||
for ($i = 0; $i < sizeof($mods); $i++) {
|
||||
$module = new $mods[$i]($scope);
|
||||
$return[$mods[$i]] = $module->get_pdfFields();
|
||||
$fields = $module->get_pdfFields();
|
||||
$return[$mods[$i]] = array();
|
||||
if (is_array($fields)) {
|
||||
foreach ($fields as $fieldID => $fieldLabel) {
|
||||
if (is_integer($fieldID)) {
|
||||
// support old PDF field list which did not contain a label
|
||||
$return[$mods[$i]][$fieldLabel] = $fieldLabel;
|
||||
}
|
||||
else {
|
||||
$return[$mods[$i]][$fieldID] = $fieldLabel;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$return['main'] = array('dn');
|
||||
return $return;
|
||||
|
|
|
@ -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
|
||||
Copyright (C) 2007 - 2009 Roland Gruber
|
||||
Copyright (C) 2007 - 2010 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
|
||||
|
@ -162,10 +162,10 @@ class shadowAccount extends baseModule implements passwordService {
|
|||
);
|
||||
// available PDF fields
|
||||
$return['PDF_fields'] = array(
|
||||
'shadowLastChange',
|
||||
'shadowWarning',
|
||||
'shadowInactive',
|
||||
'shadowExpire'
|
||||
'shadowLastChange' => _('Last password change'),
|
||||
'shadowWarning' => _('Password warning'),
|
||||
'shadowInactive' => _('Account inactive'),
|
||||
'shadowExpire' => _('Password expiration')
|
||||
);
|
||||
// help Entries
|
||||
$return['help'] = array (
|
||||
|
@ -415,8 +415,8 @@ class shadowAccount extends baseModule implements passwordService {
|
|||
function get_pdfEntries() {
|
||||
return array('shadowAccount_shadowLastChange' => array('<block><key>' . _('Last password change') . '</key><value>' . $this->attributes['shadowLastChange'][0] . '</value></block>'),
|
||||
'shadowAccount_shadowWarning' => array('<block><key>' . _('Password warning') . '</key><value>' . $this->attributes['shadowWarn'][0] . '</value><block>'),
|
||||
'shadowAccount_shadowInactive' => array('<block><key>' . _('Account inactive') . '</key><value>' . $this->attributes['shadowInactive'][0] . '</value></block>'),
|
||||
'shadowAccount_shadowExpire' => array('<block><key>' . _('Password expiration') . '</key><value>' . date('d. m. Y',$this->attributes['shadowExpire'][0]*24*3600) . '</value></block>'));
|
||||
'shadowAccount_shadowInactive' => array('<block><key>' . _('Password expiration') . '</key><value>' . $this->attributes['shadowInactive'][0] . '</value></block>'),
|
||||
'shadowAccount_shadowExpire' => array('<block><key>' . _('Account expiration date') . '</key><value>' . date('d. m. Y',$this->attributes['shadowExpire'][0]*24*3600) . '</value></block>'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -353,12 +353,30 @@ if(!isset($_SESSION['availablePDFFields'])) {
|
|||
$modules = array();
|
||||
$section_items_array = array();
|
||||
$section_items = '';
|
||||
foreach($_SESSION['availablePDFFields'] as $module => $values) {
|
||||
$modules[] = $module;
|
||||
foreach($values as $attribute) {
|
||||
$section_items_array[] = $module . '_' . $attribute;
|
||||
$section_items .= "<option>" . $module . '_' . $attribute . "</option>\n";
|
||||
$sortedModules = array();
|
||||
foreach($_SESSION['availablePDFFields'] as $module => $fields) {
|
||||
if ($module != 'main') {
|
||||
$title = getModuleAlias($module, $_GET['type']);
|
||||
}
|
||||
else {
|
||||
$title = _('Main');
|
||||
}
|
||||
$sortedModules[$module] = $title;
|
||||
}
|
||||
natcasesort($sortedModules);
|
||||
foreach($sortedModules as $module => $title) {
|
||||
$values = $_SESSION['availablePDFFields'][$module];
|
||||
if (!is_array($values) || (sizeof($values) < 1)) {
|
||||
continue;
|
||||
}
|
||||
$modules[] = $module;
|
||||
$section_items .= "<optgroup label=\"" . $title . "\"\n>";
|
||||
natcasesort($values);
|
||||
foreach($values as $attribute => $attributeLabel) {
|
||||
$section_items_array[] = $module . '_' . $attribute;
|
||||
$section_items .= "<option value=\"" . $module . '_' . $attribute . "\">" . $attributeLabel . "</option>\n";
|
||||
}
|
||||
$section_items .= "</optgroup>\n";
|
||||
}
|
||||
$modules = join(',',$modules);
|
||||
|
||||
|
@ -435,7 +453,7 @@ foreach($_SESSION['currentPDFStructure'] as $key => $entry) {
|
|||
<?php
|
||||
foreach($section_items_array as $item) {
|
||||
?>
|
||||
<option value="_<?php echo $item;?>"<?php echo ((substr($name,1) == $item) ? ' selected' : '');?>><?php echo $item;?></option>
|
||||
<option value="_<?php echo $item;?>"<?php echo ((substr($name,1) == $item) ? ' selected' : '');?>><?php echo translateFieldIDToName($item);?></option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
@ -517,7 +535,7 @@ foreach($_SESSION['currentPDFStructure'] as $key => $entry) {
|
|||
<td width="20">
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $name;?>
|
||||
<?php echo translateFieldIDToName($name, $_GET['type']);?>
|
||||
</td>
|
||||
<td width="20">
|
||||
</td>
|
||||
|
@ -624,19 +642,14 @@ foreach($_SESSION['currentPDFStructure'] as $key => $entry) {
|
|||
</legend><BR>
|
||||
<select name="new_field">
|
||||
<?php
|
||||
foreach($_SESSION['availablePDFFields'] as $module => $fields) {
|
||||
foreach($sortedModules as $module => $title) {
|
||||
$fields = $_SESSION['availablePDFFields'][$module];
|
||||
if (isset($fields) && is_array($fields) && (sizeof($fields) > 0)) {
|
||||
sort($fields);
|
||||
if ($module != 'main') {
|
||||
$title = getModuleAlias($module, $_GET['type']);
|
||||
}
|
||||
else {
|
||||
$title = _('Main');
|
||||
}
|
||||
natcasesort($fields);
|
||||
echo "<optgroup label=\"$title\">\n";
|
||||
foreach ($fields as $field) {
|
||||
echo "<option value=\"" . $module . "_" . $field . "\" label=\"$field\">$field</option>\n";
|
||||
}
|
||||
foreach ($fields as $field => $fieldLabel) {
|
||||
echo "<option value=\"" . $module . "_" . $field . "\" label=\"$fieldLabel\">$fieldLabel</option>\n";
|
||||
}
|
||||
echo "</optgroup>\n";
|
||||
}
|
||||
}
|
||||
|
@ -707,8 +720,37 @@ foreach($_SESSION['currentPDFStructure'] as $key => $entry) {
|
|||
</table>
|
||||
<input type="hidden" name="modules" value="<?php echo $modules;?>">
|
||||
<input type="hidden" name="type" value="<?php echo $_GET['type'];?>">
|
||||
<br><br><br>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<?php
|
||||
?>
|
||||
|
||||
/**
|
||||
* Translates a given field ID (e.g. inetOrgPerson_givenName) to its descriptive name.
|
||||
*
|
||||
* @param String $id field ID
|
||||
* @param String $scope account type
|
||||
*/
|
||||
function translateFieldIDToName($id, $scope) {
|
||||
foreach ($_SESSION['availablePDFFields'] as $module => $fields) {
|
||||
if (!(strpos($id, $module . '_') === 0)) {
|
||||
continue;
|
||||
}
|
||||
foreach ($fields as $name => $label) {
|
||||
if ($id == $module . '_' . $name) {
|
||||
if ($module == 'main') {
|
||||
return _('Main') . ': ' . $label;
|
||||
}
|
||||
else {
|
||||
return getModuleAlias($module, $scope) . ': ' . $label;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return $id;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue