#! /usr/bin/perl -T
use strict;
use warnings;
use utf8;

use lib '../include';
use itkaclcommon;

itkaclcommon::init();
itkaclcommon::check_csrf_token();

my $allow = $itkaclcommon::cgi->param('allow');
my $entry = $itkaclcommon::cgi->param('entry');
my $entity = $itkaclcommon::cgi->param('entity');
my $entity_type = $itkaclcommon::cgi->param('entity_type');
my $comment = $itkaclcommon::cgi->param('comment');

$itkaclcommon::dbh->do('INSERT INTO aclentries (allow,object,entity_type,entity,comment) VALUES (?,?,?,?,?)', undef,
    $allow, $entry, $entity_type, $entity, $comment)
	or die "Couldn't add new ACL entry";

# Let sync-itkacl know there's updates
utime(time(), time(), '/etc/itkacl/updated');
	
print $itkaclcommon::cgi->redirect("view.pl?entry=$entry");

