[vhffs-dev] [2062] Reworked mailinglist robots, added Vhffs::Robots::MailingList

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


Revision: 2062
Author:   gradator
Date:     2012-02-25 23:04:32 +0100 (Sat, 25 Feb 2012)
Log Message:
-----------
Reworked mailinglist robots, added Vhffs::Robots::MailingList

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Makefile.am
    trunk/vhffs-robots/Makefile.am

Added Paths:
-----------
    trunk/vhffs-api/src/Vhffs/Robots/MailingList.pm
    trunk/vhffs-robots/src/mailinglist.pl

Removed Paths:
-------------
    trunk/vhffs-robots/src/mailinglist_create.pl
    trunk/vhffs-robots/src/mailinglist_delete.pl

Modified: trunk/vhffs-api/src/Vhffs/Makefile.am
===================================================================
--- trunk/vhffs-api/src/Vhffs/Makefile.am	2012-02-25 21:52:38 UTC (rev 2061)
+++ trunk/vhffs-api/src/Vhffs/Makefile.am	2012-02-25 22:04:32 UTC (rev 2062)
@@ -55,6 +55,7 @@
 	Robots/Group.pm \
 	Robots/Mail.pm \
 	Robots/Mailing.pm \
+	Robots/MailingList.pm \
 	Robots/Mercurial.pm \
 	Robots/Mysql.pm \
 	Robots/Pgsql.pm \

Added: trunk/vhffs-api/src/Vhffs/Robots/MailingList.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/MailingList.pm	                        (rev 0)
+++ trunk/vhffs-api/src/Vhffs/Robots/MailingList.pm	2012-02-25 22:04:32 UTC (rev 2062)
@@ -0,0 +1,83 @@
+#!%PERL%
+# 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 strict;
+use utf8;
+
+use Vhffs::Constants;
+use Vhffs::Functions;
+use Vhffs::Robots;
+use Vhffs::Services::MailingList;
+
+package Vhffs::Robots::MailingList;
+
+sub create {
+	my $ml = shift;
+	return undef unless defined $ml and $ml->get_status == Vhffs::Constants::WAITING_FOR_CREATION;
+
+	my $vhffs = $ml->get_main;
+
+	$ml->set_status( Vhffs::Constants::ACTIVATED );
+	$ml->commit;
+	Vhffs::Robots::vhffs_log( $vhffs, 'Created mailing list '.$ml->get_listname );
+
+	return 1;
+}
+
+sub delete {
+	my $ml = shift;
+	return undef unless defined $ml and $ml->get_status == Vhffs::Constants::WAITING_FOR_DELETION;
+
+	my $vhffs = $ml->get_main;
+
+	# TODO: Archives of archives, remove public archives
+
+	if( $ml->delete ) {
+		Vhffs::Robots::vhffs_log( $vhffs, 'Deleted mailing list '.$ml->get_listname );
+	} else {
+		Vhffs::Robots::vhffs_log( $vhffs, 'An error occured while deleting mailing list '.$ml->get_listname );
+		$ml->set_status( Vhffs::Constants::DELETION_ERROR );
+		$ml->commit;
+		return undef;
+	}
+
+	return 1;
+}
+
+sub modify {
+	my $ml = shift;
+	return undef unless defined $ml and $ml->get_status == Vhffs::Constants::WAITING_FOR_MODIFICATION;
+	$ml->set_status( Vhffs::Constants::ACTIVATED );
+	$ml->commit;
+	return 1;
+}
+
+1;

Modified: trunk/vhffs-robots/Makefile.am
===================================================================
--- trunk/vhffs-robots/Makefile.am	2012-02-25 21:52:38 UTC (rev 2061)
+++ trunk/vhffs-robots/Makefile.am	2012-02-25 22:04:32 UTC (rev 2062)
@@ -29,8 +29,7 @@
 	src/mail_createboxes.pl \
 	src/mail_delete.pl \
 	src/mail_deleteboxes.pl \
-	src/mailinglist_create.pl \
-	src/mailinglist_delete.pl \
+	src/mailinglist.pl \
 	src/mailing.pl \
 	src/mysql.pl \
 	src/mysql_dump.pl \

Copied: trunk/vhffs-robots/src/mailinglist.pl (from rev 2056, trunk/vhffs-robots/src/mailinglist_create.pl)
===================================================================
--- trunk/vhffs-robots/src/mailinglist.pl	                        (rev 0)
+++ trunk/vhffs-robots/src/mailinglist.pl	2012-02-25 22:04:32 UTC (rev 2062)
@@ -0,0 +1,59 @@
+#!%PERL%
+# 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 strict;
+use utf8;
+
+use lib '%VHFFS_LIB_DIR%';
+use Vhffs::Robots::MailingList;
+
+my $vhffs = init Vhffs::Main;
+exit 1 unless defined $vhffs;
+
+Vhffs::Robots::lock( $vhffs, 'ml' );
+
+my $mls = Vhffs::Services::MailingList::getall( $vhffs, Vhffs::Constants::WAITING_FOR_CREATION );
+foreach ( @{$mls} ) {
+	Vhffs::Robots::MailingList::create( $_ );
+}
+
+$mls = Vhffs::Services::MailingList::getall( $vhffs, Vhffs::Constants::WAITING_FOR_DELETION );
+foreach ( @{$mls} ) {
+	Vhffs::Robots::MailingList::delete( $_ );
+}
+
+$mls = Vhffs::Services::MailingList::getall( $vhffs, Vhffs::Constants::WAITING_FOR_MODIFICATION );
+foreach ( @{$mls} ) {
+	Vhffs::Robots::MailingList::modify( $_ );
+}
+
+Vhffs::Robots::unlock( $vhffs, 'ml' );
+exit 0;

Deleted: trunk/vhffs-robots/src/mailinglist_create.pl
===================================================================
--- trunk/vhffs-robots/src/mailinglist_create.pl	2012-02-25 21:52:38 UTC (rev 2061)
+++ trunk/vhffs-robots/src/mailinglist_create.pl	2012-02-25 22:04:32 UTC (rev 2062)
@@ -1,68 +0,0 @@
-#!%PERL%
-
-# 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 strict;
-use utf8;
-
-use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Main;
-use Vhffs::Robots;
-use Vhffs::Constants;
-use Vhffs::Services::MailingList;
-
-
-my $vhffs = init Vhffs::Main;
-
-Vhffs::Robots::lock( $vhffs , "ml" );
-
-my $mls  = Vhffs::Services::MailingList::getall( $vhffs , Vhffs::Constants::WAITING_FOR_CREATION );
-my $ml;
-
-
-foreach $ml ( @{$mls} )
-{
-
-	$ml->set_status( Vhffs::Constants::ACTIVATED );
-	if( $ml->commit < 0 )
-	{
-		Vhffs::Robots::vhffs_log( $vhffs, sprintf( "Cannot create list %s", $ml->get_label ));
-	}
-	else
-	{
-		Vhffs::Robots::vhffs_log( $vhffs, sprintf( "Create list %s", $ml->get_label ));
-	}
-}
-
-Vhffs::Robots::unlock( $vhffs , "ml" );
-
-exit 0;
-

Deleted: trunk/vhffs-robots/src/mailinglist_delete.pl
===================================================================
--- trunk/vhffs-robots/src/mailinglist_delete.pl	2012-02-25 21:52:38 UTC (rev 2061)
+++ trunk/vhffs-robots/src/mailinglist_delete.pl	2012-02-25 22:04:32 UTC (rev 2062)
@@ -1,61 +0,0 @@
-#!%PERL%
-# 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 strict;
-use utf8;
-
-use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Main;
-use Vhffs::Constants;
-use Vhffs::Robots;
-use Vhffs::Services::MailingList;
-
-
-my $vhffs  = init Vhffs::Main;
-Vhffs::Robots::lock( $vhffs , "ml" );
-my $mls  = Vhffs::Services::MailingList::getall( $vhffs , Vhffs::Constants::WAITING_FOR_DELETION );
-my $ml;
-
-foreach $ml ( @{$mls} )
-{
-	if( $ml->delete < 0 )
-	{
-		Vhffs::Robots::vhffs_log( $vhffs, sprintf( "Cannot delete list %s" , $ml->get_listname ) );
-	}
-	else
-	{
-		Vhffs::Robots::vhffs_log( $vhffs, sprintf( "Delete list %s" , $ml->get_listname ) );
-	}
-}
-
-Vhffs::Robots::unlock( $vhffs , "ml" );
-
-exit 0;


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