aboutsummaryrefslogtreecommitdiffstats
path: root/lib/FPanel/Interface.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/FPanel/Interface.pm')
-rw-r--r--lib/FPanel/Interface.pm69
1 files changed, 65 insertions, 4 deletions
diff --git a/lib/FPanel/Interface.pm b/lib/FPanel/Interface.pm
index 6781ae5..b1b7fe5 100644
--- a/lib/FPanel/Interface.pm
+++ b/lib/FPanel/Interface.pm
@@ -20,9 +20,9 @@ sub cgiapp_init {
}
-# This is the first page an authenticated user sees. It lists the known
+# This is the first page seen by authenticated users. It lists the known
# domains.
-sub DomainList : StartRunmode {
+sub ListDomains : StartRunmode {
my $self = shift;
my %CFG = $self->cfg;
my $suffix = join ',', @{$CFG{ldap_suffix}};
@@ -37,9 +37,10 @@ sub DomainList : StartRunmode {
, deref => 'never'
);
die $domains->error if $domains->code;
+ $ldap->unbind;
- my $template = $self->load_tmpl( 'domain-list.html', cache => 1, utf8 => 1
+ my $template = $self->load_tmpl( 'list-domains.html', cache => 1, utf8 => 1
, loop_context_vars => 1
, global_vars => 1 );
$template->param( URL => $self->query->url );
@@ -56,6 +57,67 @@ sub DomainList : StartRunmode {
return $template->output;
}
+# This is the page used to edit domains.
+sub EditDomain : Runmode {
+ my $self = shift;
+ my %CFG = $self->cfg;
+ my $suffix = join ',', @{$CFG{ldap_suffix}};
+
+ my ($l,$d) = split /@/, $self->authen->username, 2;
+ my $authzDN = "fvu=$l,fvd=$d,". $suffix;
+ my $ldap = $self->ldap_from_auth_user($authzDN);
+
+ my $domain = (split /\//, $ENV{PATH_INFO}, 3)[1];
+
+ if (defined $self->query->param('submit') or
+ defined $self->query->param('active')) {
+ # Changes have been submitted: process them
+ my %changes;
+ if (defined $self->query->param('active')) {
+ $changes{fripostIsStatusActive} = $self->query->param('active');
+ }
+ if (defined $self->query->param('description')) {
+ my @desc;
+ foreach my $d (split /\n/, $self->query->param('description')) {
+ push @desc, $d;
+ }
+ $changes{description} = [ @desc ];
+ }
+ if (defined $self->query->param('maildrop')) {
+ my @maildrop;
+ foreach my $d (split /\n/, $self->query->param('maildrop')) {
+ $d =~ s/\s//g;
+ push @maildrop, (lc $d) unless $d =~ /^$/;
+ }
+ $changes{fripostOptionalMaildrop} = [ @maildrop ];
+ }
+
+ my $mesg = $ldap->modify( "fvd=$domain,$suffix", replace => \%changes );
+ die $mesg->error if $mesg->code;
+ }
+
+ my $answer = $ldap->search( base => 'fvd='.$domain .','. $suffix
+ , scope => 'base'
+ , filter => 'objectClass=FripostVirtualDomain'
+ , deref => 'never'
+ );
+ die $answer->error if $answer->code;
+ $answer = $answer->entry('0');
+ $ldap->unbind;
+
+ 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( USER_LOCALPART => $l, USER_DOMAINPART => $d);
+ $template->param( DOMAIN => $domain );
+ $template->param( DESCRIPTION => join ("\n",$answer->get_value('description')) );
+ $template->param( MAILDROP => join ("\n",$answer->get_value('fripostOptionalMaildrop')) );
+ $template->param( ISACTIVE => $answer->get_value('fripostIsStatusActive') eq 'TRUE' ? 1 : 0 );
+ $template->param( NEWCHANGES => defined $self->query->param('submit') );
+ return $template->output;
+}
+
# This subroutine displays the access that the given DN has on the entry.
# Possible values are :
@@ -124,4 +186,3 @@ sub ldap_from_auth_user {
1;
-