corrected some little bugs with pdf creation

This commit is contained in:
duergner 2004-05-27 17:42:19 +00:00
parent ec1c064e96
commit d699ee133b
4 changed files with 38 additions and 31 deletions

View File

@ -2,7 +2,7 @@
<pdf type="User">
<text name="User" />
<section name="Personal User Infos">
<entry name="Title" />
<entry name="title" />
<entry name="givenName" />
<entry name="sn" />
<entry name="street" />
@ -24,14 +24,14 @@
<entry name="host" />
</section>
<section name="Windows User Settings">
<entry name="Username" />
<entry name="uid" />
<entry name="Windows password" />
<entry name="Home drive" />
<entry name="Script path" />
<entry name="Profile path" />
<entry name="Login at workstation(s)" />
<entry name="Windows home directory" />
<entry name="Windows domain" />
<entry name="sambaHomeDrive" />
<entry name="sambaLogonScript" />
<entry name="sambaProfilePath" />
<entry name="sambaUserWorkstations" />
<entry name="sambaHomePath" />
<entry name="sambaDomainName" />
</section>
<section name="Quota Settings">
<entry name="User quotas" />

View File

@ -982,16 +982,8 @@ class accountContainer {
function get_pdfEntries($acount_type) {
$return = array();
for($i=0;$i<count($modules);$i++) {
$entries = $this->modules[i]->get_pdfEntries($account_type);
while(list($key,$value) = each($entries)) {
if(array_key_exists($key,$return)) {
array_push($return[$key],$value);
}
else {
$return[$key] = array($value);
}
}
while(($current = current($this->modules)) != null) {
$return = array_merge($return,$current->get_pdfEntries($account_type));
}
return $return;
}

View File

@ -716,7 +716,12 @@ class sambaSamAccount {
}
function get_pdfEntries($account_type = "User") {
return array();
return array( 'sambaDomainName' => array('<block><key>' . _('Domain') . '</key><value>' . $this->attributes['sambaDomainName'][0] . '</value></block>'),
'sambaHomeDrive' => array('<block><key>' . _('Home drive') . '</key><value>' . $this->attributes['sambaHomeDrive'][0] . '<value></<block>'),
'sambaHomePath' => array('<block><key>' . _('Home path') . '</key><value>' . $this->attributes['sambaHomePath'][0] . '</value></block>'),
'sambaProfilePath' => array('<block><key>' . _('Profile path') . '</key><value>' . $this->attributes['sambaProfilePath'][0] . '</value></block>'),
'sambaLogonScript' => array('<block><key>' . _('Login script') . '</key><value>' . $this->attributes['sambaScriptPath'][0] . '</value></block>'),
'sambaUserWorkstations' => array('<block><key>' . _('Samba workstations') . '</key><value>' . $this->attributes['sambaUserWorkstations'][0] . '</value></block>'));
}
}

View File

@ -32,7 +32,7 @@ include_once('xml_parser.inc');
$key = false;
$line_width = LAMPDF_LINEWIDTH;
function createModulePDF($accounts,$account_type) {
function createModulePDF($accounts,$account_type="") {
global $key;
@ -41,9 +41,6 @@ function createModulePDF($accounts,$account_type) {
$_SESSION['pdf_structure'] = getStructure();
}
// Get PDF structure from session
$structure = $_SESSION['pdf_structure'][$account_type];
// The decimal separator must be a dot in order to write pdf-files
setlocale(LC_NUMERIC, "C");
@ -52,6 +49,15 @@ function createModulePDF($accounts,$account_type) {
// Loop over each account and add a new page in the PDF file for it
foreach($accounts as $account) {
// Get account type from account container if none was specified or
// if it is different to the submitted or previous stored
if($account_type == "" || $account_type != $account->get_type()) {
$account_type = $account->get_type();
}
// Get PDF structure from session
$structure = $_SESSION['pdf_structure'][$account_type];
// Start a new page for each account
$pdf->AddPage();
@ -127,16 +133,19 @@ function createModulePDF($accounts,$account_type) {
}
// We have to include an entry from the account
elseif($entry['tag'] == "ENTRY") {
// Get name of current entry
$name = $entry['attributes']['NAME'];
// Get current entry
$entry = $entries[$name];
$value_entry = $entries[$name];
// Loop over all rows of this entry (most of the time this will be just one)
foreach($entry as $line) {
foreach($value_entry as $line) {
// Substitue XML syntax with valid FPDF methods
$methods = processLine($line);
// Call every method
foreach($methods as $method) {
call_user_method_array($pdf,$method[0],$method[1]);
call_user_func_array(array(&$pdf,$method[0]),$method[1]);
}
}
$key = false;
@ -145,7 +154,7 @@ function createModulePDF($accounts,$account_type) {
}
// Close PDF
$pdfFile->Close();
$pdf->Close();
// Get relative url path
$fullpath = realpath('.');
$subdirs = explode('/', str_replace($_SESSION['lampath'], '', $fullpath));
@ -153,16 +162,16 @@ function createModulePDF($accounts,$account_type) {
// use timestamp and random number from ldap.inc as filename so it should be unique.
$filename .= 'tmp/' . $_SESSION['ldap']->rand . time() .'.pdf';
// Save PDF
$pdfFile->Output($filename);
$pdf->Output($filename);
// Output meta refresh to pdf-file
metaRefresh($filename);
// Return relative path of pdf-file
return $filename;
}
function getStructure($account_type = array("User","Group","Host")) {
function getStructure($account_type = array("user","group","host")) {
$parser = new xmlParser();
$xml = $parser->parse('../config/pdf-structure.xml');
$xml = $parser->parse($_SESSION['lam_path'] . '/config/pdf-structure.xml');
$border = array();
$structure = array();
while(($current = current($account_type)) != null) {
@ -190,7 +199,8 @@ function processLine($line,$first_td = true) {
// PCRE matching a <key> tag
$key_pattern = '/(<block>)<key>(.+)<\/key>(.*<\/block>)/';
// PCRE matching a <value> tag
$value_pattern = '/(<block>.*)<value>(.+)<\/value>(<\/block>)/';
// !!FIXME!! value must contain at least one character
$value_pattern = '/(<block>.*)<value>(.*)<\/value>(<\/block>)/';
// PCRE matching a <td> tag
$td_pattern = '/(<block>.*?)<td(.*?)>(.+?)<\/td>(.*<\/block>)/';
// PCRE matching a <p> tag