[LON-CAPA-cvs] cvs: modules /msu localenroll.pm

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Sat, 10 Nov 2007 02:05:40 -0000


raeburn		Fri Nov  9 21:05:40 2007 EDT

  Modified files:              
    /modules/msu	localenroll.pm 
  Log:
  "Namespacing" of official student or faculyu/staff IDs.
  -  &id_rules() defined rules for format of official IDs for MSU faculty, staff and students which can be enabled by a DC at MSU via Domain Configuration.
  -  &id_check() checks if the proposed ID for a user matches these formats.
  
  
Index: modules/msu/localenroll.pm
diff -u modules/msu/localenroll.pm:1.31 modules/msu/localenroll.pm:1.32
--- modules/msu/localenroll.pm:1.31	Wed Oct 17 18:22:47 2007
+++ modules/msu/localenroll.pm	Fri Nov  9 21:05:38 2007
@@ -1,6 +1,6 @@
 # functions to glue school database system into Lon-CAPA for
 # automated enrollment
-# $Id: localenroll.pm,v 1.31 2007/10/17 22:22:47 albertel Exp $
+# $Id: localenroll.pm,v 1.32 2007/11/10 02:05:38 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -689,6 +689,22 @@
     return 'ok';
 }
 
+sub id_rules {
+    my ($dom,$ruleshash,$rulesorder) = @_;
+    %{$ruleshash} = (
+                  studentID => {
+                              name     => 'MSU student PID',
+                              desc     => 'Letter A or a, followed by eight digits',
+                           },
+                  facstaffID => {
+                              name     => 'MSU faculty/staff ID',
+                              desc     => 'Letter Z or z, followed by eight digits',
+                           },
+                 );
+    @{$rulesorder} = ('studentID','facstaffID');
+    return 'ok';
+}
+
 sub username_check {
     my ($dom,$uname,$to_check,$resultshash) = @_;
     my $outcome;
@@ -713,6 +729,30 @@
     return $outcome;
 }
 
+sub id_check {
+    my ($dom,$id,$to_check,$resultshash) = @_;
+    my $outcome;
+    if (ref($to_check) eq 'ARRAY') {
+        foreach my $item (@{$to_check}) {
+            if ($item eq 'facstaffID') {
+                if ($id =~ /^z\d{8}$/i) {
+                    $resultshash->{$item} = 1;
+                } else {
+                    $resultshash->{$item} = 0;
+                }
+            } elsif ($item eq 'studentID') {
+                if ($id =~ /^a\d{8}$/i) {
+                    $resultshash->{$item} = 1;
+                } else {
+                    $resultshash->{$item} = 0;
+                }
+            }
+        }
+        $outcome = 'ok';
+    }
+    return $outcome;
+}
+
 ###############################
 # sub AUTOLOAD
 #