Diff for /loncom/auth/lonroles.pm between versions 1.240.2.3 and 1.241

version 1.240.2.3, 2009/12/15 05:04:17 version 1.241, 2010/01/15 03:29:48
Line 138  use Apache::lonannounce; Line 138  use Apache::lonannounce;
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::lonpageflip();  use Apache::lonpageflip();
 use Apache::lonnavdisplay();  use Apache::lonnavdisplay();
 use Apache::lonmainmenu();  use Apache::loncoursequeueadmin;
 use GDBM_File;  use GDBM_File;
 use LONCAPA qw(:DEFAULT :match);  use LONCAPA qw(:DEFAULT :match);
 use HTML::Entities;  use HTML::Entities;
Line 225  sub handler { Line 225  sub handler {
     my %dcroles = ();      my %dcroles = ();
     my $numdc = &check_fordc(\%dcroles,$then);      my $numdc = &check_fordc(\%dcroles,$then);
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'});      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'});
     my $custommenu = &Apache::loncommon::needs_gci_custom();  
   
 # ================================================================== Roles Init  # ================================================================== Roles Init
     if ($env{'form.selectrole'}) {      if ($env{'form.selectrole'}) {
Line 320  sub handler { Line 319  sub handler {
                 }                  }
             }              }
         }          }
         if (($env{'form.cm'}) && ($env{'form.orgurl'})) {   
             $r->internal_redirect($env{'form.orgurl'});  
         }  
         foreach $envkey (keys %env) {          foreach $envkey (keys %env) {
             next if ($envkey!~/^user\.role\./);              next if ($envkey!~/^user\.role\./);
             my ($where,$trolecode,$role,$tstatus,$tend,$tstart);              my ($where,$trolecode,$role,$tstatus,$tend,$tstart);
Line 495  ENDENTERKEY Line 492  ENDENTERKEY
     $courseid = substr($courseid, 1);      $courseid = substr($courseid, 1);
  }   }
  $courseid =~ s/\//_/;   $courseid =~ s/\//_/;
  if (($cdom ne 'gcitest') && (($role eq 'cc') || ($role eq 'co'))    if ((($role eq 'cc') || ($role eq 'co')) 
                                     && ($env{'course.' . $courseid .'.course.helper.not.run'})) {                                       && ($env{'course.' . $courseid .'.course.helper.not.run'})) { 
     $furl = "/adm/helper/course.initialization.helper";      $furl = "/adm/helper/course.initialization.helper";
     # Send the user to the course they selected      # Send the user to the course they selected
Line 519  ENDENTERKEY Line 516  ENDENTERKEY
     .$env{'request.course.sec'})      .$env{'request.course.sec'})
  ) {   ) {
  my $startpage = &courseloadpage($courseid);   my $startpage = &courseloadpage($courseid);
  unless (($startpage eq 'firstres') || ($cdom eq 'gcitest')) {   unless ($startpage eq 'firstres') {         
     $msg = &mt('Entering [_1] ...',      $msg = &mt('Entering [_1] ...',
        $env{'course.'.$courseid.'.description'});         $env{'course.'.$courseid.'.description'});
     &redirect_user($r,&mt('New in course'),      &redirect_user($r,&mt('New in course'),
Line 534  ENDENTERKEY Line 531  ENDENTERKEY
 # Guess not ...  # Guess not ...
     $furl=&Apache::lonpageflip::first_accessible_resource();      $furl=&Apache::lonpageflip::first_accessible_resource();
  }   }
                                 if (($cdom eq 'gcitest') && ($custommenu)) {  
                                     $furl = '/adm/navmaps';  
                                 }  
                                 $msg = &mt('Entering [_1] ...',                                  $msg = &mt('Entering [_1] ...',
    $env{'course.'.$courseid.'.description'});     $env{'course.'.$courseid.'.description'});
  &redirect_user($r,&mt('Entering [_1]',   &redirect_user($r,&mt('Entering [_1]',
Line 579  ENDENTERKEY Line 573  ENDENTERKEY
         }          }
     }      }
   
   
 # =============================================================== No Roles Init  # =============================================================== No Roles Init
   
     &Apache::loncommon::content_type($r,'text/html');      &Apache::loncommon::content_type($r,'text/html');
Line 586  ENDENTERKEY Line 581  ENDENTERKEY
     $r->send_http_header;      $r->send_http_header;
     return OK if $r->header_only;      return OK if $r->header_only;
   
     my ($crumbtext,$pagetitle,$recent,$show_course);      my $crumbtext = 'User Roles';
       my $pagetitle = 'My Roles';
       my $recent = &mt('Recent Roles');
       my $show_course=&Apache::loncommon::show_course();
       if ($show_course) {
           $crumbtext = 'Courses';
           $pagetitle = 'My Courses';
           $recent = &mt('Recent Courses');
       }
       my $brcrum =[{href=>"/adm/roles",text=>$crumbtext}];
       my $swinfo=&Apache::lonmenu::rawconfig();
       my $start_page=&Apache::loncommon::start_page($pagetitle,undef,{bread_crumbs=>$brcrum});
       my $standby=&mt('Role selected. Please stand by.');
       $standby=~s/\n/\\n/g;
     my $noscript='<span class="LC_error">'.&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.').'<br />'.&mt('As this is not the case, most functionality in the system will be unavailable.').'</span><br />';      my $noscript='<span class="LC_error">'.&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.').'<br />'.&mt('As this is not the case, most functionality in the system will be unavailable.').'</span><br />';
     if ($custommenu) {  
         my $start_page = &Apache::loncommon::start_page('Main Menu',undef,      $r->print(<<ENDHEADER);
                                                         {'bread_crumbs' => 1});  
         $r->print(<<"ENDCUSTOM");  
 $start_page  
 <br />  
 <noscript>  
 $noscript  
 </noscript>  
 ENDCUSTOM  
     } else {  
         $crumbtext = 'User Roles';  
         $pagetitle = 'My Roles';  
         $recent = &mt('Recent Roles');  
         $show_course=&Apache::loncommon::show_course();  
         if ($show_course) {  
             $crumbtext = 'Courses';  
             $pagetitle = 'My Courses';  
             $recent = &mt('Recent Courses');  
         }  
         my $brcrum =[{href=>"/adm/roles",text=>$crumbtext}];  
         my $swinfo=&Apache::lonmenu::rawconfig();  
         my $start_page=&Apache::loncommon::start_page($pagetitle,undef,{bread_crumbs=>$brcrum});  
         my $standby=&mt('Role selected. Please stand by.');  
         $standby=~s/\n/\\n/g;  
         $r->print(<<ENDHEADER);  
 $start_page  $start_page
 <br />  <br />
 <noscript>  <noscript>
Line 640  function enterrole (thisform,rolecode,bu Line 624  function enterrole (thisform,rolecode,bu
 // ]]>  // ]]>
 </script>  </script>
 ENDHEADER  ENDHEADER
     }  
   
 # ------------------------------------------ Get Error Message from Environment  # ------------------------------------------ Get Error Message from Environment
   
Line 708  ENDHEADER Line 691  ENDHEADER
         if (($ENV{'REDIRECT_QUERY_STRING'}) && ($fn)) {          if (($ENV{'REDIRECT_QUERY_STRING'}) && ($fn)) {
        $fn.='?'.$ENV{'REDIRECT_QUERY_STRING'};         $fn.='?'.$ENV{'REDIRECT_QUERY_STRING'};
         }          }
         unless ($custommenu) {          $r->print('<form method="post" name="rolechoice" action="'.(($fn)?$fn:$r->uri).'">');
             $r->print('<form method="post" name="rolechoice" action="'.(($fn)?$fn:$r->uri).'">');          $r->print('<input type="hidden" name="orgurl" value="'.$fn.'" />');
             $r->print('<input type="hidden" name="orgurl" value="'.$fn.'" />');          $r->print('<input type="hidden" name="selectrole" value="1" />');
             $r->print('<input type="hidden" name="selectrole" value="1" />');          $r->print('<input type="hidden" name="newrole" value="" />');
             $r->print('<input type="hidden" name="newrole" value="" />');  
         }  
     }      }
   
     my (%roletext,%sortrole,%roleclass,%futureroles,%timezones);      my (%roletext,%sortrole,%roleclass,%futureroles,%timezones);
Line 723  ENDHEADER Line 704  ENDHEADER
   
     $refresh = $now;      $refresh = $now;
     &Apache::lonnet::appenv({'user.refresh.time'  => $refresh});      &Apache::lonnet::appenv({'user.refresh.time'  => $refresh});
     if ($custommenu) {  
         my %courses = &Apache::loncommon::existing_gcitest_courses();  
         $env{'browser.interface'}='faketextual';  
         $env{'environment.remote'}='off';  
         my $numcourses = keys(%courses);  
         my $switcher;  
         if ($numcourses > 0) {  
             $switcher = &Apache::lonmainmenu::gcitest_switcher(%courses);  
             my $current;  
             if ($env{'request.course.id'}) {  
                 $current = 'cc./'.$env{'course.'.$env{'request.course.id'}.'.domain'}.  
                            '/'.$env{'course.'.$env{'request.course.id'}.'.num'};  
             }  
             my $switcher_js = &Apache::lonmainmenu::gcitest_switcher_js($current,$numcourses);  
             $r->print(<<"ENDSCRIPT");  
 <script type="text/javascript">  
 // <![CDATA[  
 $switcher_js  
 // ]]>  
 </script>  
 ENDSCRIPT  
         }  
         $r->print(&Apache::lonmenu::inlinemenu('gcicustom',$switcher).  
                   &Apache::loncommon::end_page());  
         return OK;  
     }  
     if ($env{'user.adv'}) {      if ($env{'user.adv'}) {
         $r->print('<p><label><input type="checkbox" name="showall"');          $r->print('<p><label><input type="checkbox" name="showall"');
         if ($env{'form.showall'}) { $r->print(' checked="checked" '); }          if ($env{'form.showall'}) { $r->print(' checked="checked" '); }
Line 757  ENDSCRIPT Line 712  ENDSCRIPT
                  .'</p>');                   .'</p>');
     } else {      } else {
         if ($countactive > 0) {          if ($countactive > 0) {
             &queued_selfenrollment($r);              $r->print(&Apache::loncoursequeueadmin::queued_selfenrollment());
             my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description');              my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description');
             my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&');               my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&'); 
             $r->print(              $r->print(
Line 813  ENDSCRIPT Line 768  ENDSCRIPT
         }          }
         $r->print(&Apache::loncommon::end_page());          $r->print(&Apache::loncommon::end_page());
  return OK;   return OK;
     } elsif ($countactive==1) { # Is there only one choice?  
         my $needs_switchserver;  
         if ($env{'user.author'}) {  
             $needs_switchserver = &check_needs_switchserver($possiblerole);  
         }  
         if ((!$needs_switchserver) && ($env{'request.role'} eq 'cm')) {  
             $r->print('<h3>'.&mt('Please stand by.').'</h3>'.  
                 '<input type="hidden" name="'.$possiblerole.'" value="1" />'.  
             '<noscript><br /><input type="submit" name="submit" value="'.&mt('Continue').'" /></noscript>');  
             $r->print("</form>\n");  
             $r->rflush();  
             $r->print('<script type="text/javascript">document.forms.rolechoice.submit();</script>');  
             $r->print(&Apache::loncommon::end_page());  
             return OK;  
         }  
         if ($needs_switchserver) {  
             $r->print("<h2>".&mt('Server Switch Required')."</h2>\n".  
                       &mt('Construction Space access is only available from '.  
                           'the home server of the corresponding Author.').'<br />'.  
                       &mt("Click the 'Switch Server' link to go there.").'<br />');  
         }  
     }      }
 # ----------------------------------------------------------------------- Table  # ----------------------------------------------------------------------- Table
     unless ((!&Apache::loncommon::show_course()) || ($nochoose) || ($countactive==1)) {      unless ((!&Apache::loncommon::show_course()) || ($nochoose) || ($countactive==1)) {
Line 1241  sub findcourse_advice { Line 1175  sub findcourse_advice {
     }      }
     $r->print('<h3>'.&mt('Self-Enrollment').'</h3>'.      $r->print('<h3>'.&mt('Self-Enrollment').'</h3>'.
               '<p>'.&mt('The [_1]Course/Community Catalog[_2] provides information about all [_3] classes for which LON-CAPA courses have been created, as well as any communities in the domain.','<a href="/adm/coursecatalog?showdom='.$esc_dom.'">','</a>',$domdesc).'<br />');                '<p>'.&mt('The [_1]Course/Community Catalog[_2] provides information about all [_3] classes for which LON-CAPA courses have been created, as well as any communities in the domain.','<a href="/adm/coursecatalog?showdom='.$esc_dom.'">','</a>',$domdesc).'<br />');
     $r->print(&mt('You can search for courses and communities which permit self-enrollment, if you would like to enroll in one.').'</p>');      $r->print(&mt('You can search for courses and communities which permit self-enrollment, if you would like to enroll in one.').'</p>'.
     &queued_selfenrollment($r);                &Apache::loncoursequeueadmin::queued_selfenrollment());
     return;      return;
 }  }
   

Removed from v.1.240.2.3  
changed lines
  Added in v.1.241


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>