--- nsdl/nsdlloncapaorg/signon.pl 2003/07/28 14:27:05 1.1
+++ nsdl/nsdlloncapaorg/signon.pl 2003/07/28 15:03:29 1.2
@@ -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 @@ sub modifyuser {
# -------------------------------------------------------------- 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)." \n";
- }
- }
+ &logthis("Going to enroll $uname as guest");
+ my $returnval.=
+ &modifyrole($uname,$upass,$first,$last)." \n";
return $returnval;
}
# ------------------------------------------------------------- Make a password
@@ -253,7 +237,7 @@ sub makeform {
&inputline($_,$formfields{$_});
}
print "\n".
- "".
+ "".
"\n";
}
@@ -265,7 +249,7 @@ sub errorwrap {
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 @@ sub checkform {
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 @@ sub sendemail {
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=) {
- chomp($line);
- my ($name,$descr)=split(/\&/,$line);
- $democourses{$name}=$descr;
- }
- close(IN);
-}
-
sub footer {
return (<<'ENDFOOTER');
--
@@ -329,9 +302,9 @@ ENDFOOTER
# ================================================================ Main Program
print "Content-type: text/html\n\n".
- "LON-CAPA Demo Signup".
- "\n".
-"
Welcome to the LearningOnline Network with CAPA Demo Server!
";
+ "LON-CAPA NSDL Guest Signup".
+ "\n".
+"
Welcome to the LearningOnline Network with CAPA NSDL Gateway Server!
";
# ---------------------------------- Read loncapa_apache.conf and loncapa.conf
my $perlvarref=LONCAPA::Configuration::read_conf('loncapa_apache.conf',
@@ -341,7 +314,6 @@ undef $perlvarref;
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 @@ delete $perlvar{'lonSqlAccess'}; # remov
$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 @@ if ($error) {
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 @@ if ($error) {
}
# ------------------------------------------------------------------------- End
- print('