[LON-CAPA-cvs] cvs: modules /msu localenroll.pm
raeburn
lon-capa-cvs-allow@mail.lon-capa.org
Sat, 25 Aug 2007 18:49:58 -0000
raeburn Sat Aug 25 14:49:58 2007 EDT
Modified files:
/modules/msu localenroll.pm
Log:
- "begins with" type searches supported
- remove trailing spaces from lastname and leading spaces from firstname when searching by lastname.firstname.
Index: modules/msu/localenroll.pm
diff -u modules/msu/localenroll.pm:1.28 modules/msu/localenroll.pm:1.29
--- modules/msu/localenroll.pm:1.28 Sun Jul 29 11:22:24 2007
+++ modules/msu/localenroll.pm Sat Aug 25 14:49:57 2007
@@ -1,6 +1,6 @@
# functions to glue school database system into Lon-CAPA for
# automated enrollment
-# $Id: localenroll.pm,v 1.28 2007/07/29 15:22:24 raeburn Exp $
+# $Id: localenroll.pm,v 1.29 2007/08/25 18:49:57 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -539,6 +539,8 @@
if ($srchterm =~ /^\w{2,8}$/) {
if ($srchtype eq 'contains') {
$condition = "WHERE MSUNetID LIKE '%$srchterm%'";
+ } elsif ($srchtype eq 'begins') {
+ $condition = "WHERE MSUNetID LIKE '$srchterm%'";
} else {
$condition = "WHERE MSUNetID = '$srchterm'";
}
@@ -548,6 +550,9 @@
if ($srchtype eq 'contains') {
my $quoted_last = $dbh->quote('%'.$srchterm.'%');
$condition = "WHERE LastName LIKE $quoted_last";
+ } elsif ($srchtype eq 'begins') {
+ my $quoted_last = $dbh->quote($srchterm.'%');
+ $condition = "WHERE LastName LIKE $quoted_last";
} else {
my $quoted_last = $dbh->quote($srchterm);
$condition = "WHERE LastName = $quoted_last";
@@ -555,19 +560,23 @@
}
} elsif ($srchby eq 'lastfirst') {
my ($srchlast,$srchfirst) = split(/,/,$srchterm);
+ $srchlast =~ s/\s+$//;
+ $srchfirst =~ s/^\s+//;
if (($srchlast =~ /[A-Za-z\-\.']+/) &&
($srchfirst =~ /[A-Za-z\-\.']+/)) {
+ my ($quoted_first,$quoted_last);
if ($srchtype eq 'contains') {
- my $quoted_last = $dbh->quote('%'.$srchlast.'%');
- my $quoted_first = $dbh->quote('%'.$srchfirst.'%');
- $condition = "WHERE LastName LIKE $quoted_last AND
- FirstName LIKE $quoted_first";
+ $quoted_last = $dbh->quote('%'.$srchlast.'%');
+ $quoted_first = $dbh->quote('%'.$srchfirst.'%');
+ } elsif ($srchtype eq 'begins') {
+ $quoted_last = $dbh->quote($srchlast.'%');
+ $quoted_first = $dbh->quote($srchfirst.'%');
} else {
- my $quoted_last = $dbh->quote($srchterm);
- my $quoted_first = $dbh->quote($srchterm);
- $condition = "WHERE LastName = $quoted_last AND
- FirstName = $quoted_first";
+ $quoted_last = $dbh->quote($srchterm);
+ $quoted_first = $dbh->quote($srchterm);
}
+ $condition = "WHERE LastName = $quoted_last AND
+ FirstName = $quoted_first";
}
} elsif ($srchby eq 'id') {
if ($srchterm =~ /^[AZ]\d{8}$/) {