Diff for /loncom/auth/lonroles.pm between versions 1.207 and 1.213

version 1.207, 2008/10/02 14:34:03 version 1.213, 2008/12/10 21:46:50
Line 27 Line 27
 #  #
 ###  ###
   
   =pod
   
   =head1 NAME
   
   Apache::lonroles - User Roles Screen
   
   =head1 SYNOPSIS
   
   Invoked by /etc/httpd/conf/srm.conf:
   
    <Location /adm/roles>
    PerlAccessHandler       Apache::lonacc
    SetHandler perl-script
    PerlHandler Apache::lonroles
    ErrorDocument     403 /adm/login
    ErrorDocument  500 /adm/errorhandler
    </Location>
   
   =head1 OVERVIEW
   
   =head2 Choosing Roles
   
   C<lonroles> is a handler that allows a user to switch roles in
   mid-session. LON-CAPA attempts to work with "No Role Specified", the
   default role that a user has before selecting a role, as widely as
   possible, but certain handlers for example need specification which
   course they should act on, etc. Both in this scenario, and when the
   handler determines via C<lonnet>'s C<&allowed> function that a certain
   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
   what they were trying to do. C<lonroles> can also be accessed via the
   B<CRS> button in the Remote Control. 
   
   =begin latex
   
   \begin{figure}
   \begin{center}
   \includegraphics[width=0.45\paperwidth,keepaspectratio]{Sample_Roles_Screen}
     \caption{\label{Sample_Roles_Screen}Sample Roles Screen} 
   \end{center}
   \end{figure}
   
   =end latex
   
   =head2 Role Initialization
   
   The privileges for a user are established at login time and stored in the session environment. As a consequence, a new role does not become active till the next login. Handlers are able to query for privileges using C<lonnet>'s C<&allowed> function. When a user first logs in, their role is the "common" role, which means that they have the sum of all of their privileges. During a session it might become necessary to choose a particular role, which as a consequence also limits the user to only the privileges in that particular role.
   
   =head1 INTRODUCTION
   
   This module enables a user to select what role he wishes to
   operate under (instructor, student, teaching assistant, course
   coordinator, etc).  These roles are pre-established by the actions
   of upper-level users.
   
   This is part of the LearningOnline Network with CAPA project
   described at http://www.lon-capa.org.
   
   =head1 HANDLER SUBROUTINE
   
   This routine is called by Apache and mod_perl.
   
   =over 4
   
   =item *
   
   Roles Initialization (yes/no)
   
   =item *
   
   Get Error Message from Environment
   
   =item *
   
   Who is this?
   
   =item *
   
   Generate Page Output
   
   =item *
   
   Choice or no choice
   
   =item *
   
   Table
   
   =item *
   
   Privileges
   
   =back
   
   =cut
   
   
 package Apache::lonroles;  package Apache::lonroles;
   
 use strict;  use strict;
Line 272  $swinfo Line 369  $swinfo
 <form method="post">  <form method="post">
 <input type="hidden" name="selectrole" value="1" />  <input type="hidden" name="selectrole" value="1" />
 <input type="hidden" name="$trolecode" value="1" />  <input type="hidden" name="$trolecode" value="1" />
 <font size="+2">$message</font><br />  <span class="LC_fontsize_large">$message</span><br />
 <input type="submit" value="$buttontext" />  <input type="submit" value="$buttontext" />
 </form>  </form>
 $end_page  $end_page
Line 438  ENDENTERKEY Line 535  ENDENTERKEY
     $r->send_http_header;      $r->send_http_header;
     return OK if $r->header_only;      return OK if $r->header_only;
   
    my @brcrum =[{href=>"/admmm/roles",text=>"User Roles"}];
     my $swinfo=&Apache::lonmenu::rawconfig();      my $swinfo=&Apache::lonmenu::rawconfig();
     my $start_page=&Apache::loncommon::start_page('User Roles');      my $start_page=&Apache::loncommon::start_page('User Roles',undef,{bread_crumbs=>@brcrum});
     my $standby=&mt('Role selected. Please stand by.');      my $standby=&mt('Role selected. Please stand by.');
     $standby=~s/\n/\\n/g;      $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 />';
Line 483  ENDHEADER Line 581  ENDHEADER
     my $advanced=$env{'user.adv'};      my $advanced=$env{'user.adv'};
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['tryagain']);      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['tryagain']);
     my $tryagain=$env{'form.tryagain'};      my $tryagain=$env{'form.tryagain'};
       my $reinit=$env{'user.reinit'};
       delete $env{'user.reinit'};
   
 # -------------------------------------------------------- Generate Page Output  # -------------------------------------------------------- Generate Page Output
 # --------------------------------------------------------------- Error Header?  # --------------------------------------------------------------- Error Header?
Line 512  ENDHEADER Line 612  ENDHEADER
  &Apache::lonenc::check_encrypt($fn));   &Apache::lonenc::check_encrypt($fn));
     } else {      } else {
         if ($env{'user.error.msg'}) {          if ($env{'user.error.msg'}) {
     $r->print(              if ($reinit) {
                   $r->print(
    '<h3><span class="LC_error">'.
    &mt('As your session file for the course has expired, you will need to re-select the course.').'</span></h3>');
               } else {
           $r->print(
  '<h3><span class="LC_error">'.   '<h3><span class="LC_error">'.
  &mt('You need to choose another user role or enter a specific course for this function').'</span></h3>');   &mt('You need to choose another user role or enter a specific course for this function').'</span></h3>');
  }      }
           }
     }      }
 # -------------------------------------------------------- Choice or no choice?  # -------------------------------------------------------- Choice or no choice?
     if ($nochoose) {      if ($nochoose) {
Line 546  ENDHEADER Line 652  ENDHEADER
  my $roletext;   my $roletext;
  my $sortkey;   my $sortkey;
         if ($envkey=~/^user\.role\./) {          if ($envkey=~/^user\.role\./) {
             my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus,$tpstart,$tpend,$tfont);              my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus,$tpstart,$tpend);
             &role_status($envkey,$then,$now,\$role,\$where,\$trolecode,\$tstatus,\$tstart,\$tend);              &role_status($envkey,$then,$now,\$role,\$where,\$trolecode,\$tstatus,\$tstart,\$tend);
             next if (!defined($role) || $role eq '' || $role =~ /^gr/);              next if (!defined($role) || $role eq '' || $role =~ /^gr/);
             $tremark='';              $tremark='';
             $tpstart='&nbsp;';              $tpstart='&nbsp;';
             $tpend='&nbsp;';              $tpend='&nbsp;';
             $tfont='#000000';  
             if ($tstart) {              if ($tstart) {
                 $tpstart=&Apache::lonlocal::locallocaltime($tstart);                  $tpstart=&Apache::lonlocal::locallocaltime($tstart);
             }              }
Line 569  ENDHEADER Line 674  ENDHEADER
  || ($tstatus eq 'future')    || ($tstatus eq 'future') 
                 || ($env{'form.showall'})) {                  || ($env{'form.showall'})) {
                 if ($tstatus eq 'is') {                  if ($tstatus eq 'is') {
                     $tbg='#77FF77';                      $tbg='LC_roles_is';
                     $tfont='#003300';  
     $possiblerole=$trolecode;      $possiblerole=$trolecode;
     $countactive++;      $countactive++;
                 } elsif ($tstatus eq 'future') {                  } elsif ($tstatus eq 'future') {
                     $tbg='#FFFF77';                      $tbg='LC_roles_future';
                     $button=0;                      $button=0;
                     $futureroles{$trolecode} = $tstart.':'.$tend;                      $futureroles{$trolecode} = $tstart.':'.$tend;
                     $countfuture ++;                      $countfuture ++;
                 } elsif ($tstatus eq 'will') {                  } elsif ($tstatus eq 'will') {
                     $tbg='#FFAA77';                      $tbg='LC_roles_will';
                     $tremark.=&mt('Active at next login.').' ';                      $tremark.=&mt('Active at next login.').' ';
                     $roles_nextlogin{$trolecode} = $tstart.':'.$tend;                      $roles_nextlogin{$trolecode} = $tstart.':'.$tend;
                     $countwill ++;                      $countwill ++;
                 } elsif ($tstatus eq 'expired') {                  } elsif ($tstatus eq 'expired') {
                     $tbg='#FF7777';                      $tbg='LC_roles_expired';
                     $tfont='#330000';  
                     $button=0;                      $button=0;
                 } elsif ($tstatus eq 'will_not') {                  } elsif ($tstatus eq 'will_not') {
                     $tbg='#AAFF77';                      $tbg='LC_roles_will_not';
                     $tremark.=&mt('Expired after logout.').' ';                      $tremark.=&mt('Expired after logout.').' ';
                 } elsif ($tstatus eq 'selected') {                  } elsif ($tstatus eq 'selected') {
                     $tbg='#11CC55';                      $tbg='LC_roles_selected';
                     $tfont='#002200';  
     $inrole=1;      $inrole=1;
     $countactive++;      $countactive++;
                     $tremark.=&mt('Currently selected.').' ';                      $tremark.=&mt('Currently selected.').' ';
Line 654  ENDHEADER Line 756  ENDHEADER
                         $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;
                         unless ($twhere eq &mt('Currently not available')) {                          unless ($twhere eq &mt('Currently not available')) {
     $twhere.=' <font size="-2">'.      $twhere.=' <span class="LC_fontsize_small">'.
         &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom,$tfont).          &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom).
                                     '</font>';                                      '</span>';
  }   }
                     } else {                      } else {
                         my %newhash=&Apache::lonnet::coursedescription($tcourseid);                          my %newhash=&Apache::lonnet::coursedescription($tcourseid);
Line 664  ENDHEADER Line 766  ENDHEADER
     $sortkey=$role."\0".$tdom."\0".$newhash{'description'}.      $sortkey=$role."\0".$tdom."\0".$newhash{'description'}.
  "\0".$envkey;   "\0".$envkey;
                             $twhere=$newhash{'description'}.                              $twhere=$newhash{'description'}.
                               ' <font size="-2">'.                                ' <span class="LC_fontsize_small">'.
         &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom,$tfont).          &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom).
                               '</font>';                                '</span>';
                             $ttype = $newhash{'type'};                              $ttype = $newhash{'type'};
                             $trole = &Apache::lonnet::plaintext($role,$ttype);                              $trole = &Apache::lonnet::plaintext($role,$ttype);
                         } else {                          } else {
Line 689  ENDHEADER Line 791  ENDHEADER
                     $twhere=&mt('system wide');                      $twhere=&mt('system wide');
     $sortkey=$role.$twhere;      $sortkey=$role.$twhere;
                 }                  }
                 $roletext.=&build_roletext($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tfont,$trole,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver);                  $roletext.=&build_roletext($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$trole,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver,$reinit);
  $roletext{$envkey}=$roletext;   $roletext{$envkey}=$roletext;
  if (!$sortkey) {$sortkey=$twhere."\0".$envkey;}   if (!$sortkey) {$sortkey=$twhere."\0".$envkey;}
  $sortrole{$sortkey}=$envkey;   $sortrole{$sortkey}=$envkey;
Line 699  ENDHEADER Line 801  ENDHEADER
     }      }
     if ($env{'user.adv'}) {      if ($env{'user.adv'}) {
         $r->print(          $r->print(
               '<br /><span class="LC_rolesinfo"><label>'.&mt('Show all roles').': <input type="checkbox" name="showall"');                '<p><label>'.&mt('Show all roles').': <input type="checkbox" name="showall"');
         if ($env{'form.showall'}) { $r->print(' checked="checked" '); }          if ($env{'form.showall'}) { $r->print(' checked="checked" '); }
         $r->print(' /></label><input type="submit" value="'.&mt('Display').'" /></span>');          $r->print(' /></label><input type="submit" value="'.&mt('Display').'" /></p>');
     } else {      } else {
         if ($countactive > 0) {          if ($countactive > 0) {
             my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description');              my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description');
Line 726  ENDHEADER Line 828  ENDHEADER
             &print_rolerows($r,$doheaders,\%roleclass,\%sortrole,\%dcroles,              &print_rolerows($r,$doheaders,\%roleclass,\%sortrole,\%dcroles,
                             \%roletext);                              \%roletext);
             my $tremark='';              my $tremark='';
             my $tfont='#003300';              my $tbg;
             if ($env{'request.role'} eq 'cm') {              if ($env{'request.role'} eq 'cm') {
                 $r->print('<tr bgcolor="#11CC55">');                  $tbg="LC_roles_selected";
                 $tremark=&mt('Currently selected.').' ';                  $tremark=&mt('Currently selected.').' ';
                 $tfont='#002200';  
             } else {              } else {
                 $r->print('<tr bgcolor="#77FF77">');                  $tbg="LC_roles_is";
             }              }
             $r->print('<td></td><td colspan="3"><font color="'.$tfont.'"><span class="LC_rolesinfo">'.&mt('No role specified').              $r->print(&Apache::loncommon::start_data_table_row()
                       '</span></font></td><td><font color="'.$tfont.'">'.$tremark.                       .'<td class="'.$tbg.'">&nbsp;</td>'
                       '&nbsp;</font></td></tr>'."\n");                       .'<td colspan="3">'
                        .&mt('No role specified')
                        .'</td>'
                        .'<td>'.$tremark.'&nbsp;</td>'
                        .&Apache::loncommon::end_data_table_row()
               );
   
             $r->print('</table>');              $r->print(&Apache::loncommon::end_data_table());
         }          }
         $r->print(&Apache::loncommon::end_page());          $r->print(&Apache::loncommon::end_page());
  return OK;   return OK;
Line 766  ENDHEADER Line 872  ENDHEADER
             }               } 
  }   }
  if ($output) {   if ($output) {
     $r->print("<tr><td align='center' colspan='5'><font face='arial'>".      $r->print(&Apache::loncommon::start_data_table_empty_row()
       &mt('Recent Roles')."</font></td></tr>");                       .'<td align="center" colspan="5">'
                        .&mt('Recent Roles')
                        .'</td>'
                        .&Apache::loncommon::end_data_table_empty_row()
               );
     $r->print($output);      $r->print($output);
             $doheaders ++;              $doheaders ++;
  }   }
Line 781  ENDHEADER Line 891  ENDHEADER
     &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='';
         my $tfont='#003300';          my $tbg;
         if ($env{'request.role'} eq 'cm') {          if ($env{'request.role'} eq 'cm') {
     $r->print('<tr bgcolor="#11CC55">');              $tbg="LC_roles_selected";
             $tremark=&mt('Currently selected.').' ';              $tremark=&mt('Currently selected.').' ';
             $tfont='#002200';  
         } else {          } else {
             $r->print('<tr bgcolor="#77FF77">');                  $tbg="LC_roles_is";
         }          }
           $r->print(&Apache::loncommon::start_data_table_row());
         unless ($nochoose) {          unless ($nochoose) {
     if ($env{'request.role'} ne 'cm') {      if ($env{'request.role'} ne 'cm') {
         $r->print('<td><input type="submit" value="'.          $r->print('<td class="'.$tbg.'"><input type="submit" value="'.
           &mt('Select').'" name="cm" /></td>');            &mt('Select').'" name="cm" /></td>');
     } else {      } else {
         $r->print('<td>&nbsp;</td>');          $r->print('<td class="'.$tbg.'">&nbsp;</td>');
     }      }
         }          }
         $r->print('<td colspan="3"><font color="'.$tfont.'"><span class="LC_rolesinfo">'.&mt('No role specified').          $r->print('<td colspan="3">'
                   '</span></font></td><td><font color="'.$tfont.'">'.$tremark.                   .&mt('No role specified')
                   '&nbsp;</font></td></tr>'."\n");                   .'</td>'
                    .'<td>'.$tremark.'&nbsp;</td>'
                    .&Apache::loncommon::end_data_table_row()
           );
     }       } 
     $r->print('</table>');      $r->print(&Apache::loncommon::end_data_table());
     unless ($nochoose) {      unless ($nochoose) {
  $r->print("</form>\n");   $r->print("</form>\n");
     }      }
 # ------------------------------------------------------------ Privileges Info  # ------------------------------------------------------------ Privileges Info
     if (($advanced) && (($env{'user.error.msg'}) || ($error))) {      if (($advanced) && (($env{'user.error.msg'}) || ($error))) {
  $r->print('<hr /><h2>Current Privileges</h2>');   $r->print('<hr /><h2>'.&mt('Current Privileges').'</h2>');
  $r->print(&privileges_info());   $r->print(&privileges_info());
     }      }
     $r->print(&Apache::lonnet::getannounce());      $r->print(&Apache::lonnet::getannounce());
Line 829  sub roletable_headers { Line 942  sub roletable_headers {
     my ($r,$roleclass,$sortrole,$nochoose) = @_;      my ($r,$roleclass,$sortrole,$nochoose) = @_;
     my $doheaders;      my $doheaders;
     if ((ref($sortrole) eq 'HASH') && (ref($roleclass) eq 'HASH')) {      if ((ref($sortrole) eq 'HASH') && (ref($roleclass) eq 'HASH')) {
         $r->print('<br /><table id="LC_rolesmenu"><tr>');          $r->print('<br />'
                    .&Apache::loncommon::start_data_table()
                    .&Apache::loncommon::start_data_table_header_row()
           );
         if (!$nochoose) { $r->print('<th>&nbsp;</th>'); }          if (!$nochoose) { $r->print('<th>&nbsp;</th>'); }
         $r->print('<th>'.&mt('User Role').'</th><th>'.&mt('Extent')          $r->print('<th>'.&mt('User Role').'</th>'
                   .'</th><th>'.&mt('Start').'</th><th>'.&mt('End')                   .'<th>'.&mt('Extent').'</th>'
                   .'</th></tr>'."\n");                   .'<th>'.&mt('Start').'</th>'
                    .'<th>'.&mt('End').'</th>'
                    .&Apache::loncommon::end_data_table_header_row()
           );
         $doheaders=-1;          $doheaders=-1;
         my @roletypes = &roletypes();          my @roletypes = &roletypes();
         foreach my $type (@roletypes) {          foreach my $type (@roletypes) {
Line 876  sub print_rolerows { Line 995  sub print_rolerows {
             }              }
             if ($output) {              if ($output) {
                 if ($doheaders > 0) {                  if ($doheaders > 0) {
                     $r->print("<tr>".                      $r->print(&Apache::loncommon::start_data_table_empty_row()
                               "<td align='center' colspan='5'><font face='arial'>".                               .'<td align="center" colspan="5">'
                               &mt($type)."</font></td></tr>");                               .&mt($type)
                                .'</td>'
                                .&Apache::loncommon::end_data_table_empty_row()
                       );
                 }                  }
                 $r->print($output);                  $r->print($output);
             }              }
Line 988  sub role_status { Line 1110  sub role_status {
 }  }
   
 sub build_roletext {  sub build_roletext {
     my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tfont,$trole,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver) = @_;      my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$trole,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver,$reinit) = @_;
     my $roletext='<tr bgcolor="'.$tbg.'" class="LC_rolesmenu_'.$tstatus.'">';      my $roletext=&Apache::loncommon::start_data_table_row();
     my $is_dc=($trolecode =~ m/^dc\./);      my $is_dc=($trolecode =~ m/^dc\./);
     my $rowspan=($is_dc) ? ''      my $rowspan=($is_dc) ? ''
                          : ' rowspan="2" ';                           : ' rowspan="2" ';
Line 999  sub build_roletext { Line 1121  sub build_roletext {
         $buttonname=~s/\W//g;          $buttonname=~s/\W//g;
         if (!$button) {          if (!$button) {
             if ($switchserver) {              if ($switchserver) {
                 $roletext.='<td'.$rowspan.'><span class="LC_rolesinfo"><a href="/adm/switchserver?'.                  $roletext.='<td'.$rowspan.' class="'.$tbg.'">'
                 $switchserver.'">'.&mt('Switch Server').'</a></span></td>';                            .'<a href="/adm/switchserver?'.$switchserver.'">'
                             .&mt('Switch Server')
                             .'</a></td>';
             } else {              } else {
                 $roletext.=('<td'.$rowspan.'>&nbsp;</td>');                  $roletext.=('<td'.$rowspan.' class="'.$tbg.'">&nbsp;</td>');
             }              }
         } elsif ($tstatus eq 'is') {          } elsif ($tstatus eq 'is') {
             $roletext.='<td'.$rowspan.'><input name="'.$buttonname.'" type="button" value="'.              $roletext.='<td'.$rowspan.' class="'.$tbg.'">'.
                           '<input name="'.$buttonname.'" type="button" value="'.
                         &mt('Select').'" onClick="javascript:enterrole(this.form,\''.                          &mt('Select').'" onClick="javascript:enterrole(this.form,\''.
                         $trolecode."','".$buttonname.'\');" /></td>';                          $trolecode."','".$buttonname.'\');" /></td>';
         } elsif ($tryagain) {          } elsif ($tryagain) {
             $roletext.=              $roletext.=
                 '<td'.$rowspan.'><input name="'.$buttonname.'" type="button" value="'.                  '<td'.$rowspan.' class="'.$tbg.'">'.
                   '<input name="'.$buttonname.'" type="button" value="'.
                 &mt('Try Selecting Again').'" onClick="javascript:enterrole(this.form,\''.                  &mt('Try Selecting Again').'" onClick="javascript:enterrole(this.form,\''.
                         $trolecode."','".$buttonname.'\');" /></td>';                          $trolecode."','".$buttonname.'\');" /></td>';
         } elsif ($advanced) {          } elsif ($advanced) {
             $roletext.=              $roletext.=
                 '<td'.$rowspan.'><input name="'.$buttonname.'" type="button" value="'.                  '<td'.$rowspan.' class="'.$tbg.'">'.
                   '<input name="'.$buttonname.'" type="button" value="'.
                 &mt('Re-Initialize').'" onClick="javascript:enterrole(this.form,\''.                  &mt('Re-Initialize').'" onClick="javascript:enterrole(this.form,\''.
                         $trolecode."','".$buttonname.'\');" /></td>';                          $trolecode."','".$buttonname.'\');" /></td>';
           } elsif ($reinit) {
               $roletext.= 
                   '<td'.$rowspan.' class="'.$tbg.'">'.
                   '<input name="'.$buttonname.'" type="button" value="'.
                   &mt('Re-Select').'" onClick="javascript:enterrole(this.form,\''.
                           $trolecode."','".$buttonname.'\');" /></td>';
         } else {          } else {
             $roletext.='<td'.$rowspan.'>&nbsp;</td>';              $roletext.=
                   '<td'.$rowspan.' class="'.$tbg.'">'.
                   '<input name="'.$buttonname.'" type="button" value="'.
                   &mt('Re-Initialize').'" onClick="javascript:enterrole(this.form,\''.
                           $trolecode."','".$buttonname.'\');" /></td>';
         }          }
     }      }
     if ($trolecode !~ m/^(dc|ca|au|aa)\./) {      if ($trolecode !~ m/^(dc|ca|au|aa)\./) {
  $tremark.=&Apache::lonannounce::showday(time,1,   $tremark.=&Apache::lonannounce::showday(time,1,
  &Apache::lonannounce::readcalendar($tdom.'_'.$trest));   &Apache::lonannounce::readcalendar($tdom.'_'.$trest));
     }      }
     $roletext.='<td><font color="'.$tfont.'">'.$trole.      $roletext.='<td>'.$trole.'</td>'
        '</font></td><td><font color="'.$tfont.'">'.$twhere.                .'<td>'.$twhere.'</td>'
                '</font></td><td><font color="'.$tfont.'">'.$tpstart.                .'<td>'.$tpstart.'</td>'
                '</font></td><td><font color="'.$tfont.'">'.$tpend.                .'<td>'.$tpend.'</td>'
                '</font></td></tr>';                .&Apache::loncommon::end_data_table_row();
     if (!$is_dc) {      if (!$is_dc) {
  $roletext.='<tr bgcolor="'.$tbg.'"><td colspan="4"><font color="'.$tfont.'"><span class="LC_rolesinfo">'.$tremark.          $roletext.=&Apache::loncommon::continue_data_table_row()
     '</span>&nbsp;</font></td></tr><tr><td colspan="5" height="3"></td></tr>'."\n";                    .'<td colspan="4">'
                     .$tremark.'&nbsp;'
                     .'</td>'
                     .&Apache::loncommon::end_data_table_row();
     }      }
     return $roletext;      return $roletext;
 }  }
Line 1077  sub check_privs { Line 1217  sub check_privs {
     my ($cdom,$cnum,$then,$now,$checkrole) = @_;      my ($cdom,$cnum,$then,$now,$checkrole) = @_;
     my $cckey = 'user.role.'.$checkrole.'./'.$cdom.'/'.$cnum;       my $cckey = 'user.role.'.$checkrole.'./'.$cdom.'/'.$cnum; 
     if ($env{$cckey}) {      if ($env{$cckey}) {
         my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus,$tpstart,$tpend,$tfont);          my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus,$tpstart,$tpend);
         &role_status($cckey,$then,$now,\$role,\$where,\$trolecode,\$tstatus,\$tstart,\$tend);          &role_status($cckey,$then,$now,\$role,\$where,\$trolecode,\$tstatus,\$tstart,\$tend);
         unless (($tstatus eq 'is') || ($tstatus eq 'will_not')) {          unless (($tstatus eq 'is') || ($tstatus eq 'will_not')) {
             &set_privileges($cdom,$cnum,$checkrole);              &set_privileges($cdom,$cnum,$checkrole);
Line 1136  sub adhoc_course_role { Line 1276  sub adhoc_course_role {
                         return;                          return;
                     }                      }
                 }                  }
                 my (%userroles,%newrole,%newgroups);                  my (%userroles,%newrole,%newgroups,%group_privs);
                   my %cgroups =
                       &Apache::lonnet::get_active_groups($env{'user.domain'},
                                               $env{'user.name'},$cdom,$cnum);
                   foreach my $group (keys(%cgroups)) {
                       $group_privs{$group} =
                           $env{'user.priv.cc./'.$cdom.'/'.$cnum.'./'.$cdom.'/'.$cnum.'/'.$group};
                   }
                   $newgroups{'/'.$cdom.'/'.$cnum} = \%group_privs;
                 my $area = '/'.$cdom.'/'.$cnum;                  my $area = '/'.$cdom.'/'.$cnum;
                 my $spec = $role.'.'.$area;                  my $spec = $role.'.'.$area;
                 if ($usec ne '') {                  if ($usec ne '') {
Line 1144  sub adhoc_course_role { Line 1292  sub adhoc_course_role {
                     $area .= '/'.$usec;                      $area .= '/'.$usec;
                 }                  }
                 &Apache::lonnet::standard_roleprivs(\%newrole,$role,$cdom,$spec,$cnum,$area);                  &Apache::lonnet::standard_roleprivs(\%newrole,$role,$cdom,$spec,$cnum,$area);
                 &Apache::lonnet::set_userprivs(\%userroles,\%newrole,%newgroups);                  &Apache::lonnet::set_userprivs(\%userroles,\%newrole,\%newgroups);
                 my $adhocstart = $then-1;                  my $adhocstart = $then-1;
                 $userroles{'user.role.'.$spec} = $adhocstart.'.';                  $userroles{'user.role.'.$spec} = $adhocstart.'.';
                 &Apache::lonnet::appenv(\%userroles,[$role,'cm']);                  &Apache::lonnet::appenv(\%userroles,[$role,'cm']);
Line 1242  sub display_cc_role { Line 1390  sub display_cc_role {
             my $trolecode = 'cc./'.$1.'/'.$2;              my $trolecode = 'cc./'.$1.'/'.$2;
             my $twhere;              my $twhere;
             my $ttype;              my $ttype;
             my $tbg='#77FF77';              my $tbg='LC_roles_is';
             my $tfont='#003300';  
             my %newhash=&Apache::lonnet::coursedescription($tcourseid);              my %newhash=&Apache::lonnet::coursedescription($tcourseid);
             if (%newhash) {              if (%newhash) {
                 $twhere=$newhash{'description'}.                  $twhere=$newhash{'description'}.
                         ' <font size="-2">'.                          ' <span style="LC_fontsize_small">'.
                         &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$2,$1,$tfont).                          &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$2,$1).
                         '</font>';                          '</span>';
                 $ttype = $newhash{'type'};                  $ttype = $newhash{'type'};
             } else {              } else {
                 $twhere=&mt('Currently not available');                  $twhere=&mt('Currently not available');
Line 1257  sub display_cc_role { Line 1404  sub display_cc_role {
             }              }
             my $trole = &Apache::lonnet::plaintext('cc',$ttype);              my $trole = &Apache::lonnet::plaintext('cc',$ttype);
             $twhere.="<br />".&mt('Domain').":".$1;              $twhere.="<br />".&mt('Domain').":".$1;
             $roletext = &build_roletext($trolecode,$1,$2,'is',$tryagain,$advanced,'',$tbg,$tfont,$trole,$twhere,'','','',1,'');              $roletext = &build_roletext($trolecode,$1,$2,'is',$tryagain,$advanced,'',$tbg,$trole,$twhere,'','','',1,'');
         }          }
     }      }
     return ($roletext);      return ($roletext);
Line 1265  sub display_cc_role { Line 1412  sub display_cc_role {
   
 sub adhoc_roles_row {  sub adhoc_roles_row {
     my ($dcdom,$rowtype) = @_;      my ($dcdom,$rowtype) = @_;
     my $output = '<tr bgcolor="#77FF77">'.      my $output = &Apache::loncommon::continue_data_table_row()
                  ' <td colspan="5"><table><tr><td><span class="LC_rolesinfo">'                   .' <td colspan="5">'
                  .&mt('[_1]Ad hoc[_2] roles in domain [_3] --',                   .'<table><tr><td>'
                  '<span class="LC_cusr_emph">','</span>',$dcdom).'</span></td><td>';                   .&mt('[_1]Ad hoc[_2] roles in domain [_3] --'
                        ,'<span class="LC_cusr_emph">','</span>',$dcdom)
                    .'</td>'
                    .'<td>';
     my $selectcclink = &courselink($dcdom,$rowtype);      my $selectcclink = &courselink($dcdom,$rowtype);
     my $ccrole = &Apache::lonnet::plaintext('cc');      my $ccrole = &Apache::lonnet::plaintext('cc');
     my $carole = &Apache::lonnet::plaintext('ca');      my $carole = &Apache::lonnet::plaintext('ca');
     my $selectcalink = &coauthorlink($dcdom,$rowtype);      my $selectcalink = &coauthorlink($dcdom,$rowtype);
     $output.= '<span class="LC_rolesinfo">'.      $output.=&mt('[_1]: [_2]',$ccrole,$selectcclink)
             &mt('[_1]: [_2]',$ccrole,$selectcclink).              .'<br /></td>'
             '</span><br /></td><td>&nbsp;&nbsp;</td><td><span class="LC_rolesinfo">'.              .'<td>&nbsp;&nbsp;</td>'
             &mt('[_1]: [_2]',$carole,$selectcalink).              .'<td>'.&mt('[_1]: [_2]',$carole,$selectcalink).'<br /></td>'
             '</span><br /></td></tr></table></td></tr>'.              .'</tr></table>'
             '<tr><td colspan="5" height="3"></td></tr>'."\n";              .'</td>'
               .&Apache::loncommon::end_data_table_row();
     return $output;      return $output;
 }  }
   

Removed from v.1.207  
changed lines
  Added in v.1.213


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