Skip to content

Commit

Permalink
Item9318: fix failing test
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk@8175 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
CrawfordCurrie authored and CrawfordCurrie committed Jul 14, 2010
1 parent 7a09a91 commit 413cf04
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions core/lib/Foswiki/Func.pm
Expand Up @@ -56,6 +56,7 @@ use Assert;
use Foswiki ();
use Foswiki::Plugins ();
use Foswiki::Meta ();
use Foswiki::AccessControlException ();

=begin TML
Expand Down Expand Up @@ -1132,12 +1133,12 @@ use Foswiki::AccessControlException ();
try {
Foswiki::Func::createWeb( "Newweb" );
} catch Error::Simple with {
my $e = shift;
# see documentation on Error::Simple
} catch Foswiki::AccessControlException with {
my $e = shift;
# see documentation on Foswiki::AccessControlException
} catch Error::Simple with {
my $e = shift;
# see documentation on Error::Simple
} otherwise {
...
};
Expand Down Expand Up @@ -1166,12 +1167,12 @@ use Foswiki::AccessControlException ();
try {
Foswiki::Func::moveWeb( "Oldweb", "Newweb" );
} catch Error::Simple with {
my $e = shift;
# see documentation on Error::Simple
} catch Foswiki::AccessControlException with {
my $e = shift;
# see documentation on Foswiki::AccessControlException
} catch Error::Simple with {
my $e = shift;
# see documentation on Error::Simple
} otherwise {
...
};
Expand Down Expand Up @@ -1458,12 +1459,12 @@ use Error qw( :try );
try {
moveTopic( "Work", "TokyoOffice", "Trash", "ClosedOffice" );
} catch Error::Simple with {
my $e = shift;
# see documentation on Error::Simple
} catch Foswiki::AccessControlException with {
my $e = shift;
# see documentation on Foswiki::AccessControlException
} catch Error::Simple with {
my $e = shift;
# see documentation on Error::Simple
} otherwise {
...
};
Expand Down Expand Up @@ -1698,14 +1699,18 @@ Create an attachment on the given topic.
| =filedate= | Date |
| =createlink= | Set true to create a link at the end of the topic |
| =notopicchange= | Set to true to *prevent* this upload being recorded in the meta-data of the topic. |
Save an attachment to the store for a topic. On success, returns undef. If there is an error, an exception will be thrown.
Save an attachment to the store for a topic. On success, returns undef.
If there is an error, an exception will be thrown. The current user must
have CHANGE access on the topic being attached to.
<verbatim>
try {
Foswiki::Func::saveAttachment( $web, $topic, 'image.gif',
{ file => 'image.gif',
comment => 'Picture of Health',
hide => 1 } );
} catch Foswiki::AccessControlException with {
# Topic CHANGE access denied
} catch Error::Simple with {
# see documentation on Error
} otherwise {
Expand All @@ -1720,13 +1725,16 @@ This is the way 99% of extensions will create new attachments. See
sub saveAttachment {
my ( $web, $topic, $name, $data ) = @_;
ASSERT($Foswiki::Plugins::SESSION) if DEBUG;
my $result = undef;
my $meta = Foswiki::Meta->load( $Foswiki::Plugins::SESSION, $web, $topic );

# SMELL: check access controls?
$meta->attach( name => $name, %$data );

return $result;
my $meta = Foswiki::Meta->load( $Foswiki::Plugins::SESSION, $web, $topic );
my $topicObject =
Foswiki::Meta->new( $Foswiki::Plugins::SESSION, $web, $topic );
unless ( $topicObject->haveAccess('CHANGE') ) {
throw Foswiki::AccessControlException( 'CHANGE',
$Foswiki::Plugins::SESSION->{user},
$web, $topic, $Foswiki::Meta::reason );
}
$topicObject->attach( name => $name, %$data );
}

=begin TML
Expand Down

0 comments on commit 413cf04

Please sign in to comment.