]> git.sesse.net Git - itkacl/blobdiff - itkacl-web-1.0/web/deletenode.pl
Add the bare minimum of what is required for the web interface to work (but be butt...
[itkacl] / itkacl-web-1.0 / web / deletenode.pl
diff --git a/itkacl-web-1.0/web/deletenode.pl b/itkacl-web-1.0/web/deletenode.pl
new file mode 100755 (executable)
index 0000000..d49810f
--- /dev/null
@@ -0,0 +1,26 @@
+#! /usr/bin/perl -T
+use strict;
+use warnings;
+use utf8;
+
+use lib '../include';
+use itkaclcommon;
+
+itkaclcommon::init();
+
+my $entry = $itkaclcommon::cgi->param('entry');
+
+# Find the parent node before we delete this (FIXME: this will fail badly
+# for root nodes!)
+my $ref = $itkaclcommon::dbh->selectrow_hashref('SELECT parent FROM objects WHERE id=?',
+       undef, $entry);
+
+$itkaclcommon::dbh->do('DELETE FROM objects WHERE id=?', undef, $entry)
+       or die "Couldn't delete object";
+
+# Let sync-itkacl know there's updates
+utime(time(), time(), '/etc/itkacl/updated');
+
+# Redirect to the parent
+print $itkaclcommon::cgi->redirect("view.pl?entry=$ref->{'parent'}");
+