[vhffs-dev] [999] fixed bug #231, mail user part display the state of the mailbox |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 999
Author: gradator
Date: 2007-10-16 21:38:21 +0000 (Tue, 16 Oct 2007)
Log Message:
-----------
fixed bug #231, mail user part display the state of the mailbox
Modified Paths:
--------------
trunk/vhffs-api/src/Vhffs/Services/MailUser.pm
trunk/vhffs-panel/templates/user/mailuser.tmpl
trunk/vhffs-panel/user/prefs.pl
Modified: trunk/vhffs-api/src/Vhffs/Services/MailUser.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/MailUser.pm 2007-10-16 19:58:33 UTC (rev 998)
+++ trunk/vhffs-api/src/Vhffs/Services/MailUser.pm 2007-10-16 21:38:21 UTC (rev 999)
@@ -116,6 +116,13 @@
return 1;
}
+sub get_box_status
+{
+ my $self = shift;
+ return undef unless defined $self->{mail_service}->{'boxes'}->{$self->{localpart}};
+ return $self->{mail_service}->{'boxes'}->{$self->{localpart}}{'state'};
+}
+
sub addforward
{
my $self = shift;
Modified: trunk/vhffs-panel/templates/user/mailuser.tmpl
===================================================================
--- trunk/vhffs-panel/templates/user/mailuser.tmpl 2007-10-16 19:58:33 UTC (rev 998)
+++ trunk/vhffs-panel/templates/user/mailuser.tmpl 2007-10-16 21:38:21 UTC (rev 999)
@@ -1,8 +1,10 @@
<fieldset id="chooseMailMode">
<legend>
- <tmpl_var name="TEXT_MAILINFO1">
+ <tmpl_var name="TEXT_LEGEND">
</legend>
+ <tmpl_unless name="STATUSSTR">
+
<p>
<input name="mail_activate" id="mail_activate" class="labeled"
type="checkbox"
@@ -30,4 +32,9 @@
<label for="mail_usage_foward"><tmpl_var name="TEXT_MAILFORWARD"></label>
</p>
</div>
+
+
+ <tmpl_else>
+ <tmpl_var name="STATUSSTR">
+ </tmpl_unless>
</fieldset>
Modified: trunk/vhffs-panel/user/prefs.pl
===================================================================
--- trunk/vhffs-panel/user/prefs.pl 2007-10-16 19:58:33 UTC (rev 998)
+++ trunk/vhffs-panel/user/prefs.pl 2007-10-16 21:38:21 UTC (rev 999)
@@ -179,22 +179,25 @@
$panel->add_error( gettext("You must choose a method for your mail") );
} elsif( $usage == 1 ) {
#Delete forward if necessary
- $mu->delforward;
#In this case, we treat for popable accounts
if( $mu->exists_box == 0 ) {
# Box doesn't exists, need a password
if( $pwd_change == 0 ) {
$panel->add_error( gettext("Error ! You MUST provide a password in your account when you create your popable account") );
- } elsif( ($mu->addbox ($pass1 )) < 0 ) {
- $panel->add_error( gettext("An error occured while adding the box") );
- } elsif( $nospam && ( $mu->change_spam_status < 0 ) ) {
- $panel->add_error( gettext("An error occured while adding the box (anti-spam adding)") );
- } elsif( $novirus && ( $mu->change_virus_status < 0 ) ) {
- $panel->add_error( gettext("An error occured while adding the box (anti-virus adding)") );
- } else {
- $panel->add_info( gettext("Mailbox successfully added") );
- }
- } else {
+ } else {
+ #del forward if needed
+ $mu->delforward;
+ if( $mu->addbox($pass1 ) < 0 ) {
+ $panel->add_error( gettext("An error occured while adding the box") );
+ } elsif( $nospam && ( $mu->change_spam_status < 0 ) ) {
+ $panel->add_error( gettext("An error occured while adding the box (anti-spam adding)") );
+ } elsif( $novirus && ( $mu->change_virus_status < 0 ) ) {
+ $panel->add_error( gettext("An error occured while adding the box (anti-virus adding)") );
+ } else {
+ $panel->add_info( gettext("Mailbox successfully added") );
+ }
+ }
+ } else {
#Box already exists
# The user changed his password, we must update password for mail
if( $pwd_change ) {
@@ -224,18 +227,20 @@
}
}
} elsif( $usage == 2 ) {
- #Delete the box if necessary
- $mu->delbox;
#Here, we create the forward
my $ad = $user->get_mail;
if( $mu->exists_forward == 0 ) {
if( ! defined $ad ) {
$panel->add_error( gettext("There is a problem with the address you filled in your profile, unable to add forwarding") );
- } elsif( $mu->addforward( $user->get_mail ) < 0) {
- $panel->add_error( gettext("An error occured while adding the forwarding") );
} else {
- $panel->add_info( gettext('Forward added') );
- }
+ #Delete the box if necessary
+ $mu->delbox;
+ if( $mu->addforward( $user->get_mail ) < 0) {
+ $panel->add_error( gettext("An error occured while adding the forwarding") );
+ } else {
+ $panel->add_info( gettext('Forward added') );
+ }
+ }
} elsif( $mail_change ==1 ) {
$mu->delforward;
if( $mu->addforward( $mail ) < 0 ) {
@@ -372,44 +377,50 @@
my $mu = init Vhffs::Services::MailUser( $vhffs , $user );
if( defined $mu ) {
- my $subtemplate = new HTML::Template( filename => $templatedir."/panel/user/mailuser.tmpl" );
- my $subtemplate2;
- my $config = $vhffs->get_config->get_service( "mailuser" );
- my $tmp = "";
-
- $subtemplate->param( ACTIV_CHECKED => 1 ) if( $mu->exists == 1 );
- $subtemplate->param( POP_CHECKED => 1 ) if( $mu->exists_box == 1 );
- $subtemplate->param( FWD_CHECKED => 1 ) if( $mu->exists_forward == 1 );
- $subtemplate->param( TEXT_MAILACTIV => sprintf( gettext("Activate %s\@%s email"), $username, $config->{domain}) );
- $subtemplate->param( TEXT_MAILINFO1 => sprintf( gettext("We offer you the possibility to have one email box on the domain %s") , $config->{domain}) );
- $subtemplate->param( TEXT_MAILINFO2 => gettext("There is two possible usages :") );
- $subtemplate->param( TEXT_MAILBOX => sprintf( gettext("Use VHFFS servers to manage this mail,<br>you should use use the host pop.%s or imap.%s to fetch your mails") , $config->{domain} , $config->{domain} ) );
- $subtemplate->param( TEXT_MAILFORWARD => sprintf( gettext("Forward emails from %s\@%s to %s"), $username, $config->{domain}, $usermail ) );
+ my $subtemplate = new HTML::Template( filename => $templatedir.'/panel/user/mailuser.tmpl' );
+ my $config = $vhffs->get_config->get_service( 'mailuser' );
- if( defined ( my $url = $config->{'url_doc'} ) ) {
- $template->param( HELP_TEXT => gettext('Help') );
- $template->param( HELP_URL => $url );
- }
+ #nothing, a forward, or a box but activated
+ if( !$mu->exists || $mu->exists_forward || ( $mu->exists_box && $mu->get_box_status == Vhffs::Constants::ACTIVATED ) ) {
+ my $tmp = '';
- if( $vhffs->get_config->get_service('mail')->{'use_nospam'} eq 'yes' )
- {
- $subtemplate2 = new HTML::Template( filename => $templatedir."/panel/user/mailuserspam.tmpl" );
- $subtemplate2->param( TEXT_NOSPAM => gettext("Use anti-spam protection") );
- $subtemplate2->param( ACTIV_CHECKED => "checked" ) if( $mu->use_nospam == 1 );
- $tmp .= $subtemplate2->output;
- }
+ $subtemplate->param( ACTIV_CHECKED => 1 ) if( $mu->exists == 1 );
+ $subtemplate->param( POP_CHECKED => 1 ) if( $mu->exists_box == 1 && $mu->exists_forward == 0 );
+ $subtemplate->param( FWD_CHECKED => 1 ) if( $mu->exists_forward == 1 );
+ $subtemplate->param( TEXT_MAILACTIV => sprintf( gettext("Activate %s\@%s email"), $username, $config->{domain}) );
+ $subtemplate->param( TEXT_MAILINFO2 => gettext("There is two possible usages :") );
+ $subtemplate->param( TEXT_MAILBOX => sprintf( gettext("Use VHFFS servers to manage this mail,<br/>you should use use the host pop.%s or imap.%s to fetch your mails") , $config->{domain} , $config->{domain} ) );
+ $subtemplate->param( TEXT_MAILFORWARD => sprintf( gettext("Forward emails from %s\@%s to %s"), $username, $config->{domain}, $usermail ) );
- if( $vhffs->get_config->get_service('mail')->{'use_novirus'} eq 'yes' )
- {
- $subtemplate2 = new HTML::Template( filename => $templatedir."/panel/user/mailuservirus.tmpl" );
- $subtemplate2->param( TEXT_VIRUS => gettext("Use anti-virus protection") );
- $subtemplate2->param( ACTIV_CHECKED => "checked" ) if( $mu->use_novirus == 1 );
- $tmp .= $subtemplate2->output;
+ if( defined ( my $url = $config->{'url_doc'} ) ) {
+ $template->param( HELP_TEXT => gettext('Help') );
+ $template->param( HELP_URL => $url );
+ }
+
+ if( $vhffs->get_config->get_service('mail')->{'use_nospam'} eq 'yes' )
+ {
+ my $subtemplate2 = new HTML::Template( filename => $templatedir.'/panel/user/mailuserspam.tmpl' );
+ $subtemplate2->param( TEXT_NOSPAM => gettext("Use anti-spam protection") );
+ $subtemplate2->param( ACTIV_CHECKED => "checked" ) if( $mu->use_nospam == 1 );
+ $tmp .= $subtemplate2->output;
+ }
+
+ if( $vhffs->get_config->get_service('mail')->{'use_novirus'} eq 'yes' )
+ {
+ my $subtemplate2 = new HTML::Template( filename => $templatedir.'/panel/user/mailuservirus.tmpl' );
+ $subtemplate2->param( TEXT_VIRUS => gettext("Use anti-virus protection") );
+ $subtemplate2->param( ACTIV_CHECKED => "checked" ) if( $mu->use_novirus == 1 );
+ $tmp .= $subtemplate2->output;
+ }
+
+ $subtemplate->param( MAILUSER_OPTIONS => $tmp );
}
+ else {
+ $subtemplate->param( STATUSSTR => Vhffs::Functions::status_string_from_status_id( $mu->get_box_status ) );
+ }
-
- $subtemplate->param( MAILUSER_OPTIONS => $tmp );
- $template->param( MAILUSER => $subtemplate->output );
+ $subtemplate->param( TEXT_LEGEND => sprintf( gettext("We offer you the possibility to have one email box on the domain %s") , $config->{domain}) );
+ $template->param( MAILUSER => $subtemplate->output );
}