[LON-CAPA-cvs] cvs: loncom /interface createaccount.pm lonsupportreq.pm

raeburn raeburn@source.lon-capa.org
Thu, 02 Dec 2010 22:05:17 -0000


raeburn		Thu Dec  2 22:05:17 2010 EDT

  Modified files:              
    /loncom/interface	createaccount.pm lonsupportreq.pm 
  Log:
  - Self-creation of account with e-mail address as username.
    - Link to helpdesk support form includes username and e-mail address in query 
      string if new account is requested for an account which already exists.
  
  
Index: loncom/interface/createaccount.pm
diff -u loncom/interface/createaccount.pm:1.43 loncom/interface/createaccount.pm:1.44
--- loncom/interface/createaccount.pm:1.43	Wed Dec  1 21:38:29 2010
+++ loncom/interface/createaccount.pm	Thu Dec  2 22:05:17 2010
@@ -3,7 +3,7 @@
 # institutional log-in ID (institutional authentication required - localauth
 #  or kerberos) or an e-mail address.
 #
-# $Id: createaccount.pm,v 1.43 2010/12/01 21:38:29 raeburn Exp $
+# $Id: createaccount.pm,v 1.44 2010/12/02 22:05:17 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1152,16 +1152,22 @@
     if ($msgtext) {
         $msg .= '<br />'.$msgtext;
     }
-    $msg .= &linkto_email_help($contact_email,$domdesc);
+    $msg .= &linkto_email_help($contact_email,$domdesc,$error);
     return $msg;
 }
 
 sub linkto_email_help {
-    my ($contact_email,$domdesc) = @_;
+    my ($contact_email,$domdesc,$error) = @_;
     my $msg;
+    my $href = '/adm/helpdesk';
     if ($contact_email ne '') {
         my $escuri = &HTML::Entities::encode('/adm/createaccount','&<>"');
-        $msg .= '<br />'.&mt('You may wish to contact the [_1]LON-CAPA helpdesk[_2] for [_3].','<a href="/adm/helpdesk?origurl='.$escuri.'">','</a>',$domdesc).'<br />';
+        $href .= '?origurl='.$escuri;
+        if ($error eq 'existinguser') {
+            my $escemail = &HTML::Entities::encode($env{'form.useremail'});
+            $href .= '&useremail='.$escemail.'&useraccount='.$escemail;
+        }
+        $msg .= '<br />'.&mt('You may wish to contact the [_1]LON-CAPA helpdesk[_2] for [_3].','<a href="'.$href.'">','</a>',$domdesc).'<br />';
     } else {
         $msg .= '<br />'.&mt('You may wish to send an e-mail to the server administrator: [_1] for [_2].',$Apache::lonnet::perlvar{'AdminEmail'},$domdesc).'<br />';
     }
Index: loncom/interface/lonsupportreq.pm
diff -u loncom/interface/lonsupportreq.pm:1.59 loncom/interface/lonsupportreq.pm:1.60
--- loncom/interface/lonsupportreq.pm:1.59	Thu Dec  2 06:00:12 2010
+++ loncom/interface/lonsupportreq.pm	Thu Dec  2 22:05:17 2010
@@ -1,5 +1,5 @@
 #
-# $Id: lonsupportreq.pm,v 1.59 2010/12/02 06:00:12 raeburn Exp $
+# $Id: lonsupportreq.pm,v 1.60 2010/12/02 22:05:17 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -37,7 +37,7 @@
 use Apache::lonlocal;
 use Apache::lonacc();
 use Apache::courseclassifier;
-use LONCAPA;
+use LONCAPA qw(:DEFAULT :match);
  
 
 sub handler {
@@ -57,7 +57,7 @@
         &Apache::lonacc::get_posted_cgi($r);
     }
     my $function = $env{'form.function'};
-    my $origurl = &unescape($env{'form.origurl'});
+    my $origurl = $env{'form.origurl'};
     my $command = $env{'form.command'};
 
     if ($command eq 'process') {
@@ -77,8 +77,10 @@
     $browser = $env{'browser.type'};
     $bversion = $env{'browser.version'};
     $uhost = $env{'request.host'};
-    my ($uname,$udom);
-    if (($env{'user.name'} ne 'public') && ($env{'user.domain'} ne 'public')) {
+    my ($uname,$udom,$public);
+    if (($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')) {
+        $public = 1;
+    } else {
         $uname = $env{'user.name'};
         $udom = $env{'user.domain'};
     }
@@ -175,7 +177,20 @@
         my ($sec,$grp) = split(/:/,$section);
         $groupid{$sec} = $grp;
     }
-    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['codedom']);
+    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['codedom',
+                                                 'useremail','useraccount']);
+    if ($env{'form.origurl'} eq '/adm/createaccount') {
+        if ($email eq '') {
+            if ($env{'form.useremail'} =~ /^[^\@]+\@[^\@]+$/) {
+                $email = &HTML::Entities::encode($env{'form.useremail'},'"<>&');
+            }
+        }
+        if ($uname eq '') {
+            if ($env{'form.useraccount'} =~ /^$match_username$/) {
+                $uname = &HTML::Entities::encode($env{'form.useraccount'},'"<>&');
+            }
+        }
+    }
     my $codedom = &get_domain();
     my $details_title;
     if ($codedom) {
@@ -269,7 +284,7 @@
                &Apache::lonhtmlcommon::row_closure();
     $num ++;
     $i = $num%2;
-    if (defined($uname)) {
+    if (($env{'user.name'} =~ /^$match_username$/) && (!$public)) {
         $output .= &Apache::lonhtmlcommon::row_title($lt{'emac'},undef,$css[$i]).
                    '<input type="text" size="50" name="cc" value="" /><br />'."\n".
                    &Apache::lonhtmlcommon::row_closure();
@@ -281,30 +296,33 @@
                      &HTML::Entities::encode($udom,'"<>&').'" />';
     my $uname_input = '<input type="hidden" name="uname" value="'.
                       &HTML::Entities::encode($uname,'"<>&').'" />'; 
-    if (defined($uname) && defined($udom)) {
+    if (($env{'user.name'} =~ /^$match_username$/) && 
+        ($env{'user.domain'} =~ /^$match_domain$/) && (!$public)) {
         $output .= '<i>'.$lt{'unme'}.'</i>:&nbsp;'.$uname.'&nbsp;&nbsp;<i>'.$lt{'doma'}.'</i>:&nbsp;'.$udom.$udom_input.$uname_input;
     } else {
         my $udomform = '';
         my $unameform = '';
-        if (defined($udom)) {
+        if (($env{'user.domain'} =~ /^$match_domain$/) && (!$public)) {
             $output .= $lt{'entu'};
-        } elsif (defined($uname)) {
+        } elsif (($env{'user.name'} =~ /^$match_username$/) && (!$public)) { 
             $output .= $lt{'chdo'};
         } else {
             $output .= $lt{'entr'};
         }
         $output .= '<br />';
-        if (defined($udom)) {
-            $udomform = '<i>'.$lt{'doma'}.'</i>:&nbsp;'.$udom.$udom_input;
-        } elsif (defined($uname)) {
-            $unameform = '<i>'.$lt{'unme'}.'</i>:&nbsp;'.$uname.'&nbsp;&nbsp;'.$uname_input;
+        if (!$public) {
+            if ($env{'user.domain'} =~ /^$match_domain$/) {
+                $udomform = '<i>'.$lt{'doma'}.'</i>:&nbsp;'.$udom.$udom_input;
+            } elsif ($env{'user.name'} =~ /^$match_username$/) {
+                $unameform = '<i>'.$lt{'unme'}.'</i>:&nbsp;'.$uname.'&nbsp;&nbsp;'.$uname_input;
+            }
         }
         if ($udomform eq '') {
             $udomform = '<i>'.$lt{'doma'}.'</i>:&nbsp;';
             $udomform .= &Apache::loncommon::select_dom_form($codedom,'udom');
         }
         if ($unameform eq '') {
-            $unameform= '<i>'.$lt{'unme'}.'</i>:&nbsp;<input type="text" size="12" name="uname" value="'.$uname.'" />&nbsp;&nbsp;';
+            $unameform= '<i>'.$lt{'unme'}.'</i>:&nbsp;<input type="text" size="20" name="uname" value="'.$uname.'" />&nbsp;&nbsp;';
         }
         $output .= $unameform.$udomform;
     }
@@ -432,7 +450,7 @@
                &Apache::lonhtmlcommon::row_closure();
     $num ++;
     $i = $num%2; 
-    if (defined($uname)) {
+    if (($env{'user.name'} =~ /^$match_username$/) && (!$public)) {
         $output .= &Apache::lonhtmlcommon::row_title($lt{'opfi'},undef,$css[$i]).
                    ' <input type="file" name="screenshot" size="20" /><br />'.$lt{'uplf'}."\n".
         &Apache::lonhtmlcommon::row_closure();