[LON-CAPA-cvs] cvs: modules /msu localenroll.pm
raeburn
lon-capa-cvs@mail.lon-capa.org
Mon, 25 Sep 2006 17:16:05 -0000
raeburn Mon Sep 25 13:16:05 2006 EDT
Modified files:
/modules/msu localenroll.pm
Log:
&check_section() should initiate a database connection, if one was not passed in as an argument (e.g., when localenroll::check_section() is called directly from lond).
Index: modules/msu/localenroll.pm
diff -u modules/msu/localenroll.pm:1.20 modules/msu/localenroll.pm:1.21
--- modules/msu/localenroll.pm:1.20 Mon Aug 28 21:49:50 2006
+++ modules/msu/localenroll.pm Mon Sep 25 13:16:03 2006
@@ -1,6 +1,6 @@
# functions to glue school database system into Lon-CAPA for
# automated enrollment
-# $Id: localenroll.pm,v 1.20 2006/08/29 01:49:50 raeburn Exp $
+# $Id: localenroll.pm,v 1.21 2006/09/25 17:16:03 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -427,6 +427,7 @@
sub check_section {
my ($class,$owner,$dom,$dbh) = @_;
my $sectioncheck = 0;
+ my $dbflag = 0;
if ($owner =~ /^([^:]+):([^:]+)$/) {
$owner = $1;
my $ownerdom = $2;
@@ -437,6 +438,12 @@
if (defined($owner) && $owner ne '') {
if ($class =~ m/^([suf]s\d{2})(\w{2,3})(\d{3,4}\w?)(\d{3})$/) {
# Check if section exists in LONCAPA table.
+ if (!defined($dbh)) {
+ ($dbh,$dbflag) = &connect_DB($$configvars{'lonDaemons'},'RO');
+ if (!$dbflag) {
+ return $sectioncheck;
+ }
+ }
$sectioncheck = $dbh->selectrow_array(
"SELECT count(*) FROM LONCAPA ".
"WHERE Term_Code = '$1' AND Subj_Code = '$2' ".
@@ -450,6 +457,9 @@
}
}
}
+ if ($dbflag) {
+ &disconnect_DB($dbh);
+ }
return $sectioncheck;
}