dialog for delete confirmation

This commit is contained in:
Roland Gruber 2011-04-25 18:00:47 +00:00
parent c9f8b3d6cd
commit 8def4a53ff
2 changed files with 68 additions and 53 deletions

View File

@ -4,7 +4,7 @@ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2003 - 2006 Michael Duergner
2005 - 2010 Roland Gruber
2005 - 2011 Roland Gruber
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
@ -75,6 +75,23 @@ for ($i = 0; $i < sizeof($scopes); $i++) {
}
natcasesort($sortedScopes);
$container = new htmlTable();
$container->addElement(new htmlTitle(_('PDF editor')), true);
if (isset($_POST['deleteProfile']) && ($_POST['deleteProfile'] == 'true')) {
// delete structure
if (deletePDFStructureDefinition($_POST['profileDeleteType'], $_POST['profileDeleteName'])) {
$message = new htmlStatusMessage('INFO', _('Deleted PDF structure.'), getTypeAlias($_POST['profileDeleteType']) . ': ' . htmlspecialchars($_POST['profileDeleteName']));
$message->colspan = 10;
$container->addElement($message, true);
}
else {
$message = new htmlStatusMessage('ERROR', _('Unable to delete PDF structure!'), getTypeAlias($_POST['profileDeleteType']) . ': ' . htmlspecialchars($_POST['profileDeleteName']));
$message->colspan = 10;
$container->addElement($message, true);
}
}
// get list of account types
$availableScopes = '';
$templateClasses = array();
@ -97,38 +114,17 @@ for ($i = 0; $i < sizeof($templateClasses); $i++) {
exit;
}
}
// check if a profile should be deleted
for ($i = 0; $i < sizeof($templateClasses); $i++) {
if (isset($_POST['deleteTemplate_' . $templateClasses[$i]['scope']]) || isset($_POST['deleteTemplate_' . $templateClasses[$i]['scope'] . '_x'])) {
metaRefresh('pdfdelete.php?type=' . $templateClasses[$i]['scope'] . '&delete=' . $_POST['template_' . $templateClasses[$i]['scope']]);
exit;
}
}
$container = new htmlTable();
include '../main_header.php';
?>
<div class="userlist-bright smallPaddingContent">
<form action="pdfmain.php" method="post">
<?php
$container->addElement(new htmlTitle(_('PDF editor')), true);
if (isset($_GET['savedSuccessfully'])) {
$message = new htmlStatusMessage("INFO", _("PDF structure was successfully saved."), htmlspecialchars($_GET['savedSuccessfully']));
$message->colspan = 10;
$container->addElement($message, true);
}
if (isset($_GET['deleteFailed'])) {
$message = new htmlStatusMessage('ERROR', _('Unable to delete PDF structure!'), getTypeAlias($_GET['deleteScope']) . ': ' . htmlspecialchars($_GET['deleteFailed']));
$message->colspan = 10;
$container->addElement($message, true);
}
if (isset($_GET['deleteSucceeded'])) {
$message = new htmlStatusMessage('INFO', _('Deleted PDF structure.'), getTypeAlias($_GET['deleteScope']) . ': ' . htmlspecialchars($_GET['deleteSucceeded']));
$message->colspan = 10;
$container->addElement($message, true);
}
// new template
$container->addElement(new htmlSubTitle(_('Create a new PDF structure')), true);
@ -157,9 +153,10 @@ include '../main_header.php';
$exEditButton = new htmlButton('editTemplate_' . $templateClasses[$i]['scope'], 'edit.png', true);
$exEditButton->setTitle(_('Edit'));
$existingContainer->addElement($exEditButton);
$exDelButton = new htmlButton('deleteTemplate_' . $templateClasses[$i]['scope'], 'delete.png', true);
$exDelButton->setTitle(_('Delete'));
$existingContainer->addElement($exDelButton, true);
$deleteLink = new htmlLink(null, '#', '../../graphics/delete.png');
$deleteLink->setTitle(_('Delete'));
$deleteLink->setOnClick("profileShowDeleteDialog('" . _('Delete') . "', '" . _('Ok') . "', '" . _('Cancel') . "', '" . $templateClasses[$i]['scope'] . "', '" . 'template_' . $templateClasses[$i]['scope'] . "');");
$existingContainer->addElement($deleteLink, true);
$existingContainer->addElement(new htmlSpacer(null, '10px'), true);
}
$container->addElement($existingContainer, true);
@ -170,5 +167,15 @@ include '../main_header.php';
</form>
</div>
<?php
include '../main_footer.php';
// form for delete action
echo '<div id="deleteProfileDialog" class="hidden"><form id="deleteProfileForm" action="pdfmain.php" method="post">';
echo _("Do you really want to delete this PDF structure?");
echo '<br><br><div class="nowrap">';
echo _("Structure name") . ': <div id="deleteText" style="display: inline;"></div></div>';
echo '<input id="profileDeleteType" type="hidden" name="profileDeleteType" value="">';
echo '<input id="profileDeleteName" type="hidden" name="profileDeleteName" value="">';
echo '<input type="hidden" name="deleteProfile" value="true">';
echo '</form></div>';
include '../main_footer.php';
?>

View File

@ -3,7 +3,7 @@
$Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2003 - 2010 Roland Gruber
Copyright (C) 2003 - 2011 Roland Gruber
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
@ -80,12 +80,25 @@ for ($i = 0; $i < sizeof($profileClasses); $i++) {
exit;
}
}
// check if a profile should be deleted
for ($i = 0; $i < sizeof($profileClasses); $i++) {
if (isset($_POST['deleteProfile_' . $profileClasses[$i]['scope']]) || isset($_POST['deleteProfile_' . $profileClasses[$i]['scope'] . '_x'])) {
metaRefresh("profiledelete.php?type=" . $profileClasses[$i]['scope'] .
"&amp;del=" . $_POST['profile_' . $profileClasses[$i]['scope']]);
exit;
include '../main_header.php';
echo "<div class=\"userlist-bright smallPaddingContent\">\n";
echo "<form action=\"profilemain.php\" method=\"post\">\n";
$container = new htmlTable();
$container->addElement(new htmlTitle(_("Profile editor")), true);
if (isset($_POST['deleteProfile']) && ($_POST['deleteProfile'] == 'true')) {
// delete profile
if (delAccountProfile($_POST['profileDeleteName'], $_POST['profileDeleteType'])) {
$message = new htmlStatusMessage('INFO', _('Deleted profile.'), getTypeAlias($_POST['profileDeleteType']) . ': ' . htmlspecialchars($_POST['profileDeleteName']));
$message->colspan = 10;
$container->addElement($message, true);
}
else {
$message = new htmlStatusMessage('ERROR', _('Unable to delete profile!'), getTypeAlias($_POST['profileDeleteType']) . ': ' . htmlspecialchars($_POST['profileDeleteName']));
$message->colspan = 10;
$container->addElement($message, true);
}
}
@ -96,28 +109,11 @@ for ($i = 0; $i < sizeof($profileClasses); $i++) {
$profileClasses[$i]['profiles'] = $profileList;
}
include '../main_header.php';
echo "<div class=\"userlist-bright smallPaddingContent\">\n";
echo "<form action=\"profilemain.php\" method=\"post\">\n";
$container = new htmlTable();
$container->addElement(new htmlTitle(_("Profile editor")), true);
if (isset($_GET['savedSuccessfully'])) {
$message = new htmlStatusMessage("INFO", _("Profile was saved."), htmlspecialchars($_GET['savedSuccessfully']));
$message->colspan = 10;
$container->addElement($message, true);
}
if (isset($_GET['deleteFailed'])) {
$message = new htmlStatusMessage('ERROR', _('Unable to delete profile!'), getTypeAlias($_GET['deleteScope']) . ': ' . htmlspecialchars($_GET['deleteFailed']));
$message->colspan = 10;
$container->addElement($message, true);
}
if (isset($_GET['deleteSucceeded'])) {
$message = new htmlStatusMessage('INFO', _('Deleted profile.'), getTypeAlias($_GET['deleteScope']) . ': ' . htmlspecialchars($_GET['deleteSucceeded']));
$message->colspan = 10;
$container->addElement($message, true);
}
// new profile
$container->addElement(new htmlSubTitle(_('Create a new profile')), true);
@ -156,9 +152,10 @@ for ($i = 0; $i < sizeof($profileClasses); $i++) {
$editButton = new htmlButton('editProfile_' . $profileClasses[$i]['scope'], 'edit.png', true);
$editButton->setTitle(_('Edit'));
$existingContainer->addElement($editButton);
$deleteButton = new htmlButton('deleteProfile_' . $profileClasses[$i]['scope'], 'delete.png', true);
$deleteButton->setTitle(_('Delete'));
$existingContainer->addElement($deleteButton);
$deleteLink = new htmlLink(null, '#', '../../graphics/delete.png');
$deleteLink->setTitle(_('Delete'));
$deleteLink->setOnClick("profileShowDeleteDialog('" . _('Delete') . "', '" . _('Ok') . "', '" . _('Cancel') . "', '" . $profileClasses[$i]['scope'] . "', '" . 'profile_' . $profileClasses[$i]['scope'] . "');");
$existingContainer->addElement($deleteLink);
$existingContainer->addNewLine();
}
$container->addElement($existingContainer);
@ -169,6 +166,17 @@ parseHtml(null, $container, array(), false, $tabindex, 'user');
echo "</form>\n";
echo "</div>\n";
// form for delete action
echo '<div id="deleteProfileDialog" class="hidden"><form id="deleteProfileForm" action="profilemain.php" method="post">';
echo _("Do you really want to delete this profile?");
echo '<br><br><div class="nowrap">';
echo _("Profile name") . ': <div id="deleteText" style="display: inline;"></div></div>';
echo '<input id="profileDeleteType" type="hidden" name="profileDeleteType" value="">';
echo '<input id="profileDeleteName" type="hidden" name="profileDeleteName" value="">';
echo '<input type="hidden" name="deleteProfile" value="true">';
echo '</form></div>';
include '../main_footer.php';
?>