[vhffs-dev] [2226] now sending mail to users when objects are successfully created

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


Revision: 2226
Author:   gradator
Date:     2013-01-17 23:44:32 +0100 (Thu, 17 Jan 2013)
Log Message:
-----------
now sending mail to users when objects are successfully created

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Object.pm
    trunk/vhffs-api/src/Vhffs/Robots/Bazaar.pm
    trunk/vhffs-api/src/Vhffs/Robots/Cron.pm
    trunk/vhffs-api/src/Vhffs/Robots/Cvs.pm
    trunk/vhffs-api/src/Vhffs/Robots/DNS.pm
    trunk/vhffs-api/src/Vhffs/Robots/Git.pm
    trunk/vhffs-api/src/Vhffs/Robots/Group.pm
    trunk/vhffs-api/src/Vhffs/Robots/Mail.pm
    trunk/vhffs-api/src/Vhffs/Robots/MailingList.pm
    trunk/vhffs-api/src/Vhffs/Robots/Mercurial.pm
    trunk/vhffs-api/src/Vhffs/Robots/Mysql.pm
    trunk/vhffs-api/src/Vhffs/Robots/Pgsql.pm
    trunk/vhffs-api/src/Vhffs/Robots/Repository.pm
    trunk/vhffs-api/src/Vhffs/Robots/Svn.pm
    trunk/vhffs-api/src/Vhffs/Robots/Web.pm

Modified: trunk/vhffs-api/src/Vhffs/Object.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Object.pm	2013-01-17 22:16:54 UTC (rev 2225)
+++ trunk/vhffs-api/src/Vhffs/Object.pm	2013-01-17 22:44:32 UTC (rev 2226)
@@ -731,6 +731,52 @@
 
 =pod
 
+=head2 send_created_mail
+
+Send an email to the owner of the object indicating that the object has been created
+
+=cut
+sub send_created_mail {
+	my $self = shift;
+
+	my $vhffs = $self->get_vhffs;
+	my $user = $self->get_owner;
+
+	# TODO: write a beautiful module for INTL
+	bindtextdomain('vhffs', '%localedir%');
+	textdomain('vhffs');
+
+	my $prevlocale = setlocale( LC_ALL );
+	setlocale( LC_ALL , $user->get_lang );
+
+	my $docstr = '';
+	$docstr = sprintf( gettext("Related documentation is available at:\n  %s\n\n"), $self->get_config->{'url_doc'} ) if $self->get_config->{'url_doc'};
+
+	my $mail = sprintf(
+		gettext( "Hello %s %s,\n\nYour %s (%s) on %s was successfully created.\n\n%sEnjoy!\n\nCheers,\nThe moderator team\n\n---------\n%s\n%s\n" ) ,
+		$user->get_firstname,
+		$user->get_lastname,
+		Vhffs::Functions::type_string_from_type_id( $self->get_type ),
+		$self->get_label,
+		$vhffs->get_config->get_host_name,
+		$docstr,
+		$vhffs->get_config->get_host_name,
+		$vhffs->get_config->get_panel->{url}
+		);
+	my $subject = sprintf(
+		gettext('Your %s (%s) on %s was successfully created'),
+		Vhffs::Functions::type_string_from_type_id( $self->get_type ),
+		$self->get_label,
+		$vhffs->get_config->get_host_name
+		);
+
+	Vhffs::Functions::send_mail( $vhffs , $vhffs->get_config->get_moderator_mail , $user->get_mail , $vhffs->get_config->get_mailtag , $subject , $mail );
+
+	setlocale( LC_ALL , $prevlocale );
+}
+
+=pod
+
 =head2 delete_withmail()
 
 Delete this object, sending a nice mail to the owner.

Modified: trunk/vhffs-api/src/Vhffs/Robots/Bazaar.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Bazaar.pm	2013-01-17 22:16:54 UTC (rev 2225)
+++ trunk/vhffs-api/src/Vhffs/Robots/Bazaar.pm	2013-01-17 22:44:32 UTC (rev 2226)
@@ -90,7 +90,10 @@
 	Vhffs::Robots::chown_recur( $dir, $bazaar->get_owner_uid, $bazaar->get_owner_gid );
 
 	Vhffs::Robots::vhffs_log( $vhffs, 'Created bazaar repository '.$bazaar->get_reponame );
-	return modify( $bazaar );
+	return undef unless modify( $bazaar );
+
+	$bazaar->send_created_mail;
+	return 1;
 }
 
 sub delete {

Modified: trunk/vhffs-api/src/Vhffs/Robots/Cron.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Cron.pm	2013-01-17 22:16:54 UTC (rev 2225)
+++ trunk/vhffs-api/src/Vhffs/Robots/Cron.pm	2013-01-17 22:44:32 UTC (rev 2226)
@@ -80,6 +80,7 @@
 	$cron->commit;
 	Vhffs::Robots::vhffs_log( $vhffs, 'Created cron job '.$cron->get_cronpath );
 
+	$cron->send_created_mail;
 	return 1;
 }
 

Modified: trunk/vhffs-api/src/Vhffs/Robots/Cvs.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Cvs.pm	2013-01-17 22:16:54 UTC (rev 2225)
+++ trunk/vhffs-api/src/Vhffs/Robots/Cvs.pm	2013-01-17 22:44:32 UTC (rev 2226)
@@ -86,7 +86,10 @@
 	Vhffs::Robots::chown_recur( $dir, $cvs->get_owner_uid, $cvs->get_owner_gid );
 
 	Vhffs::Robots::vhffs_log( $vhffs, 'Created cvs repository '.$cvs->get_reponame );
-	return modify( $cvs );
+	return undef unless modify( $cvs );
+
+	$cvs->send_created_mail;
+	return 1;
 }
 
 sub delete {

Modified: trunk/vhffs-api/src/Vhffs/Robots/DNS.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/DNS.pm	2013-01-17 22:16:54 UTC (rev 2225)
+++ trunk/vhffs-api/src/Vhffs/Robots/DNS.pm	2013-01-17 22:44:32 UTC (rev 2226)
@@ -49,6 +49,7 @@
 	$dns->commit;
 	Vhffs::Robots::vhffs_log( $vhffs, 'Created DNS '.$dns->get_domain );
 
+	$dns->send_created_mail;
 	return 1;
 }
 

Modified: trunk/vhffs-api/src/Vhffs/Robots/Git.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Git.pm	2013-01-17 22:16:54 UTC (rev 2225)
+++ trunk/vhffs-api/src/Vhffs/Robots/Git.pm	2013-01-17 22:44:32 UTC (rev 2226)
@@ -96,7 +96,10 @@
 	Vhffs::Robots::chown_recur( $dir.'/hooks', 0, 0 );
 
 	Vhffs::Robots::vhffs_log( $vhffs, 'Created git repository '.$git->get_reponame );
-	return modify( $git );
+	return undef unless modify( $git );
+
+	$git->send_created_mail;
+	return 1;
 }
 
 sub delete {

Modified: trunk/vhffs-api/src/Vhffs/Robots/Group.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Group.pm	2013-01-17 22:16:54 UTC (rev 2225)
+++ trunk/vhffs-api/src/Vhffs/Robots/Group.pm	2013-01-17 22:44:32 UTC (rev 2226)
@@ -80,6 +80,7 @@
 
 	quota($group);
 
+	$group->send_created_mail;
 	return 1;
 }
 

Modified: trunk/vhffs-api/src/Vhffs/Robots/Mail.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Mail.pm	2013-01-17 22:16:54 UTC (rev 2225)
+++ trunk/vhffs-api/src/Vhffs/Robots/Mail.pm	2013-01-17 22:44:32 UTC (rev 2226)
@@ -75,6 +75,7 @@
 	$mail->commit;
 	Vhffs::Robots::vhffs_log( $vhffs, 'Created mail domain '.$mail->get_domain );
 
+	$mail->send_created_mail;
 	return 1;
 }
 

Modified: trunk/vhffs-api/src/Vhffs/Robots/MailingList.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/MailingList.pm	2013-01-17 22:16:54 UTC (rev 2225)
+++ trunk/vhffs-api/src/Vhffs/Robots/MailingList.pm	2013-01-17 22:44:32 UTC (rev 2226)
@@ -49,6 +49,7 @@
 	$ml->commit;
 	Vhffs::Robots::vhffs_log( $vhffs, 'Created mailing list '.$ml->get_listname );
 
+	$ml->send_created_mail;
 	return 1;
 }
 

Modified: trunk/vhffs-api/src/Vhffs/Robots/Mercurial.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Mercurial.pm	2013-01-17 22:16:54 UTC (rev 2225)
+++ trunk/vhffs-api/src/Vhffs/Robots/Mercurial.pm	2013-01-17 22:44:32 UTC (rev 2226)
@@ -90,7 +90,10 @@
 	Vhffs::Robots::chown_recur( $dir, $mercurial->get_owner_uid, $mercurial->get_owner_gid );
 
 	Vhffs::Robots::vhffs_log( $vhffs, 'Created mercurial repository '.$mercurial->get_reponame );
-	return modify( $mercurial );
+	return undef unless modify( $mercurial );
+
+	$mercurial->send_created_mail;
+	return 1;
 }
 
 sub delete {

Modified: trunk/vhffs-api/src/Vhffs/Robots/Mysql.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Mysql.pm	2013-01-17 22:16:54 UTC (rev 2225)
+++ trunk/vhffs-api/src/Vhffs/Robots/Mysql.pm	2013-01-17 22:44:32 UTC (rev 2226)
@@ -85,6 +85,7 @@
 	$mysql->set_status( Vhffs::Constants::ACTIVATED );
 	$mysql->commit;
 
+	$mysql->send_created_mail;
 	return 1;
 }
 

Modified: trunk/vhffs-api/src/Vhffs/Robots/Pgsql.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Pgsql.pm	2013-01-17 22:16:54 UTC (rev 2225)
+++ trunk/vhffs-api/src/Vhffs/Robots/Pgsql.pm	2013-01-17 22:44:32 UTC (rev 2226)
@@ -80,6 +80,7 @@
 	$pgsql->set_status( Vhffs::Constants::ACTIVATED );
 	$pgsql->commit;
 
+	$pgsql->send_created_mail;
 	return 1;
 }
 

Modified: trunk/vhffs-api/src/Vhffs/Robots/Repository.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Repository.pm	2013-01-17 22:16:54 UTC (rev 2225)
+++ trunk/vhffs-api/src/Vhffs/Robots/Repository.pm	2013-01-17 22:44:32 UTC (rev 2226)
@@ -79,6 +79,7 @@
 	$repository->commit;
 	quota($repository);
 
+	$repository->send_created_mail;
 	return 1;
 }
 

Modified: trunk/vhffs-api/src/Vhffs/Robots/Svn.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Svn.pm	2013-01-17 22:16:54 UTC (rev 2225)
+++ trunk/vhffs-api/src/Vhffs/Robots/Svn.pm	2013-01-17 22:44:32 UTC (rev 2226)
@@ -90,7 +90,10 @@
 	Vhffs::Robots::chown_recur( $dir.'/hooks', 0, 0 );
 
 	Vhffs::Robots::vhffs_log( $vhffs, 'Created svn repository '.$svn->get_reponame );
-	return modify( $svn );
+	return undef unless modify( $svn );
+
+	$svn->send_created_mail;
+	return 1;
 }
 
 sub delete {

Modified: trunk/vhffs-api/src/Vhffs/Robots/Web.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Web.pm	2013-01-17 22:16:54 UTC (rev 2225)
+++ trunk/vhffs-api/src/Vhffs/Robots/Web.pm	2013-01-17 22:44:32 UTC (rev 2226)
@@ -80,6 +80,8 @@
 	Vhffs::Robots::vhffs_log( $vhffs, 'Created web area '.$web->get_servername );
 	$web->set_status( Vhffs::Constants::ACTIVATED );
 	$web->commit;
+
+	$web->send_created_mail;
 	return 1;
 }
 


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