1
# See bottom of file for copyright and license details
5
---+ package Foswiki::If::OP_allows
9
package Foswiki::If::OP_allows;
10
use base 'Foswiki::Query::BinaryOP';
16
return $class->SUPER::new( name => 'allows', prec => 600 );
22
my $a = $node->{params}->[0]; # topic name (string)
23
my $b = $node->{params}->[1]; # access mode (string)
24
my $mode = $b->_evaluate(@_) || 'view';
26
my $session = $domain{tom}->session;
28
'No context in which to evaluate "' . $a->stringify() . '"' )
30
my $str = $a->evaluate(@_);
33
$session->normalizeWebTopicName( $session->{webName}, $str );
36
if ( $session->{store}->topicExists( $web, $topic ) ) {
38
#try the non-precise name as an existant topic first.
40
$session->security->checkAccessPermission( uc($mode),
41
$session->{user}, undef, undef, $topic, $web );
43
elsif ( $session->{store}->webExists($str) ) {
45
$session->security->checkAccessPermission( uc($mode),
46
$session->{user}, undef, undef, undef, $str );
48
elsif ( $session->{store}->webExists($web) ) {
50
#not an existing topic or web - assume any lone name is a topic without a web specified
52
$session->security->checkAccessPermission( uc($mode),
53
$session->{user}, undef, undef, $topic, $web );
65
Module of Foswiki - The Free and Open Source Wiki, http://foswiki.org/, http://Foswiki.org/
67
# Copyright (C) 2008 Foswiki Contributors. All Rights Reserved.
68
# Foswiki Contributors are listed in the AUTHORS file in the root
69
# of this distribution. NOTE: Please extend that file, not this notice.
71
# Additional copyrights apply to some or all of the code in this
74
# Copyright (C) 2005-2007 TWiki Contributors. All Rights Reserved.
75
# TWiki Contributors are listed in the AUTHORS file in the root
76
# of this distribution. NOTE: Please extend that file, not this notice.
78
This program is free software; you can redistribute it and/or
79
modify it under the terms of the GNU General Public License
80
as published by the Free Software Foundation; either version 2
81
of the License, or (at your option) any later version. For
82
more details read LICENSE in the root of this distribution.
84
This program is distributed in the hope that it will be useful,
85
but WITHOUT ANY WARRANTY; without even the implied warranty of
86
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
88
As per the GPL, removal of this notice is prohibited.
90
Author: Crawford Currie http://c-dot.co.uk
91
# See bottom of file for copyright and license details
95
---+ package Foswiki::If::OP_allows
99
package Foswiki::If::OP_allows;
100
use base 'Foswiki::Query::BinaryOP';
106
return $class->SUPER::new( name => 'allows', prec => 600 );
112
my $a = $node->{params}->[0]; # topic name (string)
113
my $b = $node->{params}->[1]; # access mode (string)
114
my $mode = $b->_evaluate(@_) || 'view';
116
my $session = $domain{tom}->session;
117
throw Error::Simple('No context in which to evaluate "'.
118
$a->stringify().'"') unless $session;
119
my $str = $a->evaluate(@_);
120
return 0 unless $str;
121
my ($web, $topic) = $session->normalizeWebTopicName(
122
$session->{webName}, $str);
124
if ($session->{store}->topicExists($web, $topic)) {
125
#try the non-precise name as an existant topic first.
126
$ok = $session->security->checkAccessPermission(
127
$mode, $session->{user}, undef, undef, $topic, $web);
128
} elsif ($session->{store}->webExists($str)) {
129
$ok = $session->security->checkAccessPermission(
130
$mode, $session->{user}, undef, undef, undef, $str);
131
} elsif ($session->{store}->webExists($web)) {
132
#not an existing topic or web - assume any lone name is a topic without a web specified
133
$ok = $session->security->checkAccessPermission(
134
$mode, $session->{user}, undef, undef, $topic, $web);
145
Module of Foswiki - The Free and Open Source Wiki, http://foswiki.org/, http://Foswiki.org/
147
# Copyright (C) 2008 Foswiki Contributors. All Rights Reserved.
148
# Foswiki Contributors are listed in the AUTHORS file in the root
149
# of this distribution. NOTE: Please extend that file, not this notice.
151
# Additional copyrights apply to some or all of the code in this
154
# Copyright (C) 2005-2007 TWiki Contributors. All Rights Reserved.
155
# TWiki Contributors are listed in the AUTHORS file in the root
156
# of this distribution. NOTE: Please extend that file, not this notice.
158
This program is free software; you can redistribute it and/or
159
modify it under the terms of the GNU General Public License
160
as published by the Free Software Foundation; either version 2
161
of the License, or (at your option) any later version. For
162
more details read LICENSE in the root of this distribution.
164
This program is distributed in the hope that it will be useful,
165
but WITHOUT ANY WARRANTY; without even the implied warranty of
166
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
168
As per the GPL, removal of this notice is prohibited.
170
Author: Crawford Currie http://c-dot.co.uk
171
# See bottom of file for copyright and license details
175
---+ package Foswiki::If::OP_allows
179
package Foswiki::If::OP_allows;
180
use base 'Foswiki::Query::BinaryOP';
186
return $class->SUPER::new( name => 'allows', prec => 600 );
192
my $a = $node->{params}->[0]; # topic name (string)
193
my $b = $node->{params}->[1]; # access mode (string)
194
my $mode = $b->_evaluate(@_) || 'view';
196
my $session = $domain{tom}->session;
197
throw Error::Simple('No context in which to evaluate "'.
198
$a->stringify().'"') unless $session;
199
my $str = $a->evaluate(@_);
200
return 0 unless $str;
201
my ($web, $topic) = $session->normalizeWebTopicName(
202
$session->{webName}, $str);
204
if ($session->{store}->topicExists($web, $topic)) {
205
#try the non-precise name as an existant topic first.
206
$ok = $session->security->checkAccessPermission(
207
$mode, $session->{user}, undef, undef, $topic, $web);
208
} elsif ($session->{store}->webExists($str)) {
209
$ok = $session->security->checkAccessPermission(
210
$mode, $session->{user}, undef, undef, undef, $str);
211
} elsif ($session->{store}->webExists($web)) {
212
#not an existing topic or web - assume any lone name is a topic without a web specified
213
$ok = $session->security->checkAccessPermission(
214
$mode, $session->{user}, undef, undef, $topic, $web);
225
Module of Foswiki - The Free and Open Source Wiki, http://foswiki.org/, http://Foswiki.org/
227
# Copyright (C) 2008-2009 Foswiki Contributors. All Rights Reserved.
228
# Foswiki Contributors are listed in the AUTHORS file in the root
229
# of this distribution. NOTE: Please extend that file, not this notice.
231
# Additional copyrights apply to some or all of the code in this
234
# Copyright (C) 2005-2007 TWiki Contributors. All Rights Reserved.
235
# TWiki Contributors are listed in the AUTHORS file in the root
236
# of this distribution. NOTE: Please extend that file, not this notice.
238
This program is free software; you can redistribute it and/or
239
modify it under the terms of the GNU General Public License
240
as published by the Free Software Foundation; either version 2
241
of the License, or (at your option) any later version. For
242
more details read LICENSE in the root of this distribution.
244
This program is distributed in the hope that it will be useful,
245
but WITHOUT ANY WARRANTY; without even the implied warranty of
246
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
248
As per the GPL, removal of this notice is prohibited.
250
Author: Crawford Currie http://c-dot.co.uk