aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Fripost/Panel/Interface.pm27
-rw-r--r--lib/Fripost/Schema.pm19
-rw-r--r--lib/Fripost/Schema/Domain.pm20
3 files changed, 56 insertions, 10 deletions
diff --git a/lib/Fripost/Panel/Interface.pm b/lib/Fripost/Panel/Interface.pm
index f102a21..ff9b291 100644
--- a/lib/Fripost/Panel/Interface.pm
+++ b/lib/Fripost/Panel/Interface.pm
@@ -167,7 +167,9 @@ sub EditDomain : Runmode {
domain => $d,
isactive => $q->param('isactive'),
description => $q->param('description'),
- catchalls => $q->param('catchalls')
+ catchalls => $q->param('catchalls'),
+ canCreateAlias => $q->param('canCreateAlias'),
+ canCreateList => $q->param('canCreateList')
}, -concat => "(\n|\x{0D}\x{0A})");
}
my %domain = $fp->domain->get( $d, -die => 404 );
@@ -177,21 +179,24 @@ sub EditDomain : Runmode {
, loop_context_vars => 1
, global_vars => 1 );
$template->param( $self->userInfo );
- $template->param( domain => encode_entities($d) );
+ $template->param( domain => encode_entities($d)
+ , isPostmaster => $domain{permissions} eq 'p');
if ($error) {
# Preserve the (incorrect) form
$template->param( isactive => $q->param('isactive')
, description => $q->param('description')
, catchalls => $q->param('catchalls')
+ , canCreateAlias => $q->param('canCreateAlias')
+ , canCreateList => $q->param('canCreateList')
, error => encode_entities ($error) );
}
else {
$template->param( isactive => $domain{isactive}
- , description => join ("\x{0D}\x{0A}",
- @{$domain{description}})
- , catchalls => join ("\x{0D}\x{0A}",
- map { encode_entities ($_) }
- @{$domain{catchalls}}) );
+ , description => &mkFormContent (@{$domain{description}})
+ , catchalls => &mkFormContentE (@{$domain{catchalls}})
+ , canCreateAlias => &mkFormContentE (@{$domain{canCreateAlias}})
+ , canCreateList => &mkFormContentE (@{$domain{canCreateList}})
+ );
}
$template->param( newChanges => defined $q->param('submit') );
return $template->output;
@@ -458,6 +463,14 @@ sub userInfo {
)
}
+sub mkFormContentE {
+ &mkFormContent (map { encode_entities ($_) } @_);
+}
+
+sub mkFormContent {
+ join ("\x{0D}\x{0A}", @_);
+}
+
=head1 AUTHOR
Guilhem Moulin C<< <guilhem at fripost.org> >>
diff --git a/lib/Fripost/Schema.pm b/lib/Fripost/Schema.pm
index bb1f3f5..ad88c82 100644
--- a/lib/Fripost/Schema.pm
+++ b/lib/Fripost/Schema.pm
@@ -211,6 +211,25 @@ under the same terms as perl itself.
=cut
+sub _dn2email {
+ my $self = shift;
+ my $dn = shift;
+ $dn =~ s/^fvd=([^,]+),.*/\@$1/ and return $dn;
+ $dn =~ s/^fv(?:u|a|l)=([^,]+),fvd=([^,]+),.*/$1\@$2/
+ or die "Wrong usage: of _dn2email: $dn";
+ return $dn;
+}
+sub _email2dn {
+ my $self = shift;
+ my $email = shift;
+ my ($l,$d) = split /\@/, $email, 2;
+ die "Wrong usage: of _email2dn: $email" unless defined $d;
+
+ my $dn = "fvd=$d,".$self->suffix;
+ $dn = "fvu=$l,".$dn if $l ne '';
+ return $dn;
+}
+
1;
__END__
diff --git a/lib/Fripost/Schema/Domain.pm b/lib/Fripost/Schema/Domain.pm
index 64a8932..80810e5 100644
--- a/lib/Fripost/Schema/Domain.pm
+++ b/lib/Fripost/Schema/Domain.pm
@@ -100,9 +100,13 @@ sub get {
return ( domain => domain_to_unicode($domain->get_value('fvd'))
, isactive => $domain->get_value('fripostIsStatusActive') eq 'TRUE'
, description => concat($concat, $domain->get_value('description'))
- , catchalls => concat($concat, map { _email_to_unicode ($_) }
+ , catchalls => concat($concat, map { &_email_to_unicode ($_) }
$domain->get_value('fripostOptionalMaildrop'))
, permissions => get_perms($domain, $self->whoami)
+ , canCreateAlias => concat($concat, map { &_email_to_unicode ($self->_dn2email($_)) }
+ $domain->get_value('fripostCanCreateAlias'))
+ , canCreateList => concat($concat, map { &_email_to_unicode ($self->_dn2email($_)) }
+ $domain->get_value('fripostCanCreateList'))
)
}
@@ -118,7 +122,7 @@ sub replace {
my $d = shift;
my %options = @_;
- foreach (qw/description catchalls/) {
+ foreach (qw/description catchalls canCreateAlias canCreateList/) {
$d->{$_} = explode ($options{'-concat'}, $d->{$_})
if defined $d->{$_};
}
@@ -131,6 +135,12 @@ sub replace {
'TRUE' : 'FALSE'
, description => $d->{description}
, fripostOptionalMaildrop => $d->{catchalls}
+ , fripostCanCreateAlias =>
+ [ map $self->_email2dn($_),
+ @{$d->{canCreateAlias}} ]
+ , fripostCanCreateList =>
+ [ map $self->_email2dn($_),
+ @{$d->{canCreateList}} ]
} );
die $mesg->error."\n" if $mesg->code;
};
@@ -165,10 +175,14 @@ sub _is_valid {
-exact => 1 );
$d->{catchalls} = [ map { email_valid($_, -prefix => 'fake') }
@{$d->{catchalls}} ];
+ $d->{canCreateAlias} = [ map { email_valid($_, -prefix => 'fake') }
+ @{$d->{canCreateAlias}} ];
+ $d->{canCreateList} = [ map { email_valid($_, -prefix => 'fake') }
+ @{$d->{canCreateList}} ];
}
-# A variante of email_to_unicode that also takes care of domain aliases.
+# A variant of email_to_unicode that also takes care of domain aliases.
sub _email_to_unicode {
my $email = shift;
return '@'.domain_to_unicode($email) if $email =~ s/^\@//;