Filename | /var/www/foswikidev/core/lib/Foswiki/If/OP_ingroup.pm |
Statements | Executed 11 statements in 292µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 17µs | 23µs | new | Foswiki::If::OP_ingroup::
1 | 1 | 1 | 12µs | 25µs | BEGIN@12 | Foswiki::If::OP_ingroup::
1 | 1 | 1 | 9µs | 13µs | BEGIN@13 | Foswiki::If::OP_ingroup::
1 | 1 | 1 | 4µs | 4µs | BEGIN@15 | Foswiki::If::OP_ingroup::
1 | 1 | 1 | 4µs | 4µs | BEGIN@18 | 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 | 30µs | 2 | 37µs | # spent 25µs (12+13) within Foswiki::If::OP_ingroup::BEGIN@12 which was called:
# once (12µs+13µs) by Foswiki::If::Parser::BEGIN@26 at line 12 # spent 25µs making 1 call to Foswiki::If::OP_ingroup::BEGIN@12
# spent 13µs making 1 call to strict::import |
13 | 2 | 30µs | 2 | 17µs | # spent 13µs (9+4) within Foswiki::If::OP_ingroup::BEGIN@13 which was called:
# once (9µs+4µs) by Foswiki::If::Parser::BEGIN@26 at line 13 # spent 13µs making 1 call to Foswiki::If::OP_ingroup::BEGIN@13
# spent 4µs making 1 call to warnings::import |
14 | |||||
15 | 2 | 49µs | 1 | 4µs | # spent 4µs within Foswiki::If::OP_ingroup::BEGIN@15 which was called:
# once (4µs+0s) by Foswiki::If::Parser::BEGIN@26 at line 15 # spent 4µs making 1 call to Foswiki::If::OP_ingroup::BEGIN@15 |
16 | 1 | 6µs | our @ISA = ('Foswiki::Query::OP'); | ||
17 | |||||
18 | # spent 4µs within Foswiki::If::OP_ingroup::BEGIN@18 which was called:
# once (4µs+0s) by Foswiki::If::Parser::BEGIN@26 at line 23 | ||||
19 | 1 | 4µs | if ( $Foswiki::cfg{UseLocale} ) { | ||
20 | require locale; | ||||
21 | import locale(); | ||||
22 | } | ||||
23 | 1 | 153µs | 1 | 4µs | } # spent 4µs making 1 call to Foswiki::If::OP_ingroup::BEGIN@18 |
24 | |||||
25 | # spent 23µs (17+6) within Foswiki::If::OP_ingroup::new which was called:
# once (17µs+6µs) by Foswiki::If::Parser::new at line 49 of /var/www/foswikidev/core/lib/Foswiki/If/Parser.pm | ||||
26 | 1 | 300ns | my $class = shift; | ||
27 | 1 | 16µs | 1 | 6µs | return $class->SUPER::new( # spent 6µs making 1 call to Foswiki::Query::OP::new |
28 | arity => 2, | ||||
29 | name => 'ingroup', | ||||
30 | prec => 600, | ||||
31 | casematters => 1 | ||||
32 | ); | ||||
33 | } | ||||
34 | |||||
35 | sub evaluate { | ||||
36 | my $this = shift; | ||||
37 | my $node = shift; | ||||
38 | my $a = | ||||
39 | $node->{params}->[0] | ||||
40 | ; # user cUID/ loginname / WikiName / WebDotWikiName :( (string) | ||||
41 | my $b = $node->{params}->[1]; # group name (string | ||||
42 | my %domain = @_; | ||||
43 | my $session = $domain{tom}->session; | ||||
44 | throw Error::Simple( | ||||
45 | 'No context in which to evaluate "' . $a->stringify() . '"' ) | ||||
46 | unless $session; | ||||
47 | my $user = $session->{users}->getCanonicalUserID( $a->evaluate(@_) ); | ||||
48 | return 0 unless $user; | ||||
49 | my $group = $b->_evaluate(@_); | ||||
50 | return 0 unless $group; | ||||
51 | return 1 if ( $session->{users}->isInGroup( $user, $group ) ); | ||||
52 | return 0; | ||||
53 | } | ||||
54 | |||||
55 | 1 | 3µs | 1; | ||
56 | __END__ |