Skip to content

Commit

Permalink
Item1709: Applying the porting and fixing done by Don Wennick
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/SignaturePlugin@4097 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
KennethLavrsen authored and KennethLavrsen committed Jun 11, 2009
1 parent f41c708 commit 070300b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 23 deletions.
33 changes: 17 additions & 16 deletions data/System/SignaturePlugin.txt
@@ -1,48 +1,49 @@
%META:TOPICINFO{author="ProjectContributor" date="1111929255" format="1.0" version="8"}%
%META:TOPICINFO{author="donw" date="1244670250" format="1.1" reprev="1.2" version="1.2"}%
---+ Signature Plugin

This plugin supports a simple tag which appears as a button with the label given by the =SIGNATURELABEL= setting. When clicked, it is replaced by the text given in the =SIGNATUREFORMAT= setting (this is typically the name of the logged in user and the current date).


---++ Syntax Rules

Insert the tag %<nop>SIGNATURE% anywhere in the topic, as many times as you like. Each such tag will create a signature button.

The following parameters are supported for the %<nop>SIGNATURE% tag.

| *Parameter:* | *Description:* | *Default:* |
| ="name"= | The wiki name of a user or group or a list of users/groups. Only these users or members of these groups are allowed to sign here. | |
| ="format"= | The signature format for this particular signature. The syntax is the same as for the setting variable =SIGNATUREFORMAT=. | |
| *Parameter:* | *Description:* | *Default:* |
| ="name"= | The wiki name of a user or group or a list of users/groups. Only these users or members of these groups are allowed to sign here. | |
| ="format"= | The signature format for this particular signature. The syntax is the same as for the setting variable =SIGNATUREFORMAT=. | |

---++ Plugin Settings

Plugin settings are stored as preferences variables. To reference
a plugin setting write ==%<nop>&lt;plugin&gt;_&lt;setting&gt;%==, i.e. ==%<nop>SIGNATUREPLUGIN_SHORTDESCRIPTION%==
* Format of the signature line. The variables =$wikiusername=, =$wikiname=, $username, and =$date= can be used, indicating the WikiName of the logged in user prefixed with the user web, the WikiName of the logged in user, the login name of the logged in user, and the date of signing, respectively.
Plugin settings are stored as preferences variables. To reference a plugin setting write ==%<nop>&lt;plugin&gt;_&lt;setting&gt;%==, i.e. ==%<nop>SIGNATUREPLUGIN_SHORTDESCRIPTION%==
* Format of the signature line. The variables =$wikiusername=, =$wikiname=, $username, and =$date= can be used, indicating the WikiName of the logged in user prefixed with the user web, the WikiName of the logged in user, the login name of the logged in user, and the date of signing, respectively.
* Set SIGNATUREFORMAT = $wikiusername - $date
* Label of the signature button
* Label of the signature button
* Set SIGNATURELABEL = Sign

* One line description, is shown in the %SYSTEMWEB%.TextFormattingRules topic:
* One line description, is shown in the %SYSTEMWEB%.TextFormattingRules topic:
* Set SHORTDESCRIPTION = Supports electronic signatures

---++ Plugin Installation Instructions
%$INSTALL_INSTRUCTIONS%
You do not need to install anything in the browser to use this extension. The following instructions are for the administrator who installs the extension on the server.

Open configure, and open the "Extensions" section. Use "Find More Extensions" to get a list of available extensions. Select "Install".

* If installed correctly you should see a button with the label indicated by the setting below.
If you have any problems, or if the extension isn't available in =configure=, then you can still install manually from the command-line. See http://foswiki.org/Support/ManuallyInstallingExtensions for more help.

* If installed correctly you should see a button with the label indicated by the setting below.
%SIGNATURE{name="AdminGroup"}%

---++ Plugin Info

| Plugin Author: | TWiki:Main/ThomasWeigert |
| Copyright: | &copy; 2006, Motorola |
| Copyright: | 2006, Motorola |
| License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) |
| Plugin Version: | 19 Nov 2006 |
| Change History: | <!-- versions below in reverse order -->&nbsp; |
| Change History: | <!-- versions below in reverse order --> |
| 09 Jun 2009: | Updated for Foswiki namespace and API, fixed groups in the name list (Main.DonWennick) |
| 03 Dec 2008: | FoswikibugLItem6109: recoded to avoid use of unpublished APIs (Crawford Currie) |
| 19 Nov 2006: | Support user designation and user-specific format. |
| 01 Aug 2006: | Initial release |
| Dependencies: | %$DEPENDENCIES% |
| Dependencies: | None |
| Plugin Home: | http://foswiki.org/Extensions/%TOPIC% |

6 changes: 3 additions & 3 deletions lib/Foswiki/Plugins/SignaturePlugin.pm
Expand Up @@ -23,10 +23,10 @@ use strict;
# *must* exist in this package
use vars qw( $VERSION $RELEASE $pluginName );

# This should always be $Rev: 0$ so that TWiki can determine the checked-in
# This should always be $Rev$ so that TWiki can determine the checked-in
# status of the plugin. It is used by the build automation tools, so
# you should leave it alone.
$VERSION = '$Rev: 0$';
$VERSION = '$Rev$';

# This is a free-form string you can use to "name" your own plugin version.
# It is *not* used by the build automation tools, but is reported as part
Expand All @@ -41,7 +41,7 @@ sub initPlugin {

if ( $Foswiki::Plugins::VERSION < 1.1 ) {
Foswiki::Func::writeWarning(
"This version of $pluginName works only with TWiki 4 and greater.");
"This version of $pluginName works only with Foswiki 1.0 and greater.");
return 0;
}

Expand Down
15 changes: 11 additions & 4 deletions lib/Foswiki/Plugins/SignaturePlugin/Signature.pm
Expand Up @@ -69,7 +69,14 @@ sub replaceSignature {

my $wuser = Foswiki::Func::getWikiName($user);
my %list = map { s/.*\.//; $_ => 1 } split( /[, ]+/, $attr->{name} );
foreach my $n (%list) {
if (Foswiki::Func::isGroup($n) || Foswiki::Func::isGroupMember($n,$wuser)) {
$list{$wuser} = 1;
}
}

unless ( !$attr->{name} || $list{$wuser} ) {
use Foswiki::OopsException;
my $session = $Foswiki::Plugins::SESSION;
Foswiki::Func::setTopicEditLock( $session->{webName},
$session->{topicName}, 0 ); # unlock Topic
Expand Down Expand Up @@ -98,9 +105,9 @@ sub replaceSignature {
my $ourDate = sprintf( '%02d %s %d', $d, $months[$m], $y );

$fmt =~ s/\$quot/\"/go;
$fmt =~ s/\$wikiusername/$user->webDotWikiName()/geo;
$fmt =~ s/\$wikiname/$user->wikiName()/geo;
$fmt =~ s/\$username/$user->login()/geo;
$fmt =~ s/\$wikiusername/&TWiki::Func::getWikiUserName($user)/geo;
$fmt =~ s/\$wikiname/&TWiki::Func::getWikiName($user)/geo;
$fmt =~ s/\$username/$user/geo;
$fmt =~ s/\$date/$ourDate/geo;

return $fmt;
Expand Down Expand Up @@ -132,7 +139,7 @@ sub doEnableEdit {
## SMELL: Update for TWiki 4.1 =checkTopicEditLock=
my ( $oopsUrl, $lockUser ) =
&Foswiki::Func::checkTopicEditLock( $theWeb, $theTopic, 'edit' );
if ( $lockUser && !( $lockUser eq $user->login ) ) {
if ( $lockUser && !( $lockUser eq $user ) ) {

# warn user that other person is editing this topic
&Foswiki::Func::redirectCgiQuery( $query, $oopsUrl );
Expand Down

0 comments on commit 070300b

Please sign in to comment.