PDF improved; some things still open; should work now;
This commit is contained in:
parent
eb6128bdfc
commit
ee5619ba08
|
@ -276,6 +276,15 @@ function getAvailablePDFFields($scope) {
|
||||||
return $_SESSION["profile_account_$scope"]->getAvailablePDFFields();
|
return $_SESSION["profile_account_$scope"]->getAvailablePDFFields();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a list of current available scopes
|
||||||
|
*
|
||||||
|
* @return array Available scopes
|
||||||
|
*/
|
||||||
|
function getAvailableScopes() {
|
||||||
|
return array('user','group','host');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class includes all modules and attributes of an account.
|
* This class includes all modules and attributes of an account.
|
||||||
*
|
*
|
||||||
|
@ -1098,7 +1107,7 @@ class accountContainer {
|
||||||
function getAvailablePDFFields() {
|
function getAvailablePDFFields() {
|
||||||
$return = array();
|
$return = array();
|
||||||
foreach($this->module as $moduleName => $module) {
|
foreach($this->module as $moduleName => $module) {
|
||||||
echo "<pre>moduleName: $moduleName\n</pre>";
|
//echo "<pre>moduleName: $moduleName\n</pre>";
|
||||||
$return[$moduleName] = $module->get_pdfFields($this->type);
|
$return[$moduleName] = $module->get_pdfFields($this->type);
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
|
|
|
@ -92,15 +92,8 @@ function createModulePDF($accounts,$pdf_structure="default.xml") {
|
||||||
}
|
}
|
||||||
// We have to include a static text.
|
// We have to include a static text.
|
||||||
elseif($entry['tag'] == "TEXT") {
|
elseif($entry['tag'] == "TEXT") {
|
||||||
// Decide which individual text to fetch
|
// Load PDF text from structure array
|
||||||
if(isset($entry['attributes']['NAME'])) {
|
$info_string = $entry['value'];
|
||||||
$text_name = $entry['attributes']['NAME'];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$text_name = "User";
|
|
||||||
}
|
|
||||||
// Load string with individual text for PDF from session
|
|
||||||
$info_string = $_SESSION['config']->get_pdftext($text_name);
|
|
||||||
// Get all allowed vairables from account-object
|
// Get all allowed vairables from account-object
|
||||||
$values = get_object_vars($account);
|
$values = get_object_vars($account);
|
||||||
$values = array_keys($values);
|
$values = array_keys($values);
|
||||||
|
|
|
@ -89,4 +89,8 @@ function savePDFStructureDefinitions($scope,$definition) {
|
||||||
fwrite($handle,$file);
|
fwrite($handle,$file);
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deletePDFStructureDefinition($scope,$definition) {
|
||||||
|
return unlink($_SESSION['lampath'] . 'config/pdf/' . $scope . '/' . $definition . '.xml');
|
||||||
|
}
|
||||||
?>
|
?>
|
|
@ -0,0 +1,91 @@
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
|
||||||
|
Copyright (C) 2004 Michael Dürgner
|
||||||
|
|
||||||
|
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
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manages deletion of pdf structures.
|
||||||
|
*
|
||||||
|
* @package PDF
|
||||||
|
* @author Michael Dürgner
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** helper functions for pdf */
|
||||||
|
include_once('../../lib/pdfstruct.inc');
|
||||||
|
|
||||||
|
// start session
|
||||||
|
session_save_path("../../sess");
|
||||||
|
@session_start();
|
||||||
|
|
||||||
|
setlanguage();
|
||||||
|
|
||||||
|
// check if user is logged in, if not go to login
|
||||||
|
if (!$_SESSION['ldap'] || !$_SESSION['ldap']->server()) {
|
||||||
|
metaRefresh("../login.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// print standard header
|
||||||
|
echo $_SESSION['header'];
|
||||||
|
echo ("<title>" . _("Delete PDF Structure") . "</title>\n");
|
||||||
|
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n";
|
||||||
|
echo ("</head>\n<body>\n<p><br></p>\n");
|
||||||
|
|
||||||
|
// check if admin has submited delete operation
|
||||||
|
if ($_POST['submit']) {
|
||||||
|
// delete user profile
|
||||||
|
if(!deletePDFStructureDefinition($_POST['type'],$_POST['delete'])) {
|
||||||
|
StatusMessage('ERROR', '', _('Unable to delete pdf structure!') . ' ' . _('Scope') . ': ' . $_POST['type'] . ' ' . _('Name') . ': ' . substr($_POST['delete'],0,strlen($_POST['delete']) - 4));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
StatusMessage('INFO', '', _('Deleted pdf structure:') . ' ' . _('Scope') . ': ' . $_POST['type'] . ' ' . _('Name') . ': ' . substr($_POST['delete'],0,strlen($_POST['delete']) - 4));
|
||||||
|
}
|
||||||
|
echo ("<br><a href=\"pdfmain.php\">" . _("Back to PDF Editor") . "</a>");
|
||||||
|
echo ("</body></html>\n");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if admin has aborted delete operation
|
||||||
|
if ($_POST['abort']) {
|
||||||
|
StatusMessage("INFO", "", _("Delete operation canceled."));
|
||||||
|
echo ("<br><a href=\"pdfmain.php\">" . _("Back to PDF Editor") . "</a>");
|
||||||
|
echo ("</body></html>\n");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if right type was given
|
||||||
|
$type = $_GET['type'];
|
||||||
|
if (($type == "user") || ($type == "host") || ($type == "group")) {
|
||||||
|
echo ("<p align=\"center\"><big>" . _("Do you really want to delete this pdf structure?") . " <b>");
|
||||||
|
echo (_('Scope') . ': ' . $_GET['type'] . ' ' . _('Name') . ': ' . substr($_GET['delete'],0,strlen($_GET['delete']) - 4) . "</b></big><br></p>\n");
|
||||||
|
echo ("<form action=\"pdfdelete.php\" method=\"post\">\n");
|
||||||
|
echo ("<p align=\"center\">\n");
|
||||||
|
echo ("<input type=\"submit\" name=\"submit\" value=\"" . _("Submit") . "\">\n");
|
||||||
|
echo ("<input type=\"submit\" name=\"abort\" value=\"" . _("Abort") . "\">\n");
|
||||||
|
echo ("<input type=\"hidden\" name=\"type\" value=\"" . $_GET['type'] . "\">");
|
||||||
|
echo ("<input type=\"hidden\" name=\"delete\" value=\"" . $_GET['delete'] . "\">");
|
||||||
|
echo ("</p></form></body></html>\n");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
// no valid pdf type
|
||||||
|
StatusMessage("ERROR", "", _("Wrong or missing type!") . " " . $type);
|
||||||
|
echo ("<a href=\"pdfmain.php\">" . _("Back to PDF Editor") . "</a>");
|
||||||
|
}
|
|
@ -26,6 +26,7 @@ $Id$
|
||||||
include_once("../../lib/pdfstruct.inc");
|
include_once("../../lib/pdfstruct.inc");
|
||||||
include_once("../../lib/ldap.inc");
|
include_once("../../lib/ldap.inc");
|
||||||
include_once("../../lib/config.inc");
|
include_once("../../lib/config.inc");
|
||||||
|
include_once("../../lib/modules.inc");
|
||||||
|
|
||||||
// start session
|
// start session
|
||||||
session_save_path("../../sess");
|
session_save_path("../../sess");
|
||||||
|
@ -56,65 +57,33 @@ if ($_POST['forward'] == "yes") {
|
||||||
}
|
}
|
||||||
// on submit forward to other pdf structure pages
|
// on submit forward to other pdf structure pages
|
||||||
else if($_POST['submit']) {
|
else if($_POST['submit']) {
|
||||||
// create new user pdf structure
|
if($_POST['pdf'] == 'new') {
|
||||||
if ($_POST['pdf'] == "new_user") {
|
metaRefresh('pdfpage.php?type=' . $_POST['scope']);
|
||||||
metaRefresh("pdfpage.php?type=user");
|
|
||||||
}
|
}
|
||||||
// edit user pdf structure
|
else if($_POST['pdf'] == 'edit') {
|
||||||
elseif($_POST['pdf'] == "edit_user") {
|
$edit = split(':',$_POST['edit']);
|
||||||
metaRefresh("pdfpage.php?type=user&edit=" . $_POST['edit_user']);
|
metaRefresh('pdfpage.php?type=' . $edit[0] . '&edit=' . $edit[1]);
|
||||||
}
|
}
|
||||||
// delete user pdf structure
|
else if($_POST['pdf'] == 'delete') {
|
||||||
elseif($_POST['pdf'] == "delete_user") {
|
$delete = split(':',$_POST['delete']);
|
||||||
metaRefresh("pdfdelete.php?type=user&delete=" . $_POST['delete_user']);
|
metaRefresh('pdfdelete.php?type=' . $delete[0] . '&delete=' . $delete[1]);
|
||||||
}
|
|
||||||
// create new group pdf structure
|
|
||||||
elseif ($_POST['pdf'] == "new_group") {
|
|
||||||
metaRefresh("pdfpage.php?type=group");
|
|
||||||
}
|
|
||||||
// edit group pdf structure
|
|
||||||
elseif($_POST['pdf'] == "edit_group") {
|
|
||||||
metaRefresh("pdfpage.php?type=group&edit=" . $_POST['edit_group']);
|
|
||||||
}
|
|
||||||
// delete group pdf structure
|
|
||||||
elseif($_POST['pdf'] == "delete_group") {
|
|
||||||
metaRefresh("pdfdelete.php?type=group&delete=" . $_POST['delete_group']);
|
|
||||||
}
|
|
||||||
// create new host pdf structure
|
|
||||||
elseif ($_POST['pdf'] == "new_host") {
|
|
||||||
metaRefresh("pdfpage.php?type=host");
|
|
||||||
}
|
|
||||||
// edit host pdf structure
|
|
||||||
elseif($_POST['pdf'] == "edit_host") {
|
|
||||||
metaRefresh("pdfpage.php?type=host&edit=" . $_POST['edit_host']);
|
|
||||||
}
|
|
||||||
// delete host pdf structure
|
|
||||||
elseif($_POST['pdf'] == "delete_host") {
|
|
||||||
metaRefresh("pdfdelete.php?type=host&delete=" . $_POST['delete_host']);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get available user PDF structure definitions
|
$scopes = getAvailableScopes();
|
||||||
$pdfStructDefs = getPDFStructureDefinitions('user');
|
|
||||||
$user_pdf = '';
|
|
||||||
for($i = 0;$i < count($pdfStructDefs); $i++) {
|
|
||||||
$user_pdf .= '<option value="' . $pdfStructDefs[$i] . '.xml">' . $pdfStructDefs[$i] . "</option>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get available group PDF structure definitions
|
$availableStructureDefinitions = '';
|
||||||
$pdfStructDefs = getPDFStructureDefinitions('group');
|
$availableScopes = '';
|
||||||
$group_pdf = '';
|
|
||||||
for($i = 0;$i < count($pdfStructDefs); $i++) {
|
|
||||||
$group_pdf .= '<option value="' . $pdfStructDefs[$i] . '.xml">' . $pdfStructDefs[$i] . "</option>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get available host PDF structure definitions
|
foreach($scopes as $scope) {
|
||||||
$pdfStructDefs = getPDFStructureDefinitions('host');
|
$pdfStructDefs = getPDFStructureDefinitions($scope);
|
||||||
$host_pdf = '';
|
$availableScopes .= '<option value="' . $scope . '">' . $scope . "</option>\n";
|
||||||
for($i = 0;$i < count($pdfStructDefs); $i++) {
|
|
||||||
$host_pdf .= '<option value="' . $pdfStructDefs[$i] . '.xml">' . $pdfStructDefs[$i] . "</option>\n";
|
foreach($pdfStructDefs as $pdfStructureDefinition) {
|
||||||
|
$availableStructureDefinitions .= '<option value="' . $scope . ':' . $pdfStructureDefinition . '.xml">' . $scope . ' - ' . $pdfStructureDefinition . "</option>\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
echo $_SESSION['header'];
|
echo $_SESSION['header'];
|
||||||
|
@ -125,128 +94,47 @@ echo $_SESSION['header'];
|
||||||
<body>
|
<body>
|
||||||
<p></p>
|
<p></p>
|
||||||
<form action="pdfmain.php" method="post">
|
<form action="pdfmain.php" method="post">
|
||||||
<!-- user pdf structure options -->
|
<!-- pdf structure options -->
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>
|
<legend>
|
||||||
<b><?php echo _("User PDF structures"); ?></b>
|
<b><?php echo _("PDF structures"); ?></b>
|
||||||
</legend>
|
</legend>
|
||||||
<table border=0>
|
<table border=0>
|
||||||
<!-- new user pdf structure -->
|
<!-- new pdf structure -->
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<input type="radio" name="pdf" value="new_user" checked>
|
<input type="radio" name="pdf" value="new" checked="checked">
|
||||||
</td>
|
</td>
|
||||||
<td colspan=2><?php echo _("Create a new user PDF structure"); ?></td>
|
<td colspan=2><?php echo _("Create a new PDF structure for scope: "); ?><select name="scope" size="1"><?php echo $availableScopes; ?></select></td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- edit user pdf structure -->
|
<!-- edit pdf structure -->
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<input type="radio" name="pdf" value="edit_user">
|
<input type="radio" name="pdf" value="edit">
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select name="edit_user" size=1>
|
<select name="edit" size=1>
|
||||||
<?php echo $user_pdf ?>
|
<?php echo $availableStructureDefinitions; ?>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
<td><?php echo _("Edit user PDF structure"); ?></td>
|
<td><?php echo _("Edit PDF structure"); ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- delete user pdf structure -->
|
<!-- delete pdf structure -->
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<input type="radio" name="pdf" value="delete_user">
|
<input type="radio" name="pdf" value="delete">
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select name="delete_user" size=1>
|
<select name="delete" size=1>
|
||||||
<?php echo $user_pdf ?>
|
<?php echo $availableStructureDefinitions; ?>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
<td><?php echo _("Delete user PDF structure"); ?></td>
|
<td><?php echo _("Delete PDF structure"); ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<p></p>
|
<p></p>
|
||||||
|
|
||||||
<!-- group pdf structure options -->
|
|
||||||
<fieldset>
|
|
||||||
<legend>
|
|
||||||
<b><?php echo _("Group PDF structures"); ?></b>
|
|
||||||
</legend>
|
|
||||||
<table border=0>
|
|
||||||
<!-- new group pdf structure -->
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<input type="radio" name="pdf" value="new_group">
|
|
||||||
</td>
|
|
||||||
<td colspan=2><?php echo _("Create a new group PDF structure"); ?></td>
|
|
||||||
</tr>
|
|
||||||
<!-- edit group pdf structure -->
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<input type="radio" name="pdf" value="edit_group">
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<select name="edit_group" size=1>
|
|
||||||
<?php echo $group_pdf ?>
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
<td><?php echo _("Edit group PDF structure"); ?></td>
|
|
||||||
</tr>
|
|
||||||
<!-- delete group pdf structure -->
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<input type="radio" name="pdf" value="delete_group">
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<select name="delete_group" size=1>
|
|
||||||
<?php echo $group_pdf ?>
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
<td><?php echo _("Delete group PDF structure"); ?></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</fieldset>
|
|
||||||
<p></p>
|
|
||||||
|
|
||||||
<!-- host pdf structure options -->
|
|
||||||
<fieldset>
|
|
||||||
<legend>
|
|
||||||
<b><?php echo _("Host PDF structures"); ?></b>
|
|
||||||
</legend>
|
|
||||||
<table border=0>
|
|
||||||
<!-- new host pdf structure -->
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<input type="radio" name="pdf" value="new_host">
|
|
||||||
</td>
|
|
||||||
<td colspan=2><?php echo _("Create a new host PDF structure"); ?></td>
|
|
||||||
</tr>
|
|
||||||
<!-- edit host pdf structure -->
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<input type="radio" name="pdf" value="edit_host">
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<select name="edit_host" size=1>
|
|
||||||
<?php echo $host_pdf ?>
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
<td><?php echo _("Edit host PDF structure"); ?></td>
|
|
||||||
</tr>
|
|
||||||
<!-- delete host pdf structure -->
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<input type="radio" name="pdf" value="delete_host">
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<select name="delete_host" size=1>
|
|
||||||
<?php echo $host_pdf ?>
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
<td><?php echo _("Delete host PDF structure"); ?></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</fieldset>
|
|
||||||
|
|
||||||
<!-- forward is used to check if buttons were pressed -->
|
<!-- forward is used to check if buttons were pressed -->
|
||||||
<p>
|
<p>
|
||||||
<input type="hidden" name="forward" value="yes">
|
<input type="hidden" name="forward" value="yes">
|
||||||
|
|
|
@ -303,6 +303,7 @@ if(!isset($_SESSION['currentPDFStructure'])) {
|
||||||
// Load structure file to be edit
|
// Load structure file to be edit
|
||||||
if($_GET['edit']) {
|
if($_GET['edit']) {
|
||||||
$_SESSION['currentPDFStructure'] = loadPDFStructureDefinitions($_GET['type'],$_GET['edit']);
|
$_SESSION['currentPDFStructure'] = loadPDFStructureDefinitions($_GET['type'],$_GET['edit']);
|
||||||
|
$_GET['pdfname'] = substr($_GET['edit'],0,strlen($_GET['edit']) - 4);
|
||||||
}
|
}
|
||||||
// Load default structure file when creating a new one
|
// Load default structure file when creating a new one
|
||||||
else {
|
else {
|
||||||
|
@ -578,6 +579,9 @@ foreach($_SESSION['currentPDFStructure'] as $key => $entry) {
|
||||||
<b><?php echo _("Submit"); ?></b>
|
<b><?php echo _("Submit"); ?></b>
|
||||||
</legend>
|
</legend>
|
||||||
<table border="0" align="left">
|
<table border="0" align="left">
|
||||||
|
<?php
|
||||||
|
if(!isset($_GET['pdfname'])) {
|
||||||
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<b><?php echo _("Structure name"); ?>:</b>
|
<b><?php echo _("Structure name"); ?>:</b>
|
||||||
|
@ -594,8 +598,18 @@ foreach($_SESSION['currentPDFStructure'] as $key => $entry) {
|
||||||
 
|
 
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
|
<?php
|
||||||
|
if(isset($_GET['pdfname'])) {
|
||||||
|
?>
|
||||||
|
<input type="hidden" name="pdfname" value="<?php echo $_GET['pdfname']; ?>">
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
<input type="submit" name="submit" value="<?php echo _("Save");?>">
|
<input type="submit" name="submit" value="<?php echo _("Save");?>">
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|
Loading…
Reference in New Issue