Skip to content

Commit

Permalink
Item8291: add configure settings to download
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/SendEmailPlugin@5926 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
ArthurClemens authored and ArthurClemens committed Jan 4, 2010
1 parent 2ec0bcb commit b5fddd0
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 30 deletions.
23 changes: 8 additions & 15 deletions data/System/SendEmailPlugin.txt
Expand Up @@ -63,7 +63,7 @@ Each =Deny= is evaluated after each =Allow=, so Deny settings overrule Allow set
The same rules apply for =MailFrom= and =MailCc=.

---++ Examples
---+++ Example with plain html
---+++ Example with a handcrafted HTML form
%TWISTY{showlink=" Show code" hidelink=" Hide code" showimgleft="%ICONURLPATH{toggleopen}%" hideimgleft="%ICONURLPATH{toggleclose}%" mode="div"}%
<verbatim>
<form enctype="application/x-www-form-urlencoded" name="mailform" action="%SCRIPTURL{sendemail}%/%WEB%/%TOPIC%" method="POST">
Expand Down Expand Up @@ -105,7 +105,6 @@ The same rules apply for =MailFrom= and =MailCc=.
</verbatim>
%ENDTWISTY%


<form enctype="application/x-www-form-urlencoded" name="mailform" action="%SCRIPTURL{sendemail}%/%WEB%/%TOPIC%" method="POST">
<input type="hidden" name="successsection" value="thanks" />
<fieldset>
Expand Down Expand Up @@ -135,12 +134,13 @@ The same rules apply for =MailFrom= and =MailCc=.
</form>
%SENDEMAIL%

<style type="text/css">
%ADDTOHEAD{text="<style type=\"text/css\">
#patternPage fieldset {
border:1px solid #ddd;
padding:1em
}
</style>
"}%

<!--
%STARTSECTION{"thanks"}%
Expand Down Expand Up @@ -350,25 +350,18 @@ Summary: %FORMFIELD{"Summary"}%
| =sendEmailPluginError= | Styles =sendEmailPluginNotification= in case of an error |



---++ Plugin Installation Instructions

__Note:__ You do not need to install anything on the browser to use this
plugin. The following instructions are for the administrator who installs the
plugin on the server where Foswiki is running.

* Download the ZIP file from the Plugin web (see below)
* Unzip ==%TOPIC%.zip== in your Foswiki installation directory. Content:
| *File:* | *Description:* |
%$MANIFEST%
%$INSTALL_INSTRUCTIONS%

---++ Plugin Info

| Plugin Author: | Foswiki:Main.ArthurClemens |
| Copyright: | &copy; 2007-2009 Arthur Clemens; 2008 Michael Daum |
| Copyright: | &copy; 2007-2010 Arthur Clemens; 2008 Michael Daum |
| License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) |
| Plugin Version: | 1.4.1 (29 Mar 2009) |
| Version: | %$VERSION% |
| Release: | %$RELEASE% |
| Change History: | <!-- versions below in reverse order -->&nbsp; |
| 03 Jan 2010 | 1.4.2 Add configure settings to download. |
| 29 Mar 2009 | 1.4.1 Arthur Clemens: removed default restrictions in =Deny= settings so that only the =Allow= setting needs to be set to send emails. |
| 21 Mar 2009 | 1.4 Arthur Clemens: moved topic and hardcoded settings to configure. |
| 12 Mar 2009 | 1.3 Foswiki version. |
Expand Down
2 changes: 1 addition & 1 deletion lib/Foswiki/Plugins/SendEmailPlugin.pm
Expand Up @@ -20,7 +20,7 @@ use strict;
use Foswiki::Func;

our $VERSION = '$Rev: 11069$';
our $RELEASE = '1.4.1';
our $RELEASE = '1.4.2';
our $pluginName = 'SendEmailPlugin';
our $NO_PREFS_IN_TOPIC = 1;

Expand Down
3 changes: 2 additions & 1 deletion lib/Foswiki/Plugins/SendEmailPlugin/Config.spec
@@ -1,4 +1,5 @@
#---+ SendEmailPlugin
#---+ Extensions
#---++ SendEmailPlugin
# **BOOLEAN**
# Enable debugging (debug messages will be written to data/debug.txt)
$Foswiki::cfg{Plugins}{SendEmailPlugin}{Debug} = '0';
Expand Down
43 changes: 30 additions & 13 deletions lib/Foswiki/Plugins/SendEmailPlugin/Core.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (c) 2007-2009 by Arthur Clemens, Michael Daum
# Copyright (c) 2007-2010 by Arthur Clemens, Michael Daum
#
# and Foswiki Contributors. All Rights Reserved. Foswiki Contributors
# are listed in the AUTHORS file in the root of this distribution.
Expand All @@ -22,6 +22,7 @@ package Foswiki::Plugins::SendEmailPlugin::Core;

# Always use strict to enforce variable scoping
use strict;
use Foswiki;
use Foswiki::Func;
use Foswiki::Plugins;

Expand Down Expand Up @@ -69,7 +70,10 @@ sub init {
my $session = shift;
$Foswiki::Plugins::SESSION ||= $session;
my $pluginName = $Foswiki::Plugins::SendEmailPlugin::pluginName;
$debug = $Foswiki::cfg{Plugins}{$pluginName}{Debug} || 0;
$debug =
Foswiki::Func::getPreferencesFlag('SENDEMAILPLUGIN_DEBUG')
|| $Foswiki::cfg{Plugins}{$pluginName}{Debug}
|| 0;
$emailRE = Foswiki::Func::getRegularExpression('emailAddrRegex');
initMessageStrings();
}
Expand Down Expand Up @@ -323,10 +327,11 @@ sub matchesPreference {
writeDebug("matching pattern=$pattern");
writeDebug( "mode=" . ( $mode =~ /Allow/i ? 1 : 0 ) );

if ($mode =~ /Deny/i && !$pattern) {
# no pattern, so noone is denied
return 0;
}
if ( $mode =~ /Deny/i && !$pattern ) {

# no pattern, so noone is denied
return 0;
}

$pattern =~ s/^\s//o;
$pattern =~ s/\s$//o;
Expand All @@ -335,8 +340,8 @@ sub matchesPreference {
writeDebug("final matching pattern=$pattern");

my $result = ( $value =~ /$pattern/ ) ? 1 : 0;
writeDebug( "result=$result");

writeDebug("result=$result");

return $result;
}
Expand Down Expand Up @@ -378,8 +383,18 @@ sub handleSendEmailTag {
( $errorStatus == $ERROR_STATUS{'error'} )
? $feedbackError
: $feedbackSuccess;
$userMessage =~ s/^\s*(.*?)\s*$/$1/go; # remove surrounding spaces

$userMessage =~ s/^[[:space:]]+//s; # trim at start
$userMessage =~ s/[[:space:]]+$//s; # trim at end

my $errorMessage = $query->param($ERROR_MESSAGE_TAG) || '';

#$errorMessage = Foswiki::entityEncode($errorMessage);
# TODO: change newlines to <br />

writeDebug("userMessage=$userMessage");
writeDebug("errorStatus=$errorStatus");
writeDebug("errorMessage=$errorMessage");

return wrapHtmlNotificationContainer( $userMessage, $errorStatus,
$errorMessage, $topic, $web );
Expand Down Expand Up @@ -413,10 +428,11 @@ sub finishSendEmail {

$query->param( -name => 'origurl', -value => $origUrl );

my $section =
$query->param( ( $errorStatus == $ERROR_STATUS{'error'} )
my $section = $query->param(
( $errorStatus == $ERROR_STATUS{'error'} )
? 'errorsection'
: 'successsection' );
: 'successsection'
);

$query->param( -name => 'section', -value => $section )
if $section;
Expand Down Expand Up @@ -462,7 +478,7 @@ sub wrapHtmlNotificationContainer {
else {
my $oopsUrl =
Foswiki::Func::getOopsUrl( $web, $topic, 'oopsgeneric' );
$errorMessage = '<verbatim>' . $errorMessage . '</verbatim>';

my $errorForm = <<'HERE';
<form enctype="application/x-www-form-urlencoded" name="mailerrorfeedbackform" action="%OOPSURL%" method="POST">
<input type="hidden" name="template" value="oopsgeneric" />
Expand All @@ -478,6 +494,7 @@ HERE
$errorForm =~ s/%ERRORMESSAGE%/$errorMessage/go;
$errorForm =~ s/%ERRORBUTTON%/$ERROR_BUTTON_LABEL/go;
$message .= ' ' . $errorForm;
writeDebug("message=$message");
}
}

Expand Down

0 comments on commit b5fddd0

Please sign in to comment.