[vhffs-dev] [992] When a maildomain is asked for deletion, archive(or delete) all maiboxes, then delete the full domain tree |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
- To: vhffs-dev@xxxxxxxxx
- Subject: [vhffs-dev] [992] When a maildomain is asked for deletion, archive(or delete) all maiboxes, then delete the full domain tree
- From: subversion@xxxxxxxxxxxxx
- Date: Tue, 16 Oct 2007 15:21:22 +0200
Revision: 992
Author: gradator
Date: 2007-10-16 13:21:21 +0000 (Tue, 16 Oct 2007)
Log Message:
-----------
When a maildomain is asked for deletion, archive(or delete) all maiboxes, then delete the full domain tree
Modified Paths:
--------------
trunk/vhffs-api/src/Vhffs/Services/Mail.pm
trunk/vhffs-robots/src/mail_delete.pl
Modified: trunk/vhffs-api/src/Vhffs/Services/Mail.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Mail.pm 2007-10-15 20:40:26 UTC (rev 991)
+++ trunk/vhffs-api/src/Vhffs/Services/Mail.pm 2007-10-16 13:21:21 UTC (rev 992)
@@ -142,6 +142,16 @@
return 1;
}
+
+sub get_dir
+{
+ my $self = shift;
+
+ return undef unless defined $self;
+ return( $self->{'main'}->get_config->get_datadir . '/mail/boxes/' . $self->{'boxes_path'} );
+}
+
+
sub change_forward
{
my $self = shift;
@@ -458,6 +468,21 @@
return 0;
}
+
+sub nb_boxes
+{
+ my $self = shift;
+ return scalar( keys( %{$self->{'boxes'}} ) );
+}
+
+
+sub nb_forwards
+{
+ my $self = shift;
+ return scalar( keys( %{$self->{'forward'}} ) );
+}
+
+
#Following function is needed by courier to fetch accounts
sub crypt_pwd
Modified: trunk/vhffs-robots/src/mail_delete.pl
===================================================================
--- trunk/vhffs-robots/src/mail_delete.pl 2007-10-15 20:40:26 UTC (rev 991)
+++ trunk/vhffs-robots/src/mail_delete.pl 2007-10-16 13:21:21 UTC (rev 992)
@@ -49,16 +49,26 @@
my $list;
foreach $mail ( @{$mails} )
{
- my $lists = Vhffs::Services::MailingList::getall( $vhffs , undef , undef , undef , $mail->get_domain );
+ my $lists = Vhffs::Services::MailingList::getall( $vhffs , undef , undef , undef , $mail->get_domain );
if( @$lists != 0) {
- Vhffs::Robots::vhffs_log( sprintf( "Cannot delete mail domain %s, remains lists" , $mail->get_domain ) , $vhffs);
foreach $list ( @{$lists} ) {
$list->set_status( Vhffs::Constants::TO_DELETE );
$list->commit;
}
+ Vhffs::Robots::vhffs_log( sprintf( 'Cannot delete mail domain %s, remains lists, requests have been sent to delete them' , $mail->get_domain ) , $vhffs);
+ } elsif( $mail->nb_boxes() > 0 ) {
+ foreach my $bo ( values( %{$mail->get_boxes()} ) ) {
+ $mail->set_box_status( $bo->{'local_part'} , Vhffs::Constants::TO_DELETE );
+ }
+ Vhffs::Robots::vhffs_log( sprintf( 'Cannot delete mail domain %s, remains %d boxes, requests have been sent to delete them' , $mail->get_domain , $mail->nb_boxes() ) , $vhffs);
} else {
Vhffs::Robots::vhffs_log( sprintf( "Delete mail domain %s" , $mail->get_domain ) , $vhffs);
- $mail->delete;
+ if( $mail->get_dir && -d $mail->get_dir && chdir( $mail->get_dir ) ) {
+ my $cmd = 'rm -r '.$mail->get_dir;
+ print $cmd."\n";
+ #system( $cmd );
+ }
+ #$mail->delete;
}
}