[LON-CAPA-cvs] cvs: loncom /auth lonlogin.pm /interface coursecatalog.pm /lonnet/perl lonnet.pm
raeburn
lon-capa-cvs@mail.lon-capa.org
Sun, 14 Jan 2007 02:01:18 -0000
raeburn Sat Jan 13 21:01:18 2007 EDT
Modified files:
/loncom/interface coursecatalog.pm
/loncom/auth lonlogin.pm
/loncom/lonnet/perl lonnet.pm
Log:
Move &additional_machine_domains() to lonnet.pm so it is more widely available
Move determination of default domain based on $ENV{'HTTP_HOST'} from lonlogin.pm to &default_login_domain() in lonnet.pm so it is more widely available
Default domain in coursecatalog now uses lonnet::default_login_domain() to display catlog for appropriate domain on a server with multiple domains, based on URL.
Bug 5136. If course catalog is displayed by a logged in user (other than public), catalog is shown for the domain of the current user's role, unless no role is selected, in which case catalog is shown for user's domain.
Non-logged in user and public users see course catalog of the domain of the machine, as determined from lonnet:::default_login_domain().
Index: loncom/interface/coursecatalog.pm
diff -u loncom/interface/coursecatalog.pm:1.18 loncom/interface/coursecatalog.pm:1.19
--- loncom/interface/coursecatalog.pm:1.18 Fri Jan 12 18:37:22 2007
+++ loncom/interface/coursecatalog.pm Sat Jan 13 20:59:37 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler for displaying the course catalog interface
#
-# $Id: coursecatalog.pm,v 1.18 2007/01/12 23:37:22 raeburn Exp $
+# $Id: coursecatalog.pm,v 1.19 2007/01/14 01:59:37 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -59,7 +59,14 @@
&Apache::lonacc::get_posted_cgi($r);
&Apache::lonlocal::get_language_handle($r);
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['sortby']);
- my $codedom = $Apache::lonnet::perlvar{'lonDefDomain'};
+ my $codedom = &Apache::lonnet::default_login_domain();
+
+ if (($env{'user.domain'} ne '') && ($env{'user.domain'} ne 'public')) {
+ $codedom = $env{'user.domain'};
+ if ($env{'request.role.domain'} ne '') {
+ $codedom = $env{'request.role.domain'};
+ }
+ }
my $formname = 'coursecatalog';
my $domdesc = $Apache::lonnet::domaindescription{$codedom};
@@ -87,10 +94,13 @@
'add_entries' => \%add_entries,
'no_inline_link' => 1,});
$r->print($start_page);
+ if ($env{'form.numtitles'} > 0) {
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>"/adm/coursecatalog",
+ text=>"Select courses"});
+ }
&Apache::lonhtmlcommon::add_breadcrumb
- ({href=>"/adm/coursecatalog",
- text=>"Select courses"},
- {href=>"javascript:document.$formname.submit()",
+ ({href=>"javascript:document.$formname.submit()",
text=>"Course listing"},
{text=>"Course details"});
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Details'));
@@ -204,11 +214,16 @@
'no_inline_link' => 1,});
$r->print($start_page);
if ($env{'form.state'} eq 'listing') {
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>"/adm/coursecatalog",
- text=>"Select courses"},
- {text=>"Course listing"});
- $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Listing'));
+ if ($numtitles > 0) {
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>"/adm/coursecatalog",
+ text=>"Select courses"},
+ {text=>"Course listing"});
+ } else {
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({text=>"Course listing"});
+ }
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Listing'));
} else {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"/adm/coursecatalog",
@@ -267,7 +282,8 @@
if ($numtitles > 0) {
$r->print('<input type="submit" name="catalogfilter" value="'.&mt('Display courses').'" />');
}
- $r->print('</form>');
+ $r->print('<input type="hidden" name="numtitles" value="'.
+ $numtitles.'" /></form>');
if (($numtitles > 0) && ($env{'form.state'} eq 'listing')) {
$r->print('<br /><br />');
}
Index: loncom/auth/lonlogin.pm
diff -u loncom/auth/lonlogin.pm:1.86 loncom/auth/lonlogin.pm:1.87
--- loncom/auth/lonlogin.pm:1.86 Sat Jan 13 15:39:57 2007
+++ loncom/auth/lonlogin.pm Sat Jan 13 21:00:04 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Login Screen
#
-# $Id: lonlogin.pm,v 1.86 2007/01/13 20:39:57 raeburn Exp $
+# $Id: lonlogin.pm,v 1.87 2007/01/14 02:00:04 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -40,17 +40,6 @@
use lib '/home/httpd/lib/perl/';
use LONCAPA;
-
-sub additional_machine_domains {
- my @domains;
- open(my $fh,"<".$Apache::lonnet::perlvar{'lonTabDir'}.'/expected_domains.tab');
- while( my $line = <$fh>) {
- $line =~ s/\s//g;
- push(@domains,$line);
- }
- return @domains;
-}
-
sub handler {
my $r = shift;
@@ -137,12 +126,7 @@
}
my $iconpath= 'http://'.$ENV{'HTTP_HOST'}.':'.$port_to_use.
$r->dir_config('lonIconsURL');
- my $domain = $r->dir_config('lonDefDomain');
- my $testdomain=(split(/\./,$ENV{'HTTP_HOST'}))[0];
- foreach my $posdom (&Apache::lonnet::current_machine_domains(),
- &additional_machine_domains()) {
- if (lc($posdom) eq lc($testdomain)) { $domain=$posdom; }
- }
+ my $domain = &Apache::lonnet::default_login_domain();
if (($env{'form.domain'}) &&
($Apache::lonnet::domaindescription{$env{'form.domain'}})) {
$domain=$env{'form.domain'};
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.823 loncom/lonnet/perl/lonnet.pm:1.824
--- loncom/lonnet/perl/lonnet.pm:1.823 Fri Jan 12 17:14:28 2007
+++ loncom/lonnet/perl/lonnet.pm Sat Jan 13 21:01:16 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.823 2007/01/12 22:14:28 albertel Exp $
+# $Id: lonnet.pm,v 1.824 2007/01/14 02:01:16 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -7302,6 +7302,29 @@
return @ids;
}
+sub additional_machine_domains {
+ my @domains;
+ open(my $fh,"<$perlvar{'lonTabDir'}/expected_domains.tab");
+ while( my $line = <$fh>) {
+ $line =~ s/\s//g;
+ push(@domains,$line);
+ }
+ return @domains;
+}
+
+sub default_login_domain {
+ my $domain = $perlvar{'lonDefDomain'};
+ my $testdomain=(split(/\./,$ENV{'HTTP_HOST'}))[0];
+ foreach my $posdom (¤t_machine_domains(),
+ &additional_machine_domains()) {
+ if (lc($posdom) eq lc($testdomain)) {
+ $domain=$posdom;
+ last;
+ }
+ }
+ return $domain;
+}
+
# ------------------------------------------------------------- Declutters URLs
sub declutter {