1 rizwank 1.1 # See Plugin topic for history and plugin information
2 package TWiki::Plugins::CommentPlugin;
3
4 use strict;
5 use integer;
6
7 use TWiki::Plugins::CommentPlugin::Comment;
8 use TWiki::Func;
9
10 use vars qw( $VERSION $firstCall );
11
12 BEGIN {
13 $VERSION = '3.003';
14 $firstCall = 0;
15 }
16
17 sub initPlugin {
18 #my ( $topic, $web, $user, $installWeb ) = @_;
19
20 if( $TWiki::Plugins::VERSION < 1.010 ) {
21 TWiki::Func::writeWarning( "Version mismatch between CommentPlugin and Plugins.pm $TWiki::Plugins::VERSION" );
22 rizwank 1.1 return 0;
23 }
24 if( $TWiki::Plugins::VERSION < 1.020 ) {
25 TWiki::Func::writeWarning( "Version mismatch between ActionTrackerPlugin and Plugins.pm $TWiki::Plugins::VERSION. Will not work without compatability module." );
26 }
27 $firstCall = 1;
28
29 return 1;
30 }
31
32 sub commonTagsHandler {
33 ### my ( $text, $topic, $web ) = @_;
34
35 my $query = TWiki::Func::getCgiQuery();
36 return unless( defined( $query ));
37 my $action = $query->param( 'comment_action' ) || "";
38 if ( defined( $action ) && $action eq "save" &&
39 $query->path_info() eq "/$_[2]/$_[1]" ) {
40 # $firstCall ensures we only save once, ever.
41 if ( $firstCall ) {
42 $firstCall = 0;
43 rizwank 1.1 CommentPlugin::Comment::save( $_[2], $_[1], $query );
44 }
45 } elsif ( $_[0] =~ m/%COMMENT({.*?})?%/o ) {
46 # Nasty, tacky way to find out where we were invoked from
47 my $scriptname = $ENV{'SCRIPT_NAME'} || "";
48 my $previewing = ($scriptname =~ /\/preview/ ||
49 $scriptname =~ /\/gnusave/);
50 CommentPlugin::Comment::prompt( $previewing, @_ );
51 }
52 }
53
54 1;
|