From d699ee133b595b4d109277907ec764c399e2d348 Mon Sep 17 00:00:00 2001 From: duergner Date: Thu, 27 May 2004 17:42:19 +0000 Subject: [PATCH] corrected some little bugs with pdf creation --- lam/config/pdf-structure.xml | 16 +++++++------- lam/lib/modules.inc | 12 ++-------- lam/lib/modules/sambaSamAccount.inc | 7 +++++- lam/lib/pdf.inc | 34 +++++++++++++++++++---------- 4 files changed, 38 insertions(+), 31 deletions(-) diff --git a/lam/config/pdf-structure.xml b/lam/config/pdf-structure.xml index 291943b8..ab9725c4 100644 --- a/lam/config/pdf-structure.xml +++ b/lam/config/pdf-structure.xml @@ -2,7 +2,7 @@
- + @@ -24,14 +24,14 @@
- + - - - - - - + + + + + +
diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc index 528ec7da..5c85ae11 100644 --- a/lam/lib/modules.inc +++ b/lam/lib/modules.inc @@ -982,16 +982,8 @@ class accountContainer { function get_pdfEntries($acount_type) { $return = array(); - for($i=0;$imodules[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; } diff --git a/lam/lib/modules/sambaSamAccount.inc b/lam/lib/modules/sambaSamAccount.inc index 1f07228d..a6798157 100644 --- a/lam/lib/modules/sambaSamAccount.inc +++ b/lam/lib/modules/sambaSamAccount.inc @@ -716,7 +716,12 @@ class sambaSamAccount { } function get_pdfEntries($account_type = "User") { - return array(); + return array( 'sambaDomainName' => array('' . _('Domain') . '' . $this->attributes['sambaDomainName'][0] . ''), + 'sambaHomeDrive' => array('' . _('Home drive') . '' . $this->attributes['sambaHomeDrive'][0] . ''), + 'sambaHomePath' => array('' . _('Home path') . '' . $this->attributes['sambaHomePath'][0] . ''), + 'sambaProfilePath' => array('' . _('Profile path') . '' . $this->attributes['sambaProfilePath'][0] . ''), + 'sambaLogonScript' => array('' . _('Login script') . '' . $this->attributes['sambaScriptPath'][0] . ''), + 'sambaUserWorkstations' => array('' . _('Samba workstations') . '' . $this->attributes['sambaUserWorkstations'][0] . '')); } } diff --git a/lam/lib/pdf.inc b/lam/lib/pdf.inc index 44ef7874..c9e45510 100644 --- a/lam/lib/pdf.inc +++ b/lam/lib/pdf.inc @@ -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 tag $key_pattern = '/()(.+)<\/key>(.*<\/block>)/'; // PCRE matching a tag - $value_pattern = '/(.*)(.+)<\/value>(<\/block>)/'; + // !!FIXME!! value must contain at least one character + $value_pattern = '/(.*)(.*)<\/value>(<\/block>)/'; // PCRE matching a tag $td_pattern = '/(.*?)(.+?)<\/td>(.*<\/block>)/'; // PCRE matching a

tag