Diff for /loncom/auth/lonroles.pm between versions 1.245 and 1.248

version 1.245, 2010/03/16 19:55:31 version 1.248, 2010/06/02 14:55:37
Line 57  course they should act on, etc. Both in Line 57  course they should act on, etc. Both in
 handler determines via C<lonnet>'s C<&allowed> function that a certain  handler determines via C<lonnet>'s C<&allowed> function that a certain
 action is not allowed, C<lonroles> is used as error handler. This  action is not allowed, C<lonroles> is used as error handler. This
 allows the user to select another role which may have permission to do  allows the user to select another role which may have permission to do
 what they were trying to do. C<lonroles> can also be accessed via the  what they were trying to do.
 B<CRS> button in the Remote Control.   
   
 =begin latex  =begin latex
   
Line 260  sub handler { Line 259  sub handler {
                         my ($server_status,$home) = &check_author_homeserver($user,$domain);                          my ($server_status,$home) = &check_author_homeserver($user,$domain);
                         if ($server_status eq 'switchserver') {                          if ($server_status eq 'switchserver') {
                             my $trolecode = 'au./'.$domain.'/';                              my $trolecode = 'au./'.$domain.'/';
                             my $switchserver = '/adm/switchserver?otherserver='.$home.'&role='.$trolecode;                              my $switchserver = '/adm/switchserver?otherserver='.$home.'&amp;role='.$trolecode;
                             $r->internal_redirect($switchserver);                              $r->internal_redirect($switchserver);
                         }                          }
                         last;                          last;
Line 271  sub handler { Line 270  sub handler {
                             my ($server_status,$home) = &check_author_homeserver($user,$domain);                              my ($server_status,$home) = &check_author_homeserver($user,$domain);
                             if ($server_status eq 'switchserver') {                              if ($server_status eq 'switchserver') {
                                 my $trolecode = 'ca./'.$domain.'/'.$user;                                  my $trolecode = 'ca./'.$domain.'/'.$user;
                                 my $switchserver = '/adm/switchserver?otherserver='.$home.'&role='.$trolecode;                                  my $switchserver = '/adm/switchserver?otherserver='.$home.'&amp;role='.$trolecode;
                                 $r->internal_redirect($switchserver);                                  $r->internal_redirect($switchserver);
                             }                              }
                             last;                              last;
Line 292  sub handler { Line 291  sub handler {
                             if ($server_status eq 'switchserver') {                              if ($server_status eq 'switchserver') {
                                 my $trolecode = 'ca./'.$domain.'/'.$user;                                   my $trolecode = 'ca./'.$domain.'/'.$user; 
                                 my $switchserver = '/adm/switchserver?'                                  my $switchserver = '/adm/switchserver?'
                                                   .'otherserver='.$home.'&role='.$trolecode;                                                    .'otherserver='.$home.'&amp;role='.$trolecode;
                                 $r->internal_redirect($switchserver);                                  $r->internal_redirect($switchserver);
                             }                              }
                         } else {                          } else {
Line 753  ENDHEADER Line 752  ENDHEADER
  return OK;   return OK;
     }      }
 # ----------------------------------------------------------------------- Table  # ----------------------------------------------------------------------- Table
   
       if ($numdc > 0) {
           $r->print(&coursepick_jscript());
           $r->print(&Apache::loncommon::coursebrowser_javascript().
                     &Apache::loncommon::authorbrowser_javascript());
       }
   
     unless ((!&Apache::loncommon::show_course()) || ($nochoose) || ($countactive==1)) {      unless ((!&Apache::loncommon::show_course()) || ($nochoose) || ($countactive==1)) {
  $r->print("<h2>".&mt('Select a Course to Enter')."</h2>\n");   $r->print("<h2>".&mt('Select a Course to Enter')."</h2>\n");
     }      }
Line 764  ENDHEADER Line 770  ENDHEADER
                       $env{'form.destsymb'}.'" />');                        $env{'form.destsymb'}.'" />');
         }          }
     }      }
   
     my $doheaders = &roletable_headers($r,\%roleclass,\%sortrole,$nochoose);      my $doheaders = &roletable_headers($r,\%roleclass,\%sortrole,$nochoose);
     if ($env{'environment.recentroles'}) {      if ($env{'environment.recentroles'}) {
         my %recent_roles =          my %recent_roles =
                &Apache::lonhtmlcommon::get_recent('roles',$env{'environment.recentrolesn'});                 &Apache::lonhtmlcommon::get_recent('roles',$env{'environment.recentrolesn'});
  my $output='';   my $output='';
  foreach (sort(keys(%recent_roles))) {   foreach my $role (sort(keys(%recent_roles))) {
     if (ref($roletext{'user.role.'.$_}) eq 'ARRAY') {      if (ref($roletext{'user.role.'.$role}) eq 'ARRAY') {
  $output.= &Apache::loncommon::start_data_table_row().   $output.= &Apache::loncommon::start_data_table_row().
                           $roletext{'user.role.'.$_}->[0].                            $roletext{'user.role.'.$role}->[0].
                           &Apache::loncommon::end_data_table_row().                            &Apache::loncommon::end_data_table_row().
                           &Apache::loncommon::continue_data_table_row().                            &Apache::loncommon::continue_data_table_row().
                           $roletext{'user.role.'.$_}->[1].                            $roletext{'user.role.'.$role}->[1].
                           &Apache::loncommon::end_data_table_row();                            &Apache::loncommon::end_data_table_row();
                 if ($_ =~ m-dc\./($match_domain)/-                   if ($role =~ m{dc\./($match_domain)/} 
     && $dcroles{$1}) {      && $dcroles{$1}) {
     $output .= &adhoc_roles_row($1,'recent');      $output .= &adhoc_roles_row($1,'recent');
                 }                  }
     } elsif ($numdc > 0) {      } elsif ($numdc > 0) {
                 unless ($_ =~/^error\:/) {                  unless ($role =~/^error\:/) {
                     $output.=&display_cc_role('user.role.'.$_);                      $output.=&display_cc_role('user.role.'.$_);
                 }                  }
             }               }
  }   }
  if ($output) {   if ($output) {
     $r->print(&Apache::loncommon::start_data_table_empty_row()      $r->print(&Apache::loncommon::start_data_table_empty_row()
Line 798  ENDHEADER Line 805  ENDHEADER
             $doheaders ++;              $doheaders ++;
  }   }
     }      }
   
     if ($numdc > 0) {  
         $r->print(&coursepick_jscript());  
         $r->print(&Apache::loncommon::coursebrowser_javascript().  
                   &Apache::loncommon::authorbrowser_javascript());  
     }  
     &print_rolerows($r,$doheaders,\%roleclass,\%sortrole,\%dcroles,\%roletext);      &print_rolerows($r,$doheaders,\%roleclass,\%sortrole,\%dcroles,\%roletext);
     if ($countactive > 1) {      if ($countactive > 1) {
         my $tremark='';          my $tremark='';
Line 926  sub gather_roles { Line 927  sub gather_roles {
                     foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }                      foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
                     if (!$allowed) {                      if (!$allowed) {
                         $button=0;                          $button=0;
                         $switchserver='otherserver='.$home.'&role='.$trolecode;                          $switchserver='otherserver='.$home.'&amp;role='.$trolecode;
                     }                      }
                     #next if ($home eq 'no_host');                      #next if ($home eq 'no_host');
                     $home = &Apache::lonnet::hostname($home);                      $home = &Apache::lonnet::hostname($home);
Line 946  sub gather_roles { Line 947  sub gather_roles {
                     foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }                      foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
                     if (!$allowed) {                      if (!$allowed) {
                         $button=0;                          $button=0;
                         $switchserver='otherserver='.$home.'&role='.$trolecode;                          $switchserver='otherserver='.$home.'&amp;role='.$trolecode;
                     }                      }
                     #next if ($home eq 'no_host');                      #next if ($home eq 'no_host');
                     $home = &Apache::lonnet::hostname($home);                      $home = &Apache::lonnet::hostname($home);
Line 963  sub gather_roles { Line 964  sub gather_roles {
                     if ($env{'course.'.$tcourseid.'.description'}) {                      if ($env{'course.'.$tcourseid.'.description'}) {
                         $twhere=$env{'course.'.$tcourseid.'.description'};                          $twhere=$env{'course.'.$tcourseid.'.description'};
                         $sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey;                          $sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey;
                           $twhere = &HTML::Entities::encode($twhere,'"<>&');
                         unless ($twhere eq &mt('Currently not available')) {                          unless ($twhere eq &mt('Currently not available')) {
                             $twhere.=' <span class="LC_fontsize_small">'.                              $twhere.=' <span class="LC_fontsize_small">'.
         &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom).          &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom).
Line 973  sub gather_roles { Line 975  sub gather_roles {
                         if (%newhash) {                          if (%newhash) {
                             $sortkey=$role."\0".$tdom."\0".$newhash{'description'}.                              $sortkey=$role."\0".$tdom."\0".$newhash{'description'}.
                                 "\0".$envkey;                                  "\0".$envkey;
                             $twhere=$newhash{'description'}.                              $twhere=&HTML::Entities::encode($newhash{'description'},'"<>&').
                               ' <span class="LC_fontsize_small">'.                                      ' <span class="LC_fontsize_small">'.
         &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom).                                       &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom).
                               '</span>';                                      '</span>';
                             $ttype = $newhash{'type'};                              $ttype = $newhash{'type'};
                             $trole = &Apache::lonnet::plaintext($role,$ttype,$tcourseid);                              $trole = &Apache::lonnet::plaintext($role,$ttype,$tcourseid);
                         } else {                          } else {
Line 1634  course they should act on, etc. Both in Line 1636  course they should act on, etc. Both in
 handler determines via C<lonnet>'s C<&allowed> function that a certain  handler determines via C<lonnet>'s C<&allowed> function that a certain
 action is not allowed, C<lonroles> is used as error handler. This  action is not allowed, C<lonroles> is used as error handler. This
 allows the user to select another role which may have permission to do  allows the user to select another role which may have permission to do
 what they were trying to do. C<lonroles> can also be accessed via the  what they were trying to do.
 B<CRS> button in the Remote Control.   
   
 =begin latex  =begin latex
   

Removed from v.1.245  
changed lines
  Added in v.1.248


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