Diff for /loncom/auth/lonroles.pm between versions 1.128 and 1.136

version 1.128, 2005/08/09 20:06:40 version 1.136, 2005/11/15 21:39:28
Line 89  sub handler { Line 89  sub handler {
   
 # ================================================================== Roles Init  # ================================================================== Roles Init
     if ($env{'form.selectrole'}) {      if ($env{'form.selectrole'}) {
           if ($env{'form.newrole'}) {
               $env{'form.'.$env{'form.newrole'}}=1;
    }
  if ($env{'request.course.id'}) {   if ($env{'request.course.id'}) {
     my %temp=('logout_'.$env{'request.course.id'} => time);      my %temp=('logout_'.$env{'request.course.id'} => time);
     &Apache::lonnet::put('email_status',\%temp);      &Apache::lonnet::put('email_status',\%temp);
Line 244  ENDENTERKEY Line 247  ENDENTERKEY
       "request.course.id"  => $cdom.'_'.$cnum);        "request.course.id"  => $cdom.'_'.$cnum);
  $furl='/adm/roles?tryagain=1';   $furl='/adm/roles?tryagain=1';
  $msg=   $msg=
     '<h1><font color=red>'.      '<h1><font color="red">'.
  &mt('Could not initialize course at this time.').   &mt('Could not initialize course at this time.').
     '</font></h1><h3>'.&mt('Please try again.').'</h3>'.$ferr;      '</font></h1><h3>'.&mt('Please try again.').'</h3>'.$ferr;
     }      }
Line 312  ENDENTERKEY Line 315  ENDENTERKEY
   
     my $swinfo=&Apache::lonmenu::rawconfig();      my $swinfo=&Apache::lonmenu::rawconfig();
     my $bodytag=&Apache::loncommon::bodytag('User Roles');      my $bodytag=&Apache::loncommon::bodytag('User Roles');
       my $standby=&mt('Role selected. Please stand by.');
       $standby=~s/\n/\\n/g;
     my $helptag='<table><tr><td>'.&Apache::loncommon::help_open_menu('','General Intro','General_Intro','User Roles',1,undef,undef,undef,undef,,&mt("Click here for help")).'</td></td></tr></table>';      my $helptag='<table><tr><td>'.&Apache::loncommon::help_open_menu('','General Intro','General_Intro','User Roles',1,undef,undef,undef,undef,,&mt("Click here for help")).'</td></td></tr></table>';
     $r->print(<<ENDHEADER);      $r->print(<<ENDHEADER);
 <html>  <html>
Line 323  $helptag<br /> Line 328  $helptag<br />
 <script>  <script>
 $swinfo  $swinfo
 window.focus();  window.focus();
   
   active=true;
   
   function enterrole (thisform,rolecode,buttonname) {
       if (active) {
    active=false;
           document.title='$standby';
           window.status='$standby';
    thisform.newrole.value=rolecode;
    thisform.submit();
       } else {
          alert('$standby');
       }   
   }
 </script>  </script>
 ENDHEADER  ENDHEADER
   
Line 362  ENDHEADER Line 381  ENDHEADER
     } else {      } else {
         if ($env{'user.error.msg'}) {          if ($env{'user.error.msg'}) {
     $r->print(      $r->print(
  '<h3><font color=red>'.   '<h3><font color="red">'.
  &mt('You need to choose another user role or enter a specific course for this function').'</font></h3>');   &mt('You need to choose another user role or enter a specific course for this function').'</font></h3>');
  }   }
     }      }
Line 396  ENDHEADER Line 415  ENDHEADER
         $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="" />');
     }      }
     if ($env{'user.adv'}) {      if ($env{'user.adv'}) {
  $r->print(   $r->print(
Line 416  ENDHEADER Line 436  ENDHEADER
         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,$tfont);
             &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 '');              next if (!defined($role) || $role eq '' || $role =~ /^gr/);
             $tremark='';              $tremark='';
             $tpstart='&nbsp;';              $tpstart='&nbsp;';
             $tpend='&nbsp;';              $tpend='&nbsp;';
Line 461  ENDHEADER Line 481  ENDHEADER
                 my $trole;                  my $trole;
                 if ($role =~ /^cr\//) {                  if ($role =~ /^cr\//) {
                     my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role);                      my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role);
                     $tremark.='<br />'.&mt('Defined by ').$rauthor.      if ($tremark) { $tremark.='<br />'; }
                       $tremark.=&mt('Defined by ').$rauthor.
  &mt(' at ').$rdomain.'.';   &mt(' at ').$rdomain.'.';
                     $trole=$rrole;                      $trole=$rrole;
                 } else {                  } else {
Line 479  ENDHEADER Line 500  ENDHEADER
     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=&Apache::lonnet::escape('http://'.                          $switchserver='otherserver='.$home.'&role='.$trolecode;
                          $Apache::lonnet::hostname{$home}.  
                          '/adm/login?domain='.$env{'user.domain'}.  
   '&username='.$env{'user.name'}.  
                           '&firsturl=/priv/'.$trest.'/');  
                     }                      }
                     #next if ($home eq 'no_host');                      #next if ($home eq 'no_host');
                     $home = $Apache::lonnet::hostname{$home};                      $home = $Apache::lonnet::hostname{$home};
Line 593  ENDHEADER Line 610  ENDHEADER
     $r->print('<br /><table><tr>');      $r->print('<br /><table><tr>');
     unless ($nochoose) { $r->print('<th>&nbsp;</th>'); }      unless ($nochoose) { $r->print('<th>&nbsp;</th>'); }
     $r->print('<th>'.&mt('User Role').'</th><th>'.&mt('Extent').      $r->print('<th>'.&mt('User Role').'</th><th>'.&mt('Extent').
          '</th><th>'.&mt('Start').'</th><th>'.&mt('End').'</th><th>'.           '</th><th>'.&mt('Start').'</th><th>'.&mt('End').'</th></tr>'."\n");
       &mt('Remarks and Calendar Announcements').'</th></tr>'."\n");  
     my $doheaders=-1;      my $doheaders=-1;
     foreach my $type ('Construction Space','Course','Domain','System') {      foreach my $type ('Domain','Construction Space','Course','System') {
  my $haverole=0;   my $haverole=0;
  foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {   foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {
     if ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/) {       if ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/) { 
Line 613  ENDHEADER Line 629  ENDHEADER
  foreach (sort(keys(%recent_roles))) {   foreach (sort(keys(%recent_roles))) {
     if (defined($roletext{'user.role.'.$_})) {      if (defined($roletext{'user.role.'.$_})) {
  $output.=$roletext{'user.role.'.$_};   $output.=$roletext{'user.role.'.$_};
                   if ($_ =~ m-dc\./(\w+)/- && $dcroles{$1}) {
       $output .= &allcourses_row($1);
                   }
     } elsif ($numdc > 0) {      } elsif ($numdc > 0) {
                 unless ($_ =~/^error\:/) {                  unless ($_ =~/^error\:/) {
                     $output.=&display_cc_role('user.role.'.$_);                      $output.=&display_cc_role('user.role.'.$_);
Line 620  ENDHEADER Line 639  ENDHEADER
             }               } 
  }   }
  if ($output) {   if ($output) {
     $r->print("<tr><td align='center' colspan='6'><font face='arial'>".      $r->print("<tr><td align='center' colspan='5'><font face='arial'>".
       &mt('Recent Roles')."</font></td>");        &mt('Recent Roles')."</font></td>");
     $r->print($output);      $r->print($output);
     $r->print("</tr>");      $r->print("</tr>");
Line 632  ENDHEADER Line 651  ENDHEADER
         $r->print(&coursepick_jscript());          $r->print(&coursepick_jscript());
         $r->print(&Apache::loncommon::coursebrowser_javascript());          $r->print(&Apache::loncommon::coursebrowser_javascript());
     }      }
     foreach my $type ('Construction Space','Course','Domain','System') {      foreach my $type ('Construction Space','Domain','Course','System') {
  my $output;   my $output;
  foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {   foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {
     if ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/) {       if ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/) { 
Line 647  ENDHEADER Line 666  ENDHEADER
  if ($output) {   if ($output) {
     if ($doheaders > 0) {      if ($doheaders > 0) {
  $r->print("<tr>".   $r->print("<tr>".
   "<td align='center' colspan='6'><font face='arial'>".&mt($type)."</font></td></tr>");    "<td align='center' colspan='5'><font face='arial'>".&mt($type)."</font></td></tr>");
     }      }
     $r->print($output);      $r->print($output);
  }   }
Line 663  ENDHEADER Line 682  ENDHEADER
     }      }
     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><input type="submit" value="'.
       &mt('Select').'" name="cm"></td>');        &mt('Select').'" name="cm"></td>');
  } else {   } else {
     $r->print('<td>&nbsp;</td>');      $r->print('<td>&nbsp;</td>');
  }   }
     }      }
     $r->print('<td colspan="4"><font color="'.$tfont.'">'.&mt('No role specified').      $r->print('<td colspan="3"><font color="'.$tfont.'">'.&mt('No role specified').
       '</font></td><td><font color="'.$tfont.'">'.$tremark.        '</font></td><td><font color="'.$tfont.'">'.$tremark.
       '&nbsp;</font></td></tr>'."\n");        '&nbsp;</font></td></tr>'."\n");
   
Line 769  sub role_status { Line 788  sub role_status {
 sub build_roletext {  sub build_roletext {
     my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tfont,$trole,$ttype,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver) = @_;      my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tfont,$trole,$ttype,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver) = @_;
     my $roletext='<tr bgcolor="'.$tbg.'">';      my $roletext='<tr bgcolor="'.$tbg.'">';
       my $is_dc=($trolecode =~ m/^dc\./);
       my $rowspan=($is_dc) ? ''
                            : ' rowspan="2" ';
   
     unless ($nochoose) {      unless ($nochoose) {
           my $buttonname=$trolecode;
           $buttonname=~s/\W//g;
         if (!$button) {          if (!$button) {
             if ($switchserver) {              if ($switchserver) {
                 $roletext.='<td><a href="/adm/logout?handover='.                  $roletext.='<td'.$rowspan.'><a href="/adm/switchserver?'.
                 $switchserver.'">'.&mt('Switch Server').'</a></td>';                  $switchserver.'">'.&mt('Switch Server').'</a></td>';
             } else {              } else {
                 $roletext.=('<td>&nbsp;</td>');                  $roletext.=('<td>&nbsp;</td>');
             }              }
         } elsif ($tstatus eq 'is') {          } elsif ($tstatus eq 'is') {
             $roletext.=('<td><input type=submit value="'.              $roletext.='<td'.$rowspan.'><input name="'.$buttonname.'" type="button" value="'.
                         &mt('Select').'" name="'.                          &mt('Select').'" onClick="javascript:enterrole(this.form,\''.
                         $trolecode.'"></td>');                          $trolecode."','".$buttonname.'\');"></td>';
         } elsif ($tryagain) {          } elsif ($tryagain) {
             $roletext.=              $roletext.=
                 '<td><input type=submit value="'.                  '<td'.$rowspan.'><input name="'.$buttonname.'" type="button" value="'.
                 &mt('Try Selecting Again').'" name="'.$trolecode.'"></td>';                  &mt('Try Selecting Again').'" onClick="javascript:enterrole(this.form,\''.
                           $trolecode."','".$buttonname.'\');"></td>';
         } elsif ($advanced) {          } elsif ($advanced) {
             $roletext.=              $roletext.=
                 '<td><input type=submit value="'.                  '<td'.$rowspan.'><input name="'.$buttonname.'" type="button" value="'.
                 &mt('Re-Initialize').'" name="'.$trolecode.'"></td>';                  &mt('Re-Initialize').'" onClick="javascript:enterrole(this.form,\''.
                           $trolecode."','".$buttonname.'\');"></td>';
         } else {          } else {
             $roletext.='<td>&nbsp;</td>';              $roletext.='<td'.$rowspan.'>&nbsp;</td>';
         }          }
     }      }
     $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><font color="'.$tfont.'">'.$trole.
        '</font></td><td><font color="'.$tfont.'">'.$twhere.         '</font></td><td><font color="'.$tfont.'">'.$twhere.
                '</font></td><td><font color="'.$tfont.'">'.$tpstart.                 '</font></td><td><font color="'.$tfont.'">'.$tpstart.
                '</font></td><td><font color="'.$tfont.'">'.$tpend.                 '</font></td><td><font color="'.$tfont.'">'.$tpend.
                '</font></td><td><font color="'.$tfont.'">'.$tremark.                 '</font></td></tr>';
                '&nbsp;</font></td></tr>'."\n";      if (!$is_dc) {
    $roletext.='<tr bgcolor="'.$tbg.'"><td colspan="4"><font color="'.$tfont.'">'.$tremark.
       '&nbsp;</font></td></tr><tr><td colspan="5" height="3"></td></tr>'."\n";
       }
     return $roletext;      return $roletext;
 }  }
   
Line 899  function process_pick(dom) { Line 928  function process_pick(dom) {
         if (pickedCourse != '') {          if (pickedCourse != '') {
             if (numbutton != -1) {              if (numbutton != -1) {
                 var courseTarget = "cc./"+pickedDomain+"/"+pickedCourse                  var courseTarget = "cc./"+pickedDomain+"/"+pickedCourse
                 opener.document.rolechoice.elements[numbutton+1].name = courseTarget                  opener.document.rolechoice.elements[numbutton].name = courseTarget
                 opener.document.rolechoice.submit()                  opener.document.rolechoice.submit()
             }              }
         }          }
Line 955  sub allcourses_row { Line 984  sub allcourses_row {
     my $dcdom = shift;      my $dcdom = shift;
     my $ccrole = Apache::lonnet::plaintext('cc');      my $ccrole = Apache::lonnet::plaintext('cc');
     my $selectlink = &courselink($dcdom);      my $selectlink = &courselink($dcdom);
     my $output = '<tr bgcolor="#99FF99">'.      my $output = '<tr bgcolor="#77FF77">'.
               '<td><input type="button" value="'.   '<input type="hidden" name="ccpick_'.$dcdom.'" />'.
               &mt('Select').'" name="ccpick_'.$dcdom.'"'.   '<input type="hidden" name="pick_'.$dcdom.'" value="1" />'.
               'onClick="verifyCoursePick(this)">'.   '<td colspan="5">'.
               '<input type="hidden" name="pick_'.$dcdom.'" value="1"></td>'.   '<font color="#002200">'.$ccrole.'</font>'.
               '<td><font color="#002200">'.   ' <b>'.$selectlink.'</b>'.
               $ccrole.'</font></td>'.   ' from '.&mt('Domain').' '.$dcdom.
               '<td><font color="#002200">'.&mt('All courses').':<b>&nbsp;'.   '<tr><td colspan="5" height="3"></td></tr>'."\n";
               $selectlink.'</b>'.  
               '<br />'.&mt('Domain').':'.$dcdom.'</font>'.  
               '<td colspan="3"><font color="#002200">'.  
               &mt('Course Coordinator access to all courses in domain').  
               ': <b>'.$dcdom.'</b></font></td></tr>'."\n";  
     return $output;      return $output;
 }  }
   

Removed from v.1.128  
changed lines
  Added in v.1.136


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