Diff for /loncom/publisher/lonrights.pm between versions 1.7 and 1.15

version 1.7, 2003/03/21 14:13:30 version 1.15, 2004/05/20 13:42:35
Line 36  use Apache::lonnet(); Line 36  use Apache::lonnet();
 use Apache::loncommon();  use Apache::loncommon();
 use HTML::LCParser;  use HTML::LCParser;
 use Apache::File;  use Apache::File;
   use Apache::lonlocal;
   
 sub handler {  sub handler {
   
   my $r=shift;    my $r=shift;
   $r->content_type('text/html');    my $target = $ENV{'form.grade_target'};
     if ($target eq 'meta') {
         &Apache::loncommon::content_type($r,'text/html');
         $r->send_http_header;
         $ENV{'request.uri'}=$r->uri;
         my $file = &Apache::lonnet::filelocation("",$r->uri);
         my $content=&Apache::lonnet::getfile($file);
         my $result=&Apache::lonxml::xmlparse(undef,'meta',$content);
         $r->print($result);
         return OK;
     }
     &Apache::loncommon::content_type($r,'text/html');
   $r->send_http_header;    $r->send_http_header;
   
   $r->print(    $r->print(
      '<html><head><title>LON-CAPA Custom Distribution Rights</title></head>');       '<html><head><title>LON-CAPA Custom Distribution Rights</title>'.
      &Apache::loncommon::coursebrowser_javascript().'</head>');
   
   $r->print(&Apache::loncommon::bodytag('Custom Distribution Rights'));    $r->print(&Apache::loncommon::bodytag('Custom Distribution Rights'));
   $r->rflush();    $r->rflush();
Line 152  sub handler { Line 165  sub handler {
           $contents=join('',<$fh>);            $contents=join('',<$fh>);
           $fh->close();            $fh->close();
       }        }
       $r->print('<form method="post">');        $r->print('<form name="rules" method="post">');
   }    }
   unless ($contents=~/\<accessrule/s) {    unless ($contents=~/\<accessrule/s) {
       $contents='<accessrule effect="deny" />';        $contents='<accessrule effect="deny" />';
Line 160  sub handler { Line 173  sub handler {
   my $parser=HTML::LCParser->new(\$contents);    my $parser=HTML::LCParser->new(\$contents);
   my $token;    my $token;
   my $rulecounter=0;    my $rulecounter=0;
   my $colzero=($constructmode?'Edit action':'Rule');    my $colzero=&mt($constructmode?'Edit action':'Rule');
     my %lt=&Apache::lonlocal::texthash('ef' => 'Effect',
        'do' => 'Domain',
        'co' => 'Course',
        'se' => 'Section/Group',
        'ro' => 'Role');
 # ---------------------------------------------------------- Start table output  # ---------------------------------------------------------- Start table output
   $r->print(<<ENDSTARTTABLE);    $r->print(<<ENDSTARTTABLE);
 <table border="2">  <table border="2">
     <tr><th>$colzero</th><th>Effect</th><th>Domain</th><th>Course</th>      <tr><th>$colzero</th><th>$lt{'ef'}</th><th>$lt{'do'}</th><th>$lt{'co'}</th>
 <th>Section</th><th>Role</th></tr>  <th>$lt{'se'}</th><th>$lt{'ro'}</th></tr>
 ENDSTARTTABLE  ENDSTARTTABLE
 # --------------------------------------------------------------------- Default  # --------------------------------------------------------------------- Default
 # Fast forward to first rule  # Fast forward to first rule
Line 192  ENDSTARTTABLE Line 210  ENDSTARTTABLE
   }    }
   $r->print('</td><td colspan="4">Default');    $r->print('</td><td colspan="4">Default');
   if (($token->[2]->{'realm'}) || ($token->[2]->{'role'})) {    if (($token->[2]->{'realm'}) || ($token->[2]->{'role'})) {
       $r->print(' - <font color="red">Error! No default set.</font>');        $r->print(' - <font color="red">'.&mt('Error! No default set.').
    '</font>');
   }    }
   $r->print('</td></tr>');    $r->print('</td></tr>');
 # Additional roles  # Additional roles
   while ($token=$parser->get_token) {    while ($token=$parser->get_token) {
       if (($token->[0] eq 'S') && ($token->[1] eq 'accessrule')) {        if (($token->[0] eq 'S') && ($token->[1] eq 'accessrule')) {
           $rulecounter++;            $rulecounter++;
   $r->print('<tr><td align="right">');    $r->print('<tr><td align="right" rowspan="2">');
 # insert, delete, etc  # insert, delete, etc
   $r->print($rulecounter.'.&nbsp;');    $r->print($rulecounter.'.&nbsp;');
           if ($constructmode) {            if ($constructmode) {
Line 212  ENDSTARTTABLE Line 231  ENDSTARTTABLE
                      'moveup'      => 'Move rule up',                       'moveup'      => 'Move rule up',
                      'movedown'    => 'Move rule down')));                       'movedown'    => 'Move rule down')));
   }    }
           $r->print('</td><td>');            $r->print('</td><td rowspan="2">');
 # effect  # effect
           if ($constructmode) {            if ($constructmode) {
              $r->print(&Apache::loncommon::select_form               $r->print(&Apache::loncommon::select_form
Line 254  ENDSTARTTABLE Line 273  ENDSTARTTABLE
               $r->print($rsec);                $r->print($rsec);
           }            }
   
           $r->print('</td><td>');            $r->print('</td><td rowspan="2">');
 # role  # role
           if ($constructmode) {            if ($constructmode) {
       my %hash=('' => '');        my %hash=('' => '');
Line 268  ENDSTARTTABLE Line 287  ENDSTARTTABLE
           } else {            } else {
               $r->print(&Apache::lonnet::plaintext($token->[2]->{'role'}));                $r->print(&Apache::lonnet::plaintext($token->[2]->{'role'}));
           }            }
   # course selection link
             $r->print('</td></tr><tr><td colspan="3" align="right">');
             if ($rcourse) {
         my %descript=
                    &Apache::lonnet::coursedescription($rdom.'_'.$rcourse);
                 $r->print($descript{'description'}.'&nbsp;&nbsp;&nbsp;');
             }
     if ($constructmode) {
         $r->print(&Apache::loncommon::selectcourse_link('rules',
           'course_'.$rulecounter,'domain_'.$rulecounter));
     }
 # close row  # close row
           $r->print('</td></tr>');            $r->print('</td></tr>');
      }                                              }                                       
Line 275  ENDSTARTTABLE Line 305  ENDSTARTTABLE
   $r->print('</table>');    $r->print('</table>');
 # ------------------------------------------------------------ End table output  # ------------------------------------------------------------ End table output
   if ($constructmode) {     if ($constructmode) { 
      $r->print('<input type="submit" name="store" value="Store" /></form>');        $r->print('<input type="submit" name="store" value="'.&mt('Store').'" /></form>'); 
   }    }
   $r->print('</body></html>');    $r->print('</body></html>');
   return OK;      return OK;  

Removed from v.1.7  
changed lines
  Added in v.1.15


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