aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config.in2
-rw-r--r--lib/Fripost/Panel/Interface.pm57
-rw-r--r--lib/Fripost/Schema/Alias.pm24
-rw-r--r--lib/Fripost/Schema/List.pm23
-rw-r--r--lib/Fripost/Schema/Mailbox.pm24
-rw-r--r--template/edit-alias.html5
-rw-r--r--template/edit-list.html6
-rw-r--r--template/edit-mailbox.html6
8 files changed, 117 insertions, 30 deletions
diff --git a/config.in b/config.in
index 9a40f9d..1eccd78 100644
--- a/config.in
+++ b/config.in
@@ -15,7 +15,7 @@ default_realm = fripost.org
ldap_suffix = ou=virtual,o=mailHosting,dc=fripost,dc=dev
# TODO: This should be replaced with a Keberos ticket.
-ldap_authcID = FPanel
+ldap_authcID = AdminPanel
ldap_authcPW = panel
# The minimum password length.
diff --git a/lib/Fripost/Panel/Interface.pm b/lib/Fripost/Panel/Interface.pm
index b636861..6859e57 100644
--- a/lib/Fripost/Panel/Interface.pm
+++ b/lib/Fripost/Panel/Interface.pm
@@ -171,7 +171,7 @@ sub EditDomain : Runmode {
my $template = $self->load_tmpl( 'edit-domain.html', cache => 1, utf8 => 1
, loop_context_vars => 1
, global_vars => 1 );
- $template->param( url => $self->query->url
+ $template->param( url => $q->url
, user_localpart => $ul
, user_domainpart => $ud
, domain => $d
@@ -190,7 +190,7 @@ sub EditDomain : Runmode {
, catchalls => join ("\x{0D}\x{0A}",
@{$domain{catchalls}}) );
}
- $template->param( newChanges => defined $self->query->param('submit') );
+ $template->param( newChanges => defined $q->param('submit') );
return $template->output;
}
@@ -209,10 +209,25 @@ sub EditLocal : Runmode {
my $fp = Fripost::Schema::->SASLauth( $self->authen->username, %CFG );
+ # Search for *the* matching mailbox, alias or list.
+ my %local = $fp->local->get ($l, $d, -die => 404,
+ -concat => "\x{0D}\x{0A}");
+ die "Unknown type" unless grep { $local{type} eq $_ }
+ qw/mailbox alias list/;
+
my $error; # Tells whether the change submission has failed.
- if (defined $q->param('submit')) {
+ my $t = $local{type};
+
+ if (defined $q->param('a') and $q->param('a') eq 'delete') {
+ # Delete the entry
+ $error = $fp->$t->delete($l, $d, -die => 0);
+ unless ($error) {
+ $fp->done;
+ return $self->redirect($q->url .'/'. $d .'/');
+ }
+ }
+ elsif (defined $q->param('submit')) {
# Changes have been submitted: process them
- my $t = $q->param('t') // die "Undefined type";
my %entry;
if ($t eq 'mailbox') {
$entry{user} = $l.'@'.$d;
@@ -269,19 +284,16 @@ sub EditLocal : Runmode {
unless $error;
}
- # Search for *the* matching mailbox, alias or list.
- my %local = $fp->local->get ($l, $d, -die => 404,
- -concat => "\x{0D}\x{0A}");
$fp->done;
- my $template = $self->load_tmpl( "edit-$local{type}.html",
+ my $template = $self->load_tmpl( "edit-$t.html",
cache => 1, utf8 => 1 );
- $template->param( url => $self->query->url
+ $template->param( url => $q->url
, user_localpart => $ul
, user_domainpart => $ud
, domain => $d
);
- if ($error) {
+ if ($error and defined $q->param('submit')) {
# Preserve the (incorrect) form, except the passwords
if ($local{type} eq 'mailbox') {
$template->param( user => $l
@@ -295,33 +307,32 @@ sub EditLocal : Runmode {
$template->param( list => $l );
}
else {
- # Unknown type
- return $self->redirect($q->url.'/'.$d.'/');
+ die "Unknown type";
}
$template->param( isactive => $q->param('isactive')
- , description => $q->param('description')
- , error => encode_entities ($error, "‘‘") );
+ , description => $q->param('description') );
}
else {
- if ($local{type} eq 'mailbox') {
+ if ($t eq 'mailbox') {
$template->param( user => $local{user}
, forwards => $local{forwards} );
}
- elsif ($local{type} eq 'alias') {
+ elsif ($t eq 'alias') {
$template->param( alias => $local{alias}
, maildrop => $local{maildrop} );
}
- elsif ($local{type} eq 'list') {
+ elsif ($t eq 'list') {
$template->param( list => $local{list} );
}
- else {
- # Unknown type
- return $self->redirect($q->url.'/'.$d.'/');
- }
$template->param( isactive => $local{isactive}
, description => $local{description} );
}
- $template->param( newChanges => defined $self->query->param('submit') );
+ my $news = (defined $q->param('submit') or
+ (defined $q->param('a') and $q->param('a') eq 'delete'));
+ $template->param( newChanges => $news );
+ $template->param( error => encode_entities ($error, "‘‘") ) if $error;
+ $template->param( canDelete => 1 ); # TODO
+ $q->delete('a');
return $template->output;
}
@@ -383,7 +394,7 @@ sub AddLocal : Runmode {
}
my $template = $self->load_tmpl( "add-$t.html", cache => 1, utf8 => 1 );
- $template->param( url => $self->query->url
+ $template->param( url => $q->url
, user_localpart => $ul
, user_domainpart => $ud
, domain => $d
diff --git a/lib/Fripost/Schema/Alias.pm b/lib/Fripost/Schema/Alias.pm
index c413257..0976093 100644
--- a/lib/Fripost/Schema/Alias.pm
+++ b/lib/Fripost/Schema/Alias.pm
@@ -134,6 +134,30 @@ sub add {
return $@;
}
+
+=item B<delete> (I<alias>, I<domain>, I<OPTIONS>)
+
+Delete the given alias.
+
+=cut
+
+sub delete {
+ my $self = shift;
+ my $l = shift;
+ my $d = shift;
+ my %options = @_;
+
+ my $mesg = $self->ldap->delete( "fva=$l,fvd=$d,".$self->suffix );
+ if ($mesg->code) {
+ if (defined $options{'-die'}) {
+ return $mesg->error unless $options{'-die'};
+ die $options{'-die'}."\n";
+ }
+ die $mesg->error;
+ }
+}
+
+
=back
=head1 GLOBAL OPTIONS
diff --git a/lib/Fripost/Schema/List.pm b/lib/Fripost/Schema/List.pm
index ad0902d..ec66f76 100644
--- a/lib/Fripost/Schema/List.pm
+++ b/lib/Fripost/Schema/List.pm
@@ -143,6 +143,29 @@ sub add {
}
+=item B<delete> (I<list>, I<domain>, I<OPTIONS>)
+
+Delete the given list. Note: this will NOT wipe the archives off the
+disk, but merely delete the list entry in the LDAP directory.
+
+=cut
+
+sub delete {
+ my $self = shift;
+ my $l = shift;
+ my $d = shift;
+ my %options = @_;
+
+ my $mesg = $self->ldap->delete( "fvl=$l,fvd=$d,".$self->suffix );
+ if ($mesg->code) {
+ if (defined $options{'-die'}) {
+ return $mesg->error unless $options{'-die'};
+ die $options{'-die'}."\n";
+ }
+ die $mesg->error;
+ }
+}
+
=back
diff --git a/lib/Fripost/Schema/Mailbox.pm b/lib/Fripost/Schema/Mailbox.pm
index a3ae4be..28ef376 100644
--- a/lib/Fripost/Schema/Mailbox.pm
+++ b/lib/Fripost/Schema/Mailbox.pm
@@ -160,6 +160,30 @@ sub add {
}
+=item B<delete> (I<mailbox>, I<domain>, I<OPTIONS>)
+
+Delete the given mailbox. Note: this will NOT wipe the mailbox off the
+disk, but merely delete its entry in the LDAP directory.
+
+=cut
+
+sub delete {
+ my $self = shift;
+ my $l = shift;
+ my $d = shift;
+ my %options = @_;
+
+ my $mesg = $self->ldap->delete( "fvu=$l,fvd=$d,".$self->suffix );
+ if ($mesg->code) {
+ if (defined $options{'-die'}) {
+ return $mesg->error unless $options{'-die'};
+ die $options{'-die'}."\n";
+ }
+ die $mesg->error;
+ }
+}
+
+
=back
=head1 GLOBAL OPTIONS
diff --git a/template/edit-alias.html b/template/edit-alias.html
index ef7c553..85e2d5f 100644
--- a/template/edit-alias.html
+++ b/template/edit-alias.html
@@ -22,7 +22,9 @@
<hr/>
<div id="content">
- <h1>Edit alias <span class="email"><TMPL_VAR NAME=alias>@<TMPL_VAR NAME=domain></span></h1>
+ <h1>Edit alias <span class="email"><TMPL_VAR NAME=alias>@<TMPL_VAR NAME=domain></span><TMPL_IF NAME=canDelete
+ ><span class="action">[<a href="<TMPL_VAR NAME=url>/<TMPL_VAR NAME=domain>/<TMPL_VAR NAME=alias>/?a=delete">delete</a>]</span
+ ></TMPL_IF></h1>
<TMPL_IF NAME=newChanges>
<TMPL_IF NAME=error>
@@ -39,7 +41,6 @@
<form class="editform" name="editform" method="post" action="?">
<div class="editform">
<input type="hidden" name="a" value="edit" />
- <input type="hidden" name="t" value="alias" />
<h4 class="label" id="status">Status</h4>
<select name="isactive">
diff --git a/template/edit-list.html b/template/edit-list.html
index 0a2b5e3..66e5d45 100644
--- a/template/edit-list.html
+++ b/template/edit-list.html
@@ -22,7 +22,10 @@
<hr/>
<div id="content">
- <h1>Edit list <span class="email"><TMPL_VAR NAME=list>@<TMPL_VAR NAME=domain></span></h1>
+ <h1>Edit list <span class="email"><TMPL_VAR NAME=list>@<TMPL_VAR NAME=domain></span><TMPL_IF NAME=canDelete
+ ><span class="action">[<a href="<TMPL_VAR NAME=url>/<TMPL_VAR NAME=domain>/<TMPL_VAR NAME=list>/?a=delete">delete</a>]</span
+ ></TMPL_IF></h1>
+
<TMPL_IF NAME=newChanges>
<TMPL_IF NAME=error>
@@ -39,7 +42,6 @@
<form class="editform" name="editform" method="post" action="?">
<div class="editform">
<input type="hidden" name="a" value="edit" />
- <input type="hidden" name="t" value="list" />
<h4 class="label" id="status">Status</h4>
<select name="isactive">
diff --git a/template/edit-mailbox.html b/template/edit-mailbox.html
index 5b8ff99..4ce6837 100644
--- a/template/edit-mailbox.html
+++ b/template/edit-mailbox.html
@@ -22,7 +22,10 @@
<hr/>
<div id="content">
- <h1>Edit mailbox <span class="mailbox"><TMPL_VAR NAME=user>@<TMPL_VAR NAME=domain></span></h1>
+ <h1>Edit mailbox <span class="mailbox"><TMPL_VAR NAME=user>@<TMPL_VAR NAME=domain></span><TMPL_IF NAME=canDelete
+ ><span class="action">[<a href="<TMPL_VAR NAME=url>/<TMPL_VAR NAME=domain>/<TMPL_VAR NAME=user>/?a=delete">delete</a>]</span
+ ></TMPL_IF></h1>
+
<TMPL_IF NAME=newChanges>
<TMPL_IF NAME=error>
@@ -39,7 +42,6 @@
<form class="editform" name="editform" method="post" action="?">
<div class="editform">
<input type="hidden" name="a" value="edit" />
- <input type="hidden" name="t" value="mailbox" />
<h4 class="label" id="status">Status</h4>
<select name="isactive">