Skip to content

Commit

Permalink
Item12009: move CHANGE access check from _newTag() to _addTag()
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/TagMePlugin@15221 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
FlorianSchlichting authored and FlorianSchlichting committed Jul 27, 2012
1 parent 976f3c6 commit 7658a7f
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions lib/Foswiki/Plugins/TagMePlugin.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1099,13 +1099,9 @@ sub _newTag {
my $note = $attr->{note} || '';
my $silent = $attr->{silent} || '';

my $topicObject =
Foswiki::Meta->new( $Foswiki::Plugins::SESSION, $web, $topic );

if ( !$topicObject->haveAccess('CHANGE') ) {
return _wrapHtmlErrorFeedbackMessage( "<nop>$user cannot add new tags",
$note );
}
return _wrapHtmlErrorFeedbackMessage( "<nop>$user cannot add new tags",
$note )
if ( $user =~ /^(WikiGuest|guest)$/ );

$tag = _makeSafeTag($tag);

Expand Down Expand Up @@ -1169,7 +1165,22 @@ sub _addTag {
my $num = '';
my $users = '';
my @result = ();
if ( Foswiki::Func::topicExists( $web, $topic ) ) {

# check if topic exists, and if the user has CHANGE permission
if ( !Foswiki::Func::topicExists( $web, $topic ) ) {
$text .=
_wrapHtmlFeedbackErrorInline("tag not added, topic does not exist");
}
else {
my $topicObject =
Foswiki::Meta->new( $Foswiki::Plugins::SESSION, $web, $topic );
$text .= _wrapHtmlFeedbackErrorInline("<nop>$user cannot add new tags")
if ( !$topicObject->haveAccess('CHANGE') );
}

unless ($text) {

# checks completed ok
foreach my $line (@tagInfo) {
if ( $line =~ /$lineRegex/ ) {
$num = $1;
Expand Down Expand Up @@ -1207,10 +1218,6 @@ sub _addTag {
@tagInfo = reverse sort(@result);
_writeTagInfo( $webTopic, @tagInfo );
}
else {
$text .=
_wrapHtmlFeedbackErrorInline("tag not added, topic does not exist");
}

# Suppress status? FWM, 03-Oct-2006
return _showDefault(@tagInfo) . ( ($noStatus) ? '' : $text );
Expand Down

0 comments on commit 7658a7f

Please sign in to comment.