Diff for /loncom/auth/lonroles.pm between versions 1.256.2.6.2.3 and 1.264

version 1.256.2.6.2.3, 2012/02/09 01:11:52 version 1.264, 2011/12/14 21:02:30
Line 141  use Apache::loncoursequeueadmin; Line 141  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;
    
   
 sub redirect_user {  sub redirect_user {
     my ($r,$title,$url,$msg,$launch_nav) = @_;      my ($r,$title,$url,$msg) = @_;
     $msg = $title if (! defined($msg));      $msg = $title if (! defined($msg));
     &Apache::loncommon::content_type($r,'text/html');      &Apache::loncommon::content_type($r,'text/html');
     &Apache::loncommon::no_cache($r);      &Apache::loncommon::no_cache($r);
     $r->send_http_header;      $r->send_http_header;
     my $swinfo=&Apache::lonmenu::rawconfig();  
     my $navwindow;  
     if ($launch_nav eq 'on') {  
         $navwindow.=&Apache::lonnavdisplay::launch_win('now',undef,undef,  
                                                        ($url =~ m-^/adm/whatsnew-));  
     } else {  
         $navwindow.=&Apache::lonnavmaps::close();  
     }  
   
     # Breadcrumbs      # Breadcrumbs
     my $brcrum = [{'href' => $url,      my $brcrum = [{'href' => $url,
Line 171  sub redirect_user { Line 163  sub redirect_user {
     $url=~s/ /\%20/g;      $url=~s/ /\%20/g;
     $r->print(<<ENDREDIR);      $r->print(<<ENDREDIR);
 $start_page  $start_page
 <script type="text/javascript">  
 // <![CDATA[  
 $swinfo  
 // ]]>  
 </script>  
 $navwindow  
 <p>$msg</p>  <p>$msg</p>
 $end_page  $end_page
 ENDREDIR  ENDREDIR
Line 514  ENDENTERKEY Line 500  ENDENTERKEY
                         my $msg;                          my $msg;
  my ($furl,$ferr)=   my ($furl,$ferr)=
     &Apache::lonuserstate::readmap($cdom.'/'.$cnum);      &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
                         unless (($ferr) || ($env{'form.switchrole'})) {  
                             &Apache::lonnet::put('nohist_crslastlogin',  
                                 {$env{'user.name'}.':'.$env{'user.domain'}.  
                                 ':'.$csec.':'.$role => $now},$cdom,$cnum);  
                         }  
  if (($env{'form.orgurl'}) &&    if (($env{'form.orgurl'}) && 
     ($env{'form.orgurl'}!~/^\/adm\/flip/)) {      ($env{'form.orgurl'}!~/^\/adm\/flip/)) {
     my $dest=$env{'form.orgurl'};      my $dest=$env{'form.orgurl'};
Line 582  ENDENTERKEY Line 563  ENDENTERKEY
                                         }                                          }
                                         &redirect_user($r, &mt('Entering [_1]',                                          &redirect_user($r, &mt('Entering [_1]',
                                                        $env{'course.'.$courseid.'.description'}),                                                         $env{'course.'.$courseid.'.description'}),
                                                        $dest, $msg,                                                         $dest, $msg);
                                                        $env{'environment.remotenavmap'});  
                                         return OK;                                          return OK;
                                     }                                      }
     if (&Apache::lonnet::allowed('whn',      if (&Apache::lonnet::allowed('whn',
Line 596  ENDENTERKEY Line 576  ENDENTERKEY
  unless ($startpage eq 'firstres') {            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'),
                                                            '/adm/whatsnew?refpage=start',$msg,                                         '/adm/whatsnew?refpage=start', $msg);
                                                            $env{'environment.remotenavmap'});  
     return OK;      return OK;
  }   }
     }      }
  }   }
 # Are we allowed to look at the first resource?  # Are we allowed to look at the first resource?
  if (($furl !~ m|^/adm/|) ||    if ($furl !~ m|^/adm/|) {
                                     (($env{'environment.remotenavmap'} eq 'on') &&   
                                      ($furl =~ m{^/adm/navmaps}))) {  
 # Guess not ...  # Guess not ...
     $furl=&Apache::lonpageflip::first_accessible_resource();      $furl=&Apache::lonpageflip::first_accessible_resource();
  }   }
                                 $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]',
                                                       $env{'course.'.$courseid.'.description'}),                                 $env{'course.'.$courseid.'.description'}),
                                                $furl,$msg,                                 $furl, $msg);
                                                $env{'environment.remotenavmap'});  
     }      }
     return OK;      return OK;
  }   }
Line 625  ENDENTERKEY Line 601  ENDENTERKEY
                     if ($role =~ /^(au|ca|aa)$/) {                      if ($role =~ /^(au|ca|aa)$/) {
                         my $redirect_url = '/priv/';                          my $redirect_url = '/priv/';
                         if ($role eq 'au') {                          if ($role eq 'au') {
                             $redirect_url.=$env{'user.name'};                              $redirect_url.=$env{'user.domain'}.'/'.$env{'user.name'};
                         } else {                          } else {
                             $where =~ /\/(.*)$/;                              $redirect_url .= $where;
                             $redirect_url .= $1;  
                         }                          }
                         $redirect_url .= '/';                          $redirect_url .= '/';
                         &redirect_user($r,&mt('Entering Construction Space'),                          &redirect_user($r,&mt('Entering Construction Space'),
Line 698  function enterrole (thisform,rolecode,bu Line 673  function enterrole (thisform,rolecode,bu
  thisform.submit();   thisform.submit();
     } else {      } else {
        alert('$standby');         alert('$standby');
     }         }
 }  }
   
 function setToUpdate(thisform) {  function setToUpdate(thisform) {
Line 767  ENDHEADER Line 742  ENDHEADER
     }      }
         }          }
     }      }
 # -------------------------------------------------------- Choice or no choice?  
     if ($nochoose) {      if ($nochoose) {
         $r->print("<h2>".&mt('Sorry ...')."</h2>\n<span class='LC_error'>".   $r->print("<h2>".&mt('Sorry ...')."</h2>\n<span class='LC_error'>".
                   &mt('This action is currently not authorized.').'</span>'.    &mt('This action is currently not authorized.').'</span>'.
                   &Apache::loncommon::end_page());    &Apache::loncommon::end_page());
         return OK;   return OK;
     } else {      } else {
         $r->print($updateresult);          $r->print($updateresult); 
         if (($ENV{'REDIRECT_QUERY_STRING'}) && ($fn)) {          if (($ENV{'REDIRECT_QUERY_STRING'}) && ($fn)) {
             $fn.='?'.$ENV{'REDIRECT_QUERY_STRING'};         $fn.='?'.$ENV{'REDIRECT_QUERY_STRING'};
         }          }
         $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.'" />');
Line 786  ENDHEADER Line 760  ENDHEADER
     $r->rflush();      $r->rflush();
   
     my (%roletext,%sortrole,%roleclass,%futureroles,%timezones);      my (%roletext,%sortrole,%roleclass,%futureroles,%timezones);
     my ($countactive,$countfuture,$inrole,$possiblerole) =      my ($countactive,$countfuture,$inrole,$possiblerole) = 
         &gather_roles($update,$refresh,$now,$reinit,$nochoose,\%roletext,\%sortrole,\%roleclass,          &gather_roles($update,$refresh,$now,$reinit,$nochoose,\%roletext,\%sortrole,\%roleclass,
                       \%futureroles,\%timezones,$loncaparev);                        \%futureroles,\%timezones,$loncaparev);
     $refresh = $now;      $refresh = $now;
Line 804  ENDHEADER Line 778  ENDHEADER
     }      }
     if ($env{'user.adv'}) {      if ($env{'user.adv'}) {
         my $showall = '<label><input type="checkbox" name="showall"';          my $showall = '<label><input type="checkbox" name="showall"';
         if ($env{'form.showall'}) {          if ($env{'form.showall'}) { 
             $showall .= ' checked="checked" ';              $showall .= ' checked="checked" ';
         }          }
         $showall .= ' />'.&mt('Show all roles').'</label>&nbsp;'.          $showall .= ' />'.&mt('Show all roles').'</label>&nbsp;'.
Line 824  ENDHEADER Line 798  ENDHEADER
         if ($countactive > 0) {          if ($countactive > 0) {
             $r->print(&Apache::loncoursequeueadmin::queued_selfenrollment());              $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(
                 '<p>'                  '<p>'
                .&mt('[_1]Visit the [_2]Course/Community Catalog[_3]'                 .&mt('[_1]Visit the [_2]Course/Community Catalog[_3]'
Line 878  ENDHEADER Line 852  ENDHEADER
         }          }
         $r->print(&Apache::loncommon::end_page());          $r->print(&Apache::loncommon::end_page());
  return OK;   return OK;
     } elsif ($countactive==1 && $countfuture==0) { # 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
   
Line 2503  sub gather_roleprivs { Line 2456  sub gather_roleprivs {
         my $spec=$role.'.'.$area;          my $spec=$role.'.'.$area;
         $userroles->{'user.role.'.$spec} = $tstart.'.'.$tend;          $userroles->{'user.role.'.$spec} = $tstart.'.'.$tend;
         my ($tdummy,$tdomain,$trest)=split(/\//,$area);          my ($tdummy,$tdomain,$trest)=split(/\//,$area);
         if ($status eq 'active') {          if ($status eq 'active') { 
             if ($role =~ /^cr\//) {              if ($role =~ /^cr\//) {
                 &Apache::lonnet::custom_roleprivs($allroles,$role,$tdomain,$trest,$spec,$area);                  &Apache::lonnet::custom_roleprivs($allroles,$role,$tdomain,$trest,$spec,$area);
             } elsif ($role eq 'gr') {              } elsif ($role eq 'gr') {

Removed from v.1.256.2.6.2.3  
changed lines
  Added in v.1.264


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