Skip to content

Commit

Permalink
Item14327: Perltidy and update MANIFEST
Browse files Browse the repository at this point in the history
  • Loading branch information
gac410 committed Feb 25, 2017
1 parent 56c0b2e commit 103a90d
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 36 deletions.
Empty file added TIDY
Empty file.
44 changes: 28 additions & 16 deletions lib/Foswiki/Plugins/NotificationPlugin.pm
Expand Up @@ -76,7 +76,7 @@ sub beforeSaveHandler {
push( @notifyUsers, getUsersToNotify( $_[2], $_[1], 1 ) );
push( @notifyUsers, getUsersToNotify( $_[2], $_[1], 2 ) );

Foswiki::Func::writeDebug( "COUNT = $#notifyUsers" );
Foswiki::Func::writeDebug("COUNT = $#notifyUsers");
my $subject = "Topic $_[2].$_[1] has been changed by $wikiUser.";
my $body =
"Topic "
Expand All @@ -90,8 +90,7 @@ sub beforeSaveHandler {
sub getUsers {
my @result;

my @topics =
Foswiki::Func::getTopicList($Foswiki::cfg{UsersWebName});
my @topics = Foswiki::Func::getTopicList( $Foswiki::cfg{UsersWebName} );

foreach my $name (@topics) {
next unless $name =~ /^(.*)NotifyList$/;
Expand All @@ -112,7 +111,7 @@ sub getUsersToNotify {
foreach my $tmp (@users) {

#Foswiki::Func::writeDebug( "TMP = $tmp" );
my $text = Foswiki::Func::readTopic($Foswiki::cfg{UsersWebName},
my $text = Foswiki::Func::readTopic( $Foswiki::cfg{UsersWebName},
"$tmp" . "NotifyList" );
my $test = "";
foreach my $line ( split( /\n/, $text ) ) {
Expand Down Expand Up @@ -190,12 +189,12 @@ sub getNotificationsOfUser {
sub notifyUsers {
my ( $notifyUsers, $subject, $body ) = @_;

Foswiki::Func::writeDebug( "NT = $notifyUsers" );
Foswiki::Func::writeDebug("NT = $notifyUsers");
foreach my $tmp ( @{$notifyUsers} ) {
Foswiki::Func::writeDebug("MAIL SENT TO $tmp ...");

my $to = getUserEmail($tmp);
my $email = <<"HERE";
my $to = getUserEmail($tmp);
my $email = <<"HERE";
From: $sender
To: $to
Subject: $subject
Expand All @@ -213,7 +212,7 @@ $body
--------------2D594AE113AD25493C2C7246--
HERE

Foswiki::Func::writeDebug( "Sending mail to $tmp ..." );
Foswiki::Func::writeDebug("Sending mail to $tmp ...");
my $error = Foswiki::Func::sendEmail($email);
if ($error) {
Foswiki::Func::writeDebug("ERROR WHILE SENDING MAIL - $error");
Expand Down Expand Up @@ -244,7 +243,8 @@ sub addItemToNotifyList {
if ( isItemInSection( $who, $what, $section, $text ) );
my @items =
Foswiki::Plugins::NotificationPlugin::getNotificationsOfUser(
Foswiki::Func::getWikiName(), $section, $text );
Foswiki::Func::getWikiName(),
$section, $text );
my $newText = "";
my $tmp = 0;
foreach $line ( split( /\n/, $text ) ) {
Expand Down Expand Up @@ -281,7 +281,8 @@ sub removeItemFromNotifyList {
if ( !isItemInSection( $who, $what, $section, $text ) );
my @items =
Foswiki::Plugins::NotificationPlugin::getNotificationsOfUser(
Foswiki::Func::getWikiName(), $section, $text );
Foswiki::Func::getWikiName(),
$section, $text );
my $newText = "";
my $tmp = 0;
foreach $line ( split( /\n/, $text ) ) {
Expand Down Expand Up @@ -310,16 +311,24 @@ sub checkUserNotifyList {
my $tmpMeta;

#Foswiki::Func::writeDebug( "NTF:checkUserNotifyList: WHO = $who" );
if ( !Foswiki::Func::topicExists( $Foswiki::cfg{UsersWebName}, $who . "NotifyList" ) ) {
if (
!Foswiki::Func::topicExists(
$Foswiki::cfg{UsersWebName},
$who . "NotifyList"
)
)
{
Foswiki::Func::writeDebug("TEST1");
( $tmpMeta, $tmpText ) =
Foswiki::Func::readTopic( $Foswiki::cfg{UsersWebName}, "NotificationPluginListTemplate" );
Foswiki::Func::readTopic( $Foswiki::cfg{UsersWebName},
"NotificationPluginListTemplate" );
$tmpMeta->put( "TOPICPARENT", { "name" => $who } );
saveUserNotifyList( $who, $tmpMeta, $tmpText );
}
else {
( $tmpMeta, $tmpText ) =
Foswiki::Func::readTopic( $Foswiki::cfg{UsersWebName}, $who . "NotifyList" );
Foswiki::Func::readTopic( $Foswiki::cfg{UsersWebName},
$who . "NotifyList" );
}
return ( $tmpMeta, $tmpText );
}
Expand All @@ -330,9 +339,12 @@ sub saveUserNotifyList {
#Foswiki::Func::writeDebug( "NTF:saveUserNotifyList: Saving Main.".$who."NotifyList topic..." );
$text =~ s/ /\t/g;

my $topicObject =
Foswiki::Func::saveTopic( $Foswiki::cfg{UsersWebName}, $who . "NotifyList", $meta, $text );
if (! $topicObject ) {
my $topicObject = Foswiki::Func::saveTopic(
$Foswiki::cfg{UsersWebName},
$who . "NotifyList",
$meta, $text
);
if ( !$topicObject ) {
my $url =
Foswiki::Func::getOopsUrl( $web, $topic, "oopssaveerr", $error );
Foswiki::Func::redirectCgiQuery( $query, $url );
Expand Down
41 changes: 21 additions & 20 deletions lib/Foswiki/Plugins/NotificationPlugin/MANIFEST
@@ -1,20 +1,21 @@
data/Main/NotificationPluginListTemplate.txt NEW
data/System/NotificationPlugin.txt NEW
lib/Foswiki/Plugins/NotificationPlugin/Config.spec NEW
lib/Foswiki/Plugins/NotificationPlugin.pm NEW
templates/changes-multi-text.tmpl NEW
templates/changes-single-html.tmpl NEW
templates/changes-single-text.tmpl NEW
templates/changes-srg-html.pattern.tmpl NEW
templates/changes-srg-html.tmpl NEW
templates/changes-srg-text.tmpl NEW
templates/htmlchanges.tmpl NEW
templates/mailnotify-multi-html.tmpl NEW
templates/mailnotify-multi-text.tmpl NEW
templates/mailnotify-single-html.tmpl NEW
templates/mailnotify-single-text.tmpl NEW
templates/mailnotify-srg-html.tmpl NEW
templates/mailnotify-srg-text.tmpl NEW
templates/view.NP.tmpl NEW
tools/changenotify NEW
tools/mailnotify-NP NEW
data/Main/NotificationPluginListTemplate.txt 0644
data/System/NotificationPlugin.txt 0644
lib/Foswiki/Plugins/NotificationPlugin.pm 0644
lib/Foswiki/Plugins/NotificationPlugin/Config.spec 0755
lib/Foswiki/Plugins/NotificationPlugin/DEPENDENCIES 0644
templates/changes-multi-text.tmpl 0644
templates/changes-single-html.tmpl 0644
templates/changes-single-text.tmpl 0644
templates/changes-srg-html.pattern.tmpl 0644
templates/changes-srg-html.tmpl 0644
templates/changes-srg-text.tmpl 0644
templates/htmlchanges.tmpl 0644
templates/mailnotify-multi-html.tmpl 0644
templates/mailnotify-multi-text.tmpl 0644
templates/mailnotify-single-html.tmpl 0644
templates/mailnotify-single-text.tmpl 0644
templates/mailnotify-srg-html.tmpl 0644
templates/mailnotify-srg-text.tmpl 0644
templates/view.NP.tmpl 0644
tools/changenotify 0755
tools/mailnotify-NP 0755

0 comments on commit 103a90d

Please sign in to comment.