corrected some little bugs with pdf creation
This commit is contained in:
parent
ec1c064e96
commit
d699ee133b
|
@ -2,7 +2,7 @@
|
||||||
<pdf type="User">
|
<pdf type="User">
|
||||||
<text name="User" />
|
<text name="User" />
|
||||||
<section name="Personal User Infos">
|
<section name="Personal User Infos">
|
||||||
<entry name="Title" />
|
<entry name="title" />
|
||||||
<entry name="givenName" />
|
<entry name="givenName" />
|
||||||
<entry name="sn" />
|
<entry name="sn" />
|
||||||
<entry name="street" />
|
<entry name="street" />
|
||||||
|
@ -24,14 +24,14 @@
|
||||||
<entry name="host" />
|
<entry name="host" />
|
||||||
</section>
|
</section>
|
||||||
<section name="Windows User Settings">
|
<section name="Windows User Settings">
|
||||||
<entry name="Username" />
|
<entry name="uid" />
|
||||||
<entry name="Windows password" />
|
<entry name="Windows password" />
|
||||||
<entry name="Home drive" />
|
<entry name="sambaHomeDrive" />
|
||||||
<entry name="Script path" />
|
<entry name="sambaLogonScript" />
|
||||||
<entry name="Profile path" />
|
<entry name="sambaProfilePath" />
|
||||||
<entry name="Login at workstation(s)" />
|
<entry name="sambaUserWorkstations" />
|
||||||
<entry name="Windows home directory" />
|
<entry name="sambaHomePath" />
|
||||||
<entry name="Windows domain" />
|
<entry name="sambaDomainName" />
|
||||||
</section>
|
</section>
|
||||||
<section name="Quota Settings">
|
<section name="Quota Settings">
|
||||||
<entry name="User quotas" />
|
<entry name="User quotas" />
|
||||||
|
|
|
@ -982,16 +982,8 @@ class accountContainer {
|
||||||
|
|
||||||
function get_pdfEntries($acount_type) {
|
function get_pdfEntries($acount_type) {
|
||||||
$return = array();
|
$return = array();
|
||||||
for($i=0;$i<count($modules);$i++) {
|
while(($current = current($this->modules)) != null) {
|
||||||
$entries = $this->modules[i]->get_pdfEntries($account_type);
|
$return = array_merge($return,$current->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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -716,7 +716,12 @@ class sambaSamAccount {
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_pdfEntries($account_type = "User") {
|
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>'));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ include_once('xml_parser.inc');
|
||||||
$key = false;
|
$key = false;
|
||||||
$line_width = LAMPDF_LINEWIDTH;
|
$line_width = LAMPDF_LINEWIDTH;
|
||||||
|
|
||||||
function createModulePDF($accounts,$account_type) {
|
function createModulePDF($accounts,$account_type="") {
|
||||||
|
|
||||||
global $key;
|
global $key;
|
||||||
|
|
||||||
|
@ -41,9 +41,6 @@ function createModulePDF($accounts,$account_type) {
|
||||||
$_SESSION['pdf_structure'] = getStructure();
|
$_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
|
// The decimal separator must be a dot in order to write pdf-files
|
||||||
setlocale(LC_NUMERIC, "C");
|
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
|
// Loop over each account and add a new page in the PDF file for it
|
||||||
foreach($accounts as $account) {
|
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
|
// Start a new page for each account
|
||||||
$pdf->AddPage();
|
$pdf->AddPage();
|
||||||
|
|
||||||
|
@ -127,16 +133,19 @@ function createModulePDF($accounts,$account_type) {
|
||||||
}
|
}
|
||||||
// We have to include an entry from the account
|
// We have to include an entry from the account
|
||||||
elseif($entry['tag'] == "ENTRY") {
|
elseif($entry['tag'] == "ENTRY") {
|
||||||
|
// Get name of current entry
|
||||||
|
$name = $entry['attributes']['NAME'];
|
||||||
|
|
||||||
// Get current entry
|
// 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)
|
// 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
|
// Substitue XML syntax with valid FPDF methods
|
||||||
$methods = processLine($line);
|
$methods = processLine($line);
|
||||||
// Call every method
|
// Call every method
|
||||||
foreach($methods as $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;
|
$key = false;
|
||||||
|
@ -145,7 +154,7 @@ function createModulePDF($accounts,$account_type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close PDF
|
// Close PDF
|
||||||
$pdfFile->Close();
|
$pdf->Close();
|
||||||
// Get relative url path
|
// Get relative url path
|
||||||
$fullpath = realpath('.');
|
$fullpath = realpath('.');
|
||||||
$subdirs = explode('/', str_replace($_SESSION['lampath'], '', $fullpath));
|
$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.
|
// use timestamp and random number from ldap.inc as filename so it should be unique.
|
||||||
$filename .= 'tmp/' . $_SESSION['ldap']->rand . time() .'.pdf';
|
$filename .= 'tmp/' . $_SESSION['ldap']->rand . time() .'.pdf';
|
||||||
// Save PDF
|
// Save PDF
|
||||||
$pdfFile->Output($filename);
|
$pdf->Output($filename);
|
||||||
// Output meta refresh to pdf-file
|
// Output meta refresh to pdf-file
|
||||||
metaRefresh($filename);
|
metaRefresh($filename);
|
||||||
// Return relative path of pdf-file
|
// Return relative path of pdf-file
|
||||||
return $filename;
|
return $filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStructure($account_type = array("User","Group","Host")) {
|
function getStructure($account_type = array("user","group","host")) {
|
||||||
$parser = new xmlParser();
|
$parser = new xmlParser();
|
||||||
$xml = $parser->parse('../config/pdf-structure.xml');
|
$xml = $parser->parse($_SESSION['lam_path'] . '/config/pdf-structure.xml');
|
||||||
$border = array();
|
$border = array();
|
||||||
$structure = array();
|
$structure = array();
|
||||||
while(($current = current($account_type)) != null) {
|
while(($current = current($account_type)) != null) {
|
||||||
|
@ -190,7 +199,8 @@ function processLine($line,$first_td = true) {
|
||||||
// PCRE matching a <key> tag
|
// PCRE matching a <key> tag
|
||||||
$key_pattern = '/(<block>)<key>(.+)<\/key>(.*<\/block>)/';
|
$key_pattern = '/(<block>)<key>(.+)<\/key>(.*<\/block>)/';
|
||||||
// PCRE matching a <value> tag
|
// 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
|
// PCRE matching a <td> tag
|
||||||
$td_pattern = '/(<block>.*?)<td(.*?)>(.+?)<\/td>(.*<\/block>)/';
|
$td_pattern = '/(<block>.*?)<td(.*?)>(.+?)<\/td>(.*<\/block>)/';
|
||||||
// PCRE matching a <p> tag
|
// PCRE matching a <p> tag
|
||||||
|
|
Loading…
Reference in New Issue