Diff for /loncom/auth/lonroles.pm between versions 1.118 and 1.126

version 1.118, 2005/04/07 06:56:21 version 1.126, 2005/07/08 10:39:49
Line 39  use Apache::loncommon; Line 39  use Apache::loncommon;
 use Apache::lonhtmlcommon;  use Apache::lonhtmlcommon;
 use Apache::lonannounce;  use Apache::lonannounce;
 use Apache::lonlocal;  use Apache::lonlocal;
   use GDBM_File;
   
 sub redirect_user {  sub redirect_user {
     my ($r,$title,$url,$msg,$launch_nav) = @_;      my ($r,$title,$url,$msg,$launch_nav) = @_;
Line 226  ENDENTERKEY Line 227  ENDENTERKEY
                     my $tadv=0;                      my $tadv=0;
     my $msg=&mt('Entering course ...');      my $msg=&mt('Entering course ...');
   
     if (($cnum) && ($role ne 'ca')) {      if (($cnum) && ($role ne 'ca') && ($role ne 'aa')) {
  my ($furl,$ferr)=   my ($furl,$ferr)=
     &Apache::lonuserstate::readmap($cdom.'/'.$cnum);      &Apache::lonuserstate::readmap($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'};
     if ( &Apache::lonnet::mod_perl_version() == 2 ) {  
  &Apache::lonnet::cleanenv();  
     }  
     if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; }      if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; }
     &Apache::lonnet::appenv('request.role.adv'=>$tadv);      &Apache::lonnet::appenv('request.role.adv'=>$tadv);
     $r->internal_redirect($dest);      $r->internal_redirect($dest);
Line 262  ENDENTERKEY Line 260  ENDENTERKEY
     if ($role eq 'cc' && $env{'course.' . $courseid .       if ($role eq 'cc' && $env{'course.' . $courseid . 
   '.course.helper.not.run'}) {    '.course.helper.not.run'}) {
  $furl = "/adm/helper/course.initialization.helper";   $furl = "/adm/helper/course.initialization.helper";
    # Send the user to the course they selected
       } elsif (($env{'request.course.fn'}) 
        && ($role eq 'cc' && ($env{'environment.course_init_display'} ne 'firstres')))  {
    $msg = &mt('Entering course ....');
    &redirect_user($r,&mt('New in course'),
          '/adm/whatsnew',$msg,
          $env{'environment.remotenavmap'});
    return OK;
     }      }
                             # Send the user to the course they selected      &redirect_user($r,&mt('Entering Course'),
                             &redirect_user($r,&mt('Entering Course'),  
                                            $furl,$msg,                                             $furl,$msg,
    $env{'environment.remotenavmap'});     $env{'environment.remotenavmap'});
                             return OK;      return OK;
  }   }
     }      }
                     #                      #
                     # Send the user to the construction space they selected                      # Send the user to the construction space they selected
                     if ($role =~ /^(au|ca)$/) {                      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.name'};
Line 338  ENDHEADER Line 343  ENDHEADER
 # --------------------------------------------------------------- Error Header?  # --------------------------------------------------------------- Error Header?
     if ($error) {      if ($error) {
  $r->print("<h1>LON-CAPA Access Control</h1>");   $r->print("<h1>LON-CAPA Access Control</h1>");
         $r->print("<hr><pre>Access  : ".          $r->print("<!-- LONCAPAACCESSCONTROLERRORSCREEN --><hr /><pre>Access  : ".
                   Apache::lonnet::plaintext($priv)."\n");                    Apache::lonnet::plaintext($priv)."\n");
         $r->print("Resource: ".&Apache::lonenc::check_encrypt($fn)."\n");          $r->print("Resource: ".&Apache::lonenc::check_encrypt($fn)."\n");
         $r->print("Action  : $msg\n</pre><hr>");          $r->print("Action  : $msg\n</pre><hr />");
    my $url=$fn;
    my $last;
    if (tie(my %hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
    &GDBM_READER(),0640)) {
       $last=$hash{'last_known'};
       untie(%hash);
    }
    if ($last) { $fn.='?symb='.&Apache::lonnet::escape($last); }
   
    &Apache::londocs::changewarning($r,undef,'You have modified your course recently, [_1] may fix this access problem.',
    &Apache::lonenc::check_encrypt($fn));
     } else {      } else {
         if ($env{'user.error.msg'}) {          if ($env{'user.error.msg'}) {
     $r->print(      $r->print(
Line 371  ENDHEADER Line 387  ENDHEADER
                       ($env{'user.name'},$env{'user.domain'})}.                        ($env{'user.name'},$env{'user.domain'})}.
       "<br />\n");        "<br />\n");
     $r->print(&mt(      $r->print(&mt(
       "Author and Co-Author roles may not be available on servers other than your home server."));        "Author and Co-Author roles are not available on servers other than their respective home servers."));
         }          }
         if (($ENV{'REDIRECT_QUERY_STRING'}) && ($fn)) {          if (($ENV{'REDIRECT_QUERY_STRING'}) && ($fn)) {
        $fn.='?'.$ENV{'REDIRECT_QUERY_STRING'};         $fn.='?'.$ENV{'REDIRECT_QUERY_STRING'};
Line 414  ENDHEADER Line 430  ENDHEADER
  $tstatus='selected';   $tstatus='selected';
             }              }
             my $tbg;              my $tbg;
       my $tbghigh;
             if (($tstatus eq 'is') || ($tstatus eq 'selected') ||              if (($tstatus eq 'is') || ($tstatus eq 'selected') ||
                 ($env{'form.showall'})) {                  ($env{'form.showall'})) {
                 if ($tstatus eq 'is') {                  if ($tstatus eq 'is') {
                     $tbg='#77FF77';                      $tbg='#77FF77';
       $tbghigh='#99CC77';
                     $tfont='#003300';                      $tfont='#003300';
     $possiblerole=$trolecode;      $possiblerole=$trolecode;
     $countactive++;      $countactive++;
                 } elsif ($tstatus eq 'future') {                  } elsif ($tstatus eq 'future') {
                     $tbg='#FFFF77';                      $tbg='#FFFF77';
                       $tbghigh='#DDDD55';
                     $button=0;                      $button=0;
                 } elsif ($tstatus eq 'will') {                  } elsif ($tstatus eq 'will') {
                     $tbg='#FFAA77';                      $tbg='#FFAA77';
                     $tremark.=&mt('Active at next login. ');                      $tremark.=&mt('Active at next login. ');
                 } elsif ($tstatus eq 'expired') {                  } elsif ($tstatus eq 'expired') {
                     $tbg='#FF7777';                      $tbg='#FF7777';
                       $tbghigh='#EE9955';
                     $tfont='#330000';                      $tfont='#330000';
                     $button=0;                      $button=0;
                 } elsif ($tstatus eq 'will_not') {                  } elsif ($tstatus eq 'will_not') {
                     $tbg='#AAFF77';                      $tbg='#AAFF77';
                       $tbghigh='#BBDD55';
                     $tremark.=&mt('Expired after logout. ');                      $tremark.=&mt('Expired after logout. ');
                 } elsif ($tstatus eq 'selected') {                  } elsif ($tstatus eq 'selected') {
                     $tbg='#11CC55';                      $tbg='#11CC55';
                       $tbghigh='339944';
                     $tfont='#002200';                      $tfont='#002200';
     $inrole=1;      $inrole=1;
     $countactive++;      $countactive++;
Line 444  ENDHEADER Line 466  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.                      $tremark.='<br />'.&mt('Defined by ').$rauthor.
  &mt(' at ').$rdomain.'.';   &mt(' at ').$rdomain.'.';
                     $trole=$rrole;                      $trole=$rrole;
                 } else {                  } else {
Line 455  ENDHEADER Line 477  ENDHEADER
                 my ($tdom,$trest,$tsection)=                  my ($tdom,$trest,$tsection)=
                     split(/\//,Apache::lonnet::declutter($where));                      split(/\//,Apache::lonnet::declutter($where));
                 # First, Co-Authorship roles                  # First, Co-Authorship roles
                 if ($role eq 'ca') {                  if (($role eq 'ca') || ($role eq 'aa')) {
                     my $home = &Apache::lonnet::homeserver($trest,$tdom);                      my $home = &Apache::lonnet::homeserver($trest,$tdom);
     my $allowed=0;      my $allowed=0;
     my @ids=&Apache::lonnet::current_machine_ids();      my @ids=&Apache::lonnet::current_machine_ids();
Line 502  ENDHEADER Line 524  ENDHEADER
     $sortkey=$role;      $sortkey=$role;
                 } elsif ($trest) {                  } elsif ($trest) {
                     $ttype='Course';                      $ttype='Course';
                     if ($tsection) {  
                         $ttype.='<br>'.&mt('Section/Group').': '.$tsection;  
     }  
                     my $tcourseid=$tdom.'_'.$trest;                      my $tcourseid=$tdom.'_'.$trest;
                     if ($env{'course.'.$tcourseid.'.description'}) {                      if ($env{'course.'.$tcourseid.'.description'}) {
                         $twhere=$env{'course.'.$tcourseid.'.description'};                          $twhere=$env{'course.'.$tcourseid.'.description'};
Line 529  ENDHEADER Line 548  ENDHEADER
     $sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey;      $sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey;
                         }                          }
                     }                      }
                       if ($tsection) {
                           $twhere.='<br />'.&mt('Section/Group').': '.$tsection;
       }
   
     if ($role ne 'st') { $twhere.="<br />".&mt('Domain').":".$tdom; }      if ($role ne 'st') { $twhere.="<br />".&mt('Domain').":".$tdom; }
                 } elsif ($tdom) {                  } elsif ($tdom) {
                     $ttype='Domain';                      $ttype='Domain';
Line 540  ENDHEADER Line 563  ENDHEADER
     $sortkey=$role.$twhere;      $sortkey=$role.$twhere;
                 }                  }
     
                 $roletext.=&build_roletext($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tfont,$trole,$ttype,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver);                  $roletext.=&build_roletext($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tbghigh,$tfont,$trole,$ttype,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver);
  $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 574  ENDHEADER Line 597  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 colspan=2>'.&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><th>'.
       &mt('Remarks and Calendar Announcements').'</th></tr>'."\n");        &mt('Remarks and Calendar Announcements').'</th></tr>'."\n");
     my $doheaders=-1;      my $doheaders=-1;
Line 602  ENDHEADER Line 625  ENDHEADER
             }               } 
  }   }
  if ($output) {   if ($output) {
     $r->print("<tr bgcolor='#BBffBB'><td align='center' colspan='7'>".      $r->print("<tr><td colspan='6'><font face='arial'>".
       &mt('Recent Roles')."</td>");        &mt('Recent Roles')."</font></td>");
     $r->print($output);      $r->print($output);
     $r->print("</tr>");      $r->print("</tr>");
             $doheaders ++;              $doheaders ++;
Line 628  ENDHEADER Line 651  ENDHEADER
  }   }
  if ($output) {   if ($output) {
     if ($doheaders > 0) {      if ($doheaders > 0) {
  $r->print("<tr bgcolor='#BBffBB'>".   $r->print("<tr>".
   "<td align='center' colspan='7'>".&mt($type)."</td></tr>");    "<td colspan='6'><font face='arial'>".&mt($type)."</font></td></tr>");
     }      }
     $r->print($output);      $r->print($output);
  }   }
Line 651  ENDHEADER Line 674  ENDHEADER
     $r->print('<td>&nbsp;</td>');      $r->print('<td>&nbsp;</td>');
  }   }
     }      }
     $r->print('<td colspan=5><font color="'.$tfont.'">'.&mt('No role specified').      $r->print('<td colspan="4"><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 749  sub role_status { Line 772  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,$tbghigh,$tfont,$trole,$ttype,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver) = @_;
     my $roletext='<tr bgcolor="'.$tbg.'">';      my $roletext='<tr bgcolor="'.$tbg.'" onMouseOver="javascript:style.backgroundColor=\''.$tbghigh.'\'" onMouseOut="javascript:style.backgroundColor=\''.$tbg.'\'" >';
     unless ($nochoose) {      unless ($nochoose) {
         if (!$button) {          if (!$button) {
             if ($switchserver) {              if ($switchserver) {
Line 780  sub build_roletext { Line 803  sub build_roletext {
   
   
     $roletext.='<td><font color="'.$tfont.'">'.$trole.      $roletext.='<td><font color="'.$tfont.'">'.$trole.
                '</font></td><td><font color="'.$tfont.'">'.$ttype.         '</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><td><font color="'.$tfont.'">'.$tremark.
Line 916  sub display_cc_role { Line 938  sub display_cc_role {
             my $trole = Apache::lonnet::plaintext('cc');              my $trole = Apache::lonnet::plaintext('cc');
             my $twhere;              my $twhere;
             my $tbg='#77FF77';              my $tbg='#77FF77';
       my $tbghigh='#99CC77';
             my $tfont='#003300';              my $tfont='#003300';
             my %newhash=&Apache::lonnet::coursedescription($tcourseid);              my %newhash=&Apache::lonnet::coursedescription($tcourseid);
             if (%newhash) {              if (%newhash) {
Line 928  sub display_cc_role { Line 951  sub display_cc_role {
                 $env{'course.'.$tcourseid.'.description'}=$twhere;                  $env{'course.'.$tcourseid.'.description'}=$twhere;
             }              }
             $twhere.="<br />".&mt('Domain').":".$1;              $twhere.="<br />".&mt('Domain').":".$1;
             $roletext = &build_roletext($trolecode,$1,$2,'is',$tryagain,$advanced,'',$tbg,$tfont,$trole,&mt('Course'),$twhere,'','','',1,'');              $roletext = &build_roletext($trolecode,$1,$2,'is',$tryagain,$advanced,'',$tbg,$tbghigh,$tfont,$trole,&mt('Course'),$twhere,'','','',1,'');
         }          }
     }      }
     return $roletext;      return $roletext;
Line 938  sub allcourses_row { Line 961  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="#77FF77">'.      my $output = '<tr bgcolor="#99FF99" onMouseOver="javascript:style.backgroundColor=\'#BBEE99\'"  onMouseOut="javascript:style.backgroundColor=\'#99FF99\'" >'.
               '<td><input type="button" value="'.                '<td><input type="button" value="'.
               &mt('Select').'" name="ccpick_'.$dcdom.'"'.                &mt('Select').'" name="ccpick_'.$dcdom.'"'.
               'onClick="verifyCoursePick(this)">'.                'onClick="verifyCoursePick(this)">'.
               '<input type="hidden" name="pick_'.$dcdom.'" value="1"></td>'.                '<input type="hidden" name="pick_'.$dcdom.'" value="1"></td>'.
               '<td><font color="#002200">'.                '<td><font color="#002200">'.
               $ccrole.'</font></td><td>'.&mt('Course').'</td>'.                $ccrole.'</font></td>'.
               '<td><font color="#002200">'.&mt('All courses').':<b>&nbsp;'.                '<td><font color="#002200">'.&mt('All courses').':<b>&nbsp;'.
               $selectlink.'</b>'.                $selectlink.'</b>'.
               '<br />'.&mt('Domain').':'.$dcdom.'</font>'.                '<br />'.&mt('Domain').':'.$dcdom.'</font>'.
               '<td colspan="4"><font color="#002200">'.                '<td colspan="3"><font color="#002200">'.
               &mt('Course Coordinator access to all courses in domain').                &mt('Course Coordinator access to all courses in domain').
               ': <b>'.$dcdom.'</b></font></td></tr>'."\n";                ': <b>'.$dcdom.'</b></font></td></tr>'."\n";
     return $output;      return $output;

Removed from v.1.118  
changed lines
  Added in v.1.126


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