Introduce a confirmation between clicking on delete and actually doing it.

Note that this will depend on a new version of AWL which implements the
session methods we use to avoid having predictable links for such things.
This commit is contained in:
Andrew McMillan 2006-11-21 19:42:33 +13:00
parent 002806b16c
commit 7020dbd7cb

View File

@ -19,15 +19,22 @@ require_once("interactive-page.php");
$rt->Initialise('relationship_type', array( 'rt_id' => $rt_id ) );
switch( strtolower($action) ) {
case 'delete':
$qry = new PgQuery("DELETE FROM relationship_type WHERE rt_id = $rt_id;");
if ( $qry->Exec() ) {
$c->messages[] = i18n("Relationship Type Deleted.");
if ( $session->CheckConfirmationHash('GET', 'confirm') ) {
$qry = new PgQuery("DELETE FROM relationship_type WHERE rt_id = $rt_id;");
if ( $qry->Exec() ) {
$c->messages[] = i18n("Relationship Type Deleted.");
}
else {
$c->messages[] = i18n("Database Error.");
if ( preg_match("/violates foreign key constraint/", $qry->errorstring ) ) {
$c->messages[] = i18n("That relationship type is being used. See ##RelationshipTypeUsed##");
}
}
}
else {
$c->messages[] = i18n("Database Error.");
if ( preg_match("/violates foreign key constraint/", $qry->errorstring ) ) {
$c->messages[] = i18n("That relationship type is being used. See ##RelationshipTypeUsed##");
}
$c->messages[] = i18n("Please Confirm Deletion");
$confirmation_required = true;
$confirmation_hash = $session->BuildConfirmationHash('GET', 'confirm');
}
break;
@ -103,6 +110,10 @@ require_once("interactive-page.php");
include("page-header.php");
if ( $confirmation_required ) {
printf('<p><a href="%s&%s">%s</a></p>', $_SERVER['REQUEST_URI'], $confirmation_hash, translate("Confirm Deletion of the Relationship Type"));
}
echo "<form method='post' enctype='multipart/form-data' action='$REQUEST_URI'>";
echo $browser->Render();
echo "</form>";