diff options
author | Guilhem Moulin <guilhem.moulin@fripost.org> | 2012-09-29 21:17:15 +0200 |
---|---|---|
committer | Guilhem Moulin <guilhem.moulin@fripost.org> | 2012-09-29 21:17:15 +0200 |
commit | a4fb637c441cad75350edcbbb2520f7a303b33c2 (patch) | |
tree | 7761e4104a6c3cb64b0930293bc2a748e0c52c11 | |
parent | 58825808fb1fd2d9950e8f7a81ad62db18be4aa7 (diff) |
Grant the right to create aliases and/or lists.
-rw-r--r-- | TODO.org | 2 | ||||
-rw-r--r-- | lib/Fripost/Panel/Interface.pm | 27 | ||||
-rw-r--r-- | lib/Fripost/Schema.pm | 19 | ||||
-rw-r--r-- | lib/Fripost/Schema/Domain.pm | 20 | ||||
-rw-r--r-- | template/edit-domain.html | 42 |
5 files changed, 97 insertions, 13 deletions
@@ -43,7 +43,7 @@ CLOSED: [2012-09-27 Thu 03:38] Mailman and Schleuder do not support IDNs, but we convert the list name into punicode first. -* TODO Give the right for domain owners and postmasters to grant the right +* DONE Give the right for domain postmasters to grant the right to create aliases and lists. * TODO Give the right to appoint co owners (for list and aliases). 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/^\@//; diff --git a/template/edit-domain.html b/template/edit-domain.html index 3844775..a8af3fb 100644 --- a/template/edit-domain.html +++ b/template/edit-domain.html @@ -52,7 +52,7 @@ <hr/> <h4 class="label" id="description">Description</h4> - <textarea name="description" cols="50" rows="3" ><TMPL_VAR NAME=description></textarea> + <textarea name="description" cols="50" rows="5" ><TMPL_VAR NAME=description></textarea> <div class="help"> An optional description. (HTML tags are allowed.) </div> @@ -60,7 +60,7 @@ <hr/> <h4 class="label" id="catch-all">Catch-All aliases</h4> - <textarea name="catchalls" cols="50" rows="10" ><TMPL_VAR NAME=catchalls></textarea> + <textarea name="catchalls" cols="50" rows="5" ><TMPL_VAR NAME=catchalls></textarea> <div class="help"> An optional list of destinations (one e-mail address per line) that will receive mail sent to <i>non existing</i> recipients. @@ -70,6 +70,44 @@ will then be sent to <span class="email">inexisting@example.org</span>. </div> + <TMPL_IF NAME=isPostmaster> + <hr/> + + <h4 class="label" id="canCreateAlias">Grant right to create aliases</h4> + <textarea name="canCreateAlias" cols="50" rows="5" ><TMPL_VAR NAME=canCreateAlias></textarea> + <div class="help"> + An optional list of e-mails (one address per line) that are + allowed to create aliases under your domain + <span class="domain"><TMPL_VAR NAME=domain></span>. + It is possible to grant right for a whole domain by leaving out + the local part: For instance, listing + <span class="email">@example.org</span> here will give every user + under <span class="domain">example.org</span> the right to + create aliases under + <span class="domain"><TMPL_VAR NAME=domain></span>. + <i>Note</i>: You already have this right, so there is no need to + list your e-mail here. + </div> + + <hr/> + + <h4 class="label" id="canCreateList">Grant right to create lists</h4> + <textarea name="canCreateList" cols="50" rows="5" ><TMPL_VAR NAME=canCreateList></textarea> + <div class="help"> + An optional list of e-mails (one address per line) that are + allowed to create mailing lists under your domain + <span class="domain"><TMPL_VAR NAME=domain></span>. + It is possible to grant right for a whole domain by leaving out + the local part: For instance, listing + <span class="email">@example.org</span> here will give every user + under <span class="domain">example.org</span> the right to + create mailing lists under + <span class="domain"><TMPL_VAR NAME=domain></span>. + <i>Note</i>: You already have this right, so there is no need to + list your e-mail here. + </div> + + </TMPL_IF> <hr/> <br/> |