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

raeburn raeburn@source.lon-capa.org
Fri, 08 Oct 2010 01:59:39 -0000


This is a MIME encoded message

--raeburn1286503179
Content-Type: text/plain

raeburn		Fri Oct  8 01:59:39 2010 EDT

  Modified files:              
    /loncom/interface	loncreateuser.pm 
  Log:
  - Move breadcrumbs construction into hash refs for bread_crumbs and 
     bread_crumbs_component in third arg paseed to loncommon::start_page().
  - Consolidate calls to loncommon::end_page() into a single call at 
     end of handler. 
  
  
--raeburn1286503179
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20101008015939.txt"

Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.350 loncom/interface/loncreateuser.pm:1.351
--- loncom/interface/loncreateuser.pm:1.350	Sun Sep 26 01:57:21 2010
+++ loncom/interface/loncreateuser.pm	Fri Oct  8 01:59:39 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.350 2010/09/26 01:57:21 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.351 2010/10/08 01:59:39 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -479,7 +479,7 @@
 # =================================================================== Phase one
 
 sub print_username_entry_form {
-    my ($r,$context,$response,$srch,$forcenewuser,$crstype) = @_;
+    my ($r,$context,$response,$srch,$forcenewuser,$crstype,$brcrum) = @_;
     my $defdom=$env{'request.role.domain'};
     my $formtoset = 'crtuser';
     if (exists($env{'form.startrolename'})) {
@@ -503,31 +503,36 @@
         && (&Apache::lonnet::allowed('mcr','/'))) {
         $jscript .= &customrole_javascript();
     }
-    my %loaditems = (
-                'onload' => "javascript:setFormElements(document.$formtoset)",
-                    );
-    my %breadcrumb_text = &singleuser_breadcrumb($crstype);
-    my $start_page =
-	&Apache::loncommon::start_page('User Management',
-				       $jscript,{'add_entries' => \%loaditems,});
-    if ($env{'form.action'} eq 'custom') {
-        &Apache::lonhtmlcommon::add_breadcrumb
-          ({href=>"javascript:backPage(document.crtuser)",
-            text=>"Pick custom role",});
-    } else {
-        &Apache::lonhtmlcommon::add_breadcrumb
-          ({href=>"javascript:backPage(document.crtuser)",
-            text=>$breadcrumb_text{'search'},
-            faq=>282,bug=>'Instructor Interface',});
-    }
     my $helpitem = 'Course_Change_Privileges';
     if ($env{'form.action'} eq 'custom') {
         $helpitem = 'Course_Editing_Custom_Roles';
     } elsif ($env{'form.action'} eq 'singlestudent') {
         $helpitem = 'Course_Add_Student';
     }
-    my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('User Management',
-                                                     $helpitem);
+    my %breadcrumb_text = &singleuser_breadcrumb($crstype);
+    if ($env{'form.action'} eq 'custom') {
+        push(@{$brcrum},
+                 {href=>"javascript:backPage(document.crtuser)",       
+                  text=>"Pick custom role",
+                  help => $helpitem,}
+                 );
+    } else {
+        push (@{$brcrum},
+                  {href => "javascript:backPage(document.crtuser)",
+                   text => $breadcrumb_text{'search'},
+                   help => $helpitem,
+                   faq  => 282,
+                   bug  => 'Instructor Interface',}
+                  );
+    }
+    my %loaditems = (
+                'onload' => "javascript:setFormElements(document.$formtoset)",
+                    );
+    my $args = {bread_crumbs           => $brcrum,
+                bread_crumbs_component => 'User Management',
+                add_entries            => \%loaditems,};
+    $r->print(&Apache::loncommon::start_page('User Management',$jscript,$args));
+
     my %lt=&Apache::lonlocal::texthash(
                     'srst' => 'Search for a user and enroll as a student',
                     'srme' => 'Search for a user and enroll as a member',
@@ -538,7 +543,7 @@
                     'nr'   => "role name",
                     'cre'  => "Next",
 				       );
-    $r->print($start_page."\n".$crumbs);
+
     if ($env{'form.action'} eq 'custom') {
         if (&Apache::lonnet::allowed('mcr','/')) {
             my $newroletext = &mt('Define new custom role:');
@@ -591,7 +596,6 @@
         }
         $r->print(&entry_form($defdom,$srch,$forcenewuser,$context,$response,$crstype));
     }
-    $r->print(&Apache::loncommon::end_page());
 }
 
 sub customrole_javascript {
@@ -761,7 +765,7 @@
 
 # =================================================================== Phase two
 sub print_user_selection_page {
-    my ($r,$response,$srch,$srch_results,$srcharray,$context,$opener_elements,$crstype) = @_;
+    my ($r,$response,$srch,$srch_results,$srcharray,$context,$opener_elements,$crstype,$brcrum) = @_;
     my @fields = ('username','domain','lastname','firstname','permanentemail');
     my $sortby = $env{'form.sortby'};
 
@@ -802,25 +806,30 @@
     if ($context eq 'requestcrs') {
         $r->print('<div>');
     } else {
-        $r->print(&Apache::loncommon::start_page('User Management',$jscript));
-
         my %breadcrumb_text = &singleuser_breadcrumb($crstype);
-        &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',});
+        my $helpitem;
+        if ($env{'form.action'} eq 'singleuser') {
+            $helpitem = 'Course_Change_Privileges';
+        } elsif ($env{'form.action'} eq 'singlestudent') {
+            $helpitem = 'Course_Add_Student';
+        }
+        push (@{$brcrum},
+                  {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',
+                   help => $helpitem}
+                  );
+        $r->print(&Apache::loncommon::start_page('User Management',$jscript,{bread_crumbs => $brcrum}));
         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,undef,$crstype));
             $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>");
             if ($crstype eq 'Community') {
                 $r->print($lt{'memsrch'});
@@ -897,12 +906,12 @@
     if ($context eq 'requestcrs') {
         $r->print($opener_elements.'</form></div>');
     } else {
-        $r->print($response.'</form>'.&Apache::loncommon::end_page());
+        $r->print($response.'</form>');
     }
 }
 
 sub print_user_query_page {
-    my ($r,$caller) = @_;
+    my ($r,$caller,$brcrum) = @_;
 # FIXME - this is for a network-wide name search (similar to catalog search)
 # To use frames with similar behavior to catalog/portfolio search.
 # To be implemented. 
@@ -910,11 +919,11 @@
 }
 
 sub print_user_modification_page {
-    my ($r,$ccuname,$ccdomain,$srch,$response,$context,$permission,$crstype) = @_;
+    my ($r,$ccuname,$ccdomain,$srch,$response,$context,$permission,$crstype,$brcrum) = @_;
     if (($ccuname eq '') || ($ccdomain eq '')) {
         my $usermsg = &mt('No username and/or domain provided.');
         $env{'form.phase'} = '';
-	&print_username_entry_form($r,$context,$usermsg,'','',$crstype);
+	&print_username_entry_form($r,$context,$usermsg,'','',$crstype,$brcrum);
         return;
     }
     my ($form,$formname);
@@ -955,7 +964,7 @@
                             ,'<a href="'.$helplink.'">','</a>')
                         .'</p><br />';
             $env{'form.phase'} = '';
-            &print_username_entry_form($r,$context,$response,undef,undef,$crstype);
+            &print_username_entry_form($r,$context,$response,undef,undef,$crstype,$brcrum);
             return;
         }
         $newuser = 1;
@@ -979,7 +988,7 @@
                             'username');
                     }
                     $env{'form.phase'} = '';
-                    &print_username_entry_form($r,$context,$userchkmsg,undef,undef,$crstype);
+                    &print_username_entry_form($r,$context,$userchkmsg,undef,undef,$crstype,$brcrum);
                     return;
                 }
             }
@@ -1000,34 +1009,37 @@
 
     my $js = &validation_javascript($context,$ccdomain,$pjump_def,
                                $groupslist,$newuser,$formname,\%loaditem);
-    my $args = {'add_entries' => \%loaditem};  
-    if ($env{'form.popup'}) {
-       $args->{'no_nav_bar'} = 1; 
-    }
-    my $start_page = 
-	&Apache::loncommon::start_page('User Management',$js,$args);
     my %breadcrumb_text = &singleuser_breadcrumb($crstype);
-    &Apache::lonhtmlcommon::add_breadcrumb
-     ({href=>"javascript:backPage($form)",
-       text=>$breadcrumb_text{'search'},
-       faq=>282,bug=>'Instructor Interface',});
-
-    if ($env{'form.phase'} eq 'userpicked') {
-        &Apache::lonhtmlcommon::add_breadcrumb
-     ({href=>"javascript:backPage($form,'get_user_info','select')",
-       text=>$breadcrumb_text{'userpicked'},
-       faq=>282,bug=>'Instructor Interface',});
-    }
-    &Apache::lonhtmlcommon::add_breadcrumb
-      ({href=>"javascript:backPage($form,'$env{'form.phase'}','modify')",
-        text=>$breadcrumb_text{'modify'},
-        faq=>282,bug=>'Instructor Interface',});
     my $helpitem = 'Course_Change_Privileges';
     if ($env{'form.action'} eq 'singlestudent') {
         $helpitem = 'Course_Add_Student';
     }
-    my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('User Management',
-                                                     $helpitem);
+    push (@{$brcrum},
+        {href => "javascript:backPage($form)",
+         text => $breadcrumb_text{'search'},
+         faq  => 282,
+         bug  => 'Instructor Interface',});
+    if ($env{'form.phase'} eq 'userpicked') {
+       push(@{$brcrum},
+              {href => "javascript:backPage($form,'get_user_info','select')",
+               text => $breadcrumb_text{'userpicked'},
+               faq  => 282,
+               bug  => 'Instructor Interface',});
+    }
+    push(@{$brcrum},
+            {href => "javascript:backPage($form,'$env{'form.phase'}','modify')",
+             text => $breadcrumb_text{'modify'},
+             faq  => 282,
+             bug  => 'Instructor Interface',
+             help => $helpitem});
+    my $args = {'add_entries'           => \%loaditem,
+                'bread_crumbs'          => $brcrum,
+                'bread_crumbs_component' => 'User Management'};
+    if ($env{'form.popup'}) {
+        $args->{'no_nav_bar'} = 1;
+    }
+    my $start_page =
+        &Apache::loncommon::start_page('User Management',$js,$args);
 
     my $forminfo =<<"ENDFORMINFO";
 <form action="/adm/createuser" method="post" name="$formname">
@@ -1076,7 +1088,6 @@
         );
 	$r->print(<<ENDTITLE);
 $start_page
-$crumbs
 $response
 $forminfo
 <script type="text/javascript" language="Javascript">
@@ -1190,7 +1201,6 @@
 				       );
 	$r->print(<<ENDCHANGEUSER);
 $start_page
-$crumbs
 $forminfo
 <h2>
 ENDCHANGEUSER
@@ -1337,7 +1347,6 @@
     $r->print(&Apache::lonhtmlcommon::echo_form_input(['phase','userrole','ccdomain','prevphase','currstate','ccuname','ccdomain']));
     $r->print('<input type="hidden" name="currstate" value="" />');
     $r->print('<input type="hidden" name="prevphase" value="'.$env{'form.phase'}.'" />');
-    $r->print("</form>".&Apache::loncommon::end_page());
     return;
 }
 
@@ -2180,7 +2189,7 @@
 
 # ================================================================= Phase Three
 sub update_user_data {
-    my ($r,$context,$crstype) = @_; 
+    my ($r,$context,$crstype,$brcrum) = @_; 
     my $uhome=&Apache::lonnet::homeserver($env{'form.ccuname'},
                                           $env{'form.ccdomain'});
     # Error messages
@@ -2205,36 +2214,39 @@
                   '// ]]>'."\n".
                   '</script>'."\n";
     my %breadcrumb_text = &singleuser_breadcrumb($crstype);
-    my $args;
-    if ($env{'form.popup'}) {
-        $args->{'no_nav_bar'} = 1;
-    } else {
-        $args = undef;
-    }
-    $r->print(&Apache::loncommon::start_page($title,$jscript,$args));
-    &Apache::lonhtmlcommon::add_breadcrumb
-       ({href=>"javascript:backPage(document.userupdate)",
-         text=>$breadcrumb_text{'search'},
-         faq=>282,bug=>'Instructor Interface',});
+    push (@{$brcrum},
+             {href => "javascript:backPage(document.userupdate)",
+              text => $breadcrumb_text{'search'},
+              faq  => 282,
+              bug  => 'Instructor Interface',}
+             );
     if ($env{'form.prevphase'} eq 'userpicked') {
-        &Apache::lonhtmlcommon::add_breadcrumb
-           ({href=>"javascript:backPage(document.userupdate,'get_user_info','select')",
-             text=>$breadcrumb_text{'userpicked'},
-             faq=>282,bug=>'Instructor Interface',});
-    }
-    &Apache::lonhtmlcommon::add_breadcrumb
-       ({href=>"javascript:backPage(document.userupdate,'$env{'form.prevphase'}','modify')",
-         text=>$breadcrumb_text{'modify'},
-         faq=>282,bug=>'Instructor Interface',},
-        {href=>"/adm/createuser",
-         text=>"Result",
-         faq=>282,bug=>'Instructor Interface',});
+        push(@{$brcrum},
+               {href => "javascript:backPage(document.userupdate,'get_user_info','select')",
+                text => $breadcrumb_text{'userpicked'},
+                faq  => 282,
+                bug  => 'Instructor Interface',});
+    }
     my $helpitem = 'Course_Change_Privileges';
     if ($env{'form.action'} eq 'singlestudent') {
         $helpitem = 'Course_Add_Student';
     }
-    $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management',
-                                                 $helpitem));
+    push(@{$brcrum}, 
+            {href => "javascript:backPage(document.userupdate,'$env{'form.prevphase'}','modify')",
+             text => $breadcrumb_text{'modify'},
+             faq  => 282,
+             bug  => 'Instructor Interface',},
+            {href => "/adm/createuser",
+             text => "Result",
+             faq  => 282,
+             bug  => 'Instructor Interface',
+             help => $helpitem});
+    my $args = {bread_crumbs          => $brcrum,
+                bread_crumbs_component => 'User Management'};
+    if ($env{'form.popup'}) {
+        $args->{'no_nav_bar'} = 1;
+    }
+    $r->print(&Apache::loncommon::start_page($title,$jscript,$args));
     $r->print(&update_result_form($uhome));
     # Check Inputs
     if (! $env{'form.ccuname'} ) {
@@ -2884,7 +2896,6 @@
                      .&mt('Create/Modify Another User').'</a></p>');
         }
     }
-    $r->print(&Apache::loncommon::end_page());
 }
 
 sub display_userinfo {
@@ -3624,7 +3635,7 @@
 # ========================================================== Custom Role Editor
 
 sub custom_role_editor {
-    my ($r) = @_;
+    my ($r,$brcrum) = @_;
     my $action = $env{'form.customroleaction'};
     my $rolename; 
     if ($action eq 'new') {
@@ -3633,11 +3644,6 @@
         $rolename=$env{'form.rolename'};
     }
 
-    $rolename=~s/[^A-Za-z0-9]//gs;
-    if (!$rolename || $env{'form.phase'} eq 'pickrole') {
-	&print_username_entry_form($r);
-        return;
-    }
     my ($crstype,$context);
     if ($env{'request.course.id'}) {
         $crstype = &Apache::loncommon::course_type();
@@ -3646,6 +3652,13 @@
         $context = 'domain';
         $crstype = $env{'form.templatecrstype'};
     }
+
+    $rolename=~s/[^A-Za-z0-9]//gs;
+    if (!$rolename || $env{'form.phase'} eq 'pickrole') {
+	&print_username_entry_form($r,undef,undef,undef,undef,$crstype,$brcrum);
+        return;
+    }
+
 # ------------------------------------------------------- What can be assigned?
     my %full=();
     my %courselevel=();
@@ -3753,25 +3766,28 @@
     $head_script .= "\n".$jsback."\n"
                    .'// ]]>'."\n"
                    .'</script>'."\n";
-    $r->print(&Apache::loncommon::start_page('Custom Role Editor',$head_script));
-   &Apache::lonhtmlcommon::add_breadcrumb
-     ({href=>"javascript:backPage(document.form1,'pickrole','')",
-       text=>"Pick custom role",
-       faq=>282,bug=>'Instructor Interface',},
-      {href=>"javascript:backPage(document.form1,'','')",
-         text=>"Edit custom role",
-         faq=>282,bug=>'Instructor Interface',});
-    $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management',
-                                                  'Course_Editing_Custom_Roles'));
-
-    $r->print($body_top);
+    push (@{$brcrum},
+              {href => "javascript:backPage(document.form1,'pickrole','')",
+               text => "Pick custom role",
+               faq  => 282,bug=>'Instructor Interface',},
+              {href => "javascript:backPage(document.form1,'','')",
+               text => "Edit custom role",
+               faq  => 282,
+               bug  => 'Instructor Interface',
+               help => 'Course_Editing_Custom_Roles'}
+              );
+    my $args = { bread_crumbs          => $brcrum,
+                 bread_crumbs_component => 'User Management'};
+ 
+    $r->print(&Apache::loncommon::start_page('Custom Role Editor',
+                                             $head_script,$args).
+              $body_top);
     my %lt=&Apache::lonlocal::texthash(
 		    'prv'  => "Privilege",
 		    'crl'  => "Course Level",
                     'dml'  => "Domain Level",
                     'ssl'  => "System Level");
 
-
     $r->print('<div class="LC_left_float">'
              .'<form action=""><fieldset>'
              .'<legend>'.&mt('Select a Template').'</legend>'
@@ -3822,8 +3838,7 @@
    '<input type="hidden" name="startrolename" value="'.$env{'form.rolename'}.
    '" />'."\n".'<input type="hidden" name="currstate" value="" />'."\n".   
    '<input type="reset" value="'.&mt("Reset").'" />'."\n".
-   '<input type="submit" value="'.&mt('Save').'" /></form>'.
-	      &Apache::loncommon::end_page());
+   '<input type="submit" value="'.&mt('Save').'" /></form>');
 }
 # --------------------------------------------------------
 sub make_script_template {
@@ -3901,11 +3916,11 @@
 }
 # ---------------------------------------------------------- Call to definerole
 sub set_custom_role {
-    my ($r,$context) = @_;
+    my ($r,$context,$brcrum) = @_;
     my $rolename=$env{'form.rolename'};
     $rolename=~s/[^A-Za-z0-9]//gs;
     if (!$rolename) {
-	&custom_role_editor($r);
+	&custom_role_editor($r,$brcrum);
         return;
     }
     my ($jsback,$elements) = &crumb_utilities();
@@ -3914,20 +3929,23 @@
                  .$jsback."\n"
                  .'// ]]>'."\n"
                  .'</script>'."\n";
-
-    $r->print(&Apache::loncommon::start_page('Save Custom Role'),$jscript);
-    &Apache::lonhtmlcommon::add_breadcrumb
-        ({href=>"javascript:backPage(document.customresult,'pickrole','')",
-          text=>"Pick custom role",
-          faq=>282,bug=>'Instructor Interface',},
-         {href=>"javascript:backPage(document.customresult,'selected_custom_edit','')",
-          text=>"Edit custom role",
-          faq=>282,bug=>'Instructor Interface',},
-         {href=>"javascript:backPage(document.customresult,'set_custom_roles','')",
-          text=>"Result",
-          faq=>282,bug=>'Instructor Interface',});
-    $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management',
-                                                  'Course_Editing_Custom_Roles'));
+    my $brcrum = [{href => "javascript:backPage(document.customresult,'pickrole','')",
+                   text => "Pick custom role",
+                   faq  => 282,
+                   bug  => 'Instructor Interface',},
+                  {href => "javascript:backPage(document.customresult,'selected_custom_edit','')",
+                   text => "Edit custom role",
+                   faq  => 282,
+                   bug  => 'Instructor Interface',},
+                  {href => "javascript:backPage(document.customresult,'set_custom_roles','')",
+                   text => "Result",
+                   faq  => 282,
+                   bug  => 'Instructor Interface',
+                   help => 'Course_Editing_Custom_Roles'},
+                 ];
+    my $args = { bread_crumbs          => $brcrum,
+                 bread_crumbs_component => 'User Management'}; 
+    $r->print(&Apache::loncommon::start_page('Save Custom Role',$jscript,$args));
 
     my ($rdummy,$roledef)=
 	&Apache::lonnet::get('roles',["rolesdef_$rolename"]);
@@ -3984,7 +4002,6 @@
     }
     $r->print('<p><a href="javascript:backPage(document.customresult,'."'pickrole'".')">'.&mt('Create or edit another custom role').'</a></p><form name="customresult" method="post">');
     $r->print(&Apache::lonhtmlcommon::echo_form_input([]).'</form>');
-    $r->print(&Apache::loncommon::end_page());
 }
 
 # ================================================================ Main Handler
@@ -4008,11 +4025,14 @@
         ['action','state','callingform','roletype','showrole','bulkaction','popup','phase',
          'username','domain','srchterm','srchdomain','srchin','srchby','srchtype']);
     &Apache::lonhtmlcommon::clear_breadcrumbs();
+    my $args;
+    my $brcrum = [];
+    my $bread_crumbs_component = 'User Management';
     if ($env{'form.action'} ne 'dateselect') {
-        &Apache::lonhtmlcommon::add_breadcrumb
-            ({href=>"/adm/createuser",
-              text=>"User Management",
-              help=>'Course_Create_Class_List,Course_Change_Privileges,Course_View_Class_List,Course_Editing_Custom_Roles,Course_Add_Student,Course_Drop_Student,Course_Automated_Enrollment,Course_Self_Enrollment,Course_Manage_Group'});
+        $brcrum = [{href=>"/adm/createuser",
+                    text=>"User Management",
+                    help=>'Course_Create_Class_List,Course_Change_Privileges,Course_View_Class_List,Course_Editing_Custom_Roles,Course_Add_Student,Course_Drop_Student,Course_Automated_Enrollment,Course_Self_Enrollment,Course_Manage_Group'}
+                  ];
     }
     #SD Following files not added to help, because the corresponding .tex-files seem to
     #be missing: Course_Approve_Selfenroll,Course_User_Logs,
@@ -4030,17 +4050,20 @@
 
     # Main switch on form.action and form.state, as appropriate
     if (! exists($env{'form.action'})) {
-        $r->print(&header());
-        $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management'));
+        $args = {bread_crumbs => $brcrum,
+                 bread_crumbs_component => $bread_crumbs_component}; 
+        $r->print(&header(undef,$args));
         $r->print(&print_main_menu($permission,$context,$crstype));
-        $r->print(&Apache::loncommon::end_page());
     } elsif ($env{'form.action'} eq 'upload' && $permission->{'cusr'}) {
-        $r->print(&header());
-        &Apache::lonhtmlcommon::add_breadcrumb
-            ({href=>'/adm/createuser?action=upload&state=',
-              text=>"Upload Users List"});
-        $r->print(&Apache::lonhtmlcommon::breadcrumbs('Upload Users List',
-                                                   'Course_Create_Class_List'));
+        push(@{$brcrum},
+              { href => '/adm/createuser?action=upload&state=',
+                text => 'Upload Users List',
+                help => 'Course_Create_Class_List',
+              });
+        $bread_crumbs_component = 'Upload Users List';
+        $args = {bread_crumbs           => $brcrum,
+                 bread_crumbs_component => $bread_crumbs_component};
+        $r->print(&header(undef,$args));
         $r->print('<form name="studentform" method="post" '.
                   'enctype="multipart/form-data" '.
                   ' action="/adm/createuser">'."\n");
@@ -4056,7 +4079,6 @@
         } else {
             &Apache::lonuserutils::print_first_users_upload_form($r,$context);
         }
-        $r->print('</form>'.&Apache::loncommon::end_page());
     } elsif ((($env{'form.action'} eq 'singleuser') || ($env{'form.action'}
              eq 'singlestudent')) && ($permission->{'cusr'})) {
         my $phase = $env{'form.phase'};
@@ -4073,13 +4095,13 @@
                 if ($env{'form.srchterm'} !~ /^$match_username$/) {
                     my $response = &mt('You must specify a valid username. Only the following are allowed: letters numbers - . @');
                     $env{'form.phase'} = '';
-                    &print_username_entry_form($r,$context,$response,$srch,undef,$crstype);
+                    &print_username_entry_form($r,$context,$response,$srch,undef,$crstype,$brcrum);
                 } else {
                     my $ccuname =&LONCAPA::clean_username($srch->{'srchterm'});
                     my $ccdomain=&LONCAPA::clean_domain($srch->{'srchdomain'});
                     &print_user_modification_page($r,$ccuname,$ccdomain,
                                                   $srch,$response,$context,
-                                                  $permission,$crstype);
+                                                  $permission,$crstype,$brcrum);
                 }
             } elsif ($env{'form.phase'} eq 'get_user_info') {
                 my ($currstate,$response,$forcenewuser,$results) = 
@@ -4089,7 +4111,8 @@
                 }
                 if ($currstate eq 'select') {
                     &print_user_selection_page($r,$response,$srch,$results,
-                                               \@search,$context,undef,$crstype);
+                                               \@search,$context,undef,$crstype,
+                                               $brcrum);
                 } elsif ($currstate eq 'modify') {
                     my ($ccuname,$ccdomain);
                     if (($srch->{'srchby'} eq 'uname') && 
@@ -4107,56 +4130,62 @@
                     }
                     &print_user_modification_page($r,$ccuname,$ccdomain,
                                                   $srch,$response,$context,
-                                                  $permission,$crstype);
+                                                  $permission,$crstype,$brcrum);
                 } elsif ($currstate eq 'query') {
-                    &print_user_query_page($r,'createuser');
+                    &print_user_query_page($r,'createuser',$brcrum);
                 } else {
                     $env{'form.phase'} = '';
                     &print_username_entry_form($r,$context,$response,$srch,
-                                               $forcenewuser,$crstype);
+                                               $forcenewuser,$crstype,$brcrum);
                 }
             } elsif ($env{'form.phase'} eq 'userpicked') {
                 my $ccuname = &LONCAPA::clean_username($env{'form.seluname'});
                 my $ccdomain = &LONCAPA::clean_domain($env{'form.seludom'});
                 &print_user_modification_page($r,$ccuname,$ccdomain,$srch,'',
-                                              $context,$permission,$crstype);
+                                              $context,$permission,$crstype,
+                                              $brcrum);
             }
         } elsif ($env{'form.phase'} eq 'update_user_data') {
-            &update_user_data($r,$context,$crstype);
+            &update_user_data($r,$context,$crstype,$brcrum);
         } else {
-            &print_username_entry_form($r,$context,undef,$srch,undef,$crstype);
+            &print_username_entry_form($r,$context,undef,$srch,undef,$crstype,
+                                       $brcrum);
         }
     } elsif ($env{'form.action'} eq 'custom' && $permission->{'custom'}) {
         if ($env{'form.phase'} eq 'set_custom_roles') {
-            &set_custom_role($r,$context);
+            &set_custom_role($r,$context,$brcrum);
         } else {
-            &custom_role_editor($r);
+            &custom_role_editor($r,$brcrum);
         }
     } elsif (($env{'form.action'} eq 'listusers') && 
              ($permission->{'view'} || $permission->{'cusr'})) {
         if ($env{'form.phase'} eq 'bulkchange') {
-            &Apache::lonhtmlcommon::add_breadcrumb
-                ({href=>'/adm/createuser?action=listusers',
-                  text=>"List Users"},
-                {href=>"/adm/createuser",
-                  text=>"Result"});
+            push(@{$brcrum},
+                    {href => '/adm/createuser?action=listusers',
+                     text => "List Users"},
+                    {href => "/adm/createuser",
+                     text => "Result",
+                     help => 'Course_View_Class_List'});
+            $bread_crumbs_component = 'Update Users';
+            $args = {bread_crumbs           => $brcrum,
+                     bread_crumbs_component => $bread_crumbs_component};
+            $r->print(&header(undef,$args));
             my $setting = $env{'form.roletype'};
             my $choice = $env{'form.bulkaction'};
-            $r->print(&header());
-            $r->print(&Apache::lonhtmlcommon::breadcrumbs("Update Users",
-                                                          'Course_View_Class_List'));
             if ($permission->{'cusr'}) {
                 &Apache::lonuserutils::update_user_list($r,$context,$setting,$choice,$crstype);
-                $r->print(&Apache::loncommon::end_page());
             } else {
                 $r->print(&mt('You are not authorized to make bulk changes to user roles'));
                 $r->print('<p><a href="/adm/createuser?action=listusers">'.&mt('Display User Lists').'</a>');
-                $r->print(&Apache::loncommon::end_page());
             }
         } else {
-            &Apache::lonhtmlcommon::add_breadcrumb
-                ({href=>'/adm/createuser?action=listusers',
-                  text=>"List Users"});
+            push(@{$brcrum},
+                    {href => '/adm/createuser?action=listusers',
+                     text => "List Users",
+                     help => 'Course_View_Class_List'});
+            $bread_crumbs_component = 'List Users';
+            $args = {bread_crumbs           => $brcrum,
+                     bread_crumbs_component => $bread_crumbs_component};
             my ($cb_jscript,$jscript,$totcodes,$codetitles,$idlist,$idlist_titles);
             my $formname = 'studentform';
             if (($context eq 'domain') && (($env{'form.roletype'} eq 'course') ||
@@ -4180,127 +4209,128 @@
                 my $loadcode = 
                     &Apache::lonuserutils::course_selector_loadcode($formname);
                 if ($loadcode ne '') {
-                    $r->print(&header($js,{'onload' => $loadcode,}));
-                } else {
-                    $r->print(&header($js));
+                    $args->{add_entries} = {onload => $loadcode};
                 }
+                $r->print(&header($js,$args));
             } else {
-                $r->print(&header(&add_script(&verify_user_display())));
+                $r->print(&header(&add_script(&verify_user_display()),$args));
             }
-            $r->print(&Apache::lonhtmlcommon::breadcrumbs("List Users",
-                                                          'Course_View_Class_List'));
             &Apache::lonuserutils::print_userlist($r,undef,$permission,$context,
                          $formname,$totcodes,$codetitles,$idlist,$idlist_titles);
-            $r->print(&Apache::loncommon::end_page());
         }
     } elsif ($env{'form.action'} eq 'drop' && $permission->{'cusr'}) {
-        $r->print(&header());
         my $brtext;
         if ($crstype eq 'Community') {
             $brtext = 'Drop Members';
         } else {
             $brtext = 'Drop Students';
         }
-        &Apache::lonhtmlcommon::add_breadcrumb
-            ({href=>'/adm/createuser?action=drop',
-              text=>$brtext});
+        push(@{$brcrum},
+                {href => '/adm/createuser?action=drop',
+                 text => $brtext,
+                 help => 'Course_Drop_Student'});
+        if ($env{'form.state'} eq 'done') {
+            push(@{$brcrum},
+                     {href=>'/adm/createuser?action=drop',
+                      text=>"Result"});
+        }
+        $bread_crumbs_component = $brtext;
+        $args = {bread_crumbs           => $brcrum,
+                 bread_crumbs_component => $bread_crumbs_component}; 
+        $r->print(&header(undef,$args));
         if (!exists($env{'form.state'})) {
-            $r->print(&Apache::lonhtmlcommon::breadcrumbs($brtext,
-                                                          'Course_Drop_Student'));
-
             &Apache::lonuserutils::print_drop_menu($r,$context,$permission,$crstype);
         } elsif ($env{'form.state'} eq 'done') {
-            &Apache::lonhtmlcommon::add_breadcrumb
-            ({href=>'/adm/createuser?action=drop',
-              text=>"Result"});
-            $r->print(&Apache::lonhtmlcommon::breadcrumbs($brtext,
-                                                          'Course_Drop_Student'));
             &Apache::lonuserutils::update_user_list($r,$context,undef,
                                                     $env{'form.action'});
         }
-        $r->print(&Apache::loncommon::end_page());
     } elsif ($env{'form.action'} eq 'dateselect') {
         if ($permission->{'cusr'}) {
-            $r->print(&header(undef,undef,{'no_nav_bar' => 1}).
+            $r->print(&header(undef,{'no_nav_bar' => 1}).
                       &Apache::lonuserutils::date_section_selector($context,
-                                                                   $permission,$crstype).
-                      &Apache::loncommon::end_page());
+                                                                   $permission,$crstype));
         } else {
-            $r->print(&header().
-                     '<span class="LC_error">'.&mt('You do not have permission to modify dates or sections for users').'</span>'. 
-                     &Apache::loncommon::end_page());
+            $r->print(&header(undef,{'no_nav_bar' => 1}).
+                     '<span class="LC_error">'.&mt('You do not have permission to modify dates or sections for users').'</span>'); 
         }
     } elsif ($env{'form.action'} eq 'selfenroll') {
-        $r->print(&header());
-        &Apache::lonhtmlcommon::add_breadcrumb
-            ({href=>'/adm/createuser?action=selfenroll',
-              text=>"Configure Self-enrollment"});
+        push(@{$brcrum},
+                {href => '/adm/createuser?action=selfenroll',
+                 text => "Configure Self-enrollment",
+                 help => 'Course_Self_Enrollment'});
         if (!exists($env{'form.state'})) {
-            $r->print(&Apache::lonhtmlcommon::breadcrumbs('Configure Self-enrollment',
-                                                          'Course_Self_Enrollment'));
+            $args = { bread_crumbs           => $brcrum,
+                      bread_crumbs_component => 'Configure Self-enrollment'};
+            $r->print(&header(undef,$args));
             $r->print('<h3>'.&mt('Self-enrollment with a student role').'</h3>'."\n");
             &print_selfenroll_menu($r,$context,$permission);
         } elsif ($env{'form.state'} eq 'done') {
-            &Apache::lonhtmlcommon::add_breadcrumb
-            ({href=>'/adm/createuser?action=selfenroll',
-              text=>"Result"});
-            $r->print(&Apache::lonhtmlcommon::breadcrumbs('Self-enrollment result',
-                                                          'Course_Self_Enrollment'));
+            push (@{$brcrum},
+                      {href=>'/adm/createuser?action=selfenroll',
+                       text=>"Result"});
+            $args = { bread_crumbs           => $brcrum,
+                      bread_crumbs_component => 'Self-enrollment result'};
+            $r->print(&header(undef,$args));
             $r->print('<h3>'.&mt('Self-enrollment with a student role').'</h3>'."\n");
             &update_selfenroll_config($r,$context,$permission);
         }
-        $r->print(&Apache::loncommon::end_page());
     } elsif ($env{'form.action'} eq 'selfenrollqueue') {
-        $r->print(&header());
-        &Apache::lonhtmlcommon::add_breadcrumb
-            ({href=>'/adm/createuser?action=selfenrollqueue',
-              text=>"Enrollment requests"});
+        push(@{$brcrum},
+                 {href => '/adm/createuser?action=selfenrollqueue',
+                  text => 'Enrollment requests',
+                  help => 'Course_Self_Enrollment'});
+        $bread_crumbs_component = 'Enrollment requests';
+        if ($env{'form.state'} eq 'done') {
+            push(@{$brcrum},
+                     {href => '/adm/createuser?action=selfenrollqueue',
+                      text => 'Result',
+                      help => 'Course_Self_Enrollment'});
+            $bread_crumbs_component = 'Enrollment result';
+        }
+        $args = { bread_crumbs           => $brcrum,
+                  bread_crumbs_component => $bread_crumbs_component};
+        $r->print(&header(undef,$args));
         my $cid = $env{'request.course.id'};
         my $cdom = $env{'course.'.$cid.'.domain'};
         my $cnum = $env{'course.'.$cid.'.num'};
         my $coursedesc = $env{'course.'.$cid.'.description'};
         if (!exists($env{'form.state'})) {
-            $r->print(&Apache::lonhtmlcommon::breadcrumbs('Enrollment requests',
-                                                          'Course_SelfEnrollment_Approval'));
             $r->print('<h3>'.&mt('Pending enrollment requests').'</h3>'."\n");
             $r->print(&Apache::loncoursequeueadmin::display_queued_requests($context,
                                                                        $cdom,$cnum));
         } elsif ($env{'form.state'} eq 'done') {
-            &Apache::lonhtmlcommon::add_breadcrumb
-            ({href=>'/adm/createuser?action=selfenrollqueue',
-              text=>"Result"});
-            $r->print(&Apache::lonhtmlcommon::breadcrumbs('Enrollment result',
-                                                          'Course_Self_Enrollment'));
             $r->print('<h3>'.&mt('Enrollment request processing').'</h3>'."\n");
             $r->print(&Apache::loncoursequeueadmin::update_request_queue($context,
                           $cdom,$cnum,$coursedesc));
         }
-        $r->print(&Apache::loncommon::end_page());
     } elsif ($env{'form.action'} eq 'changelogs') {
-        $r->print(&header());
-        &Apache::lonhtmlcommon::add_breadcrumb
-            ({href=>'/adm/createuser?action=changelogs',
-              text=>"User Management Logs"});
-        $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Changes',
-                                                      'Course_User_Logs'));
-            &print_userchangelogs_display($r,$context,$permission);
-        $r->print(&Apache::loncommon::end_page());        
+        push (@{$brcrum},
+                 {href => '/adm/createuser?action=changelogs',
+                  text => 'User Management Logs',
+                  help => 'Course_User_Logs'});
+        $bread_crumbs_component = 'User Changes';
+        $args = { bread_crumbs           => $brcrum,
+                  bread_crumbs_component => $bread_crumbs_component};
+        $r->print(&header(undef,$args));
+        &print_userchangelogs_display($r,$context,$permission);
     } else {
-        $r->print(&header());
-        $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management'));
+        $bread_crumbs_component = 'User Management';
+        $args = { bread_crumbs           => $brcrum,
+                  bread_crumbs_component => $bread_crumbs_component};
+        $r->print(&header(undef,$args));
         $r->print(&print_main_menu($permission,$context,$crstype));
-        $r->print(&Apache::loncommon::end_page());
     }
+    $r->print(&Apache::loncommon::end_page());
     return OK;
 }
 
 sub header {
-    my ($jscript,$loaditems,$args) = @_;
+    my ($jscript,$args) = @_;
     my $start_page;
-    if (ref($loaditems) eq 'HASH') {
-        $start_page=&Apache::loncommon::start_page('User Management',$jscript,{'add_entries' => $loaditems});
-    } else {
+    if (ref($args) eq 'HASH') {
         $start_page=&Apache::loncommon::start_page('User Management',$jscript,$args);
+    } else {
+        $start_page=&Apache::loncommon::start_page('User Management',$jscript);
     }
     return $start_page;
 }

--raeburn1286503179--