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 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.
|
||||
*
|
||||
|
@ -1098,7 +1107,7 @@ class accountContainer {
|
|||
function getAvailablePDFFields() {
|
||||
$return = array();
|
||||
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 $return;
|
||||
|
|
|
@ -92,15 +92,8 @@ function createModulePDF($accounts,$pdf_structure="default.xml") {
|
|||
}
|
||||
// We have to include a static text.
|
||||
elseif($entry['tag'] == "TEXT") {
|
||||
// Decide which individual text to fetch
|
||||
if(isset($entry['attributes']['NAME'])) {
|
||||
$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);
|
||||
// Load PDF text from structure array
|
||||
$info_string = $entry['value'];
|
||||
// Get all allowed vairables from account-object
|
||||
$values = get_object_vars($account);
|
||||
$values = array_keys($values);
|
||||
|
|
|
@ -89,4 +89,8 @@ function savePDFStructureDefinitions($scope,$definition) {
|
|||
fwrite($handle,$file);
|
||||
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/ldap.inc");
|
||||
include_once("../../lib/config.inc");
|
||||
include_once("../../lib/modules.inc");
|
||||
|
||||
// start session
|
||||
session_save_path("../../sess");
|
||||
|
@ -56,65 +57,33 @@ if ($_POST['forward'] == "yes") {
|
|||
}
|
||||
// on submit forward to other pdf structure pages
|
||||
else if($_POST['submit']) {
|
||||
// create new user pdf structure
|
||||
if ($_POST['pdf'] == "new_user") {
|
||||
metaRefresh("pdfpage.php?type=user");
|
||||
if($_POST['pdf'] == 'new') {
|
||||
metaRefresh('pdfpage.php?type=' . $_POST['scope']);
|
||||
}
|
||||
// edit user pdf structure
|
||||
elseif($_POST['pdf'] == "edit_user") {
|
||||
metaRefresh("pdfpage.php?type=user&edit=" . $_POST['edit_user']);
|
||||
else if($_POST['pdf'] == 'edit') {
|
||||
$edit = split(':',$_POST['edit']);
|
||||
metaRefresh('pdfpage.php?type=' . $edit[0] . '&edit=' . $edit[1]);
|
||||
}
|
||||
// delete user pdf structure
|
||||
elseif($_POST['pdf'] == "delete_user") {
|
||||
metaRefresh("pdfdelete.php?type=user&delete=" . $_POST['delete_user']);
|
||||
}
|
||||
// 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']);
|
||||
else if($_POST['pdf'] == 'delete') {
|
||||
$delete = split(':',$_POST['delete']);
|
||||
metaRefresh('pdfdelete.php?type=' . $delete[0] . '&delete=' . $delete[1]);
|
||||
}
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
// Get available user PDF structure definitions
|
||||
$pdfStructDefs = getPDFStructureDefinitions('user');
|
||||
$user_pdf = '';
|
||||
for($i = 0;$i < count($pdfStructDefs); $i++) {
|
||||
$user_pdf .= '<option value="' . $pdfStructDefs[$i] . '.xml">' . $pdfStructDefs[$i] . "</option>\n";
|
||||
}
|
||||
$scopes = getAvailableScopes();
|
||||
|
||||
// Get available group PDF structure definitions
|
||||
$pdfStructDefs = getPDFStructureDefinitions('group');
|
||||
$group_pdf = '';
|
||||
for($i = 0;$i < count($pdfStructDefs); $i++) {
|
||||
$group_pdf .= '<option value="' . $pdfStructDefs[$i] . '.xml">' . $pdfStructDefs[$i] . "</option>\n";
|
||||
}
|
||||
$availableStructureDefinitions = '';
|
||||
$availableScopes = '';
|
||||
|
||||
// Get available host PDF structure definitions
|
||||
$pdfStructDefs = getPDFStructureDefinitions('host');
|
||||
$host_pdf = '';
|
||||
for($i = 0;$i < count($pdfStructDefs); $i++) {
|
||||
$host_pdf .= '<option value="' . $pdfStructDefs[$i] . '.xml">' . $pdfStructDefs[$i] . "</option>\n";
|
||||
foreach($scopes as $scope) {
|
||||
$pdfStructDefs = getPDFStructureDefinitions($scope);
|
||||
$availableScopes .= '<option value="' . $scope . '">' . $scope . "</option>\n";
|
||||
|
||||
foreach($pdfStructDefs as $pdfStructureDefinition) {
|
||||
$availableStructureDefinitions .= '<option value="' . $scope . ':' . $pdfStructureDefinition . '.xml">' . $scope . ' - ' . $pdfStructureDefinition . "</option>\n";
|
||||
}
|
||||
}
|
||||
|
||||
echo $_SESSION['header'];
|
||||
|
@ -125,128 +94,47 @@ echo $_SESSION['header'];
|
|||
<body>
|
||||
<p></p>
|
||||
<form action="pdfmain.php" method="post">
|
||||
<!-- user pdf structure options -->
|
||||
<!-- pdf structure options -->
|
||||
<fieldset>
|
||||
<legend>
|
||||
<b><?php echo _("User PDF structures"); ?></b>
|
||||
<b><?php echo _("PDF structures"); ?></b>
|
||||
</legend>
|
||||
<table border=0>
|
||||
<!-- new user pdf structure -->
|
||||
<!-- new pdf structure -->
|
||||
<tr>
|
||||
<td>
|
||||
<input type="radio" name="pdf" value="new_user" checked>
|
||||
<input type="radio" name="pdf" value="new" checked="checked">
|
||||
</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>
|
||||
<!-- edit user pdf structure -->
|
||||
<!-- edit pdf structure -->
|
||||
<tr>
|
||||
<td>
|
||||
<input type="radio" name="pdf" value="edit_user">
|
||||
<input type="radio" name="pdf" value="edit">
|
||||
</td>
|
||||
<td>
|
||||
<select name="edit_user" size=1>
|
||||
<?php echo $user_pdf ?>
|
||||
<select name="edit" size=1>
|
||||
<?php echo $availableStructureDefinitions; ?>
|
||||
</select>
|
||||
</td>
|
||||
<td><?php echo _("Edit user PDF structure"); ?></td>
|
||||
<td><?php echo _("Edit PDF structure"); ?></td>
|
||||
</tr>
|
||||
<!-- delete user pdf structure -->
|
||||
<!-- delete pdf structure -->
|
||||
<tr>
|
||||
<td>
|
||||
<input type="radio" name="pdf" value="delete_user">
|
||||
<input type="radio" name="pdf" value="delete">
|
||||
</td>
|
||||
<td>
|
||||
<select name="delete_user" size=1>
|
||||
<?php echo $user_pdf ?>
|
||||
<select name="delete" size=1>
|
||||
<?php echo $availableStructureDefinitions; ?>
|
||||
</select>
|
||||
</td>
|
||||
<td><?php echo _("Delete user PDF structure"); ?></td>
|
||||
<td><?php echo _("Delete PDF structure"); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
<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 -->
|
||||
<p>
|
||||
<input type="hidden" name="forward" value="yes">
|
||||
|
|
|
@ -303,6 +303,7 @@ if(!isset($_SESSION['currentPDFStructure'])) {
|
|||
// Load structure file to be edit
|
||||
if($_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
|
||||
else {
|
||||
|
@ -578,6 +579,9 @@ foreach($_SESSION['currentPDFStructure'] as $key => $entry) {
|
|||
<b><?php echo _("Submit"); ?></b>
|
||||
</legend>
|
||||
<table border="0" align="left">
|
||||
<?php
|
||||
if(!isset($_GET['pdfname'])) {
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<b><?php echo _("Structure name"); ?>:</b>
|
||||
|
@ -594,8 +598,18 @@ foreach($_SESSION['currentPDFStructure'] as $key => $entry) {
|
|||
 
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<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");?>">
|
||||
</td>
|
||||
<td>
|
||||
|
|
Loading…
Reference in New Issue