Filename | /usr/local/src/github.com/foswiki/core/lib/Foswiki/If/OP_ingroup.pm |
Statements | Executed 10 statements in 428µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 28µs | 43µs | new | Foswiki::If::OP_ingroup::
1 | 1 | 1 | 28µs | 35µs | BEGIN@12 | Foswiki::If::OP_ingroup::
1 | 1 | 1 | 16µs | 33µs | BEGIN@13 | Foswiki::If::OP_ingroup::
1 | 1 | 1 | 9µs | 9µs | BEGIN@15 | Foswiki::If::OP_ingroup::
0 | 0 | 0 | 0s | 0s | evaluate | Foswiki::If::OP_ingroup::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # See bottom of file for license and copyright information | ||||
2 | |||||
3 | =begin TML | ||||
4 | |||||
5 | ---+ package Foswiki::If::OP_ingroup | ||||
6 | Test if the user named on the LHS is in the user group named on the RHS. | ||||
7 | |||||
8 | =cut | ||||
9 | |||||
10 | package Foswiki::If::OP_ingroup; | ||||
11 | |||||
12 | 2 | 45µs | 2 | 42µs | # spent 35µs (28+7) within Foswiki::If::OP_ingroup::BEGIN@12 which was called:
# once (28µs+7µs) by Foswiki::If::Parser::BEGIN@26 at line 12 # spent 35µs making 1 call to Foswiki::If::OP_ingroup::BEGIN@12
# spent 7µs making 1 call to strict::import |
13 | 2 | 44µs | 2 | 49µs | # spent 33µs (16+17) within Foswiki::If::OP_ingroup::BEGIN@13 which was called:
# once (16µs+17µs) by Foswiki::If::Parser::BEGIN@26 at line 13 # spent 33µs making 1 call to Foswiki::If::OP_ingroup::BEGIN@13
# spent 17µs making 1 call to warnings::import |
14 | |||||
15 | 2 | 298µs | 1 | 9µs | # spent 9µs within Foswiki::If::OP_ingroup::BEGIN@15 which was called:
# once (9µs+0s) by Foswiki::If::Parser::BEGIN@26 at line 15 # spent 9µs making 1 call to Foswiki::If::OP_ingroup::BEGIN@15 |
16 | 1 | 10µs | our @ISA = ('Foswiki::Query::OP'); | ||
17 | |||||
18 | # spent 43µs (28+15) within Foswiki::If::OP_ingroup::new which was called:
# once (28µs+15µs) by Foswiki::If::Parser::new at line 42 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/If/Parser.pm | ||||
19 | 2 | 27µs | my $class = shift; | ||
20 | 1 | 14µs | return $class->SUPER::new( # spent 14µs making 1 call to Foswiki::Query::OP::new | ||
21 | arity => 2, | ||||
22 | name => 'ingroup', | ||||
23 | prec => 600, | ||||
24 | casematters => 1 | ||||
25 | ); | ||||
26 | } | ||||
27 | |||||
28 | sub evaluate { | ||||
29 | my $this = shift; | ||||
30 | my $node = shift; | ||||
31 | my $a = | ||||
32 | $node->{params}->[0] | ||||
33 | ; # user cUID/ loginname / WikiName / WebDotWikiName :( (string) | ||||
34 | my $b = $node->{params}->[1]; # group name (string | ||||
35 | my %domain = @_; | ||||
36 | my $session = $domain{tom}->session; | ||||
37 | throw Error::Simple( | ||||
38 | 'No context in which to evaluate "' . $a->stringify() . '"' ) | ||||
39 | unless $session; | ||||
40 | my $user = $session->{users}->getCanonicalUserID( $a->evaluate(@_) ); | ||||
41 | return 0 unless $user; | ||||
42 | my $group = $b->_evaluate(@_); | ||||
43 | return 0 unless $group; | ||||
44 | return 1 if ( $session->{users}->isInGroup( $user, $group ) ); | ||||
45 | return 0; | ||||
46 | } | ||||
47 | |||||
48 | 1 | 6µs | 1; | ||
49 | __END__ |