Skip to content

Commit

Permalink
Item1066: same functinoality, but snuck in where FSA lets us do it wi…
Browse files Browse the repository at this point in the history
…thout a redirect

git-svn-id: http://svn.foswiki.org/trunk@2477 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
SvenDowideit authored and SvenDowideit committed Feb 13, 2009
1 parent 8a8f34b commit 27e3c97
Showing 1 changed file with 30 additions and 41 deletions.
71 changes: 30 additions & 41 deletions HomePagePlugin/lib/Foswiki/Plugins/HomePagePlugin.pm
Expand Up @@ -49,54 +49,40 @@ sub initPlugin {
__PACKAGE__, ' and Plugins.pm' );
return 0;
}

my $url = $Foswiki::Plugins::SESSION->{request}->path_info();
if ($url eq '' or $url eq '/') {
my $userHomePage;
if (Foswiki::Func::topicExists($Foswiki::cfg{UsersWebName},
Foswiki::Func::getWikiName($user)) ) {
my( $meta, $text ) = Foswiki::Func::readTopic( $Foswiki::cfg{UsersWebName},
Foswiki::Func::getWikiName($user) );
#TODO: make fieldname a setting.
my $field = $meta->get( 'FIELD', 'HomePage' );
$userHomePage = $field->{value} if (defined($field));
}
if ($userHomePage) {
if (Foswiki::Func::webExists($userHomePage)) {
#if they only set a webname, dwim
$userHomePage .= '.'.$Foswiki::cfg{HomeTopicName};
}
my ( $web, $topic ) =
$Foswiki::Plugins::SESSION->normalizeWebTopicName( '', $userHomePage );

if (($web ne $Foswiki::Plugins::SESSION->{webName}) or
($topic ne $Foswiki::Plugins::SESSION->{topicName})) {
Foswiki::Func::redirectCgiQuery(
undef, Foswiki::Func::getScriptUrl($web, $topic, 'view'), 1);
}
}

}

return 1;
}

sub initializeUserHandler {
my ( $loginName, $url, $pathInfo ) = @_;

=begin TML
---++ earlyInitPlugin()
show the Site's default topic as set in configure if no web/topic is set in the URL
=cut

sub earlyInitPlugin {
return if ($Foswiki::Plugins::SESSION->inContext('viewfile'));

#my $script_path = $Foswiki::Plugins::SESSION->{scriptUrlPath};
#my $script_name = $Foswiki::Plugins::SESSION->{request}->script_name();
#my $web = $Foswiki::Plugins::SESSION->{webName};
#my $topic = $Foswiki::Plugins::SESSION->{topicName};

#we don't know the user at this point so can only set up the site wide default
my $url = $Foswiki::Plugins::SESSION->{request}->path_info();
if ($url eq '' or $url eq '/') {
my $path_info = $Foswiki::Plugins::SESSION->{request}->path_info();

#print STDERR "\n!-------- >$loginName< $web, $topic ($script_name)($path_info)";
#print STDERR "\n!-=-=".join(',', $Foswiki::Plugins::SESSION->{request}->param());

if (($path_info eq '' or $path_info eq '/') or
($Foswiki::Plugins::SESSION->{request}->param('logout' )) ) {
my $siteDefault = $Foswiki::cfg{HomePagePlugin}{SiteDefaultTopic};

if (Foswiki::Func::topicExists($Foswiki::cfg{UsersWebName},
Foswiki::Func::getWikiName($loginName)) ) {
my( $meta, $text ) = Foswiki::Func::readTopic( $Foswiki::cfg{UsersWebName},
Foswiki::Func::getWikiName($loginName) );
#TODO: make fieldname a setting.
my $field = $meta->get( 'FIELD', 'HomePage' );
my $userHomePage = $field->{value} if (defined($field));
$siteDefault = $userHomePage if ($userHomePage and ($userHomePage ne ''));
}

if (Foswiki::Func::webExists($siteDefault)) {
#if they only set a webname, dwim
$siteDefault .= '.'.$Foswiki::cfg{HomeTopicName};
Expand All @@ -105,11 +91,14 @@ sub earlyInitPlugin {
$Foswiki::Plugins::SESSION->normalizeWebTopicName( '', $siteDefault );
$Foswiki::Plugins::SESSION->{webName} = $web;
$Foswiki::Plugins::SESSION->{topicName} = $topic;
}


#print STDERR "-------- ($script_name)($path_info) --> ( $web, $topic )";
#print STDERR '-=-='.join(',', $Foswiki::Plugins::SESSION->{request}->param());

return undef;
}

}

1;
__END__
Expand Down

0 comments on commit 27e3c97

Please sign in to comment.