From 3c8b9dba04da6d66f7e592c3c1367a2367e1c5a5 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Mon, 3 Sep 2012 00:05:22 +0200 Subject: Domain edition. --- css/style.css | 67 +++++++++++++++++++++++++++++++++++++++-- lib/FPanel/Interface.pm | 69 +++++++++++++++++++++++++++++++++++++++--- lib/FPanel/Login.pm | 24 +++++++++------ template/domain-list.html | 42 -------------------------- template/edit-domain.html | 75 ++++++++++++++++++++++++++++++++++++++++++++++ template/list-domains.html | 47 +++++++++++++++++++++++++++++ template/login.html | 6 ++-- 7 files changed, 270 insertions(+), 60 deletions(-) delete mode 100644 template/domain-list.html create mode 100644 template/edit-domain.html create mode 100644 template/list-domains.html diff --git a/css/style.css b/css/style.css index 87b0275..390a634 100644 --- a/css/style.css +++ b/css/style.css @@ -1,6 +1,6 @@ /* Global */ body { - font-family: "DejaVu Sans", Helvetica, Arial, sans-serif; + font-family: Helvetica, Arial, sans-serif; font-size: 11pt; line-height: 140%; color: #1a1a1a; @@ -8,6 +8,10 @@ body { .error { color: #FF0040; } +tt { + font-family: Inconsolata, "Lucida Console", "Droid Sans Mono", Cousine, monospace; +} + /* Login form */ @@ -30,8 +34,9 @@ table.loginform td { text-align: center; font-size: 12pt; } -.label { +td.label { text-align: right; + vertical-align: top; } @@ -56,6 +61,27 @@ table.loginform td { text-align: right; } +#columns { + width: 100%; +} +#columns .column { + position: relative; + padding: 0pt; + border: 0pt; +} +#columns .left { + width: 50%; + padding: 0 0 0 30pt; + float: left; + text-align: left; +} +#columns .right { + width: 50%; + padding: 0 0 0 30pt; + float: right; + text-align: right; +} + /* Listing table */ table.list { @@ -89,7 +115,7 @@ table.list thead th { font-weight:bold; color:#66a3d3 } -.nonactive { +.inactive { color: #FF0040; } .active { @@ -99,3 +125,38 @@ table.list thead th { font-size: 6pt; color: lightgray; } +.help { + font-size: 8pt; + text-align: justify; + color: #6A6A6A; + padding: 0 50pt; +} +h4.label { + font-weight: bold; + text-align: center; + font-size: 12pt; +} + +/* Edit forms */ +form.editform { + margin: 0px auto; + border: 1px solid #cccccc; + padding: 10pt; + position: relative; + width: 80ex; + background:#E7EFF7; +} +table.editform { + margin:0 auto 5pt auto; + border-collapse:collapse; +} +table.editform td { + padding:0 5pt 0 0; +} +div.editform { + text-align: center; +} +.ack { + font-weight: bold; + color: #32CD32; +} 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; - diff --git a/lib/FPanel/Login.pm b/lib/FPanel/Login.pm index 506a7b8..173a34f 100644 --- a/lib/FPanel/Login.pm +++ b/lib/FPanel/Login.pm @@ -59,6 +59,7 @@ sub cgiapp_init { my $ldap = Net::LDAP->new( $CFG{ldap_uri} ); my $mesg = $ldap->bind ( $bind_dn, password => $p ); + $ldap->unbind; $mesg->code ? 0 : $u; } ], STORE => 'Session', @@ -87,23 +88,22 @@ sub setup { print STDERR $ENV{PATH_INFO} . '?' . $q->query_string, "\n"; # The user just logged in - return 'okay' if (defined $q->param('authen_username')) and - (defined $q->param('authen_password')); + return 'okay' if defined $q->param('login'); my $a = $q->param('a'); return 'login' if defined $a and $a eq 'login'; return 'logout' if defined $a and $a eq 'logout'; - # /domain/{user,alias,list}/?requests + # /domain/{user,alias,list}/?query_url my ($null,$domain,$local,$crap) = split /\//, $ENV{PATH_INFO}; - return 'DomainList' unless (defined $null) and $null eq ''; + return 'ListDomains' unless (defined $null) and $null eq ''; unless (defined $domain and $domain ne '') { if (defined $a) { return 'AddDomain' if $a eq 'AddDomain'; } - return 'DomainList'; + return 'ListDomains'; } unless (defined $local and $local ne '') { @@ -111,15 +111,16 @@ sub setup { return 'EditDomain' if $a eq 'edit'; return 'AddAccount' if $a eq 'AddAccount'; return 'AddAlias' if $a eq 'AddAlias'; + return 'AddList' if $a eq 'AddList'; } - return 'LocalList'; + return 'ListLocals'; } unless (defined $crap and $crap ne '') { - return 'LocalEdit'; + return 'EditLocal'; } - return 'DomainList'; + return 'error_404'; }); } @@ -193,11 +194,16 @@ sub error_rm : ErrorRunmode { my $template = $self->load_tmpl( 'error.html', cache => 1, utf8 => 1 ); $template->param( EMAIL => $self->cfg('report_email') ); $template->param( MESSAGE => $error ); - $template->param( URL => $self->query->url ); + $template->param( URL => $self->query->url . '/'); return $template->output; } +sub error_404 : Runmode { + my $self = shift; + $self->header_props ( -status => '404 Not found' ); + return ''; +} 1; diff --git a/template/domain-list.html b/template/domain-list.html deleted file mode 100644 index fcc7b23..0000000 --- a/template/domain-list.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - - Domain names for <TMPL_VAR NAME=USER> - - - - -

Manage domains

- - - - - - - - - - - - - - - - - - - -
Domain (add)PermissionsDescriptionActive?
(none)(none)
- - diff --git a/template/edit-domain.html b/template/edit-domain.html new file mode 100644 index 0000000..38abc62 --- /dev/null +++ b/template/edit-domain.html @@ -0,0 +1,75 @@ + + + + + Domain names for <TMPL_VAR NAME=USER> + + + + +
+ +

Edit domain

+ + + + + + + +
+ Status: ActiveInactive + (toggle) + + + Your changes have succesfully been submitted. + +
+ +
+ +
+
+ + +

+

Description

+ +
+ An optional description of your domain. +
+

+ +
+ +

+

Catch-All aliases

+ +
+ An optional list of destinations (one e-mail address per line) that + will receive mail sent to non existing recipients. + Domain aliases can be defined by leaving the local part of + the destination empty, like in @example.org: email + to inexisting@ + will then be sent to inexisting@example.org. +
+

+ +
+ + + +
+
+ + diff --git a/template/list-domains.html b/template/list-domains.html new file mode 100644 index 0000000..9b8cf0e --- /dev/null +++ b/template/list-domains.html @@ -0,0 +1,47 @@ + + + + + Domain names for <TMPL_VAR NAME=USER> + + + + +
+ +

Manage domains

+ + + + + + + + + + + + + + + + + + + + + + +
Domain (add)PermissionsDescriptionActive?Action
(none)(none)edit
+ + diff --git a/template/login.html b/template/login.html index 6ed2a7e..293f20f 100644 --- a/template/login.html +++ b/template/login.html @@ -13,10 +13,12 @@ src="/img/fripost_logo.png" title="fripost.org|demokratisk e-post" /> +

Administrator Panel



-
+ + @@ -28,7 +30,7 @@
Username
- +
-- cgit v1.2.3