[vhffs-dev] [516] Mailing lists SQL refactoring.

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 516
Author:   beuss
Date:     2007-03-20 15:47:07 +0000 (Tue, 20 Mar 2007)

Log Message:
-----------
Mailing lists SQL refactoring.
Added signature property (appended to all ml messages)

Modified Paths:
--------------
    branches/vhffs_4.1/Makefile
    branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Mailinglist.pm
    branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Main.pm
    branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Mailing.pm
    branches/vhffs_4.1/vhffs-backend/src/pgsql/initdb.sql
    branches/vhffs_4.1/vhffs-compat/4.0.sql
    branches/vhffs_4.1/vhffs-listengine/src/archives/archives.pl
    branches/vhffs_4.1/vhffs-listengine/src/archives/show_msg.pl
    branches/vhffs_4.1/vhffs-listengine/src/listengine.pl
    branches/vhffs_4.1/vhffs-panel/mailinglist/add_sub.pl
    branches/vhffs_4.1/vhffs-panel/mailinglist/change_right.pl
    branches/vhffs_4.1/vhffs-panel/mailinglist/del_member.pl
    branches/vhffs_4.1/vhffs-panel/mailinglist/delete.pl
    branches/vhffs_4.1/vhffs-panel/mailinglist/prefs.pl
    branches/vhffs_4.1/vhffs-panel/mailinglist/save_options.pl
    branches/vhffs_4.1/vhffs-panel/mailinglist/submit.pl
    branches/vhffs_4.1/vhffs-panel/templates/mailinglist/prefs.tmpl
    branches/vhffs_4.1/vhffs-robots/src/create_ml.pl
    branches/vhffs_4.1/vhffs-robots/src/delete_group.pl
    branches/vhffs_4.1/vhffs-robots/src/delete_mail.pl
    branches/vhffs_4.1/vhffs-robots/src/listengine_publicarchives.pl
    branches/vhffs_4.1/vhffs-robots/src/refused_ml.pl
    branches/vhffs_4.1/vhffs-tests/src/Stats.pl

Added Paths:
-----------
    branches/vhffs_4.1/vhffs-panel/mailinglist/save_sig.pl
    branches/vhffs_4.1/vhffs-tests/src/Services/Mailing.pl


Modified: branches/vhffs_4.1/Makefile
===================================================================
--- branches/vhffs_4.1/Makefile	2007-03-20 15:44:17 UTC (rev 515)
+++ branches/vhffs_4.1/Makefile	2007-03-20 15:47:07 UTC (rev 516)
@@ -309,6 +309,8 @@
 	@perl -I vhffs-tests/src/ -I vhffs-api/src/ -e 'use Test::Harness; Test::Harness::runtests("vhffs-tests/src/Services/Httpd.pl");'
 test-mail:
 	@perl -I vhffs-tests/src/ -I vhffs-api/src/ -e 'use Test::Harness; Test::Harness::runtests("vhffs-tests/src/Services/Mail.pl");'
+test-ml:
+	@perl -I vhffs-tests/src/ -I vhffs-api/src/ vhffs-tests/src/Services/Mailing.pl
 test-mysql:
 	@perl -I vhffs-tests/src/ -I vhffs-api/src/ -e 'use Test::Harness; Test::Harness::runtests("vhffs-tests/src/Services/Mysql.pl");'
 test-pgsql:

Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Mailinglist.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Mailinglist.pm	2007-03-20 15:44:17 UTC (rev 515)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Mailinglist.pm	2007-03-20 15:47:07 UTC (rev 516)
@@ -115,27 +115,18 @@
 
 sub create_list
 {
-    my $main = shift;
-    my $lpart = shift;
-    my $domain = shift;
-    my $user = shift;
-    my $group = shift;
+    my ($main, $lpart, $domain, $description, $user, $group) = @_;
     
     return -5 if( ! defined $user );
-    return -5 if( $group->fetch < 0 ); 
+    return -5 if( ! defined $group ); 
     
-    my $list = new Vhffs::Services::Mailing( $main , $lpart , $domain );
+    my $list = Vhffs::Services::Mailing::create( $main , $lpart , $domain, $user->get_mail, $description, $user, $group );
     return -1 if( ! defined $list );
-    $list->set_user( $user );
-    $list->set_group( $group );
-    $list->set_admin( $user->get_mail );
     
-    return -1 if ( $list->create < 0 );
-    
     return -2 if ( Vhffs::Acl::add_acl( $user , $list , Vhffs::Constants::ACL_DELETE , $main ) < 0 );
     return -3 if( Vhffs::Acl::add_acl( $group , $list , Vhffs::Constants::ACL_VIEW , $main ) < 0 ); 
     
-    return 1;
+    return $list;
 }
 
 
@@ -160,32 +151,26 @@
 	my $mls = Vhffs::Services::Mailing::getall( $vhffs , undef , undef , $group );
 	my $ml;
 	my $output = "";
-	if( defined $mls )
-	{
-		foreach $ml ( @{$mls} )
-		{
-			if( $ml->get_status == Vhffs::Constants::ACTIVATED )
-			{
-				$subtemplate = new HTML::Template( filename => "$templatesdir/mailinglist/menu_sub.tmpl" );
-				$subtemplate->param( NAME => $ml->get_localpart . "\@" . $ml->get_domain);
-				$subtemplate->param( LOCAL => $ml->get_localpart );
-				$subtemplate->param( DOMAIN => $ml->get_domain );
-	            $subtemplate->param( HISTORY => gettext("History"));
-	            $subtemplate->param( OID => $ml->get_oid );
-			}
-			else
-			{
-				$subtemplate = new HTML::Template( filename => "$templatesdir/mailinglist/menu_sub_wait.tmpl" );
-				$subtemplate->param( NAME => $ml->get_localpart . "\@" . $ml->get_domain);
-	            $subtemplate->param( HISTORY => gettext("History"));
-	            $subtemplate->param( REASON => Vhffs::Functions::status_string_from_status_id( $ml->get_status ));
-	            $subtemplate->param( OID => $ml->get_oid );
-			}
 
-
-			$output .= $subtemplate->output if( defined $subtemplate );
-			undef( $subtemplate );
+	foreach $ml ( @{$mls} ) {
+		if( $ml->get_status == Vhffs::Constants::ACTIVATED ) {
+			$subtemplate = new HTML::Template( filename => "$templatesdir/mailinglist/menu_sub.tmpl" );
+			$subtemplate->param( NAME => $ml->get_localpart . "\@" . $ml->get_domain);
+			$subtemplate->param( LOCAL => $ml->get_localpart );
+			$subtemplate->param( DOMAIN => $ml->get_domain );
+            $subtemplate->param( HISTORY => gettext("History"));
+            $subtemplate->param( OID => $ml->get_oid );
+		} else {
+			$subtemplate = new HTML::Template( filename => "$templatesdir/mailinglist/menu_sub_wait.tmpl" );
+			$subtemplate->param( NAME => $ml->get_localpart . "\@" . $ml->get_domain);
+	        $subtemplate->param( HISTORY => gettext("History"));
+	        $subtemplate->param( REASON => Vhffs::Functions::status_string_from_status_id( $ml->get_status ));
+	        $subtemplate->param( OID => $ml->get_oid );
 		}
+
+
+		$output .= $subtemplate->output if( defined $subtemplate );
+		undef( $subtemplate );
 	}
 
 	$template->param( SUB_MAILINGLIST => $output );

Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Main.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Main.pm	2007-03-20 15:44:17 UTC (rev 515)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Main.pm	2007-03-20 15:47:07 UTC (rev 516)
@@ -348,7 +348,7 @@
 		$temp = "";
 		$template->param( WEBAREA => gettext("Webarea for this group") );
 		$objects = Vhffs::Services::Httpd::getall( $vhffs , undef , undef , $group );
-		if( defined $objects )
+		if( @$objects != 0 )
 		{	
 			foreach $object ( @{$objects} )
 			{

Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Mailing.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Mailing.pm	2007-03-20 15:44:17 UTC (rev 515)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Mailing.pm	2007-03-20 15:47:07 UTC (rev 516)
@@ -87,9 +87,38 @@
 }
 
 
-# Create the object in the database
 sub create
 {
+    if($_[0]->isa('Vhffs::Services::Mailing')) {
+        my ($package, $file, $line) = caller();
+        warn "Using deprecated form of Vhffs::Services::Mailing::create from $package ($file:$line).\n";
+        return old_create(@_);
+    }
+
+    my ($main, $local, $domain, $admin, $description, $user, $group) = @_;
+    
+    return undef unless(defined $user && defined $group);
+    return undef unless($local =~ /^[a-z0-9\_\-]+$/);
+    return undef unless(Vhffs::Functions::check_domain_name($domain));
+    $admin = $user->get_mail() unless(defined $admin);
+
+    my $dbh = $main->get_db_object();
+    my $sql = 'SELECT mxdomain_id FROM vhffs_mxdomain WHERE domain = ? AND owner_gid = ?';
+    return undef unless($domain eq $main->get_config()->get_service("mailing")->{'default_domain'} ||
+                            $dbh->do($sql, undef, $domain, $group->get_gid) > 0);
+
+    my $parent = Vhffs::Object::create($main, $user->get_uid, $description, undef, Vhffs::Constants::TYPE_ML);
+    return undef unless(defined $parent);
+
+    $sql = 'INSERT INTO vhffs_ml(local_part, domain, prefix, owner_uid, owner_gid, object_id, admin, open_post, open_archive, open_sub, reply_to, moderated) VALUES(?, ?, ?, ?, ?, ?, ?, FALSE, FALSE, TRUE, TRUE, FALSE)';
+    my $sth = $dbh->prepare($sql);
+    return undef unless($sth->execute($local, $domain, $local, $user->get_uid, $group->get_gid, $parent->get_oid, $admin));
+    return get_by_mladdress($main, $local, $domain);
+}
+
+# Create the object in the database
+sub old_create
+{
     my $self = shift;
     my $query;
     my $request;
@@ -100,10 +129,6 @@
     return -1 if( ! defined $self->{'user'} );
     return -1 if( ! defined $self->{'group'} );
 
-    # If user or group^does not exists in the VHFFS database, we return -1, the object is not created
-    return -1 if( $self->{'user'}->fetch < 0 );
-    return -1 if( $self->{'group'}->fetch < 0 );
-
     $query = "SELECT * FROM vhffs_ml where domain='".$self->{'domain'}."' AND local_part='".$self->{'local_part'}."'";
     $request = $self->{'db'}->prepare( $query ) or return -1;
     $rows = $request->execute() or return -3;
@@ -138,12 +163,51 @@
 }
 
 
-# Get all data about this mail object in the databse
-# Informations about the mail domain is stored in $ref->
-# Inforations about forwards are stored in $ref->{'forward'}
-# Informations about mailboxes are stored in $ref->{'boxes'}
+sub get_by_mladdress {
+    my ($main, $local, $domain) = @_;
+    
+    my $dbh = $main->get_db_object();
+    my $sql = 'SELECT ml.ml_id, ml.local_part, ml.domain, ml.prefix, ml.owner_gid, ml.admin, ml.open_post, ml.open_archive, ml.open_sub, ml.reply_to, ml.moderated, ml.signature, o.object_id, o.owner_uid, o.date_creation, o.state, o.description FROM vhffs_ml ml INNER JOIN vhffs_object o ON o.object_id = ml.object_id WHERE domain = ? and local_part = ?';
+    my $sth = $dbh->prepare($sql);
+    return undef unless ($sth->execute($domain, $local) > 0);
+    my @params = $sth->fetchrow_array;
+
+    $sql = 'SELECT sub_id, member, perm, hash, ml_id, language FROM vhffs_ml_subscribers WHERE ml_id = ?';
+    $sth = $dbh->prepare($sql);
+    $sth->execute($params[0]);
+    my $subs = $sth->fetchall_hashref('member');
+    push @params, $subs;
+    return _new Vhffs::Services::Mailing($main, @params);
+}
+
+sub _new {
+    my ($class, $main, $ml_id, $local_part, $domain, $prefix, $owner_gid, $admin, $open_post, $open_archive, $open_sub, $reply_to, $moderated, $signature, $oid, $owner_uid, $date_creation, $state, $description, $subs) = @_;
+
+    my $self = $class->SUPER::_new($main, $oid, $owner_uid, $date_creation, $description, $state, Vhffs::Constants::TYPE_ML);
+    return undef unless defined($self);
+
+    $self->{ml_id} = $ml_id;
+    $self->{local_part} = $local_part;
+    $self->{domain} = $domain,
+    $self->{prefix} = $prefix;
+    $self->{owner_gid} = $owner_gid;
+    $self->{admin} = $admin;
+    $self->{open_post} = $open_post;
+    $self->{open_archive} = $open_archive;
+    $self->{open_sub} = $open_sub;
+    $self->{reply_to} = $reply_to;
+    $self->{moderated} = $moderated;
+    $self->{signature} = $signature;
+    $self->{subs} = $subs;
+
+    return $self;
+}
+
 sub fetch
 {
+    my ($package, $file, $line) = caller();
+    warn "Using deprecated method Vhffs::Mailing::fetch from $package ($file:$line).\n";
+    
     my $self = shift;
 
     my ($request , $result , $request2 , $result2 , $query );
@@ -184,12 +248,10 @@
 {
     my $self = shift;	
 
-    my( $request , $result , $rows , $query , $name , $password);
+    my $sql = 'UPDATE vhffs_ml SET prefix = ?, admin = ?, open_post = ?, open_archive = ?, reply_to = ?, moderated = ?, open_sub = ?, signature = ? WHERE ml_id = ?';
+    my $dbh = $self->get_main->get_db_object();
+    $dbh->do($sql, undef, $self->{prefix}, $self->{admin}, $self->{open_post}, $self->{open_archive}, $self->{reply_to}, $self->{moderated}, $self->{open_sub}, $self->{signature}, $self->{ml_id});
 
-    $query = "UPDATE vhffs_ml SET prefix='".$self->{'prefix'}."' , admin='".$self->{'admin'}."' , open_post='".$self->{'open_post'}."', open_archive='".$self->{'open_archive'}."' , reply_to='".$self->{'reply_to'}. "', moderated='".$self->{moderated}."' , open_sub='".$self->{'open_sub'}."' WHERE ml_id='".$self->{'ml_id'}."'";
-    $request = $self->{'db'}->prepare( $query );
-    $request->execute;
-
     return -3 if( $self->SUPER::commit < 0 );
 
     return 1;
@@ -197,17 +259,13 @@
 
 sub change_right_for_sub
 {
-    my $self = shift;
-    my $subscriber = shift;
-    my $right = shift;
+    my ($self, $subscriber, $right) = @_;
 
-    return -1 if( Vhffs::Functions::valid_mail( $subscriber ) != 1 );
-    return -1 if( ! ( $right =~ /^[0-9]+$/ ) );
-
-    my $query = "UPDATE vhffs_ml_subscribers  SET perm='".$right."' WHERE ml_id='".$self->{'ml_id'}."' AND member='".$subscriber."'";
-    my $request = $self->{'db'}->prepare( $query );
-    $request->execute or return -2;
-
+    my $sql = 'UPDATE vhffs_ml_subscribers SET perm = ? WHERE ml_id = ? AND member = ?';
+    my $dbh = $self->get_db_object();
+    # FIXME compatibility hack, we should return a boolean
+    return -1 unless($dbh->do($sql, undef, $right, $self->{ml_id}, $subscriber) > 0);
+    $self->{subs}->{$subscriber}->{perm} = $right;
     return 1;
 }
 
@@ -224,20 +282,20 @@
     return -2 if( $subscriber =~ /.*\s.*/ );
     return -1 if( ! ( $right =~ /^[\d]+$/ ) );
 
-    my $query = "SELECT * FROM vhffs_ml_subscribers WHERE ml_id='".$self->{ml_id}."' AND member='".$subscriber."'";
-    my $request = $self->{'db'}->prepare( $query );
-    my $rows = $request->execute;
-    return -1 if ( $rows != 0 );
+    my $sql = 'INSERT INTO vhffs_ml_subscribers (member, perm, hash, ml_id, language) VALUES (?, ?, NULL, ?, NULL)';
+    my $dbh = $self->get_main->get_db_object();
+    $dbh->do($sql, undef, $subscriber, $right, $self->{ml_id}) or return -2;
 
-    my $sid = 1;
-    $query = "SELECT MAX(sub_id) FROM vhffs_ml_subscribers";
-    my $resultsid = $self->{'db'}->selectall_arrayref( $query );
-    $sid = $resultsid->[0][0] if ( defined $resultsid->[0][0] );
-    $sid++;
+    my $id = $dbh->last_insert_id(undef, undef, 'vhffs_ml_subscribers', undef);
 
-    $query = "INSERT INTO vhffs_ml_subscribers VALUES( '".$sid."' , '".$subscriber."' , '".$right."' ,  '1' , 'nohash' , '".$self->{'ml_id'}."')";
-    $request = $self->{'db'}->prepare( $query );
-    $request->execute or return -2;
+    $self->{subs}->{$subscriber} = {
+        sub_id => $id,
+        member => $subscriber,
+        perm => $right,
+        hash => undef,
+        ml_id => $self->{ml_id},
+        language => undef
+    };
 
     return 1;
 }
@@ -253,26 +311,27 @@
     my $hash;
 
     return undef if( Vhffs::Functions::valid_mail( $subscriber ) != 1 );
+    return undef if( $subscriber =~ /.*<.*/ );
+    return undef if( $subscriber =~ /.*>.*/ );
+    return undef if( $subscriber =~ /.*\s.*/ );
 
-    #check if sub already exists
-    my $query = "SELECT * FROM vhffs_ml_subscribers WHERE ml_id='".$self->{ml_id}."' AND member='".$subscriber."'";
-    my $request = $self->{'db'}->prepare( $query );
-    my $rows = $request->execute;
-    return undef if ( $rows != 0 );
+    $hash = Digest::MD5::md5_hex( Vhffs::Functions::generate_random_password );
+   
+    my $sql = 'INSERT INTO vhffs_ml_subscribers(member, perm, hash, ml_id, language) VALUES(?, ?, ?, ?, NULL)';
+    my $dbh = $self->get_main->get_db_object();
+    $dbh->do($sql, undef, $subscriber, Vhffs::Constants::ML_RIGHT_SUB_WAITING_FOR_REPLY, $hash, $self->{ml_id}) or return undef;
 
-    my $sid = 1;
-    $query = "SELECT MAX(sub_id) FROM vhffs_ml_subscribers";
-    my $resultsid = $self->{'db'}->selectall_arrayref( $query );
-    $sid = $resultsid->[0][0] if ( defined $resultsid->[0][0] );
-    $sid++;
+    my $id = $dbh->last_insert_id(undef, undef, 'vhffs_ml_subscribers', undef);
 
+    $self->{subs}->{$subscriber} = {
+        sub_id => $id,
+        member => $subscriber,
+        perm => Vhffs::Constants::ML_RIGHT_SUB_WAITING_FOR_REPLY,
+        hash => $hash,
+        ml_id => $self->{ml_id},
+        language => undef
+    };
 
-    $hash = Digest::MD5::md5_hex( Vhffs::Functions::generate_random_password );
-    
-    $query = "INSERT INTO vhffs_ml_subscribers VALUES( '".$sid."' , '".$subscriber."' , '".Vhffs::Constants::ML_RIGHT_SUB_WAITING_FOR_REPLY."' ,  '1' , '".$hash."' , '".$self->{'ml_id'}."')";
-    $request = $self->{'db'}->prepare( $query );
-    $request->execute or return -2;
-
     return $hash;
 }
 
@@ -283,34 +342,18 @@
     my $self = shift;
     my $subscriber = shift;
 
-    return -1 if( Vhffs::Functions::valid_mail( $subscriber ) != 1 );
+    my $sql = 'DELETE FROM vhffs_ml_subscribers WHERE ml_id = ? AND member = ?';
+    # FIXME we should return a boolean
+    return -1 unless($self->get_main->get_db_object->do($sql, undef, $self->{ml_id}, $subscriber) > 0);
 
-
-    return -2 if ( $self->sub_exists( $subscriber )  !=  1);
-
-
-    my $query = "DELETE FROM vhffs_ml_subscribers  WHERE ml_id='".$self->{'ml_id'}."' AND member='".$subscriber."'";
-    my $request = $self->{'db'}->prepare( $query );
-    $request->execute or return -1;
-
+    delete $self->{subs}->{$subscriber};
     return 1;
 }
 
+# FIXME useless
 sub change_state_for_sub
 {
-    my $self = shift;
-    my $subscriber = shift;
-    my $right = shift;
-
-    return -1 if( Vhffs::Functions::valid_mail( $subscriber ) != 1 );
-
-    return -2 if ( $self->sub_exists( $subscriber ) != 1);
-
-    my $query = "UPDATE vhffs_ml_subscribers SET perm='".$right."' WHERE ml_id='".$self->{'ml_id'}."' AND member='".$subscriber."'";
-    my $request = $self->{'db'}->prepare( $query );
-    $request->execute or return -1;
-
-    return 1;
+    return change_right_for_sub(@_);
 }
 
 sub clear_hash
@@ -318,20 +361,14 @@
     my $self = shift;
     my $subscriber = shift;
 
-    return -1 if( Vhffs::Functions::valid_mail( $subscriber ) != 1 );
-
-    return -2 if ( $self->sub_exists( $subscriber ) != 1);
-
-    my $query = "UPDATE vhffs_ml_subscribers SET hash=' ' WHERE ml_id='".$self->{'ml_id'}."' AND member='".$subscriber."'";
-    my $request = $self->{'db'}->prepare( $query );
-    $request->execute or return -1;
-
+    my $sql = 'UPDATE vhffs_ml_subscribers SET hash = NULL WHERE ml_id = ? AND member = ?';
+    # FIXME we should return a boolean
+    return -1 unless($self->get_main->get_db_object->do($sql, undef, $self->{ml_id}, $subscriber) > 0);
+    
+    $self->{subs}->{$subscriber}->{hash} = undef;
     return 1;
 }
 
-
-
-
 sub del_sub_with_reply
 {
     use Digest::MD5;
@@ -339,85 +376,41 @@
     my $self = shift;
     my $subscriber = shift;
 
-    return -1 if( Vhffs::Functions::valid_mail( $subscriber ) != 1 );
-
-
-    return -2 if ( $self->sub_exists( $subscriber ) != 1);
-
-    return -3 if( ( $self->get_members->{$subscriber}{perm} != Vhffs::Constants::ML_RIGHT_SUB ) && ( $self->get_members->{$subscriber}{perm} != Vhffs::Constants::ML_RIGHT_ADMIN ) );
     
     my $hash = Digest::MD5::md5_hex( Vhffs::Functions::generate_random_password );
-    my $query = "UPDATE vhffs_ml_subscribers SET perm='".Vhffs::Constants::ML_RIGHT_SUB_WAITING_FOR_DEL."', hash='".$hash."' WHERE ml_id='".$self->{'ml_id'}."' AND member='".$subscriber."'";
-    my $request = $self->{'db'}->prepare( $query );
-    $request->execute or return -1;
 
+    my $sql = 'UPDATE vhffs_ml_subscribers SET perm = ?, hash = ? WHERE ml_id = ? AND member = ? AND perm IN (?, ?)';
+    # FIXME we should return a boolean
+    return undef unless($self->get_main->get_db_object->do($sql, undef, Vhffs::Constants::ML_RIGHT_SUB_WAITING_FOR_DEL, $hash, $self->{ml_id}, $subscriber, Vhffs::Constants::ML_RIGHT_SUB, Vhffs::Constants::ML_RIGHT_ADMIN) > 0);
+
+    $self->{subs}->{$subscriber}->{hash} = $hash;
+    $self->{subs}->{$subscriber}->{perm} = Vhffs::Constants::ML_RIGHT_SUB_WAITING_FOR_DEL;
     return $hash;
 }
 
-sub sub_exists
-{
-    my $self = shift;
-    my $subscriber = shift;
+# No need for delete method, foreign keys do the job
+#sub delete
+#{
+#}
 
-    return -1 if( Vhffs::Functions::valid_mail( $subscriber ) != 1 );
 
-    my $query = "SELECT * FROM vhffs_ml_subscribers WHERE ml_id='".$self->{ml_id}."' AND member='".$subscriber."'";
-    my $request = $self->{'db'}->prepare( $query );
-    my $rows = $request->execute;
-    return -1 if ( $rows == 0 );
-    return 1;
-}
-
-
-sub delete
-{
-    my $self = shift;
-    my $query;
-    my $request;
-
-    $query = "DELETE FROM vhffs_ml_subscribers  WHERE ml_id='".$self->{'ml_id'}."'";
-    $request = $self->{'db'}->prepare( $query );
-    $request->execute or return -1;
-
-    $query = "DELETE FROM vhffs_ml WHERE ml_id='".$self->{'ml_id'}."'";
-    $request = $self->{'db'}->prepare( $query );
-    $request->execute or return -1;
-
-    $self->SUPER::delete;
-
-    return 1;
-}
-
-
 sub get_language_for_sub
 {
-    my $vhffs = shift;
-    my $sub = shift;
-    my $query;
-    my $request;
+    my ($main, $sub) = @_;
 
-    $query = "SELECT language FROM vhffs_ml_subscribers WHERE member='".$sub."'";
-    $request = $vhffs->{'db'}->prepare( $query );
-    return undef if ( $request->execute <= 0 );
-    
-    my $result = $request->fetchrow_arrayref;
-    return $result->[0];
+    my $sql = 'SELECT language FROM vhffs_ml_subscribers WHERE member = ?';
+    my $lang = $main->get_db_object->selectrow_array($sql, undef, $sub);
+    return $lang;
 }
 
 
 sub set_language_for_sub
 {
-    my $vhffs = shift;
-    my $sub = shift;
-    my $language = shift;
-    my $query,
-    my $request;
+    my ($main, $sub, $language) = @_;
 
-    $language = "en_US" unless( $language =~ /^[\w]+$/ );
-
-    $query = "UPDATE vhffs_ml_subscribers SET language='".$language."' WHERE member='".$sub."'";
-    $request = $vhffs->{'db'}->prepare( $query );
-    $request->execute or return -1;
+    $language = 'en_US' unless( $language =~ /^\w+$/ );
+    my $sql = 'UPDATE vhffs_ml_subscribers SET language = ? WHERE member = ?';
+    $main->get_db_object->do($sql, undef, $language, $sub) or return -1;
 }
 
 sub get_localpart
@@ -426,7 +419,19 @@
     return $self->{'local_part'};
 }
 
+sub get_signature
+{
+    my $self = shift;
+    return $self->{signature};
+}
 
+sub set_signature
+{
+    my ($self, $sig) = @_;
+    $sig =~ s/\r\n/\n/;
+    $self->{signature} = $sig;
+}
+
 sub get_open_archive
 {
     my $self = shift;
@@ -454,13 +459,6 @@
 }
 
 
-sub get_url
-{
-    my $self = shift;
-    return $self->{'url'};
-}
-
-
 sub get_moderated
 {
     my $self = shift;
@@ -546,7 +544,7 @@
 {
     my( $self , $value ) = @_;
 
-    $self->{'prefix'} = quotemeta $value;
+    $self->{'prefix'} = $value;
 }
 
 sub set_user
@@ -569,69 +567,53 @@
 
 sub getall
 {
-    my $vhffs = shift;
-    my $state = shift;
-    my $name = shift;
-    my $group = shift;
-    my $domain = shift;
+    my ($vhffs, $state, $name, $group, $domain) = @_;
 
-    my $query;
     return undef if( ! defined $vhffs );
 
-	$query = "SELECT * FROM vhffs_ml ml, vhffs_object o WHERE o.object_id=ml.object_id";
-	$query .= " AND o.state='".$state."'" if( defined $state );
-	$query .= " AND ml.owner_gid='".$group->get_gid."'" if( defined $group );
-    $query .= " AND ( ( local_part LIKE '%".$name."%' ) OR (domain LIKE '%".$name."%' ) )" if( defined $name );
-    $query .= " AND ( domain='".$domain."')" if( defined $domain );
+    my $mls = [];
+    my @params;
+    my $sql = 'SELECT local_part, domain FROM vhffs_ml ml, vhffs_object o WHERE o.object_id = ml.object_id';
 
-    my $request = $vhffs->get_db_object->prepare( $query );
-    my $rows = $request->execute() or return -3;
-	return undef if( $rows <= 0 );
-    my $result = $request->fetchall_hashref('ml_id');
-    my $object;
-    my @plop;
+    if(defined $state) {
+        $sql .= ' AND o.state = ?';
+        push @params, $state;
+    }
+    if(defined $group) {
+        $sql .= ' AND ml.owner_gid = ?';
+        push @params, $group->get_gid;
+    }
+    if(defined $name) {
+        $sql .= ' AND ( local_part LIKE ? OR domain LIKE ?)';
+        push @params, '%'.$name.'%', '%'.$name.'%';
+    }
+    if(defined $domain) {
+        $sql .= ' AND domain = ?';
+        push @params, $domain;
+    }
 
+    $sql .= ' ORDER BY local_part, domain';
 
-    
-    foreach( keys %{$result} ) 
-    {
-	$object = new Vhffs::Services::Mailing( $vhffs , $result->{$_}{local_part} , $result->{$_}{domain} );
-	push( @plop , $object ) if( ( defined $object ) && ( $object->fetch > 0 ) );
-    }
+    my $dbh = $vhffs->get_db_object;
+    my $sth = $dbh->prepare($sql);
+    $sth->execute(@params) or return -3;
 
-    return( \@plop );
+    while(my @ml = $sth->fetchrow_array) {
+        push @$mls, get_by_mladdress($vhffs, @ml);
+    }
+    return $mls;
 }
 
 
 
 #Returns all the lists for a group
+# FIXME useless
 sub getall_by_group
 {
     my $vhffs = shift;
     my $group = shift;
 
-    my $query;
-    return undef if( ! defined $vhffs );
-
-	$query = "SELECT * FROM vhffs_ml ml, vhffs_object o WHERE o.object_id=ml.object_id";
-	$query .= " AND ml.owner_gid='".$group->get_gid."'" if( defined $group );
-
-    my $request = $vhffs->get_db_object->prepare( $query );
-    my $rows = $request->execute() or return -3;
-	return undef if( $rows <= 0 );
-    my $result = $request->fetchall_hashref('ml_id');
-    my $object;
-    my @plop;
-
-
-    
-    foreach( keys %{$result} ) 
-    {
-		$object = new Vhffs::Services::Mailing( $vhffs , $result->{$_}{local_part} , $result->{$_}{domain} );
-		push( @plop , $object ) if( ( defined $object ) && ( $object->fetch > 0 ) );
-    }
-
-    return( \@plop );
+    return getall($vhffs, undef, undef, $group);
 }
 
 

Modified: branches/vhffs_4.1/vhffs-backend/src/pgsql/initdb.sql
===================================================================
--- branches/vhffs_4.1/vhffs-backend/src/pgsql/initdb.sql	2007-03-20 15:44:17 UTC (rev 515)
+++ branches/vhffs_4.1/vhffs-backend/src/pgsql/initdb.sql	2007-03-20 15:47:07 UTC (rev 516)
@@ -219,7 +219,7 @@
 	open_sub boolean,
 	reply_to boolean,
 	moderated boolean,
-	url varchar(512),
+    signature varchar(250),
 	CONSTRAINT vhffs_ml_pkey PRIMARY KEY (ml_id)
 ) WITH OIDS;
 
@@ -228,10 +228,9 @@
 	sub_id serial,
 	member varchar(256) NOT NULL,
 	perm int4 NOT NULL,
-	active int4 NOT NULL,
-	hash varchar NOT NULL,
+	hash varchar,
 	ml_id int4 NOT NULL,
-	language varchar(16) NOT NULL,
+	language varchar(16),
 	CONSTRAINT vhffs_ml_subscribers_pkey PRIMARY KEY (sub_id)
 ) WITH OIDS;
 
@@ -301,6 +300,8 @@
 ALTER TABLE vhffs_repository ADD CONSTRAINT vhffs_repository_unique_name UNIQUE (name);
 ALTER TABLE vhffs_svn ADD CONSTRAINT vhffs_svn_unique_reponame UNIQUE (reponame);
 ALTER TABLE vhffs_dns ADD CONSTRAINT vhffs_dns_unique_domain UNIQUE (domain);
+ALTER TABLE vhffs_ml ADD CONSTRAINT vhffs_ml_unique_address UNIQUE (local_part, domain);
+ALTER TABLE vhffs_ml_subscribers ADD CONSTRAINT vhffs_ml_subscribers_member_list UNIQUE (ml_id, member);
 
 -- This index drastically improves performances on get_used_letters
 CREATE INDEX idx_vhffs_httpd_servername_firstletter ON vhffs_httpd(substr(servername, 1, 1));
@@ -345,7 +346,7 @@
 ALTER TABLE vhffs_ml ADD CONSTRAINT fk_vhffs_ml_vhffs_groups FOREIGN KEY (owner_gid) REFERENCES vhffs_groups(gid);
 ALTER TABLE vhffs_ml ADD CONSTRAINT fk_vhffs_ml_vhffs_object FOREIGN KEY (object_id) REFERENCES vhffs_object(object_id) ON DELETE CASCADE;
 
-ALTER TABLE vhffs_ml_subscribers ADD CONSTRAINT fk_vhffs_ml_subscribers_vhffs_ml FOREIGN KEY (ml_id) REFERENCES vhffs_ml(ml_id);
+ALTER TABLE vhffs_ml_subscribers ADD CONSTRAINT fk_vhffs_ml_subscribers_vhffs_ml FOREIGN KEY (ml_id) REFERENCES vhffs_ml(ml_id) ON DELETE CASCADE;
 
 ALTER TABLE vhffs_mysql ADD CONSTRAINT fk_vhffs_mysql_vhffs_users FOREIGN KEY (owner_uid) REFERENCES vhffs_users(uid);
 ALTER TABLE vhffs_mysql ADD CONSTRAINT fk_vhffs_mysql_vhffs_groups FOREIGN KEY (owner_gid) REFERENCES vhffs_groups(gid);

Modified: branches/vhffs_4.1/vhffs-compat/4.0.sql
===================================================================
--- branches/vhffs_4.1/vhffs-compat/4.0.sql	2007-03-20 15:44:17 UTC (rev 515)
+++ branches/vhffs_4.1/vhffs-compat/4.0.sql	2007-03-20 15:47:07 UTC (rev 516)
@@ -105,26 +105,31 @@
 ALTER TABLE vhffs_ml ADD COLUMN open_sub boolean;
 ALTER TABLE vhffs_ml ADD COLUMN reply_to boolean;
 ALTER TABLE vhffs_ml ADD COLUMN moderated boolean;
-ALTER TABLE vhffs_ml ADD COLUMN url varchar(512);
 
 UPDATE vhffs_ml SET admin = mlp.admin,
     open_post = (mlp.open_post != 0),
     open_archive = (mlp.open_archive != 0),
     open_sub = (mlp.open_sub != 0),
     reply_to = (mlp.reply_to != 0),
-    moderated = (mlp.moderated != 0),
-    url = mlp.url
+    moderated = (mlp.moderated != 0)
     FROM vhffs_ml_prefs mlp
     WHERE mlp.ml_id = vhffs_ml.ml_id;
 
 -- DROP TABLE vhffs_ml_prefs;
 
+ALTER TABLE vhffs_ml DROP url;
+ALTER TABLE vhffs_ml ADD COLUMN signature varchar(250);
+
+
 -- merge vhffs_ml_lang to vhffs_ml_subscribers
 ALTER TABLE vhffs_ml_subscribers ADD COLUMN language varchar(16);
 UPDATE vhffs_ml_subscribers SET language = mll.lang FROM vhffs_ml_lang mll WHERE mll.member = vhffs_ml_subscribers.member;
 
 -- DROP TABLE vhffs_ml_lang;
 
+ALTER TABLE vhffs_ml_subscribers DROP active;
+ALTER TABLE vhffs_ml_subscribers ALTER COLUMN hash DROP NOT NULL;
+
 -- rename vhffs_dns_global to vhffs_dns
 ALTER TABLE vhffs_dns_global RENAME TO vhffs_dns;
 

Modified: branches/vhffs_4.1/vhffs-listengine/src/archives/archives.pl
===================================================================
--- branches/vhffs_4.1/vhffs-listengine/src/archives/archives.pl	2007-03-20 15:44:17 UTC (rev 515)
+++ branches/vhffs_4.1/vhffs-listengine/src/archives/archives.pl	2007-03-20 15:47:07 UTC (rev 516)
@@ -104,7 +104,7 @@
 
 #On obtient le domaine, le local part et on construit l'objet de la liste
 my( $lpart , $domain ) = split/\@/,$listname,2;
-my $list = new Vhffs::Services::Mailing( $vhffs , $lpart , $domain );
+my $list = Vhffs::Services::Mailing::get_by_mladdress( $vhffs , $lpart , $domain );
 my $templatedir = $vhffs->get_config->get_listengine_templatesdir;
 
 
@@ -135,7 +135,7 @@
     $template = new HTML::Template( filename => $templatedir."/error.tmpl");
     $template->param( ERROR => gettext("Error in listname") );
 }
-elsif( ( ! defined $list ) || ( $list->fetch < 0 ) )
+elsif( ! defined $list )
 {
     $template = new HTML::Template( filename => $templatedir."/error.tmpl");
     $template->param( ERROR => gettext("Undefined list") );

Modified: branches/vhffs_4.1/vhffs-listengine/src/archives/show_msg.pl
===================================================================
--- branches/vhffs_4.1/vhffs-listengine/src/archives/show_msg.pl	2007-03-20 15:44:17 UTC (rev 515)
+++ branches/vhffs_4.1/vhffs-listengine/src/archives/show_msg.pl	2007-03-20 15:47:07 UTC (rev 516)
@@ -58,7 +58,7 @@
 my $listname = $cgi->param("list");
 my $mid = $cgi->param("mid");
 my( $lpart , $domain ) = split/\@/,$listname,2;
-my $list = new Vhffs::Services::Mailing( $vhffs , $lpart , $domain );
+my $list = Vhffs::Services::Mailing::get_by_mladdress( $vhffs , $lpart , $domain );
 my $templatedir = $vhffs->get_config->get_listengine_templatesdir;
 my $theme = Vhffs::Listengine::Panel::check_theme( $cgi->cookie("theme") );
 
@@ -75,7 +75,7 @@
     $template = new HTML::Template( filename => $templatedir."/error.tmpl");
     $template->param( ERROR => gettext("Error in listname") );
 }
-elsif( ( ! defined $list ) || ( $list->fetch < 0 ) )
+elsif( ! defined $list )
 {
     $template = new HTML::Template( filename => $templatedir."/error.tmpl");
     $template->param( ERROR => gettext("Undefined list") );

Modified: branches/vhffs_4.1/vhffs-listengine/src/listengine.pl
===================================================================
--- branches/vhffs_4.1/vhffs-listengine/src/listengine.pl	2007-03-20 15:44:17 UTC (rev 515)
+++ branches/vhffs_4.1/vhffs-listengine/src/listengine.pl	2007-03-20 15:47:07 UTC (rev 516)
@@ -434,6 +434,14 @@
 		$mail->replace( 'Subject' , "[".$prefix."]"." ".$subject ) if( length( $prefix ) > 0 );
 	}
 
+    # Add list's signature at the bottom of mail
+    if(defined(my $signature = $list->get_signature)) {
+        my $body = $mail->body;
+        push @$body, '---';
+        my @sig = split(/\n/, $signature);
+        push @$body, @sig;
+    }
+
 	foreach ( keys %{$subs} )
 	{
 		#Send mail to user if he is a confirmed subscriber
@@ -452,7 +460,6 @@
     my $list = shift;
 
     exit -1 if( ! defined $list );
-    exit 0 if( $list->fetch < 0 );
     
     my ( $from ) = ( $mail->get('From') =~ /(([\+\.a-zA-Z_\-0-9^\s]+)@([a\.-zA-Z_\-0-9^\s]+)\.(\w+))/);
     my $subject = $mail->get('Subject');
@@ -467,18 +474,12 @@
        
     	$in_moderation = 1;
 
-	# If the list is moderated, we refuse the mail
-	# But if the mail is from an admin, we allow it
-	foreach ( keys %{$subs} )
-	{
-	    if( ( $from eq $_ ) && ( $subs->{$_}{perm} == Vhffs::Constants::ML_RIGHT_ADMIN ) )
-	    {
-		$authorized = 1;
-		$in_moderation = 0;
-		last;
-	    }
-	}
-
+    	# If the list is moderated, we refuse the mail
+    	# But if the mail is from an admin, we allow it
+        if(defined $subs->{$from} && $subs->{$from}{perm} == Vhffs::Constants::ML_RIGHT_ADMIN) {
+            $authorized = 1;
+            $in_moderation = 0;
+        }
     }
     elsif( $list->get_open_post == 1 )
     {
@@ -488,12 +489,10 @@
     }
     else
     {
-	# In this case, The list is not in open_post
-	# We must check if the poster is a subscriber
-	foreach ( keys %{$subs} )
-	{
-	    $authorized = 1 if( ( $from eq $_ ) && ( $subs->{$_}{perm} != Vhffs::Constants::ML_RIGHT_SUB_WAITING_FOR_REPLY ) );
-	}
+    	# In this case, The list is not in open_post
+    	# We must check if the poster is a subscriber
+        $authorized = 1 if(defined $subs->{$from} && ($subs->{$from}{perm} == Vhffs::Constants::ML_RIGHT_SUB 
+                    || $subs->{$from}{perm} == Vhffs::Constants::ML_RIGHT_ADMIN));
     }
 
     
@@ -939,8 +938,8 @@
 get_lang( $mail );
 
 #Build the list object from VHFFS
-my $list = new Vhffs::Services::Mailing( $vhffs , $lpart , $domain );
-exit( 0 ) if( $list->fetch < 0 );
+my $list = Vhffs::Services::Mailing::get_by_mladdress( $vhffs , $lpart , $domain );
+exit( 0 ) if(!defined $list);
 
 
 verify_mail_with_list( $list , $mail );

Modified: branches/vhffs_4.1/vhffs-panel/mailinglist/add_sub.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/mailinglist/add_sub.pl	2007-03-20 15:44:17 UTC (rev 515)
+++ branches/vhffs_4.1/vhffs-panel/mailinglist/add_sub.pl	2007-03-20 15:47:07 UTC (rev 516)
@@ -70,7 +70,7 @@
 
 my $templatedir = $vhffs->get_config->get_templatedir;
 
-my $list = new Vhffs::Services::Mailing( $vhffs , $lpart , $domain , $user , $group );
+my $list = Vhffs::Services::Mailing::get_by_mladdress( $vhffs , $lpart , $domain , $user , $group );
 
 $template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
 
@@ -80,10 +80,6 @@
 }
 elsif( ! defined ( $list ) )
 {
-	$message = gettext( "Cannot build object");
-}
-elsif( $list->fetch < 0 )
-{
 	$message = gettext( "Cannot get informations on this object");
 }
 elsif( $list->get_status != Vhffs::Constants::ACTIVATED )

Modified: branches/vhffs_4.1/vhffs-panel/mailinglist/change_right.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/mailinglist/change_right.pl	2007-03-20 15:44:17 UTC (rev 515)
+++ branches/vhffs_4.1/vhffs-panel/mailinglist/change_right.pl	2007-03-20 15:47:07 UTC (rev 516)
@@ -72,7 +72,7 @@
 
 my $templatedir = $vhffs->get_config->get_templatedir;
 
-my $list = new Vhffs::Services::Mailing( $vhffs , $lpart , $domain , $user , $group );
+my $list = Vhffs::Services::Mailing::get_by_mladdress( $vhffs, $lpart, $domain );
 
 $template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
 
@@ -82,10 +82,6 @@
 }
 elsif( ! defined ( $list ) )
 {
-	$message = gettext( "Cannot build object");
-}
-elsif( $list->fetch < 0 )
-{
 	$message = gettext( "Cannot get informations on this object");
 }
 elsif( $list->get_status != Vhffs::Constants::ACTIVATED )

Modified: branches/vhffs_4.1/vhffs-panel/mailinglist/del_member.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/mailinglist/del_member.pl	2007-03-20 15:44:17 UTC (rev 515)
+++ branches/vhffs_4.1/vhffs-panel/mailinglist/del_member.pl	2007-03-20 15:47:07 UTC (rev 516)
@@ -70,7 +70,7 @@
 
 my $templatedir = $vhffs->get_config->get_templatedir;
 
-my $list = new Vhffs::Services::Mailing( $vhffs , $lpart , $domain , $user , $group );
+my $list = Vhffs::Services::Mailing::get_by_mladdress( $vhffs, $lpart, $domain );
 
 $template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
 
@@ -80,10 +80,6 @@
 }
 elsif( ! defined ( $list ) )
 {
-	$message = gettext( "Cannot build object");
-}
-elsif( $list->fetch < 0 )
-{
 	$message = gettext( "Cannot get informations on this object");
 }
 elsif( $list->get_status != Vhffs::Constants::ACTIVATED )

Modified: branches/vhffs_4.1/vhffs-panel/mailinglist/delete.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/mailinglist/delete.pl	2007-03-20 15:44:17 UTC (rev 515)
+++ branches/vhffs_4.1/vhffs-panel/mailinglist/delete.pl	2007-03-20 15:47:07 UTC (rev 516)
@@ -69,7 +69,7 @@
 
 my $templatedir = $vhffs->get_config->get_templatedir;
 
-my $list = new Vhffs::Services::Mailing( $vhffs , $lpart , $domain , $user , $group );
+my $list = Vhffs::Services::Mailing::get_by_mladdress( $vhffs , $lpart , $domain );
 
 $template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
 
@@ -79,10 +79,6 @@
 }
 elsif( ! defined $list )
 {
-	$message = gettext( "Cannot build object" );
-}
-elsif( $list->fetch < 0 )
-{
 	$message = gettext( "Cannot get informations on this object");
 }
 elsif( $list->get_status != Vhffs::Constants::ACTIVATED )

Modified: branches/vhffs_4.1/vhffs-panel/mailinglist/prefs.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/mailinglist/prefs.pl	2007-03-20 15:44:17 UTC (rev 515)
+++ branches/vhffs_4.1/vhffs-panel/mailinglist/prefs.pl	2007-03-20 15:47:07 UTC (rev 516)
@@ -76,10 +76,10 @@
 
 }
 
-my $list = new Vhffs::Services::Mailing( $vhffs , $lpart , $domain , $user , $group );
+my $list = Vhffs::Services::Mailing::get_by_mladdress( $vhffs , $lpart , $domain );
 
 
-if( ( ! defined $list ) || ( $list->fetch < 0 ) )
+if( ! defined $list )
 {
 
 	$template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
@@ -119,6 +119,10 @@
 	$template->param( VALUE_PREFIX  => $list->get_prefix );
 
 	$template->param( TEXT_SUBMIT_PREFS => gettext("Save options") );
+
+    $template->param( TITLE_SIGNATURE => gettext("Signature") );
+    $template->param( VALUE_SIGNATURE => $list->get_signature );
+    $template->param( TEXT_SUBMIT_SIGNATURE => gettext("Update signature") );
 	
 	$template->param( TITLE_MEMBERS => gettext("Manage members") );
 	$template->param( TITLE_LIST_MEMBERS => gettext("List all members") );

Modified: branches/vhffs_4.1/vhffs-panel/mailinglist/save_options.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/mailinglist/save_options.pl	2007-03-20 15:44:17 UTC (rev 515)
+++ branches/vhffs_4.1/vhffs-panel/mailinglist/save_options.pl	2007-03-20 15:47:07 UTC (rev 516)
@@ -75,7 +75,7 @@
 
 my $templatedir = $vhffs->get_config->get_templatedir;
 
-my $list = new Vhffs::Services::Mailing( $vhffs , $lpart , $domain , $user , $group );
+my $list = Vhffs::Services::Mailing::get_by_mladdress( $vhffs , $lpart , $domain );
 
 $template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
 
@@ -85,10 +85,6 @@
 }
 elsif( ! defined ( $list ) )
 {
-	$message = gettext( "Cannot build object");
-}
-elsif( $list->fetch < 0 )
-{
 	$message = gettext( "Cannot get informations on this object");
 }
 elsif( $list->get_status != Vhffs::Constants::ACTIVATED )

Added: branches/vhffs_4.1/vhffs-panel/mailinglist/save_sig.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/mailinglist/save_sig.pl	2007-03-20 15:44:17 UTC (rev 515)
+++ branches/vhffs_4.1/vhffs-panel/mailinglist/save_sig.pl	2007-03-20 15:47:07 UTC (rev 516)
@@ -0,0 +1,103 @@
+#!/usr/bin/perl -w
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright 
+#   notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in 
+#   the documentation and/or other materials provided with the 
+#   distribution.
+#3. Neither the name of vhffs nor the names of its contributors 
+#   may be used to endorse or promote products derived from this 
+#   software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+# POSSIBILITY OF SUCH DAMAGE.
+
+
+use POSIX qw(locale_h);
+use HTML::Template;
+use locale;
+use Locale::gettext;
+use CGI;
+use CGI::Session;
+use strict;
+
+use lib "/usr/share/vhffs/api/";
+use Vhffs::User;
+use Vhffs::Group;
+use Vhffs::Main;
+use Vhffs::Panel::Main;
+use Vhffs::Panel::Menu;
+use Vhffs::Services::Mailing;
+use Vhffs::Acl;
+use Vhffs::Constants;
+my $panel = new Vhffs::Panel::Main();
+if(!$panel)  {
+        exit 0;
+}
+
+my $vhffs = $panel->{'vhffs'};
+my $session = $panel->{'session'};
+my $maintemplate = $panel->{'template'};
+my $user = $panel->{'user'};
+my $group = $panel->{'group'};
+my $cgi = $panel->{'cgi'};
+my $domain = $cgi->param("DOMAIN");
+my $lpart = $cgi->param("LOCALPART");
+my $sig = $cgi->param("signature");
+
+my $template;
+my $subtemplate;
+my $message;
+
+my $templatedir = $vhffs->get_config->get_templatedir;
+
+my $list = Vhffs::Services::Mailing::get_by_mladdress( $vhffs , $lpart , $domain );
+
+$template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
+
+if( ( ! defined $lpart ) ||( ! defined $domain ) || (! defined $sig) )
+{
+	$message = gettext( "CGI Error!");
+}
+elsif( ! defined ( $list ) )
+{
+	$message = gettext( "Cannot get informations on this object");
+}
+elsif( $list->get_status != Vhffs::Constants::ACTIVATED )
+{
+	$message = gettext( "This object is not functionnal yet. Please wait creation or moderation.");
+}
+elsif( ( Vhffs::Acl::what_perm_for_user( $user , $list , $vhffs ) < Vhffs::Constants::ACL_MODIFY ) && ( $user->is_admin != 1 ) )
+{
+	$message = gettext("You're not allowed to do this (ACL rights)");
+}
+else
+{
+    $list->set_signature($sig);
+    if( $list->commit < 0 ) {
+        $message = gettext( "Cannot save" );
+    } else {
+        $message = gettext( "Options successfully modified" );
+    }
+}
+
+$template->param( MESSAGE => $message );
+set_refresh_url Vhffs::Panel::Main($panel, "/mailinglist/prefs.pl?local=$lpart&domain=$domain", 0);
+display Vhffs::Panel::Main($panel, $template->output);


Property changes on: branches/vhffs_4.1/vhffs-panel/mailinglist/save_sig.pl
___________________________________________________________________
Name: svn:executable
   + *

Modified: branches/vhffs_4.1/vhffs-panel/mailinglist/submit.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/mailinglist/submit.pl	2007-03-20 15:44:17 UTC (rev 515)
+++ branches/vhffs_4.1/vhffs-panel/mailinglist/submit.pl	2007-03-20 15:47:07 UTC (rev 516)
@@ -101,38 +101,20 @@
 }
 else
 {
-	my $retour;
-	$retour = Vhffs::Panel::Mailinglist::create_list( $vhffs , $lpart , $domain , $user , $group );
+	my $lst;
+	$lst = Vhffs::Panel::Mailinglist::create_list( $vhffs, $lpart, $domain, $description, $user, $group );
 
-	if( $retour > 0 )
-	{
-		$message = gettext("Mailing-list successfully created !");
-
-		$list = new Vhffs::Services::Mailing( $vhffs , $lpart , $domain );
-		$message = gettext("An error occured while fetching information about this mailing list") if( $list->fetch < 0 );
-		$list->set_description( $description );
-		$message = gettext("An error occured while applying changes") if ( $list->commit < 0 );
-	}
-	elsif( $retour == -1 )
-	{
-		$message = gettext("An error occured while creating the list");
-	}
-	elsif( $retour == -2 )
-	{
+    if( ref($lst) )	{
+        $message = gettext("Mailing-list successfully created !");
+    } elsif( $retour == -1 ) {
+        $message = gettext("An error occured while creating the list");
+    } elsif( $retour == -2 ) {
 		$message = gettext("An error occured while adding yourself to the ACL");
-	}
-	elsif( $retour == -3 )
-	{
-		$message = gettext("An error occured while adding an ACL for the group");
-	}
-	else
-	{
-		$message = gettext("Error while creating list (unknow problem)");
-	}
-
-
-#	$list->set_description( $description );
-#	$list->commit;
+    } elsif( $retour == -3 ) {
+        $message = gettext("An error occured while adding an ACL for the group");
+    } else {
+        $message = gettext("Error while creating list (unknow problem)");
+    }
 }
 
 

Modified: branches/vhffs_4.1/vhffs-panel/templates/mailinglist/prefs.tmpl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/templates/mailinglist/prefs.tmpl	2007-03-20 15:44:17 UTC (rev 515)
+++ branches/vhffs_4.1/vhffs-panel/templates/mailinglist/prefs.tmpl	2007-03-20 15:47:07 UTC (rev 516)
@@ -52,6 +52,15 @@
 	</p>
 </form>
 
+<h2><tmpl_var name="TITLE_SIGNATURE"></h2>
+<form action="save_sig.pl" method="post">
+    <p><textarea name="signature" rows="7" cols="50"><tmpl_var name="VALUE_SIGNATURE"></textarea>
+    </p>
+    <input type="hidden" name="DOMAIN" value="<tmpl_var name="VALUE_DOMAIN">" />
+    <input type="hidden" name="LOCALPART" value="<tmpl_var name="VALUE_LOCALPART">" />
+    <input type="submit" value="<tmpl_var name="TEXT_SUBMIT_SIGNATURE">"/>
+</form>
+
 <h2><tmpl_var name="TITLE_MEMBERS"></h2>
 <h3><tmpl_var name="TITLE_LIST_MEMBERS"> (<tmpl_var name="HOWMANY_MEMBERS">)</h3>
 

Modified: branches/vhffs_4.1/vhffs-robots/src/create_ml.pl
===================================================================
--- branches/vhffs_4.1/vhffs-robots/src/create_ml.pl	2007-03-20 15:44:17 UTC (rev 515)
+++ branches/vhffs_4.1/vhffs-robots/src/create_ml.pl	2007-03-20 15:47:07 UTC (rev 516)
@@ -47,18 +47,15 @@
 foreach $ml ( @{$mls} )
 {
 
-	if( $ml->fetch > 0 )
+	$ml->set_status( Vhffs::Constants::ACTIVATED );
+	if( $ml->commit < 0 )
 	{
-		$ml->set_status( Vhffs::Constants::ACTIVATED );
-		if( $ml->commit < 0 )
-		{
-			Vhffs::Robots::vhffs_log( sprintf( "Cannot create list %s", $ml->get_title ), $vhffs);
-		}
-		else
-		{
-			Vhffs::Robots::vhffs_log( sprintf( "Create list %s", $ml->get_title ), $vhffs);
-		}
+		Vhffs::Robots::vhffs_log( sprintf( "Cannot create list %s", $ml->get_title ), $vhffs);
 	}
+	else
+	{
+		Vhffs::Robots::vhffs_log( sprintf( "Create list %s", $ml->get_title ), $vhffs);
+	}
 }
 
 Vhffs::Robots::unlock( $vhffs );

Modified: branches/vhffs_4.1/vhffs-robots/src/delete_group.pl
===================================================================
--- branches/vhffs_4.1/vhffs-robots/src/delete_group.pl	2007-03-20 15:44:17 UTC (rev 515)
+++ branches/vhffs_4.1/vhffs-robots/src/delete_group.pl	2007-03-20 15:47:07 UTC (rev 516)
@@ -62,7 +62,7 @@
 	$ok = 1;
 
     $objects = Vhffs::Services::Cvs::getall( $vhffs , undef , undef , $group );
-	$ok = 0 if( defined $objects );
+	$ok = 0 if( @$objects != 0 );
     foreach $object ( @{$objects} )
     {
 		Vhffs::Robots::vhffs_log( sprintf( "Remain cvs for group %s before delete" , $group->get_groupname ), $vhffs);
@@ -71,7 +71,7 @@
     }
 
     $objects = Vhffs::Services::Svn::getall( $vhffs , undef , undef , $group );
-	$ok = 0 if( defined $objects );
+	$ok = 0 if( @$objects != 0);
     foreach $object ( @{$objects} )
     {
 		Vhffs::Robots::vhffs_log( sprintf( "Remain svn for group %s before delete" , $group->get_groupname ), $vhffs);
@@ -80,7 +80,7 @@
     }
 
     $objects = Vhffs::Services::DNS::getall( $vhffs , undef , undef , $group );
-	$ok = 0 if( defined $objects );
+	$ok = 0 if( @$objects != 0);
     foreach $object ( @{$objects} )
     {
 		Vhffs::Robots::vhffs_log( sprintf( "Remain dns for group %s before delete" , $group->get_groupname ), $vhffs);
@@ -89,7 +89,7 @@
     }
 
     $objects = Vhffs::Services::Mysql::getall( $vhffs , undef , undef , $group );
-	$ok = 0 if( defined $objects );
+	$ok = 0 if( @$objects != 0 );
     foreach $object ( @{$objects} )
     {
 		Vhffs::Robots::vhffs_log( sprintf( "Remain mysql for group %s before delete" , $group->get_groupname ), $vhffs);
@@ -98,7 +98,7 @@
     }
 
     $objects = Vhffs::Services::Postgres::getall( $vhffs , undef , undef , $group );
-	$ok = 0 if( defined $objects );
+	$ok = 0 if( @$objects != 0 );
    foreach $object ( @{$objects} )
    {
 		Vhffs::Robots::vhffs_log( sprintf( "Remain pgsql for group %s before delete" , $group->get_groupname ), $vhffs);
@@ -108,7 +108,7 @@
 
 
     $objects = Vhffs::Services::Httpd::getall( $vhffs , undef , undef , $group );
-	$ok = 0 if( defined $objects );
+	$ok = 0 if( @$objects != 0 );
    foreach $object ( @{$objects} )
    {
 		Vhffs::Robots::vhffs_log( sprintf( "Remain website for group %s before delete" , $group->get_groupname ), $vhffs);
@@ -117,7 +117,7 @@
    }
     
 	$objects = Vhffs::Services::Mailing::getall( $vhffs , undef , undef , $group );
-	$ok = 0 if( defined $objects );
+	$ok = 0 if( @$objects != 0);
    foreach $object ( @{$objects} )
    {
 		Vhffs::Robots::vhffs_log( sprintf( "Remain list for group %s before delete" , $group->get_groupname ), $vhffs);
@@ -127,7 +127,7 @@
 
 
 	$objects = Vhffs::Services::Mail::getall( $vhffs , undef , undef , $group );
-	$ok = 0 if( defined $objects );
+	$ok = 0 if( @$objects != 0 );
    foreach $object ( @{$objects} )
    {
 		Vhffs::Robots::vhffs_log( sprintf( "Remain mail for group %s before delete" , $group->get_groupname ), $vhffs);

Modified: branches/vhffs_4.1/vhffs-robots/src/delete_mail.pl
===================================================================
--- branches/vhffs_4.1/vhffs-robots/src/delete_mail.pl	2007-03-20 15:44:17 UTC (rev 515)
+++ branches/vhffs_4.1/vhffs-robots/src/delete_mail.pl	2007-03-20 15:47:07 UTC (rev 516)
@@ -50,17 +50,13 @@
 foreach $mail ( @{$mails} )
 {
     my $lists = Vhffs::Services::Mailing::getall( $vhffs , undef , undef , undef , $mail->get_domain );
-	if( defined $lists )
-	{
+	if( @$lists != 0) {
 		Vhffs::Robots::vhffs_log( sprintf( "Cannot delete mail domain %s, remains lists" , $mail->get_domain ) , $vhffs);
-		foreach $list ( @{$lists} )
-		{
+		foreach $list ( @{$lists} ) {
 			$list->set_status( Vhffs::Constants::TO_DELETE );
 			$list->commit;
 		}
-	}
-	else
-	{
+	} else {
 		Vhffs::Robots::vhffs_log( sprintf( "Delete mail domain %s" , $mail->get_domain ) , $vhffs);
 		$mail->delete;
 	}

Modified: branches/vhffs_4.1/vhffs-robots/src/listengine_publicarchives.pl
===================================================================
--- branches/vhffs_4.1/vhffs-robots/src/listengine_publicarchives.pl	2007-03-20 15:44:17 UTC (rev 515)
+++ branches/vhffs_4.1/vhffs-robots/src/listengine_publicarchives.pl	2007-03-20 15:47:07 UTC (rev 516)
@@ -40,121 +40,118 @@
 die "Cannot create ".$outputdir." directory\n" unless( -d $outputdir );
 
 my $lists = Vhffs::Services::Mailing::getall( $vhffs , Vhffs::Constants::ACTIVATED , undef );
-if( defined $lists )
+foreach my $list ( @{$lists} )
 {
-	foreach my $list ( @{$lists} )
-	{
 #		print $list->get_domain." ".$list->get_localpart." ".Vhffs::Group::get_name_by_gid( $vhffs , $list->get_ownergid )." ".$list->get_oid." ".Vhffs::Functions::status_string_from_status_id( $list->get_status )."\n";
 
-		next if ( !defined $list->get_domain  ||  !defined $list->get_localpart  ||  $list->get_domain eq ""  ||  $list->get_localpart eq "" );
+	next if ( !defined $list->get_domain  ||  !defined $list->get_localpart  ||  $list->get_domain eq ""  ||  $list->get_localpart eq "" );
 
-		# delete previous public archives (if available) if there is no public archives for this list
-		if ( $list->get_open_archive == 0 )  {
-			my $publicdir = $outputdir."/".$list->get_domain."/".$list->get_localpart;
-			if ( -d $publicdir)  {
-				system("rm -rf $publicdir 2>/dev/null");
-			}
-			next;
+	# delete previous public archives (if available) if there is no public archives for this list
+	if ( $list->get_open_archive == 0 )  {
+		my $publicdir = $outputdir."/".$list->get_domain."/".$list->get_localpart;
+		if ( -d $publicdir)  {
+			system("rm -rf $publicdir 2>/dev/null");
 		}
+		next;
+	}
 
-		$listdir = $archivedir."/".$list->get_domain."/".$list->get_localpart;
-		next if( !defined opendir( LISTDIR , $listdir ) );
+	$listdir = $archivedir."/".$list->get_domain."/".$list->get_localpart;
+	next if( !defined opendir( LISTDIR , $listdir ) );
 
-		$outputlistdir = $outputdir."/".$list->get_domain;
-		mkdir($outputlistdir, 0755);
-		if (! -d $outputlistdir)  { die "Cannot create ".$outputlistdir." directory\n"; };
+	$outputlistdir = $outputdir."/".$list->get_domain;
+	mkdir($outputlistdir, 0755);
+	if (! -d $outputlistdir)  { die "Cannot create ".$outputlistdir." directory\n"; };
 
-		$outputlistdir = $outputdir."/".$list->get_domain."/".$list->get_localpart;
-		mkdir($outputlistdir, 0755);
-		if (! -d $outputlistdir)  { die "Cannot create ".$outputlistdir." directory\n"; };
+	$outputlistdir = $outputdir."/".$list->get_domain."/".$list->get_localpart;
+	mkdir($outputlistdir, 0755);
+	if (! -d $outputlistdir)  { die "Cannot create ".$outputlistdir." directory\n"; };
 
-		# -- index : main page
-		my $maintemplate = new HTML::Template( filename => $templatedir."/indexmain.tmpl" );
-		$maintemplate->param( NAME => $list->get_domain."/".$list->get_localpart );
-		my $indexbody = "";
-		my $oddoreven = "odd";
+	# -- index : main page
+	my $maintemplate = new HTML::Template( filename => $templatedir."/indexmain.tmpl" );
+	$maintemplate->param( NAME => $list->get_domain."/".$list->get_localpart );
+	my $indexbody = "";
+	my $oddoreven = "odd";
 
-		@years = readdir( LISTDIR );
-		foreach $year ( sort @years )
-		{
-			next if( $year =~ /^\..*$/ );
+	@years = readdir( LISTDIR );
+	foreach $year ( sort @years )
+	{
+		next if( $year =~ /^\..*$/ );
 
-			$yearpath = $listdir."/".$year;
+		$yearpath = $listdir."/".$year;
 
-			next if( !defined opendir( YEARDIR , $yearpath ) );
+		next if( !defined opendir( YEARDIR , $yearpath ) );
 
-			$outputyeardir = $outputlistdir."/".$year;
-			mkdir($outputyeardir, 0755);
-			if (! -d $outputyeardir)  { die "Cannot create ".$outputyeardir." directory\n"; };
+		$outputyeardir = $outputlistdir."/".$year;
+		mkdir($outputyeardir, 0755);
+		if (! -d $outputyeardir)  { die "Cannot create ".$outputyeardir." directory\n"; };
 
-			@months = readdir( YEARDIR );
-			foreach $month ( sort @months )
-			{
-				next if( $month =~ /^\..*$/ );
+		@months = readdir( YEARDIR );
+		foreach $month ( sort @months )
+		{
+			next if( $month =~ /^\..*$/ );
 
-				$monthpath = $yearpath."/".$month;
+			$monthpath = $yearpath."/".$month;
 
-				$outputmonthdir = $outputyeardir."/".$month;
-				mkdir($outputmonthdir, 0755);
-				if (! -d $outputmonthdir)  { die "Cannot create ".$outputmonthdir." directory\n"; };
+			$outputmonthdir = $outputyeardir."/".$month;
+			mkdir($outputmonthdir, 0755);
+			if (! -d $outputmonthdir)  { die "Cannot create ".$outputmonthdir." directory\n"; };
 
-				print $monthpath." -> ".$outputmonthdir."\n";
-				$cmd = "mhonarc -add -rc " . $configmhonarc . " -definevar MAIN-TITLE='" . $list->get_domain . "/" . $list->get_localpart . "' -outdir " . $outputmonthdir . " " . $monthpath . "/*/*";
-				print $cmd."\n";
-				system( $cmd );
+			print $monthpath." -> ".$outputmonthdir."\n";
+			$cmd = "mhonarc -add -rc " . $configmhonarc . " -definevar MAIN-TITLE='" . $list->get_domain . "/" . $list->get_localpart . "' -outdir " . $outputmonthdir . " " . $monthpath . "/*/*";
+			print $cmd."\n";
+			system( $cmd );
 
-				# -- index : part
-				my $parttemplate = new HTML::Template( filename => $templatedir."/indexpart.tmpl" );
-				$parttemplate->param( YEAR => $year );
-				$parttemplate->param( MONTH => $month );
+			# -- index : part
+			my $parttemplate = new HTML::Template( filename => $templatedir."/indexpart.tmpl" );
+			$parttemplate->param( YEAR => $year );
+			$parttemplate->param( MONTH => $month );
 
-				if( defined opendir( MONTHDIR , $monthpath ) )  {
+			if( defined opendir( MONTHDIR , $monthpath ) )  {
 
-					my $mailnb = 0;
-					my $mailsize = 0;
+				my $mailnb = 0;
+				my $mailsize = 0;
 
-					my @days = readdir ( MONTHDIR );
-					foreach my $day ( @days )
-					{
-						next if( $day =~ /^\..*$/ );
+				my @days = readdir ( MONTHDIR );
+				foreach my $day ( @days )
+				{
+					next if( $day =~ /^\..*$/ );
 
-						my $daypath = $monthpath."/".$day;
+					my $daypath = $monthpath."/".$day;
 
-						next if( !defined opendir( DAYDIR , $daypath ) );
+					next if( !defined opendir( DAYDIR , $daypath ) );
 
-						my @mails = readdir ( DAYDIR );
-						foreach my $mail ( @mails )
-						{
-							next if( $mail =~ /^\..*$/ );
+					my @mails = readdir ( DAYDIR );
+					foreach my $mail ( @mails )
+					{
+						next if( $mail =~ /^\..*$/ );
 
-							$mailnb++;
+						$mailnb++;
 
-							my $size;
-							(undef,undef,undef,undef,undef,undef,undef,$size,undef,undef,undef,undef,undef) = stat( $daypath."/".$mail );
-							$mailsize += $size;
-						}
+						my $size;
+						(undef,undef,undef,undef,undef,undef,undef,$size,undef,undef,undef,undef,undef) = stat( $daypath."/".$mail );
+						$mailsize += $size;
 					}
-
-					my $totalsize = sprintf("%d", $mailsize/1024 );
-					$parttemplate->param( NUMBER => $mailnb );
-					$parttemplate->param( SIZE => $totalsize );
-					$parttemplate->param( SIZEUNIT => "KB" );
-					$parttemplate->param( ODDOREVEN => $oddoreven );
-					if ( $oddoreven eq "odd" ) { $oddoreven = "even"; }
-					else { $oddoreven = "odd"; }
 				}
 
-				$indexbody .= $parttemplate->output;
+				my $totalsize = sprintf("%d", $mailsize/1024 );
+				$parttemplate->param( NUMBER => $mailnb );
+				$parttemplate->param( SIZE => $totalsize );
+				$parttemplate->param( SIZEUNIT => "KB" );
+				$parttemplate->param( ODDOREVEN => $oddoreven );
+				if ( $oddoreven eq "odd" ) { $oddoreven = "even"; }
+				else { $oddoreven = "odd"; }
 			}
 
-			closedir ( YEARDIR );
+			$indexbody .= $parttemplate->output;
 		}
 
-		$maintemplate->param( BODY => $indexbody );
-		open( OUTPUT , ">".$outputlistdir."/index.html" );
-		print OUTPUT $maintemplate->output;
-		close( OUTPUT );
-
-		closedir( LISTDIR );
+		closedir ( YEARDIR );
 	}
+
+	$maintemplate->param( BODY => $indexbody );
+	open( OUTPUT , ">".$outputlistdir."/index.html" );
+	print OUTPUT $maintemplate->output;
+	close( OUTPUT );
+
+	closedir( LISTDIR );
 }

Modified: branches/vhffs_4.1/vhffs-robots/src/refused_ml.pl
===================================================================
--- branches/vhffs_4.1/vhffs-robots/src/refused_ml.pl	2007-03-20 15:44:17 UTC (rev 515)
+++ branches/vhffs_4.1/vhffs-robots/src/refused_ml.pl	2007-03-20 15:47:07 UTC (rev 516)
@@ -60,30 +60,27 @@
 
 foreach $object ( @{$objects} )
 {
-	if( ( defined $object ) && ( $object->fetch > 0 ) )
-	{
-		$user = $object->get_user;
-		$lang = Vhffs::Panel::User::get_lang( $user );
-		setlocale( LC_ALL , $lang ) if( defined $lang );
-		if( defined $user )
-		{
-			$message  = sprintf( gettext("Your Mailing-list request : %s ") , $object->get_listname);
-			$message .= gettext("has been refused by the Moderators team")."\n";
-			$message .= gettext("In hope to keep you in our hosting service")."\n\n";
-			if( length( $object->get_description ) > 1 )
-			{
-			    $message .= gettext("Reason given : ");
-			    $message .= $object->get_description . "\n";
-			}
-			$message .= sprintf( gettext("If you encounters problem, please mail: %s\n") , $vhffs->get_config->get_moderator_mail ) if( defined $vhffs->get_config->get_moderator_mail );
-			$message .= gettext("Cheers,")."\n";
-			$message .= gettext("The Moderator and Admin team");
-			$subject = gettext("Your Mailing-list request");
-			Vhffs::Functions::send_mail( $vhffs->get_config->get_moderator_mail , $user->get_mail , $subject , $message );
-		}
+    $user = $object->get_user;
+    $lang = Vhffs::Panel::User::get_lang( $user );
+    setlocale( LC_ALL , $lang ) if( defined $lang );
+    if( defined $user )
+    {
+        $message  = sprintf( gettext("Your Mailing-list request : %s ") , $object->get_listname);
+        $message .= gettext("has been refused by the Moderators team")."\n";
+        $message .= gettext("In hope to keep you in our hosting service")."\n\n";
+        if( length( $object->get_description ) > 1 )
+        {
+            $message .= gettext("Reason given : ");
+            $message .= $object->get_description . "\n";
+        }
+        $message .= sprintf( gettext("If you encounters problem, please mail: %s\n") , $vhffs->get_config->get_moderator_mail ) if( defined $vhffs->get_config->get_moderator_mail );
+        $message .= gettext("Cheers,")."\n";
+        $message .= gettext("The Moderator and Admin team");
+        $subject = gettext("Your Mailing-list request");
+        Vhffs::Functions::send_mail( $vhffs->get_config->get_moderator_mail , $user->get_mail , $subject , $message );
+    }
 		
-		$object->delete;
-	}
+	$object->delete;
 }
 
 

Added: branches/vhffs_4.1/vhffs-tests/src/Services/Mailing.pl
===================================================================
--- branches/vhffs_4.1/vhffs-tests/src/Services/Mailing.pl	2007-03-20 15:44:17 UTC (rev 515)
+++ branches/vhffs_4.1/vhffs-tests/src/Services/Mailing.pl	2007-03-20 15:47:07 UTC (rev 516)
@@ -0,0 +1,38 @@
+use strict;
+use Vhffs::Tests::Main;
+use Vhffs::Tests::Utils;
+use Vhffs::Constants;
+use Vhffs::User;
+use Vhffs::Services::Mail;
+use Vhffs::Services::Mailing;
+use Test::More 'no_plan';
+
+my $main = init Vhffs::Tests::Main;
+isa_ok($main, 'Vhffs::Tests::Main', '$main');
+
+Vhffs::Tests::Utils::init_db($main->get_db_object);
+
+my $user1 = Vhffs::User::create($main, 'test1', 'abcdef', 0, 'test1@xxxxxxxx');
+isa_ok($user1, 'Vhffs::User', '$user1');
+
+my $group1 = Vhffs::Group::create($main, 'mailgroup1', $user1->get_uid, undef, 'Test group for Mail Domain');
+isa_ok($group1, 'Vhffs::Group', '$group1');
+
+my $mail1 = Vhffs::Services::Mail::create($main, 'test.com', 'Test mail domain 1', $user1, $group1);
+isa_ok($mail1, 'Vhffs::Services::Mail', '$mail1');
+cmp_ok($mail1->get_owneruid, '==', $user1->get_uid, 'uid matches');
+cmp_ok($mail1->get_ownergid, '==', $group1->get_gid, 'gid matches');
+
+my $ml1 = Vhffs::Services::Mailing::create($main, 'list1', 'test.com', 'admin@xxxxxxxx', 'Test ml 1', $user1, $group1);
+isa_ok($ml1, 'Vhffs::Services::Mailing', '$ml1');
+
+$ml1->add_sub('toto@xxxxxxxx', Vhffs::Constants::ML_RIGHT_SUB);
+cmp_ok(keys(%{$ml1->{subs}}), '==', 1, 'One subscriber registered');
+
+my $tmpml = Vhffs::Services::Mailing::get_by_mladdress($main, 'list1', 'test.com');
+my $subs = $tmpml->{subs};
+cmp_ok(keys(%$subs), '==', 1, 'One subscriber registered (fetched)');
+ok(defined $subs->{'toto@xxxxxxxx'}, 'Subscriber key is email address');
+my $sub = $subs->{'toto@xxxxxxxx'};
+cmp_ok($sub->{member}, 'eq', 'toto@xxxxxxxx', 'Email address matches');
+cmp_ok($sub->{perm}, '==', Vhffs::Constants::ML_RIGHT_SUB, 'Permissions matches');

Modified: branches/vhffs_4.1/vhffs-tests/src/Stats.pl
===================================================================
--- branches/vhffs_4.1/vhffs-tests/src/Stats.pl	2007-03-20 15:44:17 UTC (rev 515)
+++ branches/vhffs_4.1/vhffs-tests/src/Stats.pl	2007-03-20 15:47:07 UTC (rev 516)
@@ -301,16 +301,14 @@
 for(my $i = 1 ; $i < 10 ; ++$i) {
     $group = Vhffs::Group::get_by_groupname($main, "testgroup0$i");
     $user = Vhffs::User::get_by_username($main, "testuser0$i");
-    $svc = new Vhffs::Services::Mailing($main, "ml", "mail0$i.test.com", $user, $group);
-    $svc->create;
+    $svc = Vhffs::Services::Mailing::create($main, "ml", "mail0$i.test.com", undef, "Test list #$i", $user, $group);
 }
 
 $stats = new Vhffs::Stats($main);
 is($stats->get_lists_in_moderation, 9, 'All Mailing Lists services waiting for moderation');
 
 for(my $i = 1 ; $i < 10 ; ++$i) {
-    $svc = new Vhffs::Services::Mailing($main, "ml", "mail0$i.test.com");
-    $svc->fetch;
+    $svc = Vhffs::Services::Mailing::get_by_mladdress($main, "ml", "mail0$i.test.com");
     $svc->set_status(Vhffs::Constants::WAITING_FOR_CREATION);
     $svc->commit;
     $stats = new Vhffs::Stats($main);
@@ -319,8 +317,7 @@
 }
 
 for(my $i = 1 ; $i < 10 ; ++$i) {
-    $svc = new Vhffs::Services::Mailing($main, "ml", "mail0$i.test.com");
-    $svc->fetch;
+    $svc = Vhffs::Services::Mailing::get_by_mladdress($main, "ml", "mail0$i.test.com");
     $svc->set_status(Vhffs::Constants::ACTIVATED);
     $svc->commit;
     $stats = new Vhffs::Stats($main);
@@ -330,8 +327,7 @@
 # Subscribers test
 
 for(my $i = 1 ; $i < 10 ; ++$i) {
-    $svc = new Vhffs::Services::Mailing($main, "ml", "mail0$i.test.com");
-    $svc->fetch;
+    $svc = Vhffs::Services::Mailing::get_by_mladdress($main, "ml", "mail0$i.test.com");
     for(my $j = 0 ; $j < 10 ; ++$j) {
         $svc->add_sub("sub0$j\@test.com", Vhffs::Constants::USER_NORMAL);
     }


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/