Diff for /loncom/interface/lonmeta.pm between versions 1.189 and 1.191

version 1.189, 2006/11/20 20:58:30 version 1.191, 2007/01/02 11:38:28
Line 39  use Apache::lonpublisher; Line 39  use Apache::lonpublisher;
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::lonmysql;  use Apache::lonmysql;
 use Apache::lonmsg;  use Apache::lonmsg;
 use lib '/home/httpd/lib/perl/';  use LONCAPA qw(:DEFAULT :match);
 use LONCAPA;  
   
   
 ############################################################  ############################################################
Line 63  use LONCAPA; Line 62  use LONCAPA;
 ############################################################  ############################################################
 sub get_dynamic_metadata_from_sql {  sub get_dynamic_metadata_from_sql {
     my ($url) = shift();      my ($url) = shift();
     my ($authordom,$author)=($url=~m:^/res/(\w+)/(\w+)/:);      my ($authordom,$author)=($url=~m{^/res/($match_domain)/($match_username)/});
     if (! defined($authordom)) {      if (! defined($authordom)) {
         $authordom = shift();          $authordom = shift();
     }      }
Line 112  sub get_dynamic_metadata_from_sql { Line 111  sub get_dynamic_metadata_from_sql {
 sub dynamicmeta {  sub dynamicmeta {
     my $url=&Apache::lonnet::declutter(shift);      my $url=&Apache::lonnet::declutter(shift);
     $url=~s/\.meta$//;      $url=~s/\.meta$//;
     my ($adomain,$aauthor)=($url=~/^(\w+)\/(\w+)\//);      my ($adomain,$aauthor)=($url=~/^($match_domain)\/($match_username)\//);
     my $regexp=$url;      my $regexp=$url;
     $regexp=~s/(\W)/\\$1/g;      $regexp=~s/(\W)/\\$1/g;
     $regexp='___'.$regexp.'___';      $regexp='___'.$regexp.'___';
Line 236  sub fieldnames { Line 235  sub fieldnames {
          'lowestgradelevel' => 'Lowest Grade Level',           'lowestgradelevel' => 'Lowest Grade Level',
          'highestgradelevel' => 'Highest Grade Level');           'highestgradelevel' => 'Highest Grade Level');
           
     if (! defined($file_type) || $file_type ne 'portfolio') {      if ( !defined($file_type) || ($file_type ne 'portfolio' && $file_type ne 'groups') ) {
         %fields =           %fields = 
         (%fields,          (%fields,
          'domain' => 'Domain',           'domain' => 'Domain',
Line 449  sub prettyprint { Line 448  sub prettyprint {
  ($type eq 'owner') ||   ($type eq 'owner') ||
  ($type eq 'modifyinguser') ||   ($type eq 'modifyinguser') ||
  ($type eq 'authorspace')) {   ($type eq 'authorspace')) {
  $value=~s/(\w+)(\:|\@)(\w+)/&authordisplay($1,$3)/gse;   $value=~s/($match_username)(\:|\@)($match_domain)/&authordisplay($1,$3)/gse;
  return $value;   return $value;
     }      }
     # Gradelevel      # Gradelevel
Line 732  sub handler { Line 731  sub handler {
     $r->send_http_header;      $r->send_http_header;
     return OK if $r->header_only;      return OK if $r->header_only;
     my ($resdomain,$resuser)=      my ($resdomain,$resuser)=
         (&Apache::lonnet::declutter($uri)=~/^(\w+)\/(\w+)\//);          (&Apache::lonnet::declutter($uri)=~/^($match_domain)\/($match_username)\//);
     if ($uri=~m:/adm/bombs/(.*)$:) {      if ($uri=~m:/adm/bombs/(.*)$:) {
         $r->print(&Apache::loncommon::start_page('Error Messages'));          $r->print(&Apache::loncommon::start_page('Error Messages'));
         # Looking for all bombs?          # Looking for all bombs?
         &report_bombs($r,$uri);          &report_bombs($r,$uri);
     } elsif ($uri=~m|^/editupload/[^/]+/[^/]+/portfolio/|) {      } elsif ($uri=~m|^/editupload/[^/]+/[^/]+/portfolio/|) {
     ($resdomain,$resuser)=      ($resdomain,$resuser)=
  (&Apache::lonnet::declutter($uri)=~m|^(\w+)/(\w+)/portfolio|);   (&Apache::lonnet::declutter($uri)=~m|^($match_domain)/($match_name)/portfolio|);
         $r->print(&Apache::loncommon::start_page('Edit Portfolio File Catalog Information',          $r->print(&Apache::loncommon::start_page('Edit Portfolio File Catalog Information',
  undef,   undef,
  {'domain' => $resdomain,}));   {'domain' => $resdomain,}));
Line 793  sub report_bombs { Line 792  sub report_bombs {
     $uri =~ s:/adm/bombs/::;      $uri =~ s:/adm/bombs/::;
     $uri = &Apache::lonnet::declutter($uri);      $uri = &Apache::lonnet::declutter($uri);
     $r->print('<h1>'.&Apache::lonnet::clutter($uri).'</h1>');      $r->print('<h1>'.&Apache::lonnet::clutter($uri).'</h1>');
     my ($domain,$author)=($uri=~/^(\w+)\/(\w+)\//);      my ($domain,$author)=($uri=~/^($match_domain)\/($match_username)\//);
     if (&Apache::loncacc::constructaccess('/~'.$author.'/',$domain)) {      if (&Apache::loncacc::constructaccess('/~'.$author.'/',$domain)) {
  if ($env{'form.clearbombs'}) {   if ($env{'form.clearbombs'}) {
     &Apache::lonmsg::clear_author_res_msg($uri);      &Apache::lonmsg::clear_author_res_msg($uri);
Line 1060  sub print_dynamic_metadata { Line 1059  sub print_dynamic_metadata {
     } else {      } else {
         $r->print('<h4>'.&mt('No Evaluation Data is available for this resource.').'</h4>');          $r->print('<h4>'.&mt('No Evaluation Data is available for this resource.').'</h4>');
     }      }
     $uri=~/^\/res\/(\w+)\/(\w+)\//;       $uri=~/^\/res\/($match_domain)\/($match_username)\//; 
     if ((($env{'user.domain'} eq $1) && ($env{'user.name'} eq $2))      if ((($env{'user.domain'} eq $1) && ($env{'user.name'} eq $2))
         || ($env{'user.role.ca./'.$1.'/'.$2})) {          || ($env{'user.role.ca./'.$1.'/'.$2})) {
         if (exists($dynmeta{'comments'})) {          if (exists($dynmeta{'comments'})) {
Line 1253  ENDEDIT Line 1252  ENDEDIT
     }      }
   
     if ($Apache::lonpublisher::metadatafields{'courserestricted'} ne 'none') {      if ($Apache::lonpublisher::metadatafields{'courserestricted'} ne 'none') {
  $r->print(&mt('Associated with course [_1]',                  if ($file_type eq 'portfolio') {
       $r->print(&mt('Associated with course [_1]',
         '<strong><a href="'.$uri.'?changecourse=true">'.          '<strong><a href="'.$uri.'?changecourse=true">'.
         $env{$Apache::lonpublisher::metadatafields{'courserestricted'}.          $env{$Apache::lonpublisher::metadatafields{'courserestricted'}.
         ".description"}.          ".description"}.
       '</a></strong>').'<br />');        '</a></strong>').'<br />');
                   } else {
                       $r->print(&mt('Associated with course [_1]',
                           '<strong>'.
     $env{$Apache::lonpublisher::metadatafields{'courserestricted'}.
                           ".description"}.'</strong>').'<br />');
                   }
     } else {      } else {
  $r->print('<a href="'.$uri.'?changecourse=true">This resource is not associated with a course.</a><br />');   $r->print('<a href="'.$uri.'?changecourse=true">This resource is not associated with a course.</a><br />');
     }      }
Line 1337  ENDEDIT Line 1343  ENDEDIT
     }      }
     if ($fn =~ m|^$Apache::lonnet::perlvar{'lonDocRoot'}/userfiles|) {      if ($fn =~ m|^$Apache::lonnet::perlvar{'lonDocRoot'}/userfiles|) {
         my ($path, $new_fn);          my ($path, $new_fn);
         if ($fn =~ m|\w+/groups/\w+/portfolio/|) {          if ($fn =~ m|$match_name/groups/\w+/portfolio/|) {
                     ($path, $new_fn) = ($fn =~ m|/(groups/\w+/portfolio.*)/([^/]*)$|);                      ($path, $new_fn) = ($fn =~ m|/(groups/\w+/portfolio.*)/([^/]*)$|);
         } else {          } else {
     ($path, $new_fn) = ($fn =~ m|/(portfolio.*)/([^/]*)$|);      ($path, $new_fn) = ($fn =~ m|/(portfolio.*)/([^/]*)$|);
Line 1351  ENDEDIT Line 1357  ENDEDIT
       &mt('FAIL').'</font></p>');        &mt('FAIL').'</font></p>');
  } else {   } else {
     print $mfh ($file_content);      print $mfh ($file_content);
                       close($mfh);
     $r->print('<p><font color="blue">'.&mt('Wrote Metadata').      $r->print('<p><font color="blue">'.&mt('Wrote Metadata').
       ' '.&Apache::lonlocal::locallocaltime(time).        ' '.&Apache::lonlocal::locallocaltime(time).
       '</font></p>');        '</font></p>');
Line 1360  ENDEDIT Line 1367  ENDEDIT
  $r->print($output.'<br /><input type="submit" name="store" value="'.   $r->print($output.'<br /><input type="submit" name="store" value="'.
                   &mt('Store Catalog Information').'" />');                    &mt('Store Catalog Information').'" />');
   
  if ($file_type eq 'portfolio') {   if ($file_type eq 'portfolio' || $file_type eq 'groups') {
     my ($port_path,$group) = &get_port_path_and_group($uri);      my ($port_path,$group) = &get_port_path_and_group($uri);
             if ($group) {              if ($group ne '') {
                 $r->print('<input type="hidden" name="group" value="'.$group.'" />');                  $r->print('<input type="hidden" name="group" value="'.$group.'" />');
             }              }
             $r->print('<input type="hidden" name="currentpath" value="'.$env{'form.currentpath'}.'" />');              $r->print('<input type="hidden" name="currentpath" value="'.$env{'form.currentpath'}.'" />');
     $r->print('</form><br /><br /><form method="post" action="'.$port_path.'">');      $r->print('</form><br /><br /><form method="post" action="'.$port_path.'">');
     if ($group) {      if ($group ne '') {
         $r->print('<input type="hidden" name="group" value="'.$group.'" />');          $r->print('<input type="hidden" name="group" value="'.$group.'" />');
     }              }
     $r->print('<input type="hidden" name="currentpath" value="'.$path.'" />'.      $r->print('<input type="hidden" name="currentpath" value="'.$path.'" />'.
       '<input type="submit" name="cancel" value="'.&mt('Discard Edits and Return to Portfolio').'" />');        '<input type="submit" name="cancel" value="'.&mt('Discard Edits and Return to Portfolio').'" />');
  }   }

Removed from v.1.189  
changed lines
  Added in v.1.191


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