Filename | /var/www/foswikidev/core/lib/Foswiki/Macros/USERINFO.pm |
Statements | Executed 209 statements in 1.03ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
11 | 3 | 3 | 169µs | 379µs | USERINFO | Foswiki::
11 | 1 | 1 | 52µs | 164µs | _USERINFO_token | Foswiki::
7 | 1 | 1 | 39µs | 57µs | __ANON__[:42] | Foswiki::
2 | 1 | 1 | 17µs | 23µs | __ANON__[:26] | Foswiki::
1 | 1 | 1 | 16µs | 29µs | BEGIN@4.103 | Foswiki::
2 | 1 | 1 | 13µs | 33µs | __ANON__[:51] | Foswiki::
1 | 1 | 1 | 10µs | 14µs | BEGIN@5.104 | Foswiki::
1 | 1 | 1 | 4µs | 4µs | BEGIN@7.105 | Foswiki::
0 | 0 | 0 | 0s | 0s | __ANON__[:34] | Foswiki::
0 | 0 | 0 | 0s | 0s | __ANON__[:57] | Foswiki::
0 | 0 | 0 | 0s | 0s | __ANON__[:71] | Foswiki::
0 | 0 | 0 | 0s | 0s | __ANON__[:79] | Foswiki::
0 | 0 | 0 | 0s | 0s | __ANON__[:87] | Foswiki::
0 | 0 | 0 | 0s | 0s | __ANON__[:92] | Foswiki::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # See bottom of file for license and copyright information | ||||
2 | package Foswiki; | ||||
3 | |||||
4 | 2 | 26µs | 2 | 41µs | # spent 29µs (16+12) within Foswiki::BEGIN@4.103 which was called:
# once (16µs+12µs) by Foswiki::_expandMacroOnTopicRendering at line 4 # spent 29µs making 1 call to Foswiki::BEGIN@4.103
# spent 12µs making 1 call to strict::import |
5 | 2 | 45µs | 2 | 18µs | # spent 14µs (10+4) within Foswiki::BEGIN@5.104 which was called:
# once (10µs+4µs) by Foswiki::_expandMacroOnTopicRendering at line 5 # spent 14µs making 1 call to Foswiki::BEGIN@5.104
# spent 4µs making 1 call to warnings::import |
6 | |||||
7 | # spent 4µs within Foswiki::BEGIN@7.105 which was called:
# once (4µs+0s) by Foswiki::_expandMacroOnTopicRendering at line 12 | ||||
8 | 1 | 5µs | if ( $Foswiki::cfg{UseLocale} ) { | ||
9 | require locale; | ||||
10 | import locale(); | ||||
11 | } | ||||
12 | 1 | 654µs | 1 | 4µs | } # spent 4µs making 1 call to Foswiki::BEGIN@7.105 |
13 | |||||
14 | # Set to true if user details should be cloaked. Selected tokens will return an empty string. | ||||
15 | 1 | 400ns | my $USERINFO_cloak = 0; | ||
16 | |||||
17 | my %USERINFO_tokens = ( | ||||
18 | # spent 23µs (17+7) within Foswiki::__ANON__[/var/www/foswikidev/core/lib/Foswiki/Macros/USERINFO.pm:26] which was called 2 times, avg 12µs/call:
# 2 times (17µs+7µs) by Foswiki::_USERINFO_token at line 145, avg 12µs/call | ||||
19 | 2 | 1µs | my ( $this, $user ) = @_; | ||
20 | 2 | 500ns | return '' if ($USERINFO_cloak); | ||
21 | |||||
22 | 2 | 5µs | 2 | 6µs | my $username = $this->{users}->getLoginName($user); # spent 6µs making 2 calls to Foswiki::Users::getLoginName, avg 3µs/call |
23 | 2 | 200ns | $username = 'unknown' unless defined $username; | ||
24 | |||||
25 | 2 | 6µs | return $username; | ||
26 | }, | ||||
27 | |||||
28 | # Item2466: There is some usage of this undocumented token in VariableTests | ||||
29 | cUID => sub { | ||||
30 | my ( $this, $user ) = @_; | ||||
31 | |||||
32 | return '' if ($USERINFO_cloak); | ||||
33 | return $user; | ||||
34 | }, | ||||
35 | # spent 57µs (39+18) within Foswiki::__ANON__[/var/www/foswikidev/core/lib/Foswiki/Macros/USERINFO.pm:42] which was called 7 times, avg 8µs/call:
# 7 times (39µs+18µs) by Foswiki::_USERINFO_token at line 145, avg 8µs/call | ||||
36 | 7 | 3µs | my ( $this, $user ) = @_; | ||
37 | 7 | 11µs | 7 | 18µs | my $wikiname = $this->{users}->getWikiName($user); # spent 18µs making 7 calls to Foswiki::Users::getWikiName, avg 2µs/call |
38 | |||||
39 | 7 | 800ns | $wikiname = 'UnknownUser' unless defined $wikiname; | ||
40 | |||||
41 | 7 | 16µs | return $wikiname; | ||
42 | }, | ||||
43 | # spent 33µs (13+20) within Foswiki::__ANON__[/var/www/foswikidev/core/lib/Foswiki/Macros/USERINFO.pm:51] which was called 2 times, avg 16µs/call:
# 2 times (13µs+20µs) by Foswiki::_USERINFO_token at line 145, avg 16µs/call | ||||
44 | 2 | 1µs | my ( $this, $user ) = @_; | ||
45 | 2 | 5µs | 2 | 20µs | my $wikiusername = $this->{users}->webDotWikiName($user); # spent 20µs making 2 calls to Foswiki::Users::webDotWikiName, avg 10µs/call |
46 | |||||
47 | 2 | 300ns | $wikiusername = "$Foswiki::cfg{UsersWebName}.UnknownUser" | ||
48 | unless defined $wikiusername; | ||||
49 | |||||
50 | 2 | 6µs | return $wikiusername; | ||
51 | }, | ||||
52 | emails => sub { | ||||
53 | my ( $this, $user ) = @_; | ||||
54 | |||||
55 | return '' if ($USERINFO_cloak); | ||||
56 | return join( ', ', $this->{users}->getEmails($user) ); | ||||
57 | }, | ||||
58 | groups => sub { | ||||
59 | my ( $this, $user ) = @_; | ||||
60 | my @groupNames; | ||||
61 | return '' if ($USERINFO_cloak); | ||||
62 | |||||
63 | my $it = $this->{users}->eachMembership($user); | ||||
64 | |||||
65 | while ( $it->hasNext() ) { | ||||
66 | my $group = $it->next(); | ||||
67 | push( @groupNames, $group ); | ||||
68 | } | ||||
69 | |||||
70 | return join( ', ', @groupNames ); | ||||
71 | }, | ||||
72 | |||||
73 | # Item2466: $admin was re-documented as $isadmin November 2011, do not remove | ||||
74 | admin => sub { | ||||
75 | my ( $this, $user ) = @_; | ||||
76 | |||||
77 | return '' if ($USERINFO_cloak); | ||||
78 | return $this->{users}->isAdmin($user) ? 'true' : 'false'; | ||||
79 | }, | ||||
80 | |||||
81 | # Item2466: $isadmin & $isgroup added November 2011 | ||||
82 | isadmin => sub { | ||||
83 | my ( $this, $user ) = @_; | ||||
84 | |||||
85 | return '' if ($USERINFO_cloak); | ||||
86 | return $this->{users}->isAdmin($user) ? 'true' : 'false'; | ||||
87 | }, | ||||
88 | isgroup => sub { | ||||
89 | my ( $this, $user ) = @_; | ||||
90 | |||||
91 | return $this->{users}->isGroup($user) ? 'true' : 'false'; | ||||
92 | } | ||||
93 | 1 | 21µs | ); | ||
94 | 1 | 4µs | my $USERINFO_tokenregex = join( '|', keys %USERINFO_tokens ); | ||
95 | |||||
96 | # spent 379µs (169+210) within Foswiki::USERINFO which was called 11 times, avg 34µs/call:
# 7 times (88µs+113µs) by Foswiki::WIKINAME at line 22 of /var/www/foswikidev/core/lib/Foswiki/Macros/WIKINAME.pm, avg 29µs/call
# 2 times (52µs+55µs) by Foswiki::WIKIUSERNAME at line 22 of /var/www/foswikidev/core/lib/Foswiki/Macros/WIKIUSERNAME.pm, avg 54µs/call
# 2 times (29µs+42µs) by Foswiki::USERNAME at line 23 of /var/www/foswikidev/core/lib/Foswiki/Macros/USERNAME.pm, avg 35µs/call | ||||
97 | 11 | 4µs | my ( $this, $params ) = @_; | ||
98 | 11 | 4µs | my $format = $params->{format} || '$username, $wikiusername, $emails'; | ||
99 | 11 | 4µs | my $user = $this->{user}; | ||
100 | 11 | 1µs | my $info = $format; | ||
101 | |||||
102 | 11 | 4µs | if ( $params->{_DEFAULT} ) { | ||
103 | $user = $params->{_DEFAULT}; | ||||
104 | return '' if !$user; | ||||
105 | |||||
106 | # map wikiname to a login name | ||||
107 | my $cuid = $this->{users}->getCanonicalUserID($user); | ||||
108 | if ( !$cuid ) { | ||||
109 | |||||
110 | # Failed to get a cUID: if it's a group, leave $user alone | ||||
111 | if ( !$this->{users}->isGroup($user) ) { | ||||
112 | return ''; | ||||
113 | } | ||||
114 | } | ||||
115 | else { | ||||
116 | $user = $cuid; | ||||
117 | } | ||||
118 | return '' unless $user; | ||||
119 | |||||
120 | $USERINFO_cloak = | ||||
121 | ( $Foswiki::cfg{AntiSpam}{HideUserDetails} | ||||
122 | && !$this->{users}->isAdmin( $this->{user} ) | ||||
123 | && $user ne $this->{user} ); | ||||
124 | } | ||||
125 | else { | ||||
126 | 11 | 3µs | $USERINFO_cloak = 0; | ||
127 | } | ||||
128 | |||||
129 | 11 | 1µs | return '' unless $user; | ||
130 | |||||
131 | 22 | 88µs | 11 | 164µs | $info =~ s/\$($USERINFO_tokenregex)/$this->_USERINFO_token($1, $user)/ge; # spent 164µs making 11 calls to Foswiki::_USERINFO_token, avg 15µs/call |
132 | 11 | 17µs | 11 | 45µs | $info = Foswiki::expandStandardEscapes($info); # spent 45µs making 11 calls to Foswiki::expandStandardEscapes, avg 4µs/call |
133 | |||||
134 | 11 | 30µs | return $info; | ||
135 | } | ||||
136 | |||||
137 | # spent 164µs (52+113) within Foswiki::_USERINFO_token which was called 11 times, avg 15µs/call:
# 11 times (52µs+113µs) by Foswiki::USERINFO at line 131, avg 15µs/call | ||||
138 | 11 | 12µs | my ( $this, $token, $user ) = @_; | ||
139 | |||||
140 | ASSERT($token) if DEBUG; | ||||
141 | 11 | 800ns | ASSERT( ref( $USERINFO_tokens{$token} ) eq 'CODE', | ||
142 | "No code for token '$token'" ) | ||||
143 | if DEBUG; | ||||
144 | |||||
145 | 11 | 40µs | 11 | 113µs | return $USERINFO_tokens{$token}->( $this, $user ); # spent 57µs making 7 calls to Foswiki::__ANON__[/var/www/foswikidev/core/lib/Foswiki/Macros/USERINFO.pm:42], avg 8µs/call
# spent 33µs making 2 calls to Foswiki::__ANON__[/var/www/foswikidev/core/lib/Foswiki/Macros/USERINFO.pm:51], avg 16µs/call
# spent 23µs making 2 calls to Foswiki::__ANON__[/var/www/foswikidev/core/lib/Foswiki/Macros/USERINFO.pm:26], avg 12µs/call |
146 | } | ||||
147 | |||||
148 | 1 | 5µs | 1; | ||
149 | __END__ |