[LON-CAPA-cvs] cvs: modules /gerd signon.pl

www lon-capa-cvs@mail.lon-capa.org
Mon, 22 Jul 2002 21:00:24 -0000


www		Mon Jul 22 17:00:24 2002 EDT

  Modified files:              
    /modules/gerd	signon.pl 
  Log:
  Seems to work.
  
  
Index: modules/gerd/signon.pl
diff -u modules/gerd/signon.pl:1.3 modules/gerd/signon.pl:1.4
--- modules/gerd/signon.pl:1.3	Mon Jul 22 14:38:15 2002
+++ modules/gerd/signon.pl	Mon Jul 22 17:00:24 2002
@@ -10,6 +10,11 @@
 
 my $demodomain='worf';
 my $demohome='worfl1';
+my $admemail='lon-capa@lon-capa.org';
+my $demoserver='demo.lon-capa.org';
+
+
+
 my %perlvar=();
 my %form=();
 my %democourses=();
@@ -158,13 +163,10 @@
     $uname=~s/\W//g;
     &logthis('Call to modify user '.$udom.', '.$uname.', '.
              $umode.', '.$first.', '.
-	     $last.', '.
-             (defined($desiredhome) ? ' desiredhome = '.$desiredhome :
-                                     ' desiredhome not specified'). 
-             ' by '.$ENV{'user.name'}.' at '.$ENV{'user.domain'});
+	     $last.', '.$desiredhome);
     my $uhome=$demohome;
 # ----------------------------------------------------------------- Create User
-    if (($uhome eq 'no_host') && ($umode) && ($upass)) {
+    if (($umode) && ($upass)) {
         my $unhome=$desiredhome;
         if (($unhome eq '') || ($unhome eq 'no_host')) {
 	    return 'error: unable to find a home server for '.$uname.
@@ -173,7 +175,7 @@
         my $reply=&reply('encrypt:makeuser:'.$udom.':'.$uname.':'.$umode.':'.
                          &escape($upass),$unhome);
 	unless ($reply eq 'ok') {
-            return 'error: '.$reply;
+            return 'error makeuser '.$udom.' '.$unhome.': '.$reply;
         }   
         $uhome=&homeserver($uname,$udom,'true');
         if (($uhome eq '') || ($uhome eq 'no_host') || ($uhome ne $unhome)) {
@@ -204,15 +206,15 @@
     my $reply=&modifyuser($uname,$upass,$first,$last);
     unless ($reply eq 'ok') { return $reply; }
 # -------------------------------------------------- Add student to course list
-    $reply=critical('put:'.$cdom.':'.$cnum.':classlist:'.
+    $reply=reply('put:'.$cdom.':'.$cnum.':classlist:'.
                       &escape($uname.':'.$udom).'='.
                       &escape($end.':'.$start),
 	              $chome);
     unless (($reply eq 'ok') || ($reply eq 'delayed')) {
-	return 'error: '.$reply;
+	return "error course list ".$reply;
     }
 # ---------------------------------------------------- Add student role to user
-    my $uurl='/'.$cnum;
+    my $uurl='/'.$cdom.'_'.$cnum;
     $uurl=~s/\_/\//g;
     return &assignrole($uname,$uurl,'st',$end,$start);
 }
@@ -221,9 +223,12 @@
     my ($uname,$upass,$first,$last)=@_;
     my $returnval='';
     foreach (split(/\&/,$courses)) {
-	my ($cdom,$chome,$cid)=split(/\:/,$democourses{$_});
+      my ($cdom,$chome,$cid)=split(/\:/,$democourses{$_});
+      if ($cid) {
         $returnval.=
-         &modifystudent($uname,$upass,$first,$last,$cid,$cdom,$chome)."<br>\n";
+         &modifystudent
+ ($uname,$upass,$first,$last,$cid,$cdom,$chome)."<br>\n";
+      }
     }
     return $returnval;
 }
@@ -287,6 +292,18 @@
 }
 
 sub sendemail {
+    my $upass=shift;
+   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 "  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 "\n\nThank you for your interest in LON-CAPA!\n".&footer; 
+   close MAILOUT;
 }
 
 sub readdemo {
@@ -299,6 +316,17 @@
     }
     close(IN);
 }
+
+sub footer {
+    return (<<'ENDFOOTER');
+--
+www.lon-capa.org
+lon-capa@lon-capa.org
+User Help: http://help.lon-capa.org/
+Bugs and Enhancements: http://bugs.lon-capa.org/
+Mailing Lists: http://mail.lon-capa.org/
+ENDFOOTER
+}
 # ================================================================ Main Program
 
 print "Content-type: text/html\n\n".
@@ -365,17 +393,19 @@
     print "<p><b>$error</b>";
     &makeform();
 } else {
-#if ($totalcount>200) {
-#   print "mailing\n";
-#   $emailto="$perlvar{'lonAdmEMail'},$perlvar{'lonSysEMail'}";
-#   $subj="LON: $perlvar{'lonHostID'} E:$errors W:$warnings N:$notices"; 
-#   system(
-# "metasend -b -t $emailto -s '$subj' -f $statusdir/index.html -m text/html");
-#}
+    my $upass=&genpass();
+    my $result=&enroll($form{'huser'},$upass,$form{'afirst'},$form{'blast'});
+    if ($result=~/error/) {
+	&logthis($result);
+        print &errorwrap('Sorry, demo functionality currently not available');
+    } else {
+        print "Your access information will be emailed to ".$form{'gemail'};
+        &sendemail($upass);
+    }
 }
 # ------------------------------------------------------------------------- End
-print &enroll('fred','flint','Fred','Flintstone');
-    print("</body></html>\n");
+
+    print('<p><pre>'.&footer()."</pre></body></html>\n");
 1;