[LON-CAPA-cvs] cvs: loncom(GCI_3) /interface lonsupportreq.pm

raeburn raeburn@source.lon-capa.org
Thu, 02 Dec 2010 23:18:37 -0000


raeburn		Thu Dec  2 23:18:37 2010 EDT

  Modified files:              (Branch: GCI_3)
    /loncom/interface	lonsupportreq.pm 
  Log:
  - Customization for GCI_3.
    - Backport 1.60, 1.61.
  
  
Index: loncom/interface/lonsupportreq.pm
diff -u loncom/interface/lonsupportreq.pm:1.55.6.2 loncom/interface/lonsupportreq.pm:1.55.6.3
--- loncom/interface/lonsupportreq.pm:1.55.6.2	Thu Dec  2 13:12:11 2010
+++ loncom/interface/lonsupportreq.pm	Thu Dec  2 23:18:37 2010
@@ -1,5 +1,5 @@
 #
-# $Id: lonsupportreq.pm,v 1.55.6.2 2010/12/02 13:12:11 raeburn Exp $
+# $Id: lonsupportreq.pm,v 1.55.6.3 2010/12/02 23:18:37 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -37,8 +37,7 @@
 use Apache::lonlocal;
 use Apache::lonacc();
 use Apache::courseclassifier;
-use LONCAPA;
- 
+use LONCAPA qw(:DEFAULT :match); 
 
 sub handler {
     my ($r) = @_;
@@ -57,7 +56,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') {
@@ -70,15 +69,21 @@
     
 sub print_request_form {
     my ($r,$origurl,$function) = @_;
-    my ($os,$browser,$bversion,$uhost,$uname,$udom,$uhome,$urole,$usec,$email,$cid,$cdom,$cnum,$ctitle,$ccode,$sectionlist,$lastname,$firstname,$server,$formname);
+    my ($os,$browser,$bversion,$uhost,$uname,$udom,$uhome,$urole,$usec,$email,$cid,
+        $cdom,$cnum,$ctitle,$ccode,$sectionlist,$lastname,$firstname,$server,
+        $formname,$public);
     $function = &Apache::loncommon::get_users_function() if (!$function);
     $ccode = '';
     $os = $env{'browser.os'};
     $browser = $env{'browser.type'};
     $bversion = $env{'browser.version'};
     $uhost = $env{'request.host'};
-    $uname = $env{'user.name'};
-    $udom = $env{'user.domain'};
+    if (($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')) {
+        $public = 1;
+    } else {
+        $uname = $env{'user.name'};
+        $udom = $env{'user.domain'};
+    }
     $uhome = $env{'user.home'};
     $urole = $env{'request.role'};
     $usec = $env{'request.course.sec'};
@@ -172,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) {
@@ -266,7 +284,7 @@
                &Apache::lonhtmlcommon::row_closure();
     $num ++;
     $i = $num%2;
-    if (defined($env{'user.name'})) {
+    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();
@@ -278,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="15" 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 +453,7 @@
                &Apache::lonhtmlcommon::row_closure();
     $num ++;
     $i = $num%2; 
-    if (defined($env{'user.name'})) {
+    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();