[vhffs-dev] [2081] reworked broadcasts, Vhffs::Broadcast is now a lovely object, SQL queries removed from robots and beautified, and so on...

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


Revision: 2081
Author:   gradator
Date:     2012-02-29 21:32:32 +0100 (Wed, 29 Feb 2012)
Log Message:
-----------
reworked broadcasts, Vhffs::Broadcast is now a lovely object, SQL queries removed from robots and beautified, and so on...

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Broadcast.pm
    trunk/vhffs-api/src/Vhffs/Constants.pm
    trunk/vhffs-api/src/Vhffs/Group.pm
    trunk/vhffs-api/src/Vhffs/Makefile.am
    trunk/vhffs-api/src/Vhffs/Panel/Broadcast.pm
    trunk/vhffs-api/src/Vhffs/UserGroup.pm
    trunk/vhffs-backend/src/pgsql/initdb.sql.in
    trunk/vhffs-compat/from-4.3-to-4.4.sql
    trunk/vhffs-robots/Makefile.am

Added Paths:
-----------
    trunk/vhffs-api/src/Vhffs/Robots/Broadcast.pm
    trunk/vhffs-robots/src/broadcast.pl

Removed Paths:
-------------
    trunk/vhffs-api/src/Vhffs/Robots/Mailing.pm
    trunk/vhffs-robots/src/mailing.pl

Modified: trunk/vhffs-api/src/Vhffs/Broadcast.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Broadcast.pm	2012-02-28 21:57:19 UTC (rev 2080)
+++ trunk/vhffs-api/src/Vhffs/Broadcast.pm	2012-02-29 20:32:32 UTC (rev 2081)
@@ -37,8 +37,8 @@
 
 package Vhffs::Broadcast;
 
+use strict;
 use utf8;
-use strict;
 use Vhffs::Functions;
 use Vhffs::Constants;
 use Encode;
@@ -49,39 +49,91 @@
 
 Vhffs::Broadcast - Handle broadcast message to all users.
 
-=head1 METHODS
+=cut
 
+=pod
+=head1 CLASS METHODS
 =cut
 
 =pod
 
-=head2 add_broadcast
+=head2 _new
 
-	my $ret = Vhffs::Broadcast::add_broadcast( $vhffs, $subject, $message );
+	Self constructor, almost private, please use get_by_* methods instead.
 
+=cut
+sub _new {
+	my ($class, $vhffs, $mailing_id, $subject, $message, $date, $state) = @_;
+
+	return undef unless defined $vhffs;
+
+	my $self = {};
+	bless($self, $class);
+
+	$self->{vhffs} = $vhffs;
+	$self->{mailing_id} = $mailing_id;
+	$self->{subject} = $subject;
+	$self->{message} = $message;
+	$self->{date} = $date;
+	$self->{state} = $state;
+
+	return $self;
+}
+
+=pod
+
+=head2 create
+
+	my $ret = Vhffs::Broadcast::create( $vhffs, $subject, $message );
+
 Add a broadcast message to all users.
 
-Returns 1 on success, otherwise returns < 0;
+Returns 1 on success, otherwise returns undef;
 
 =cut
-sub add_broadcast {
+sub create {
 	my $vhffs = shift;
 	my $subject = shift;
 	my $message = shift;
 
-	return -1 unless defined $vhffs;
+	return undef unless defined $vhffs;
 
 	$message =~ s/\r\n/\n/g;
 
-	my $query = 'INSERT INTO vhffs_mailings (subject,message,date,state) VALUES( ? , ? , ? , ? )';
-	my $request = $vhffs->{'db'}->prepare( $query );
-	$request->execute($subject, $message, time(), Vhffs::Constants::WAITING_FOR_CREATION) or return -2;
+	my $query = 'INSERT INTO vhffs_mailings (mailing_id, subject, message, date, state) VALUES(DEFAULT, ?, ?, ?, ? ) RETURNING mailing_id';
+	my $dbh = $vhffs->get_db_object;
+	my $request = $dbh->prepare( $query );
+	$request->execute($subject, $message, time(), Vhffs::Constants::BROADCAST_WAITING_TO_BE_SENT) or return undef;
 
-	return 1;
+	my ( $mailing_id ) = $request->fetchrow_array;
+	return get_by_mailing_id( $vhffs, $mailing_id );
 }
 
 =pod
 
+=head2 get_by_mailing_id
+
+	my $broadcast = Vhffs::Broadcast::get_by_mailing_id( $vhffs, $id );
+
+Fetch broadcast $id.
+
+=cut
+sub get_by_mailing_id {
+	my $vhffs = shift;
+	my $id = shift;
+
+	return undef unless defined $id;
+
+	my $query = 'SELECT mailing_id, subject, message, date, state FROM vhffs_mailings WHERE mailing_id=?';
+	my $dbh = $vhffs->get_db_object;
+	my @params = $dbh->selectrow_array($query, undef, $id);
+	return undef unless(@params);
+	my $mailing = _new Vhffs::Broadcast($vhffs, @params);
+	return $mailing;
+}
+
+=pod
+
 =head2 getall
 
 	my $broadcasts = Vhffs::Broadcast::getall( $vhffs, $state );
@@ -92,66 +144,104 @@
 sub getall {
 	my $vhffs = shift;
 	my $state = shift;
+	return unless defined $vhffs;
+
+	my $mailings = [];
 	my @params;
 
-	my $query = 'SELECT id_mailing,subject,message,date,state FROM vhffs_mailings ';
+	my $query = 'SELECT mailing_id, subject, message, date, state FROM vhffs_mailings ';
 	if( defined $state ) {
 		$query .= ' WHERE state=?';
 		push @params, $state;
 	}
 
-	my $request = $vhffs->{'db'}->prepare( $query );
-	$request->execute( @params ) or return undef;
+	my $dbh = $vhffs->get_db_object;
 
-	my $rows = $request->fetchall_hashref( 'id_mailing' );
-	return $rows;
+	my $sth = $dbh->prepare($query);
+	$sth->execute(@params) or return undef;
+
+	while(my $s = $sth->fetchrow_arrayref) {
+		push(@$mailings, _new Vhffs::Broadcast($vhffs, @$s));
+	}
+	return $mailings;
 }
 
 =pod
+=head1 INSTANCE METHODS
+=cut
 
-=head2 del_broadcast
+=pod
 
-	my $ret = Vhffs::Broadcast::del_broadcast( $vhffs, $id );
+=head2 get_vhffs
 
-Delete broadcast $id.
+This method returns the Vhffs::Main object.
 
-Returns 1 on success, otherwise returns < 0;
+=cut
+sub get_vhffs {
+	my $self = shift;
+	return $self->{'vhffs'};
+}
 
+=pod
+
+=head2 get_status
+
+Get the status of this broadcast. The status are given in the Vhffs::Constants class.
+
 =cut
-sub del_broadcast {
-	my $vhffs = shift;
-	my $id = shift;
-	my $db = $vhffs->get_db_object;
+sub get_status {
+	my $self = shift;
+	return $self->{'state'};
+}
 
-	my $query = 'DELETE FROM vhffs_mailings WHERE id_mailing=?';
-	my $request = $db->prepare( $query );
-	$request->execute( $id ) or return -2;
+=pod
 
+=head2 set_status
+
+Change the status. The status are available as constants in Vhffs::Constants class.
+
+=cut
+sub set_status {
+	my ($self, $value) = @_;
+	$self->{'state'} = $value;
+}
+
+=pod
+
+=head2 commit
+
+Apply all changes that were made on this broadcast. Returns undef value if failed, true if success.
+
+=cut
+sub commit {
+	my $self = shift;
+
+	my $query = 'UPDATE vhffs_mailings SET state=? WHERE mailing_id=?';
+	my $dbh = $self->get_vhffs->get_db_object;
+	my $result = $dbh->prepare($query);
+	$result->execute( $self->{'state'}, $self->{'mailing_id'} ) or return undef;
 	return 1;
 }
 
 =pod
 
-=head2 get_broadcast
+=head2 delete
 
-	my $broadcast = Vhffs::Broadcast::get_broadcast( $vhffs, $id );
+	my $ret = $mailing->delete;
 
-Fetch broadcast $id.
+Delete broadcast $mailing.
 
+Returns 1 on success, otherwise returns undef;
+
 =cut
-sub get_broadcast {
-	my $vhffs = shift;
-	my $id = shift;
-	my $db = $vhffs->get_db_object;
+sub delete {
+	my $self = shift;
 
-	return undef unless defined $id;
-
-	my $query = 'SELECT id_mailing,subject,message,date,state FROM vhffs_mailings WHERE id_mailing=?';
-	my $request = $db->prepare( $query );
-	$request->execute( $id ) or return -2;
-
-	my $row = $request->fetchrow_hashref();
-	return $row;
+	my $query = 'DELETE FROM vhffs_mailings WHERE mailing_id=?';
+	my $dbh = $self->get_vhffs->get_db_object;
+	my $request = $dbh->prepare( $query );
+	$request->execute( $self->{'mailing_id'} ) or return undef;
+	return 1;
 }
 
 1;

Modified: trunk/vhffs-api/src/Vhffs/Constants.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Constants.pm	2012-02-28 21:57:19 UTC (rev 2080)
+++ trunk/vhffs-api/src/Vhffs/Constants.pm	2012-02-29 20:32:32 UTC (rev 2081)
@@ -63,6 +63,9 @@
 	ML_POSTING_MEMBERS_ONLY_MODERATED => 4,
 	ML_POSTING_ADMINS_ONLY => 5,
 
+	BROADCAST_WAITING_TO_BE_SENT => 0,
+	BROADCAST_SENT => 1,
+
 	# Objects' types
 	TYPE_USER => 10,
 	TYPE_GROUP => 11,

Modified: trunk/vhffs-api/src/Vhffs/Group.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Group.pm	2012-02-28 21:57:19 UTC (rev 2080)
+++ trunk/vhffs-api/src/Vhffs/Group.pm	2012-02-29 20:32:32 UTC (rev 2081)
@@ -173,7 +173,6 @@
 	}
 
 	return $group;
-
 }
 
 =pod

Modified: trunk/vhffs-api/src/Vhffs/Makefile.am
===================================================================
--- trunk/vhffs-api/src/Vhffs/Makefile.am	2012-02-28 21:57:19 UTC (rev 2080)
+++ trunk/vhffs-api/src/Vhffs/Makefile.am	2012-02-29 20:32:32 UTC (rev 2081)
@@ -51,11 +51,11 @@
 	Panel/Web.pm \
 	Panel/Cron.pm \
 	Robots/Bazaar.pm \
+	Robots/Broadcast.pm \
 	Robots/Cvs.pm \
 	Robots/DNS.pm \
 	Robots/Group.pm \
 	Robots/Mail.pm \
-	Robots/Mailing.pm \
 	Robots/MailingList.pm \
 	Robots/Mercurial.pm \
 	Robots/Mysql.pm \

Modified: trunk/vhffs-api/src/Vhffs/Panel/Broadcast.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Broadcast.pm	2012-02-28 21:57:19 UTC (rev 2080)
+++ trunk/vhffs-api/src/Vhffs/Panel/Broadcast.pm	2012-02-29 20:32:32 UTC (rev 2081)
@@ -44,7 +44,7 @@
 sub broadcast_list {
 	my ($main) = @_;
 
-	my $sql = 'SELECT id_mailing as id, subject, message as body, date, state '.
+	my $sql = 'SELECT mailing_id as id, subject, message as body, date, state '.
 	  'FROM vhffs_mailings m '.
 	  'ORDER BY m.date DESC';
 
@@ -61,8 +61,8 @@
 	my $session = $panel->{'session'};
 	my $user = $panel->{'user'};
 
-	my $subject = $cgi->param('subject');
-	my $body = $cgi->param('body');
+	my $subject = Encode::decode_utf8( $cgi->param('subject') );
+	my $body = Encode::decode_utf8( $cgi->param('body') );
 	my $vars = {};
 
 	if(defined $subject and defined $body) {
@@ -70,7 +70,7 @@
 		$panel->add_error( gettext('You have to enter a message body') ) unless $body =~ /\S/;
 
 		unless( $panel->has_errors ) {
-			if( Vhffs::Broadcast::add_broadcast( $vhffs , $subject , $body ) == 1 ) {
+			if( Vhffs::Broadcast::create( $vhffs, $subject, $body ) ) {
 				$panel->render('misc/message.tt',  {
 				  message => gettext('Mailing successfully added'),
 				  refresh_url => '?do=broadcastlist'
@@ -101,14 +101,14 @@
 
 	my $mailings = broadcast_list( $vhffs );
 	foreach my $m(@$mailings) {
-		if($m->{state} == 3) {
+		if($m->{state} == Vhffs::Constants::BROADCAST_WAITING_TO_BE_SENT) {
 			$m->{state} = gettext('Awaiting sending');
-		} elsif($m->{state} == 6) {
+		} elsif($m->{state} == Vhffs::Constants::BROADCAST_SENT) {
 			$m->{state} = gettext('Sent');
 		} else {
 			$m->{state} = gettext('Unknown');
+		}
 	}
-	}
 
 	$vars->{mailings} = $mailings;
 	$panel->render('admin/broadcast/list.tt', $vars);
@@ -131,7 +131,7 @@
 		  });
 		return;
 	}
-	my $mailing = Vhffs::Broadcast::get_broadcast( $vhffs , $mid );
+	my $mailing = Vhffs::Broadcast::get_by_mailing_id( $vhffs, $mid );
 	unless( defined $mailing) {
 		$panel->render('misc/message.tt', {
 		  message => gettext('Mailing not found'),
@@ -170,8 +170,16 @@
 		  });
 		return;
 	}
+	my $mailing = Vhffs::Broadcast::get_by_mailing_id( $vhffs, $mid );
+	unless( defined $mailing) {
+		$panel->render('misc/message.tt', {
+		  message => gettext('Mailing not found'),
+		  refresh_url => '?do=broadcastlist'
+		  });
+		return;
+	}
 
-	unless( Vhffs::Broadcast::del_broadcast( $vhffs , $mid ) == 1 ) {
+	unless( $mailing->delete ) {
 		$panel->render('misc/message.tt', {
 		  message => gettext('An error occured while deleting this mailing')
 		  });
@@ -184,5 +192,4 @@
 	  });
 }
 
-
 1;

Copied: trunk/vhffs-api/src/Vhffs/Robots/Broadcast.pm (from rev 2080, trunk/vhffs-api/src/Vhffs/Robots/Mailing.pm)
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Broadcast.pm	                        (rev 0)
+++ trunk/vhffs-api/src/Vhffs/Robots/Broadcast.pm	2012-02-29 20:32:32 UTC (rev 2081)
@@ -0,0 +1,64 @@
+#!%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::Broadcast;
+use Vhffs::User;
+
+package Vhffs::Robots::Broadcast;
+
+sub send {
+	my $mailing = shift;
+	return undef unless defined $mailing and $mailing->get_status == Vhffs::Constants::BROADCAST_WAITING_TO_BE_SENT;
+
+	my $vhffs = $mailing->get_vhffs;
+
+	my $from = $vhffs->get_config->get_master_mail;
+	unless( defined $from ) {
+		Vhffs::Robots::vhffs_log( $vhffs, 'Cannot send mailing, From: (master mail) is not declared in config file' );
+		return undef;
+	}
+
+	my $users = Vhffs::User::getall( $vhffs );
+	foreach my $user ( @{$users} ) {
+		Vhffs::Functions::send_mail( $vhffs, $from, $user->get_mail, $vhffs->get_config->get_mailtag, $mailing->{subject} , $mailing->{message} , 'bulk' );
+	}
+
+	$mailing->set_status( Vhffs::Constants::BROADCAST_SENT );
+	$mailing->commit;
+}
+
+1;

Deleted: trunk/vhffs-api/src/Vhffs/Robots/Mailing.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Mailing.pm	2012-02-28 21:57:19 UTC (rev 2080)
+++ trunk/vhffs-api/src/Vhffs/Robots/Mailing.pm	2012-02-29 20:32:32 UTC (rev 2081)
@@ -1,53 +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;
-
-package Vhffs::Robots::Mailing;
-
-use Vhffs::Constants;
-
-sub getall_mailings
-{
-	my $main = shift;
-
-	my $query = "SELECT id_mailing , subject , message FROM  vhffs_mailings WHERE state='".Vhffs::Constants::WAITING_FOR_CREATION."'";
-
-	my $request = $main->{'db'}->prepare( $query ) or return -2;
-	return undef if ( $request->execute() <= 0 );
-
-	my $rows = $request->fetchall_hashref('id_mailing');
-	return $rows;
-}
-
-1;
-

Modified: trunk/vhffs-api/src/Vhffs/UserGroup.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/UserGroup.pm	2012-02-28 21:57:19 UTC (rev 2080)
+++ trunk/vhffs-api/src/Vhffs/UserGroup.pm	2012-02-29 20:32:32 UTC (rev 2081)
@@ -134,6 +134,7 @@
 	my $self = shift;
 	return $self->{'vhffs'};
 }
+
 =pod
 
 =head2 get_status

Modified: trunk/vhffs-backend/src/pgsql/initdb.sql.in
===================================================================
--- trunk/vhffs-backend/src/pgsql/initdb.sql.in	2012-02-28 21:57:19 UTC (rev 2080)
+++ trunk/vhffs-backend/src/pgsql/initdb.sql.in	2012-02-29 20:32:32 UTC (rev 2081)
@@ -255,7 +255,7 @@
 
 CREATE TABLE vhffs_mailings
 (
-	id_mailing serial,
+	mailing_id serial,
 -- Subject of the mail
 	subject VARCHAR NOT NULL,
 -- Message sent
@@ -264,7 +264,7 @@
 	date int8,
 -- State of the mailing (waiting to be sent, sent, ...)
 	state int4 NOT NULL,
-	CONSTRAINT vhffs_mailings_pkey PRIMARY KEY (id_mailing)
+	CONSTRAINT vhffs_mailings_pkey PRIMARY KEY (mailing_id)
 ) WITH OIDS;
 
 -- Mail domains hosted on this platform

Modified: trunk/vhffs-compat/from-4.3-to-4.4.sql
===================================================================
--- trunk/vhffs-compat/from-4.3-to-4.4.sql	2012-02-28 21:57:19 UTC (rev 2080)
+++ trunk/vhffs-compat/from-4.3-to-4.4.sql	2012-02-29 20:32:32 UTC (rev 2081)
@@ -17,3 +17,8 @@
 DELETE FROM vhffs_acl acl
 	WHERE acl.granted_oid IN (SELECT acl.granted_oid FROM vhffs_acl acl INNER JOIN vhffs_object ot ON ot.object_id=acl.target_oid INNER JOIN vhffs_object og ON og.object_id=acl.granted_oid WHERE og.type=11 AND og.owner_gid=ot.owner_gid AND acl.perm=2)
 	AND acl.target_oid IN (SELECT acl.target_oid FROM vhffs_acl acl INNER JOIN vhffs_object ot ON ot.object_id=acl.target_oid INNER JOIN vhffs_object og ON og.object_id=acl.granted_oid WHERE og.type=11 AND og.owner_gid=ot.owner_gid AND acl.perm=2);
+
+-- Set new mailings states
+ALTER TABLE vhffs_mailings RENAME COLUMN id_mailing TO mailing_id;
+UPDATE vhffs_mailings SET state=0 WHERE state=3;
+UPDATE vhffs_mailings SET state=1 WHERE state=6;

Modified: trunk/vhffs-robots/Makefile.am
===================================================================
--- trunk/vhffs-robots/Makefile.am	2012-02-28 21:57:19 UTC (rev 2080)
+++ trunk/vhffs-robots/Makefile.am	2012-02-29 20:32:32 UTC (rev 2081)
@@ -21,13 +21,13 @@
 	misc/git_post-receive
 
 dist_bots_SCRIPTS = \
+	src/broadcast.pl \
 	src/dns.pl \
 	src/group.pl \
 	src/group_quota.pl \
 	src/listengine_publicarchives.pl \
 	src/mail.pl \
 	src/mailinglist.pl \
-	src/mailing.pl \
 	src/mysql.pl \
 	src/mysql_dump.pl \
 	src/object_cleanup.pl \

Copied: trunk/vhffs-robots/src/broadcast.pl (from rev 2080, trunk/vhffs-robots/src/mailing.pl)
===================================================================
--- trunk/vhffs-robots/src/broadcast.pl	                        (rev 0)
+++ trunk/vhffs-robots/src/broadcast.pl	2012-02-29 20:32:32 UTC (rev 2081)
@@ -0,0 +1,49 @@
+#!%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::Broadcast;
+
+my $vhffs = init Vhffs::Main;
+exit 1 unless defined $vhffs;
+
+Vhffs::Robots::lock( $vhffs, 'mailings' );
+
+my $mailings = Vhffs::Broadcast::getall( $vhffs, Vhffs::Constants::BROADCAST_WAITING_TO_BE_SENT );
+foreach ( @{$mailings} ) {
+	Vhffs::Robots::Broadcast::send( $_ );
+}
+
+Vhffs::Robots::unlock( $vhffs, 'mailings' );
+exit 0;

Deleted: trunk/vhffs-robots/src/mailing.pl
===================================================================
--- trunk/vhffs-robots/src/mailing.pl	2012-02-28 21:57:19 UTC (rev 2080)
+++ trunk/vhffs-robots/src/mailing.pl	2012-02-29 20:32:32 UTC (rev 2081)
@@ -1,76 +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.
-
-#This bots send mailings to all hosted people
-
-use strict;
-use utf8;
-use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Main;
-use Vhffs::User;
-use Vhffs::Functions;
-use Vhffs::Robots::Mailing;
-use Vhffs::Robots::User;
-use Vhffs::Robots;
-use Vhffs::Constants;
-binmode STDOUT , ':utf8';
-
-my $vhffs = init Vhffs::Main;
-exit 1 unless defined $vhffs;
-
-my $mailings = Vhffs::Robots::Mailing::getall_mailings( $vhffs );
-exit 0 unless defined $mailings;
-
-my $from = $vhffs->get_config->get_master_mail;
-die "Cannot send mailing, From: (master mail) is not declared in config file" unless $from;
-
-Vhffs::Robots::lock( $vhffs , "mailings" );
-
-my $users = Vhffs::User::getall( $vhffs , undef );
-
-foreach my $idm ( keys %{$mailings} )
-{
-	next unless ( defined $mailings->{$idm}{subject} && defined $mailings->{$idm}{message} );
-
-	foreach my $user ( @{$users} )
-	{
-		next unless defined $user;
-		Vhffs::Functions::send_mail( $vhffs , $from , $user->get_mail , $vhffs->get_config->get_mailtag , $mailings->{$idm}{subject} , $mailings->{$idm}{message} , 'bulk' );
-	}
-
-	my $query = "UPDATE vhffs_mailings SET state='".Vhffs::Constants::ACTIVATED."' WHERE id_mailing='".$idm."'";
-	my $request = $vhffs->get_db_object->prepare( $query );
-	$request->execute or print ( "error" );
-}
-
-Vhffs::Robots::unlock( $vhffs , "mailings" );
-
-exit( 0 );


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