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

raeburn raeburn@source.lon-capa.org
Tue, 04 Aug 2009 19:59:19 -0000


raeburn		Tue Aug  4 19:59:19 2009 EDT

  Modified files:              
    /loncom/interface	loncreateuser.pm 
  Log:
  - Modifications to display of search results in &print_user_selection_page() to
  facilitate re-use in "Select User" pop-up used in Course Request form.
  - When called in 'requestcrs' context onclick action for "Select" buttons uses gochoose() javascript function provided in calling page (lonpickuser.pm).
  
  
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.301 loncom/interface/loncreateuser.pm:1.302
--- loncom/interface/loncreateuser.pm:1.301	Tue Aug  4 18:02:30 2009
+++ loncom/interface/loncreateuser.pm	Tue Aug  4 19:59:19 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.301 2009/08/04 18:02:30 bisitz Exp $
+# $Id: loncreateuser.pm,v 1.302 2009/08/04 19:59:19 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -530,7 +530,7 @@
 
 # =================================================================== Phase two
 sub print_user_selection_page {
-    my ($r,$response,$srch,$srch_results,$srcharray,$context) = @_;
+    my ($r,$response,$srch,$srch_results,$srcharray,$context,$opener_elements) = @_;
     my @fields = ('username','domain','lastname','firstname','permanentemail');
     my $sortby = $env{'form.sortby'};
 
@@ -566,28 +566,32 @@
                                        'firstname'      => "first name",
                                        'permanentemail' => "permanent e-mail",
                                       );
-    $r->print(&Apache::loncommon::start_page('User Management',$jscript));
+    if ($context eq 'requestcrs') {
+        $r->print('<div>');
+    } else {
+        $r->print(&Apache::loncommon::start_page('User Management',$jscript));
 
-    my %breadcrumb_text = &singleuser_breadcrumb();
-    &Apache::lonhtmlcommon::add_breadcrumb
-        ({href=>"javascript:backPage(document.usersrchform,'','')",
-          text=>$breadcrumb_text{'search'},
-          faq=>282,bug=>'Instructor Interface',},
-         {href=>"javascript:backPage(document.usersrchform,'get_user_info','select')",
-          text=>$breadcrumb_text{'userpicked'},
-          faq=>282,bug=>'Instructor Interface',});
-    if ($env{'form.action'} eq 'singleuser') {
-        $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management',
-                                                      'Course_Change_Privileges'));
-        $r->print("<b>$lt{'usrch'}</b><br />");
-        $r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context));
-        $r->print('<h3>'.$lt{'usel'}.'</h3>');
-    } elsif ($env{'form.action'} eq 'singlestudent') {
-        $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management',
-                                                      'Course_Add_Student'));
-        $r->print($jscript."<b>$lt{'stusrch'}</b><br />");
-        $r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context));
-        $r->print('</form><h3>'.$lt{'stusel'}.'</h3>');
+        my %breadcrumb_text = &singleuser_breadcrumb();
+        &Apache::lonhtmlcommon::add_breadcrumb
+            ({href=>"javascript:backPage(document.usersrchform,'','')",
+              text=>$breadcrumb_text{'search'},
+              faq=>282,bug=>'Instructor Interface',},
+             {href=>"javascript:backPage(document.usersrchform,'get_user_info','select')",
+              text=>$breadcrumb_text{'userpicked'},
+              faq=>282,bug=>'Instructor Interface',});
+        if ($env{'form.action'} eq 'singleuser') {
+            $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management',
+                                                          'Course_Change_Privileges'));
+            $r->print("<b>$lt{'usrch'}</b><br />");
+            $r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context));
+            $r->print('<h3>'.$lt{'usel'}.'</h3>');
+        } elsif ($env{'form.action'} eq 'singlestudent') {
+            $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management',
+                                                          'Course_Add_Student'));
+            $r->print($jscript."<b>$lt{'stusrch'}</b><br />");
+            $r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context));
+            $r->print('</form><h3>'.$lt{'stusel'}.'</h3>');
+        }
     }
     $r->print('<form name="usersrchform" method="post">'.
               &Apache::loncommon::start_data_table()."\n".
@@ -612,8 +616,20 @@
 
     foreach my $user (@sorted_users) {
         my ($uname,$udom) = split(/:/,$user);
+        my $onclick;
+        if ($context eq 'requestcrs') {
+            $onclick = 
+                'onclick="javascript:gochoose('."'$uname','$udom',".
+                                               "'$srch_results->{$user}->{firstname}',".
+                                               "'$srch_results->{$user}->{lastname}',".
+                                               "'$srch_results->{$user}->{permanentemail}'".');"';
+        } else {
+            $onclick = 
+                ' onclick="javascript:pickuser('."'".$uname."'".','."'".$udom."'".');"';
+        }
         $r->print(&Apache::loncommon::start_data_table_row().
-                  '<td><input type="button" name="seluser" value="'.&mt('Select').'" onclick="javascript:pickuser('."'".$uname."'".','."'".$udom."'".')" /></td>'.
+                  '<td><input type="button" name="seluser" value="'.&mt('Select').'" '.
+                  $onclick.' /></td>'.
                   '<td><tt>'.$uname.'</tt></td>'.
                   '<td><tt>'.$udom.'</tt></td>');
         foreach my $field ('lastname','firstname','permanentemail') {
@@ -633,7 +649,11 @@
               ' <input type="hidden" name="currstate" value="select" />'."\n".
               ' <input type="hidden" name="phase" value="get_user_info" />'."\n".
               ' <input type="hidden" name="action" value="'.$env{'form.action'}.'" />'."\n");
-    $r->print($response.'</form>'.&Apache::loncommon::end_page());
+    if ($context eq 'requestcrs') {
+        $r->print($opener_elements.'</form></div>');
+    } else {
+        $r->print($response.'</form>'.&Apache::loncommon::end_page());
+    }
 }
 
 sub print_user_query_page {