mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-08-29 18:26:05 +00:00
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:
parent
002806b16c
commit
7020dbd7cb
@ -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>";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user