diff --git a/lam/lib/lists.inc b/lam/lib/lists.inc
index 4a41d028..581e889f 100644
--- a/lam/lib/lists.inc
+++ b/lam/lib/lists.inc
@@ -177,8 +177,6 @@ class lamList {
// buttons
$this->listPrintButtons(false);
echo ("
\n");
- // PDF bar
- $this->listPrintPDFButtons();
}
else {
// buttons
@@ -428,7 +426,7 @@ class lamList {
" type=\"checkbox\" name=\"" . $info[$i]['LAM_ID'] . "\">\n";
}
echo "
";
- $this->listPrintToolLinks($info[$i]);
+ $this->listPrintToolLinks($info[$i], $info[$i]['LAM_ID']);
echo " | \n";
for ($k = 0; $k < sizeof($this->attrArray); $k++) {
echo ("");
@@ -452,23 +450,26 @@ class lamList {
/**
* Prints the tool image links (e.g. edit and delete) for each account.
*
- * $account array LDAP attributes
+ * @param array $account LDAP attributes
+ * @param String $id account ID
*/
- private function listPrintToolLinks($account) {
+ private function listPrintToolLinks($account, $id) {
// edit image
echo "type . "&DN='" . $account['dn'] . "'\">";
echo "";
- echo "";
+ echo "\n ";
// delete image
echo "type . "&DN='" . $account['dn'] . "'\">";
echo "";
- echo "";
+ echo "\n ";
+ // pdf image
+ echo "\n ";
// additional tools
$tools = $this->getAdditionalTools();
for ($i = 0; $i < sizeof($tools); $i++) {
echo "getLinkTarget() . "?type=" . $this->type . "&DN='" . $account['dn'] . "'\">";
echo "getImage() . "\" alt=\"" . $tools[$i]->getName() . "\" title=\"" . $tools[$i]->getName() . "\">";
- echo "";
+ echo "\n ";
}
}
@@ -499,7 +500,7 @@ class lamList {
*/
private function listDoPost() {
// check if button was pressed and if we have to add/delete an account
- if (isset($_POST['new']) || isset($_POST['del']) || isset($_POST['pdf']) || isset($_POST['pdf_all'])){
+ if (isset($_POST['new']) || isset($_POST['del'])){
// add new account
if (isset($_POST['new'])){
metaRefresh("../account/edit.php?type=" . $this->type . "&suffix=" . $this->suffix);
@@ -530,9 +531,31 @@ class lamList {
exit;
}
}
- // PDF for selected accounts
- elseif (isset($_POST['pdf'])){
- $pdf_structure = $_POST['pdf_structure'];
+ }
+ // PDF button
+ foreach ($_POST as $key => $value) {
+ if (strpos($key, 'createPDF_') > -1) {
+ $parts = explode("_", $key);
+ if (sizeof($parts) == 3) {
+ $this->showPDFPage($parts[1]);
+ exit;
+ }
+ }
+ }
+ // PDF creation Ok
+ if (isset($_POST['createPDFok'])) {
+ $pdfStruct = $_POST['pdf_structure'];
+ $option = $_POST['createFor'];
+ // create for clicked account
+ if ($option == 'DN') {
+ $_SESSION["accountPDF"] = new accountContainer($this->type, "accountPDF");
+ $_SESSION["accountPDF"]->load_account($this->entries[$_POST['clickedAccount']]['dn']);
+ createModulePDF(array($_SESSION["accountPDF"]),$pdfStruct);
+ unset($_SESSION["accountPDF"]);
+ exit;
+ }
+ // create for all selected accounts
+ elseif ($option == 'SELECTED') {
// search for checkboxes
$accounts = array_keys($_POST, "on");
$list = array();
@@ -544,12 +567,15 @@ class lamList {
$list[$i] = $_SESSION["accountPDF-$i"];
}
if (sizeof($list) > 0) {
- createModulePDF($list,$pdf_structure);
+ createModulePDF($list,$pdfStruct);
+ for ($i = 0; $i < sizeof($accounts); $i++) {
+ unset($_SESSION["accountPDF-$i"]);
+ }
exit;
}
}
- // PDF for all accounts
- elseif (isset($_POST['pdf_all'])){
+ // create for all accounts
+ elseif ($option == 'ALL') {
$list = array();
for ($i = 0; $i < sizeof($this->entries); $i++) {
$_SESSION["accountPDF-$i"] = new accountContainer($this->type, "accountPDF-$i");
@@ -557,7 +583,11 @@ class lamList {
$list[$i] = $_SESSION["accountPDF-$i"];
}
if (sizeof($list) > 0) {
- createModulePDF($list,$_POST['pdf_structure']);
+ createModulePDF($list,$pdfStruct);
+ for ($i = 0; $i < sizeof($this->entries); $i++) {
+ // clean session
+ unset($_SESSION["accountPDF-$i"]);
+ }
exit;
}
}
@@ -577,6 +607,68 @@ class lamList {
}
}
}
+
+ /**
+ * Shows the page where the user may select the PDF options.
+ *
+ * @param String $id account ID
+ */
+ private function showPDFPage($id) {
+ // search for checkboxes
+ $selAccounts = array_keys($_POST, "on");
+
+ $this->listPrintHeader();
+
+ echo '' . _('Create PDF') . "\n";
+ echo " |