[LON-CAPA-cvs] cvs: nsdl /nsdlloncapaorg signon.pl

www lon-capa-cvs@mail.lon-capa.org
Mon, 28 Jul 2003 15:03:29 -0000


www		Mon Jul 28 11:03:29 2003 EDT

  Modified files:              
    /nsdl/nsdlloncapaorg	signon.pl 
  Log:
  Generate Guest User Account on NSDL Gateway Server
  
  
Index: nsdl/nsdlloncapaorg/signon.pl
diff -u nsdl/nsdlloncapaorg/signon.pl:1.1 nsdl/nsdlloncapaorg/signon.pl:1.2
--- nsdl/nsdlloncapaorg/signon.pl:1.1	Mon Jul 28 10:27:05 2003
+++ nsdl/nsdlloncapaorg/signon.pl	Mon Jul 28 11:03:29 2003
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 # The LearningOnline Network with CAPA
-# Generate Demo Users on Demo Server
+# Generate Guest Users on NSDL Server
 #
 # Only works on a library server!!!
 # Has to be the only library server in the domain!!!
@@ -8,10 +8,10 @@
 
 use strict;
 
-my $demodomain='msudemo';
-my $demohome='msudemol1';
+my $demodomain='nsdl';
+my $demohome='nsdll1';
 my $admemail='lon-capa@lon-capa.org';
-my $demoserver='demo.lon-capa.org';
+my $demoserver='nsdl.lon-capa.org';
 
 
 
@@ -195,40 +195,24 @@
 
 # -------------------------------------------------------------- Modify student
 
-sub modifystudent {
-    my ($uname,$upass,$first,$last,$cnum,$cdom,$chome)=@_;
+sub modifyrole {
+    my ($uname,$upass,$first,$last)=@_;
     my $udom=$demodomain;
     my $start=time;
     my $end=$start+60*60*24*100;
 # --------------------------------------------------------------- Make the user
     my $reply=&modifyuser($uname,$upass,$first,$last);
     unless ($reply eq 'ok') { return $reply; }
-# -------------------------------------------------- Add student to course list
-    $reply=reply('put:'.$cdom.':'.$cnum.':classlist:'.
-                      &escape($uname.':'.$udom).'='.
-                      &escape($end.':'.$start),
-	              $chome);
-    unless (($reply eq 'ok') || ($reply eq 'delayed')) {
-	return "error course list ".$reply;
-    }
-# ---------------------------------------------------- Add student role to user
-    my $uurl='/'.$cdom.'_'.$cnum;
-    $uurl=~s/\_/\//g;
-    return &assignrole($uname,$uurl,'st',$end,$start);
+
+# ------------------------------------------------------ Add guest role to user
+    return &assignrole($uname,'nsdl','dg',$end,$start);
 }
 
 sub enroll {
     my ($uname,$upass,$first,$last)=@_;
-    &logthis("Going to enroll $uname for $courses");
-    my $returnval='';
-    foreach (split(/\&/,$courses)) {
-      my ($cdom,$chome,$cid)=split(/\:/,$democourses{$_});
-      if ($cid) {
-        $returnval.=
-         &modifystudent
- ($uname,$upass,$first,$last,$cid,$cdom,$chome)."<br>\n";
-      }
-    }
+    &logthis("Going to enroll $uname as guest");
+    my $returnval.=
+         &modifyrole($uname,$upass,$first,$last)."<br>\n";
     return $returnval;
 }
 # ------------------------------------------------------------- Make a password
@@ -253,7 +237,7 @@
 	&inputline($_,$formfields{$_});
     }
     print "</table>\n<input type='hidden' name='courses' value='$courses'>".
-          "<input name='submitted' value='Generate Demo User' type='submit'>".
+          "<input name='submitted' value='Generate Guest User' type='submit'>".
           "</form>\n";
 }
 
@@ -265,7 +249,7 @@
 
 sub checkform {
     unless ($form{'submitted'}) {
-	return 'Please fill out the form below to generate a demo user.';
+	return 'Please fill out the form below to generate a guest user.';
     }
 # --- Sloppy check of email address
     unless ($form{'gemail'}=~/^[^\@]+\@[^\@]+\.\w+$/) {
@@ -285,7 +269,7 @@
 	return &errorwrap('Username '.$form{'huser'}.' already exists.');
     }
     unless ($reply eq 'not_found') {
-        return &errorwrap('Sorry, demo logins currently not available.');
+        return &errorwrap('Sorry, guest logins currently not available.');
     }
     return 0;
 }
@@ -295,27 +279,16 @@
    open(MAILOUT,"|mail '$form{'gemail'}' -c '$admemail' -s 'Your LON-CAPA Demo Access Info'");
    print MAILOUT "Welcome to LON-CAPA!\n\n";
    print MAILOUT "Somebody at $ENV{'REMOTE_ADDR'}, probably you, signed up\n";
-   print MAILOUT "for a demo login to\n\n  http://$demoserver/\n\n";
+   print MAILOUT "for an NSDL guest login to\n\n  http://$demoserver/\n\n";
    print MAILOUT "  Username: $form{'huser'}\n  Password: $upass\n\n";
    print MAILOUT "Additional information provided was:\n\n";
    foreach (sort keys %formfields) {
       print MAILOUT '  '.$formfields{$_}.': '.$form{$_}."\n";
    }
-   print MAILOUT "\nCourse(s): $courses\n\nThank you for your interest in LON-CAPA!\n".&footer; 
+   print MAILOUT "\nNSDL Guest User\n\nThank you for your interest in LON-CAPA!\n".&footer; 
    close MAILOUT;
 }
 
-sub readdemo {
-    open(IN,$perlvar{'lonTabDir'}.'/democourses.tab') || 
-        die "Could not open demo course file from ".$perlvar{'lonTabDir'};
-    while (my $line=<IN>) {
-	chomp($line);
-        my ($name,$descr)=split(/\&/,$line);
-        $democourses{$name}=$descr;
-    }
-    close(IN);
-}
-
 sub footer {
     return (<<'ENDFOOTER');
 --
@@ -329,9 +302,9 @@
 # ================================================================ Main Program
 
 print "Content-type: text/html\n\n".
-      "<html><head><title>LON-CAPA Demo Signup</title></head>".
-      "<body bgcolor='#FFFFFF'>\n".
-"<h1>Welcome to the Learning<i>Online</i> Network with CAPA Demo Server!</h1>";
+      "<html><head><title>LON-CAPA NSDL Guest Signup</title></head>".
+      "<body bgcolor='#BBBBAA'>\n".
+"<h1>Welcome to the Learning<i>Online</i> Network with CAPA NSDL Gateway Server!</h1><img src='/adm/lonDomLogos/nsdl.gif' align='right' />";
 
 # ---------------------------------- Read loncapa_apache.conf and loncapa.conf
 my $perlvarref=LONCAPA::Configuration::read_conf('loncapa_apache.conf',
@@ -341,7 +314,6 @@
 delete $perlvar{'lonReceipt'};   # remove since sensitive and not needed
 delete $perlvar{'lonSqlAccess'}; # remove since sensitive and not needed
 
-&readdemo();
 
 # ------------------------------------------------------------- Read hosts file
 {
@@ -379,12 +351,6 @@
                $value =~ s/[\~\'\"]//g;
                $form{$name}=$value;
             }
-# ------------------------------------------------ Get courses from get, if any
-$courses=$ENV{'QUERY_STRING'};
-$courses =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
-$courses =~ s/[^a-z\&]//g;
-unless ($courses) { $courses='default'; }
-# ------------------------------------------------------------ Check Form Input
 
 my $error=&checkform();
 
@@ -396,7 +362,7 @@
     my $result=&enroll($form{'huser'},$upass,$form{'afirst'},$form{'blast'});
     if ($result=~/error/) {
 	&logthis($result);
-        print &errorwrap('Sorry, demo functionality currently not available');
+        print &errorwrap('Sorry, guest functionality currently not available');
     } else {
         print "Your access information will be emailed to ".$form{'gemail'};
         &sendemail($upass);
@@ -404,7 +370,7 @@
 }
 # ------------------------------------------------------------------------- End
 
-    print('<p><pre>'.&footer()."</pre></body></html>\n");
+    print('<p><table bgcolor="#999999" width="100%" cellspacing="3"><tr><td bgcolor="#FFFFFF"><pre>'.&footer().'</pre></td><td bgcolor="#FFFFFF"><img src="/adm/lonIcons/SMETE_white.gif" align="right"></td></tr></table></body></html>');
 1;