[vhffs-dev] [1462] IRC moderation allows to add additional comments when accepting a submission

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


Revision: 1462
Author:   beuss
Date:     2009-06-27 10:05:25 +0200 (Sat, 27 Jun 2009)

Log Message:
-----------
IRC moderation allows to add additional comments when accepting a submission

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Object.pm
    trunk/vhffs-irc/modobot.pl


Modified: trunk/vhffs-api/src/Vhffs/Object.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Object.pm	2009-06-24 13:08:53 UTC (rev 1461)
+++ trunk/vhffs-api/src/Vhffs/Object.pm	2009-06-27 08:05:25 UTC (rev 1462)
@@ -386,6 +386,7 @@
 sub moderate_accept
 {
 	my $self = shift;
+	my $comments = shift;
 
 	my $vhffs = $self->{main};
 	my $user = $self->get_user;
@@ -400,18 +401,32 @@
 	my $prevlocale = setlocale( LC_ALL );
 	setlocale( LC_ALL , $user->get_lang );
 
-	my $mail = sprintf(
-		gettext( "Hello %s %s,\n\nYour request for a %s (%s) on %s was accepted.\nPlease wait while we are creating your object.\n\nCheers,\nThe moderator team\n\n---------\n%s\n%s\n" ) ,
+	my $mail;
 
+	if(defined $comments) {
+		$mail = sprintf(
+			gettext( "Hello %s %s,\n\nYour request for a %s (%s) on %s was accepted, however, moderators wanted to add some precision:\n%s.\nPlease wait while we are creating your object.\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,
+		$comments,
 		$vhffs->get_config->get_host_name,
 		$vhffs->get_config->get_panel->{url}
 		);
-
+	} else {
+		$mail = sprintf(
+			gettext( "Hello %s %s,\n\nYour request for a %s (%s) on %s was accepted.\nPlease wait while we are creating your object.\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,
+		$vhffs->get_config->get_host_name,
+		$vhffs->get_config->get_panel->{url}
+		);
+	}
 	my $subject = sprintf(
 		gettext('Your request for a %s (%s) on %s was accepted'), 
 		Vhffs::Functions::type_string_from_type_id( $self->get_type ),

Modified: trunk/vhffs-irc/modobot.pl
===================================================================
--- trunk/vhffs-irc/modobot.pl	2009-06-24 13:08:53 UTC (rev 1461)
+++ trunk/vhffs-irc/modobot.pl	2009-06-27 08:05:25 UTC (rev 1462)
@@ -120,6 +120,18 @@
 
 	my $object = Vhffs::ObjectFactory::fetch_object( $vhffs , $oid );
 
+	my $wfreason;
+	my $charset;
+	eval { $wfreason = Encode::decode_utf8( $reason , Encode::FB_CROAK ); };
+	if( $@ )  {
+		#decoding from utf8 failed, falling back to iso
+		$wfreason = Encode::decode('iso-8859-1', $reason);
+		$charset = 'ISO';
+	}
+	else  {
+		$charset = 'UTF-8';
+	}
+
 	unless( defined $object )
 	{
 		irc_msg ('Error : Cannot fetch object');
@@ -133,25 +145,14 @@
 	else
 	{
 		if( $status == 1 )  {
-			if( $object->moderate_accept < 0 )  {
+			if( $object->moderate_accept( $wfreason ) < 0 )  {
 				irc_msg('Error while committing changes');
 			}
 			else {
-				irc_msg( 'Object '.$oid.' accepted' );
+				irc_msg( 'Object '.$oid.' accepted ('.$charset.' detected)' );
 			}
 		}
 		else  {
-			my $wfreason;
-			my $charset;
-			eval { $wfreason = Encode::decode_utf8( $reason , Encode::FB_CROAK ); };
-			if( $@ )  {
-				#decoding from utf8 failed, falling back to iso
-				$wfreason = Encode::decode('iso-8859-1', $reason);
-				$charset = 'ISO';
-			}
-			else  {
-				$charset = 'UTF-8';
-			}
 
 			if( $object->moderate_refuse( $wfreason ) < 0 )  {
 				irc_msg('Error while committing changes');
@@ -357,7 +358,7 @@
     my ($nick, $mynick)=($event->nick, $self->nick);
     my $texte=$event->{args}[0];
 
-    if ($texte =~ m/^${mynick}: accept [0-9]+$/)
+    if ($texte =~ m/^${mynick}: accept [0-9]+ .*$/)
     {
         if (is_modo ($nick) == 1)
 	{


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