Filename | /var/www/foswikidev/core/lib/Foswiki/Plugins/HomePagePlugin.pm |
Statements | Executed 17 statements in 505µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 13µs | 27µs | BEGIN@10 | Foswiki::Plugins::HomePagePlugin::
1 | 1 | 1 | 13µs | 17µs | initializeUserHandler | Foswiki::Plugins::HomePagePlugin::
1 | 1 | 1 | 11µs | 15µs | BEGIN@11 | Foswiki::Plugins::HomePagePlugin::
1 | 1 | 1 | 5µs | 5µs | initPlugin | Foswiki::Plugins::HomePagePlugin::
1 | 1 | 1 | 4µs | 4µs | BEGIN@13 | Foswiki::Plugins::HomePagePlugin::
1 | 1 | 1 | 4µs | 4µs | BEGIN@14 | Foswiki::Plugins::HomePagePlugin::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | |||||
2 | =pod | ||||
3 | |||||
4 | ---+ package Foswiki::Plugins::HomePagePlugin | ||||
5 | |||||
6 | =cut | ||||
7 | |||||
8 | package Foswiki::Plugins::HomePagePlugin; | ||||
9 | |||||
10 | 2 | 33µs | 2 | 40µs | # spent 27µs (13+13) within Foswiki::Plugins::HomePagePlugin::BEGIN@10 which was called:
# once (13µs+13µs) by Foswiki::Plugin::BEGIN@2.19 at line 10 # spent 27µs making 1 call to Foswiki::Plugins::HomePagePlugin::BEGIN@10
# spent 13µs making 1 call to strict::import |
11 | 2 | 28µs | 2 | 19µs | # spent 15µs (11+4) within Foswiki::Plugins::HomePagePlugin::BEGIN@11 which was called:
# once (11µs+4µs) by Foswiki::Plugin::BEGIN@2.19 at line 11 # spent 15µs making 1 call to Foswiki::Plugins::HomePagePlugin::BEGIN@11
# spent 4µs making 1 call to warnings::import |
12 | |||||
13 | 2 | 19µs | 1 | 4µs | # spent 4µs within Foswiki::Plugins::HomePagePlugin::BEGIN@13 which was called:
# once (4µs+0s) by Foswiki::Plugin::BEGIN@2.19 at line 13 # spent 4µs making 1 call to Foswiki::Plugins::HomePagePlugin::BEGIN@13 |
14 | 2 | 408µs | 1 | 4µs | # spent 4µs within Foswiki::Plugins::HomePagePlugin::BEGIN@14 which was called:
# once (4µs+0s) by Foswiki::Plugin::BEGIN@2.19 at line 14 # spent 4µs making 1 call to Foswiki::Plugins::HomePagePlugin::BEGIN@14 |
15 | |||||
16 | 1 | 600ns | our $VERSION = '1.23'; | ||
17 | 1 | 200ns | our $RELEASE = '1.23'; | ||
18 | 1 | 200ns | our $SHORTDESCRIPTION = 'Allow User specified home pages - on login'; | ||
19 | 1 | 100ns | our $NO_PREFS_IN_TOPIC = 1; | ||
20 | |||||
21 | # spent 5µs within Foswiki::Plugins::HomePagePlugin::initPlugin which was called:
# once (5µs+0s) by Foswiki::Plugin::__ANON__[/var/www/foswikidev/core/lib/Foswiki/Plugin.pm:257] at line 250 of /var/www/foswikidev/core/lib/Foswiki/Plugin.pm | ||||
22 | |||||
23 | #my ( $topic, $web, $user, $installWeb ) = @_; | ||||
24 | 1 | 4µs | return 1; | ||
25 | } | ||||
26 | |||||
27 | # spent 17µs (13+4) within Foswiki::Plugins::HomePagePlugin::initializeUserHandler which was called:
# once (13µs+4µs) by Foswiki::Plugin::load at line 212 of /var/www/foswikidev/core/lib/Foswiki/Plugin.pm | ||||
28 | 1 | 1µs | my ( $loginName, $url, $pathInfo ) = @_; | ||
29 | |||||
30 | return | ||||
31 | 1 | 2µs | 1 | 2µs | unless ( $Foswiki::Plugins::SESSION->inContext('view') # spent 2µs making 1 call to Foswiki::inContext |
32 | || $Foswiki::Plugins::SESSION->inContext('login') ); | ||||
33 | |||||
34 | return | ||||
35 | 1 | 6µs | 1 | 2µs | if ( $Foswiki::Plugins::SESSION->inContext('command_line') ); # spent 2µs making 1 call to Foswiki::inContext |
36 | |||||
37 | # Don't override web/topic if specified by url param. | ||||
38 | return | ||||
39 | if ( $Foswiki::Plugins::SESSION->{request}->param('defaultweb') | ||||
40 | || $Foswiki::Plugins::SESSION->{request}->param('topic') ); | ||||
41 | |||||
42 | my $gotoOnLogin = | ||||
43 | ( $Foswiki::cfg{HomePagePlugin}{GotoHomePageOnLogin} | ||||
44 | and $Foswiki::Plugins::SESSION->inContext('login') ); | ||||
45 | if ($gotoOnLogin) { | ||||
46 | my $test = $Foswiki::Plugins::SESSION->{request}->param('username'); | ||||
47 | $loginName = $test if defined($test); | ||||
48 | |||||
49 | # pre-load the origurl with the 'login' url which forces | ||||
50 | # templatelogin to use the requested web&topic | ||||
51 | $Foswiki::Plugins::SESSION->{request}->param( | ||||
52 | -name => 'origurl', | ||||
53 | -value => $Foswiki::Plugins::SESSION->{request}->url() | ||||
54 | ); | ||||
55 | } | ||||
56 | |||||
57 | # we don't know the user at this point so can only set up the | ||||
58 | # site wide default | ||||
59 | my $path_info = | ||||
60 | Foswiki::urlDecode( $Foswiki::Plugins::SESSION->{request}->path_info() ); | ||||
61 | |||||
62 | return | ||||
63 | unless ( ( $path_info eq '' or $path_info eq '/' ) | ||||
64 | or ($gotoOnLogin) ); | ||||
65 | |||||
66 | my $siteDefault = $Foswiki::cfg{HomePagePlugin}{SiteDefaultTopic}; | ||||
67 | |||||
68 | #$Foswiki::cfg{HomePagePlugin}{HostnameMapping} | ||||
69 | my $hostName = lc( Foswiki::Func::getUrlHost() ); | ||||
70 | if ( | ||||
71 | defined( $Foswiki::cfg{HomePagePlugin}{HostnameMapping}->{$hostName} ) ) | ||||
72 | { | ||||
73 | $siteDefault = | ||||
74 | $Foswiki::cfg{HomePagePlugin}{HostnameMapping}->{$hostName}; | ||||
75 | } | ||||
76 | |||||
77 | my $wikiName = Foswiki::Func::getWikiName($loginName); | ||||
78 | if ( ( defined $wikiName ) | ||||
79 | and | ||||
80 | Foswiki::Func::topicExists( $Foswiki::cfg{UsersWebName}, $wikiName ) ) | ||||
81 | { | ||||
82 | my ( $meta, $text ) = | ||||
83 | Foswiki::Func::readTopic( $Foswiki::cfg{UsersWebName}, $wikiName ); | ||||
84 | |||||
85 | # TODO: make fieldname a setting. | ||||
86 | my $field = $meta->get( 'FIELD', 'HomePage' ); | ||||
87 | my $userHomePage; | ||||
88 | $userHomePage = $field->{value} if ( defined($field) ); | ||||
89 | $siteDefault = $userHomePage | ||||
90 | if ( $userHomePage and ( $userHomePage ne '' ) ); | ||||
91 | } | ||||
92 | |||||
93 | if ( Foswiki::Func::webExists($siteDefault) ) { | ||||
94 | |||||
95 | # if they only set a webname, dwim | ||||
96 | $siteDefault .= '.' . $Foswiki::cfg{HomeTopicName}; | ||||
97 | } | ||||
98 | |||||
99 | return unless defined $siteDefault; | ||||
100 | |||||
101 | my ( $web, $topic ) = | ||||
102 | $Foswiki::Plugins::SESSION->normalizeWebTopicName( '', $siteDefault ); | ||||
103 | |||||
104 | if ( Foswiki::Func::isValidWebName($web) | ||||
105 | && Foswiki::Func::isValidTopicName( $topic, 1 ) ) | ||||
106 | { | ||||
107 | $Foswiki::Plugins::SESSION->{webName} = $web; | ||||
108 | $Foswiki::Plugins::SESSION->{topicName} = $topic; | ||||
109 | } | ||||
110 | |||||
111 | return; | ||||
112 | } | ||||
113 | |||||
114 | 1 | 3µs | 1; | ||
115 | __END__ |