[LON-CAPA-cvs] cvs: loncom /auth lonlogin.pm /interface coursecatalog.pm domainprefs.pm lonaboutme.pm loncommon.pm lonindexer.pm lonmodifycourse.pm lonnotify.pm lonpickcourse.pm lonpopulate.pm lonsyllabus.pm resetpw.pm /lonnet/perl lonnet.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Thu, 08 Mar 2007 01:58:49 -0000
This is a MIME encoded message
--albertel1173319129
Content-Type: text/plain
albertel Wed Mar 7 20:58:49 2007 EDT
Modified files:
/loncom/lonnet/perl lonnet.pm
/loncom/interface coursecatalog.pm domainprefs.pm lonaboutme.pm
loncommon.pm lonindexer.pm lonmodifycourse.pm
lonnotify.pm lonpickcourse.pm lonpopulate.pm
lonsyllabus.pm resetpw.pm
/loncom/auth lonlogin.pm
Log:
- eliminating the domain hash globals in favor of functional access
--albertel1173319129
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20070307205849.txt"
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.845 loncom/lonnet/perl/lonnet.pm:1.846
--- loncom/lonnet/perl/lonnet.pm:1.845 Wed Mar 7 20:54:50 2007
+++ loncom/lonnet/perl/lonnet.pm Wed Mar 7 20:58:41 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.845 2007/03/08 01:54:50 albertel Exp $
+# $Id: lonnet.pm,v 1.846 2007/03/08 01:58:41 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -39,8 +39,6 @@
%pr %prp $memcache %packagetab
%courselogs %accesshash %userrolehash %domainrolehash $processmarker $dumpcount
%coursedombuf %coursenumbuf %coursehombuf %coursedescrbuf %courseinstcodebuf %courseownerbuf %coursetypebuf
- %domaindescription %domain_auth_def %domain_auth_arg_def
- %domain_lang_def %domain_city %domain_longi %domain_lati %domain_primary
$tmpdir $_64bit %env);
use IO::Socket;
@@ -727,8 +725,8 @@
}
$items=~s/\&$//;
if (!$udom) { $udom=$env{'user.domain'}; }
- if (exists($domain_primary{$udom})) {
- my $uhome=$domain_primary{$udom};
+ if (defined(&domain($udom,'primary'))) {
+ my $uhome=&domain($udom,'primary');
my $rep=&reply("getdom:$udom:$namespace:$items",$uhome);
my @pairs=split(/\&/,$rep);
if ( $#pairs==0 && $pairs[0] =~ /^(con_lost|error|no_such_host)/i) {
@@ -751,8 +749,8 @@
sub put_dom {
my ($namespace,$storehash,$udom)=@_;
if (!$udom) { $udom=$env{'user.domain'}; }
- if (exists($domain_primary{$udom})) {
- my $uhome=$domain_primary{$udom};
+ if (defined(&domain($udom,'primary'))) {
+ my $uhome=&domain($udom,'primary');
my $items='';
foreach my $item (keys(%$storehash)) {
$items.=&escape($item).'='.&freeze_escape($$storehash{$item}).'&';
@@ -767,8 +765,8 @@
sub retrieve_inst_usertypes {
my ($udom) = @_;
my (%returnhash,@order);
- if (exists($domain_primary{$udom})) {
- my $uhome=$domain_primary{$udom};
+ if (defined(&domain($udom,'primary'))) {
+ my $uhome=&domain($udom,'primary');
my $rep=&reply("inst_usertypes:$udom",$uhome);
my ($hashitems,$orderitems) = split(/:/,$rep);
my @pairs=split(/\&/,$hashitems);
@@ -2170,12 +2168,13 @@
sub dcmaildump {
my ($dom,$startdate,$enddate,$senders) = @_;
my %returnhash=();
- if (exists($domain_primary{$dom})) {
+
+ if (defined(&domain($dom,'primary'))) {
my $cmd='dcmaildump:'.$dom.':'.&escape($startdate).':'.
&escape($enddate).':';
my @esc_senders=map { &escape($_)} @$senders;
$cmd.=&escape(join('&',@esc_senders));
- foreach my $line (split(/\&/,&reply($cmd,$domain_primary{$dom}))) {
+ foreach my $line (split(/\&/,&reply($cmd,&domain($dom,'primary')))) {
my ($key,$value) = split(/\=/,$line,2);
if (($key) && ($value)) {
$returnhash{&unescape($key)} = &unescape($value);
@@ -7567,31 +7566,36 @@
# ------------------------------------------------------------ Read domain file
{
- %domaindescription = ();
- %domain_auth_def = ();
- %domain_auth_arg_def = ();
+ my %domain;
+
my $fh;
if (open($fh,"<".$Apache::lonnet::perlvar{'lonTabDir'}.'/domain.tab')) {
while (my $line = <$fh>) {
- next if ($line =~ /^(\#|\s*$)/);
-# next if /^\#/;
- chomp $line;
- my ($domain, $domain_description, $def_auth, $def_auth_arg,
- $def_lang, $city, $longi, $lati, $primary) = split(/:/,$line,9);
- $domain_auth_def{$domain}=$def_auth;
- $domain_auth_arg_def{$domain}=$def_auth_arg;
- $domaindescription{$domain}=$domain_description;
- $domain_lang_def{$domain}=$def_lang;
- $domain_city{$domain}=$city;
- $domain_longi{$domain}=$longi;
- $domain_lati{$domain}=$lati;
- $domain_primary{$domain}=$primary;
+ next if ($line =~ /^(\#|\s*$ )/);
- # &logthis("Domain.tab: $domain, $domain_auth_def{$domain}, $domain_auth_arg_def{$domain},$domaindescription{$domain}");
+ chomp($line);
+ my ($name,@elements) = split(/:/,$line,9);
+ my %this_domain;
+ foreach my $field ('description', 'auth_def', 'auth_arg_def',
+ 'lang_def', 'city', 'longi', 'lati',
+ 'primary') {
+ $this_domain{$field} = shift(@elements);
+ }
+ $domain{$name} = \%this_domain;
# &logthis("Domain.tab: $domain ".$domaindescription{$domain} );
}
}
close ($fh);
+
+ sub domain {
+ my ($name,$what) = @_;
+ return if ( !exists($domain{$name}) );
+
+ if (!$what) {
+ return $domain{$name}{'description'};
+ }
+ return $domain{$name}{$what};
+ }
}
Index: loncom/interface/coursecatalog.pm
diff -u loncom/interface/coursecatalog.pm:1.19 loncom/interface/coursecatalog.pm:1.20
--- loncom/interface/coursecatalog.pm:1.19 Sat Jan 13 20:59:37 2007
+++ loncom/interface/coursecatalog.pm Wed Mar 7 20:58:44 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler for displaying the course catalog interface
#
-# $Id: coursecatalog.pm,v 1.19 2007/01/14 01:59:37 raeburn Exp $
+# $Id: coursecatalog.pm,v 1.20 2007/03/08 01:58:44 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -68,7 +68,7 @@
}
}
my $formname = 'coursecatalog';
- my $domdesc = $Apache::lonnet::domaindescription{$codedom};
+ my $domdesc = &Apache::lonnet::domain($codedom,'description');
&Apache::lonhtmlcommon::clear_breadcrumbs();
if ($env{'form.coursenum'} ne '' && &user_is_known()) {
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.4 loncom/interface/domainprefs.pm:1.5
--- loncom/interface/domainprefs.pm:1.4 Thu Mar 1 13:24:09 2007
+++ loncom/interface/domainprefs.pm Wed Mar 7 20:58:44 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.4 2007/03/01 18:24:09 raeburn Exp $
+# $Id: domainprefs.pm,v 1.5 2007/03/08 01:58:44 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -47,7 +47,7 @@
}
my $dom = $env{'request.role.domain'};
- my $domdesc = $Apache::lonnet::domaindescription{$dom};
+ my $domdesc = &Apache::lonnet::domain($dom,'description');
if (&Apache::lonnet::allowed('mau',$dom)) {
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
Index: loncom/interface/lonaboutme.pm
diff -u loncom/interface/lonaboutme.pm:1.60 loncom/interface/lonaboutme.pm:1.61
--- loncom/interface/lonaboutme.pm:1.60 Sun Dec 10 22:46:31 2006
+++ loncom/interface/lonaboutme.pm Wed Mar 7 20:58:44 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network
# "About Me" Personal Information
#
-# $Id: lonaboutme.pm,v 1.60 2006/12/11 03:46:31 raeburn Exp $
+# $Id: lonaboutme.pm,v 1.61 2007/03/08 01:58:44 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -131,10 +131,10 @@
'"</h2>');
}
if ($target ne 'tex') {
- $r->print('<h3>'.$Apache::lonnet::domaindescription{$cdom}.'</h3>'.
+ $r->print('<h3>'.&Apache::lonnet::domain($cdom,'description').'</h3>'.
'<p>'.&Apache::loncommon::messagewrapper('Send me a message',$cnum,$cdom).'</p>'.&Apache::lonrss::advertisefeeds($cnum,$cdom));
} else {
- $r->print('\textbf{'.$Apache::lonnet::domaindescription{$cdom}.'}\\\\');
+ $r->print('\textbf{'.&Apache::lonnet::domain($cdom,'description').'}\\\\');
}
my %syllabus=&Apache::lonnet::dump('aboutme',$cdom,$cnum);
my $allowed=0;
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.513 loncom/interface/loncommon.pm:1.514
--- loncom/interface/loncommon.pm:1.513 Fri Mar 2 20:40:28 2007
+++ loncom/interface/loncommon.pm Wed Mar 7 20:58:44 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.513 2007/03/03 01:40:28 albertel Exp $
+# $Id: loncommon.pm,v 1.514 2007/03/08 01:58:44 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1270,7 +1270,7 @@
sub domain_select {
my ($name,$value,$multiple)=@_;
my %domains=map {
- $_ => $_.' '.$Apache::lonnet::domaindescription{$_}
+ $_ => $_.' '. &Apache::lonnet::domain($_,'description')
} &Apache::lonnet::all_domains();
if ($multiple) {
$domains{''}=&mt('Any domain');
@@ -1863,7 +1863,9 @@
#-------------------------------------------
sub get_auth_defaults {
my $domain=shift;
- return ($Apache::lonnet::domain_auth_def{$domain},$Apache::lonnet::domain_auth_arg_def{$domain});
+ return (&Apache::lonnet::domain($domain,'auth_def'),
+ &Apache::lonnet::domain($domain,'auth_arg_def'));
+
}
###############################################################
## End Get Authentication Defaults for Domain ##
@@ -2447,19 +2449,21 @@
if ($browser) {
@languages=(@languages,split(/\s*(\,|\;|\:)\s*/,$browser));
}
- if ($Apache::lonnet::domain_lang_def{$env{'user.domain'}}) {
+ if (&Apache::lonnet::domain($env{'user.domain'},'lang_def')) {
@languages=(@languages,
- $Apache::lonnet::domain_lang_def{$env{'user.domain'}});
+ &Apache::lonnet::domain($env{'user.domain'},
+ 'lang_def'));
}
- if ($Apache::lonnet::domain_lang_def{$env{'request.role.domain'}}) {
+ if (&Apache::lonnet::domain($env{'request.role.domain'},'lang_def')) {
@languages=(@languages,
- $Apache::lonnet::domain_lang_def{$env{'request.role.domain'}});
+ &Apache::lonnet::domain($env{'request.role.domain'},
+ 'lang_def'));
}
- if ($Apache::lonnet::domain_lang_def{
- $Apache::lonnet::perlvar{'lonDefDomain'}}) {
+ if (&Apache::lonnet::domain($Apache::lonnet::perlvar{'lonDefDomain'},
+ 'lang_def')) {
@languages=(@languages,
- $Apache::lonnet::domain_lang_def{
- $Apache::lonnet::perlvar{'lonDefDomain'}});
+ &Apache::lonnet::domain($Apache::lonnet::perlvar{'lonDefDomain'},
+ 'lang_def'));
}
# turn "en-ca" into "en-ca,en"
my @genlanguages;
@@ -3198,8 +3202,8 @@
if (-e '/home/httpd/html/adm/lonDomLogos/'.$domain.'.gif') {
my $logo=&lonhttpdurl("/adm/lonDomLogos/$domain.gif");
return '<img src="'.$logo.'" alt="'.$domain.'" />';
- } elsif(exists($Apache::lonnet::domaindescription{$domain})) {
- return $Apache::lonnet::domaindescription{$domain};
+ } elsif (defined(&Apache::lonnet::domain($domain,'description'))) {
+ return &Apache::lonnet::domain($domain,'description');
} else {
return '';
}
Index: loncom/interface/lonindexer.pm
diff -u loncom/interface/lonindexer.pm:1.157 loncom/interface/lonindexer.pm:1.158
--- loncom/interface/lonindexer.pm:1.157 Fri Mar 2 18:17:59 2007
+++ loncom/interface/lonindexer.pm Wed Mar 7 20:58:45 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Directory Indexer
#
-# $Id: lonindexer.pm,v 1.157 2007/03/02 23:17:59 albertel Exp $
+# $Id: lonindexer.pm,v 1.158 2007/03/08 01:58:45 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -856,8 +856,8 @@
'\')"><img alt="" src="'.$iconpath.'server.gif"');
$r->print (' border="0" /></a>'."\n");
$r->print (&mt("Domain")." - $listname ");
- if ($Apache::lonnet::domaindescription{$listname}) {
- $r->print("(".$Apache::lonnet::domaindescription{$listname}.
+ if (&Apache::lonnet::domain($listname,'description')) {
+ $r->print("(".&Apache::lonnet::domain($listname,'description').
")");
}
$r->print ("</form>$tabtag</tr>\n");
Index: loncom/interface/lonmodifycourse.pm
diff -u loncom/interface/lonmodifycourse.pm:1.30 loncom/interface/lonmodifycourse.pm:1.31
--- loncom/interface/lonmodifycourse.pm:1.30 Sun Jan 14 20:08:53 2007
+++ loncom/interface/lonmodifycourse.pm Wed Mar 7 20:58:45 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# handler for DC-only modifiable course settings
#
-# $Id: lonmodifycourse.pm,v 1.30 2007/01/15 01:08:53 raeburn Exp $
+# $Id: lonmodifycourse.pm,v 1.31 2007/03/08 01:58:45 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -859,7 +859,7 @@
return OK;
}
my $dom = $env{'request.role.domain'};
- my $domdesc = $Apache::lonnet::domaindescription{$dom};
+ my $domdesc = &Apache::lonnet::domain($dom,'description');
if (&Apache::lonnet::allowed('ccc',$dom)) {
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
Index: loncom/interface/lonnotify.pm
diff -u loncom/interface/lonnotify.pm:1.25 loncom/interface/lonnotify.pm:1.26
--- loncom/interface/lonnotify.pm:1.25 Wed Nov 1 17:22:31 2006
+++ loncom/interface/lonnotify.pm Wed Mar 7 20:58:45 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Sending messages
#
-# $Id: lonnotify.pm,v 1.25 2006/11/01 22:22:31 www Exp $
+# $Id: lonnotify.pm,v 1.26 2007/03/08 01:58:45 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -787,7 +787,7 @@
$attachmenturl,$recipients,undef,undef,'dcmail');
# Store in dc email db files on primary library server for domain.
- my $server = $Apache::lonnet::domain_primary{$domain};
+ my $server = &Apache::lonnet::domain($domain,'primary');
if (defined($server)) {
unless (&Apache::lonnet::dcmailput($domain,$msgid,$message,$server)
eq 'ok') {
Index: loncom/interface/lonpickcourse.pm
diff -u loncom/interface/lonpickcourse.pm:1.61 loncom/interface/lonpickcourse.pm:1.62
--- loncom/interface/lonpickcourse.pm:1.61 Mon Dec 11 17:20:20 2006
+++ loncom/interface/lonpickcourse.pm Wed Mar 7 20:58:45 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Pick a course
#
-# $Id: lonpickcourse.pm,v 1.61 2006/12/11 22:20:20 albertel Exp $
+# $Id: lonpickcourse.pm,v 1.62 2007/03/08 01:58:45 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -198,8 +198,8 @@
my ($descr,$instcode,$owner,$ttype) = split/:/,$courses{$course};
$r->print(&course_chooser($multiple,$cdom,$cnum,$cleandesc));
$r->print($description.'('.
- ($Apache::lonnet::domaindescription{$cdom}?
- $Apache::lonnet::domaindescription{$cdom}:$cdom).")");
+ (&Apache::lonnet::domain($cdom,'description')?
+ &Apache::lonnet::domain($cdom,'description'):$cdom).")");
unless ($instcode eq '') {
$r->print(" - ".&unescape($instcode));
}
Index: loncom/interface/lonpopulate.pm
diff -u loncom/interface/lonpopulate.pm:1.48 loncom/interface/lonpopulate.pm:1.49
--- loncom/interface/lonpopulate.pm:1.48 Thu Aug 10 18:05:18 2006
+++ loncom/interface/lonpopulate.pm Wed Mar 7 20:58:45 2007
@@ -1,5 +1,5 @@
# automated enrollment configuration handler
-# $Id: lonpopulate.pm,v 1.48 2006/08/10 22:05:18 albertel Exp $
+# $Id: lonpopulate.pm,v 1.49 2007/03/08 01:58:45 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -944,7 +944,7 @@
');
my ($result,$perm_reqd)=&Apache::lonnet::auto_photo_permission($crs,$dom);
my $can_enable = 1;
- my $institution = $Apache::lonnet::domaindescription{$dom};
+ my $institution = &Apache::lonnet::domain($dom,'description');
if ($result eq 'ok') {
if ($perm_reqd eq 'yes') {
if (!($enrollvar{'photopermission'} eq 'yes')) {
@@ -2346,7 +2346,7 @@
sub print_photo_agreement {
my ($r,$realm,$dom,$crs,$action,$tasktitleref,$conditions,$courseowner)=@_;
my $response;
- my $institution = $Apache::lonnet::domaindescription{$dom};
+ my $institution = &Apache::lonnet::domain($dom,'description');
if (&user_is_courseowner($courseowner)) {
$response = '
<script type="text/javascript">
Index: loncom/interface/lonsyllabus.pm
diff -u loncom/interface/lonsyllabus.pm:1.57 loncom/interface/lonsyllabus.pm:1.58
--- loncom/interface/lonsyllabus.pm:1.57 Fri Mar 2 18:17:58 2007
+++ loncom/interface/lonsyllabus.pm Wed Mar 7 20:58:45 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Syllabus
#
-# $Id: lonsyllabus.pm,v 1.57 2007/03/02 23:17:58 albertel Exp $
+# $Id: lonsyllabus.pm,v 1.58 2007/03/08 01:58:45 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -120,10 +120,10 @@
$env{'form.register'},});
$r->print($start_page.'<h1>'.$courseenv{'description'}.'</h1><h3>'.
- $Apache::lonnet::domaindescription{$cdom}.'</h3>');
+ &Apache::lonnet::domain($cdom,'description').'</h3>');
} else {
$r->print('\noindent{\large\textbf{'.$courseenv{'description'}.'}}\\\\\\\\\textbf{'.
- $Apache::lonnet::domaindescription{$cdom}.'}\\\\');
+ &Apache::lonnet::domain($cdom,'description').'}\\\\');
}
# -------------------------------------------------------------- Announcements?
my $day = &Apache::lonannounce::showday(time,2,
Index: loncom/interface/resetpw.pm
diff -u loncom/interface/resetpw.pm:1.5 loncom/interface/resetpw.pm:1.6
--- loncom/interface/resetpw.pm:1.5 Wed Mar 7 10:59:31 2007
+++ loncom/interface/resetpw.pm Wed Mar 7 20:58:45 2007
@@ -63,7 +63,7 @@
if ($token) {
$output = &reset_passwd($r,$token,$contact_name,$contact_email);
} elsif ($uname && $udom) {
- my $domdesc = $Apache::lonnet::domaindescription{$udom};
+ my $domdesc = &Apache::lonnet::domain($udom,'description');
my $authtype = &Apache::lonnet::queryauthenticate($uname,$udom);
if ($authtype =~ /^internal/) {
my $useremail = $env{'form.useremail'};
@@ -245,7 +245,7 @@
my $delete = &Apache::lonnet::tmpdel($token);
my $now = localtime(time);
my $domdesc =
- $Apache::lonnet::domaindescription{$data{'domain'}};
+ &Apache::lonnet::domain($data{'domain'},'description');
my $mailmsg = &mt('The password for your LON-CAPA account in the [_1] domain was changed [_2] from IP address: [_3]. If you did not perform this change or authorize it, please contact the [_4] ([_5]).',$domdesc,$now,$ENV{'REMOTE_ADDR'},$contact_name,$contact_email)."\n";
my $result = &send_mail($domdesc,$data{'email'},$mailmsg,
$contact_name,$contact_email);
Index: loncom/auth/lonlogin.pm
diff -u loncom/auth/lonlogin.pm:1.88 loncom/auth/lonlogin.pm:1.89
--- loncom/auth/lonlogin.pm:1.88 Fri Mar 2 18:17:48 2007
+++ loncom/auth/lonlogin.pm Wed Mar 7 20:58:48 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Login Screen
#
-# $Id: lonlogin.pm,v 1.88 2007/03/02 23:17:48 albertel Exp $
+# $Id: lonlogin.pm,v 1.89 2007/03/08 01:58:48 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -128,7 +128,7 @@
$r->dir_config('lonIconsURL');
my $domain = &Apache::lonnet::default_login_domain();
if (($env{'form.domain'}) &&
- ($Apache::lonnet::domaindescription{$env{'form.domain'}})) {
+ (&Apache::lonnet::domain($env{'form.domain'},'description'))) {
$domain=$env{'form.domain'};
}
my $role = $r->dir_config('lonRole');
--albertel1173319129--