X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=PciIds%2FNotifications.pm;h=83eaeae9536f676a478648c9f5707e9a3dd6b826;hb=0f56177f9485580e2eb0d2f558a74f452d2d8063;hp=32a3122df1486d1925379bf5d33a99303571f123;hpb=b20440babb4c14311601fce7b14e0f990a7eac2a;p=pciids.git diff --git a/PciIds/Notifications.pm b/PciIds/Notifications.pm index 32a3122..83eaeae 100644 --- a/PciIds/Notifications.pm +++ b/PciIds/Notifications.pm @@ -41,6 +41,14 @@ sub sendNotif( $$$ ) { "$message\nThis is automatic notification message, do not respond to it.\nYou can change your notifications at http://$config{hostname}/mods/PC/?action=notifications\n" ); } +sub indent( $$ ) { + my( $text, $count ) = @_; + return '' unless defined $text; + my $ident = ' 'x$count; + $text =~ s/\n/$ident/s; + return $text; +} + sub sendOut( $$ ) { my( $notifs, $sendFun ) = @_; my( $last_address, $last_user ); @@ -58,32 +66,35 @@ sub sendOut( $$ ) { if( $reason == 0 ) { $note = "New item was created.\n Id: ".$addr->pretty()."\n Name: $newname\n"; $note .= " Description: $newdesc\n" if( defined $newdesc && ( $newdesc ne '' ) ); - $note .= " Comment text: $text\n" if( defined $text && ( $text ne '' ) ); + $text = indent( $text, 4 ); + $note .= " Comment text: $text\n" if $text ne ''; $note .= " Author: $author\n" if( defined $author && ( $author ne '' ) ); $note .= " Time: $time\n"; $note .= " Address: http://".$config{'hostname'}."/read/".$addr->get()."\n"; } elsif( $reason == 1 ) { $note = "New comment created.\n Item:\n"; $note .= " Id: ".$addr->pretty()."\n"; - $note .= " Name: $name\n" if( defined $name && ( $name ne '' ) && ( $name ne $newname ) ); - $note .= " Description: $desc\n" if( defined $desc && ( $desc ne '' ) && ( $desc ne $newdesc ) ); + $note .= " Name: $name\n" if( defined $name && ( $name ne '' ) && ( ( !defined $newname ) || ( $name ne $newname ) ) ); + $note .= " Description: $desc\n" if( defined $desc && ( $desc ne '' ) && ( ( !defined $newdesc ) || ( $desc ne $newdesc ) ) ); $note .= " Address: http://".$config{'hostname'}."/read/".$addr->get()."\n"; $note .= " Comment:\n"; $note .= " Proposed name: $newname\n" if( defined $newname && ( $newname ne '' ) ); $note .= " Deletion request\n" if defined $newname && $newname eq ''; $note .= " Proposed description: $newdesc\n" if( defined $newdesc && ( $newdesc ne '' ) ); - $note .= " Text: $text\n" if( defined $text && ( $text ne '' ) ); + $text = indent( $text, 6 ); + $note .= " Text: $text\n" if $text ne ''; $note .= " Author: $author\n" if( defined $author && ( $author ne '' ) ); $note .= " Time: $time\n"; } elsif( $reason == 2 ) { if( $name ne '' ) { - $note = "Item name approved.\n Id:".$addr->pretty()."\n"; + $note = "Item name approved.\n Id: ".$addr->pretty()."\n"; $note .= " Name: $newname\n"; $note .= " Description: $newdesc\n" if( defined $newdesc && ( $newdesc ne '' ) ); - $note .= " Comment text: $text\n" if( defined $text && ( $text ne '' ) ); + $text = indent( $text, 4 ); + $note .= " Comment text: $text\n" if $text ne ''; $note .= " Address: http://".$config{'hostname'}."/read/".$addr->get()."\n"; } else { - $note = "Item deletion approved.\n Id:".$addr->pretty()."\n"; + $note = "Item deletion approved.\n Id: ".$addr->pretty()."\n"; $note .= " Address: http://".$config{'hostname'}."/read/".$addr->get()."\n"; } }