Diff for /loncom/publisher/lonpublisher.pm between versions 1.225 and 1.226

version 1.225, 2007/06/18 20:30:32 version 1.226, 2007/07/13 19:23:33
Line 654  sub fix_ids_and_indices { Line 654  sub fix_ids_and_indices {
    join(', ',@duplicatedids));     join(', ',@duplicatedids));
     if ($duplicateids) {      if ($duplicateids) {
  print $logfile "Duplicate ID(s) exist, ".join(', ',@duplicatedids)."\n";   print $logfile "Duplicate ID(s) exist, ".join(', ',@duplicatedids)."\n";
  my $outstring='<font color="red">'.&mt('Unable to publish file, it contains duplicated ID(s), ID(s) need to be unique. The duplicated ID(s) are').': '.join(', ',@duplicatedids).'</font>';   my $outstring='<span class="LC_error">'.&mt('Unable to publish file, it contains duplicated ID(s), ID(s) need to be unique. The duplicated ID(s) are').': '.join(', ',@duplicatedids).'</span>';
  return ($outstring,1);   return ($outstring,1);
     }      }
     if ($needsfixup) {      if ($needsfixup) {
Line 825  sub store_metadata { Line 825  sub store_metadata {
     # Determine if the table exists      # Determine if the table exists
     my $status = &Apache::lonmysql::check_table('metadata');      my $status = &Apache::lonmysql::check_table('metadata');
     if (! defined($status)) {      if (! defined($status)) {
         $error='<font color="red">WARNING: Cannot connect to '.          $error='<span class="LC_error">WARNING: Cannot connect to '.
             'database!</font>';              'database!</span>';
         &Apache::lonnet::logthis($error);          &Apache::lonnet::logthis($error);
         return ($error,undef);          return ($error,undef);
     }      }
     if ($status == 0) {      if ($status == 0) {
         # It would be nice to actually create the table....          # It would be nice to actually create the table....
         $error ='<font color="red">WARNING: The metadata table does not '.          $error ='<span class="LC_error">WARNING: The metadata table does not '.
             'exist in the LON-CAPA database.</font>';              'exist in the LON-CAPA database.</span>';
         &Apache::lonnet::logthis($error);          &Apache::lonnet::logthis($error);
         return ($error,undef);          return ($error,undef);
     }      }
Line 848  sub store_metadata { Line 848  sub store_metadata {
                                                          \%metadata);                                                           \%metadata);
     }      }
     if (defined($status) && $status ne '') {      if (defined($status) && $status ne '') {
         $error='<font color="red">Error occured saving new values in '.          $error='<span class="LC_error">Error occured saving new values in '.
             'metadata table in LON-CAPA database</font>';              'metadata table in LON-CAPA database</span>';
         &Apache::lonnet::logthis($error);          &Apache::lonnet::logthis($error);
         &Apache::lonnet::logthis($status);          &Apache::lonnet::logthis($status);
         return ($error,undef);          return ($error,undef);
Line 871  sub checkonthis { Line 871  sub checkonthis {
     if (($errorcount) || ($warningcount)) {      if (($errorcount) || ($warningcount)) {
         $r->print('<br /><tt>'.$uri.'</tt>: ');          $r->print('<br /><tt>'.$uri.'</tt>: ');
  if ($errorcount) {   if ($errorcount) {
     $r->print('<img src="/adm/lonMisc/bomb.gif" /><font color="red"><b>'.      $r->print('<img src="/adm/lonMisc/bomb.gif" /><span class="LC_error"><b>'.
       $errorcount.' '.        $errorcount.' '.
       &mt('error(s)').'</b></font> ');        &mt('error(s)').'</b></span> ');
  }   }
  if ($warningcount) {   if ($warningcount) {
     $r->print('<font color="blue">'.      $r->print('<font color="blue">'.
Line 937  sub publish { Line 937  sub publish {
     my %allow=();      my %allow=();
   
     unless ($logfile=Apache::File->new('>>'.$source.'.log')) {      unless ($logfile=Apache::File->new('>>'.$source.'.log')) {
  return ('<font color="red">'.&mt('No write permission to user directory, FAIL').'</font>',1);   return ('<span class="LC_error">'.&mt('No write permission to user directory, FAIL').'</span>',1);
     }      }
     print $logfile       print $logfile 
 "\n\n================= Publish ".localtime()." Phase One  ================\n".$env{'user.name'}.':'.$env{'user.domain'}."\n";  "\n\n================= Publish ".localtime()." Phase One  ================\n".$env{'user.name'}.':'.$env{'user.domain'}."\n";
Line 951  sub publish { Line 951  sub publish {
     print $logfile "Copied original file to ".$copyfile."\n";      print $logfile "Copied original file to ".$copyfile."\n";
         } else {          } else {
     print $logfile "Unable to write backup ".$copyfile.':'.$!."\n";      print $logfile "Unable to write backup ".$copyfile.':'.$!."\n";
     return ("<font color=\"red\">Failed to write backup copy, $!,FAIL</font>",1);      return ("<span class=\"LC_error\">Failed to write backup copy, $!,FAIL</span>",1);
         }          }
 # ------------------------------------------------------------- IDs and indices  # ------------------------------------------------------------- IDs and indices
   
Line 979  sub publish { Line 979  sub publish {
                if (                 if (
        &Apache::lonnet::getfile($Apache::lonnet::perlvar{'lonDocRoot'}.'/'.         &Apache::lonnet::getfile($Apache::lonnet::perlvar{'lonDocRoot'}.'/'.
                                             $thisdep.'.meta') eq '-1') {                                              $thisdep.'.meta') eq '-1') {
    $scrout.= ' - <font color="red">'.&mt('Currently not available').     $scrout.= ' - <span class="LC_error">'.&mt('Currently not available').
        '</font>';         '</span>';
                } else {                 } else {
                    my %temphash=(&Apache::lonnet::declutter($target).'___'.                     my %temphash=(&Apache::lonnet::declutter($target).'___'.
                              &Apache::lonnet::declutter($thisdep).'___usage'                               &Apache::lonnet::declutter($thisdep).'___usage'
Line 1001  sub publish { Line 1001  sub publish {
           my $org;            my $org;
           unless ($org=Apache::File->new('>'.$source)) {            unless ($org=Apache::File->new('>'.$source)) {
              print $logfile "No write permit to $source\n";               print $logfile "No write permit to $source\n";
              return ('<font color="red">'.&mt('No write permission to').               return ('<span class="LC_error">'.&mt('No write permission to').
      ' '.$source.       ' '.$source.
      ', '.&mt('FAIL').'</font>',1);       ', '.&mt('FAIL').'</span>',1);
   }    }
           print($org $outstring);            print($org $outstring);
         }          }
Line 1414  sub phasetwo { Line 1414  sub phasetwo {
 #  #
     unless ($env{'form.obsolete'}) {      unless ($env{'form.obsolete'}) {
  if ($target=~/(\_\_\_|\&\&\&|\:\:\:)/) {   if ($target=~/(\_\_\_|\&\&\&|\:\:\:)/) {
     $r->print(      $r->print('<span class="LC_error">'.
       '<font color="red">'.&mt('Unsupported character combination').        &mt('Unsupported character combination [_1] in filename, FAIL.',"<tt>'.$1.'</tt>").
       ' "<tt>'.$1.'</tt>" '.&mt('in filename, FAIL').'</font>');        '</span>');
     return 0;      return 0;
  }   }
  unless ($target=~/\.(\w+)$/) {   unless ($target=~/\.(\w+)$/) {
     $r->print('<font color="red">'.&mt('No valid extension found in filename, FAIL').'</font>');      $r->print('<span class="LC_error">'.&mt('No valid extension found in filename, FAIL').'</span>');
     return 0;      return 0;
  }   }
  if ($target=~/\.(\d+)\.(\w+)$/) {   if ($target=~/\.(\d+)\.(\w+)$/) {
     $r->print('<font color="red">'.&mt('Cannot publish versioned resource, FAIL').'</font>');      $r->print('<span class="LC_error">'.&mt('Cannot publish versioned resource, FAIL').'</span>');
     return 0;      return 0;
  }   }
     }      }
Line 1436  sub phasetwo { Line 1436  sub phasetwo {
     my $logfile;      my $logfile;
     unless ($logfile=Apache::File->new('>>'.$source.'.log')) {      unless ($logfile=Apache::File->new('>>'.$source.'.log')) {
  $r->print(   $r->print(
         '<font color="red">'.          '<span class="LC_error">'.
  &mt('No write permission to user directory, FAIL').'</font>');   &mt('No write permission to user directory, FAIL').'</span>');
         return 0;          return 0;
     }      }
     print $logfile       print $logfile 
Line 1494  sub phasetwo { Line 1494  sub phasetwo {
  my $file=$metadatafields{'customdistributionfile'};   my $file=$metadatafields{'customdistributionfile'};
  unless ($file=~/\.rights$/) {   unless ($file=~/\.rights$/) {
             $r->print(              $r->print(
                 '<font color="red">'.&mt('No valid custom distribution rights file specified, FAIL').                  '<span class="LC_error">'.&mt('No valid custom distribution rights file specified, FAIL').
  '</font>');   '</span>');
     return 0;      return 0;
         }          }
     }      }
Line 1504  sub phasetwo { Line 1504  sub phasetwo {
         my $mfh;          my $mfh;
         unless ($mfh=Apache::File->new('>'.$source.'.meta')) {          unless ($mfh=Apache::File->new('>'.$source.'.meta')) {
             $r->print(               $r->print( 
                 '<font color="red">'.&mt('Could not write metadata, FAIL').                  '<span class="LC_error">'.&mt('Could not write metadata, FAIL').
  '</font>');   '</span>');
     return 0;      return 0;
         }          }
         foreach (sort keys %metadatafields) {          foreach (sort keys %metadatafields) {
Line 1558  sub phasetwo { Line 1558  sub phasetwo {
         unless ($srcd=~/^\/home\/httpd\/html\/res/) {          unless ($srcd=~/^\/home\/httpd\/html\/res/) {
             print $logfile "\nPANIC: Target dir is ".$srcd;              print $logfile "\nPANIC: Target dir is ".$srcd;
             $r->print(              $r->print(
  "<font color=\"red\">Invalid target directory, FAIL</font>");   "<span class=\"LC_error\">Invalid target directory, FAIL</span>");
     return 0;      return 0;
         }          }
         opendir(DIR,$srcd);          opendir(DIR,$srcd);
Line 1584  sub phasetwo { Line 1584  sub phasetwo {
             $r->print('<p>'.&mt('Copied old target file').'</p>');              $r->print('<p>'.&mt('Copied old target file').'</p>');
         } else {          } else {
     print $logfile "Unable to write ".$copyfile.':'.$!."\n";      print $logfile "Unable to write ".$copyfile.':'.$!."\n";
             $r->print("<font color=\"red\">".&mt('Failed to copy old target').              $r->print("<span class=\"LC_error\">".&mt('Failed to copy old target').
  ", $!, ".&mt('FAIL')."</font>");   ", $!, ".&mt('FAIL')."</span>");
     return 0;      return 0;
         }          }
                   
Line 1600  sub phasetwo { Line 1600  sub phasetwo {
     print $logfile "Unable to write metadata ".$copyfile.':'.$!."\n";      print $logfile "Unable to write metadata ".$copyfile.':'.$!."\n";
             if (-e $target.'.meta') {              if (-e $target.'.meta') {
                 $r->print(                   $r->print( 
                     "<font color=\"red\">".                      "<span class=\"LC_error\">".
 &mt('Failed to write old metadata copy').", $!, ".&mt('FAIL')."</font>");  &mt('Failed to write old metadata copy').", $!, ".&mt('FAIL')."</span>");
  return 0;   return 0;
     }      }
         }          }
Line 1633  sub phasetwo { Line 1633  sub phasetwo {
         $r->print('<p>'.&mt('Copied source file').'</p>');          $r->print('<p>'.&mt('Copied source file').'</p>');
     } else {      } else {
         print $logfile "\nUnable to write ".$copyfile.':'.$!."\n";          print $logfile "\nUnable to write ".$copyfile.':'.$!."\n";
         $r->print("<font color=\"red\">".          $r->print("<span class=\"LC_error\">".
     &mt('Failed to copy source').", $!, ".&mt('FAIL')."</font>");      &mt('Failed to copy source').", $!, ".&mt('FAIL')."</span>");
  return 0;   return 0;
     }      }
           
Line 1648  sub phasetwo { Line 1648  sub phasetwo {
     } else {      } else {
         print $logfile "\nUnable to write metadata ".$copyfile.':'.$!."\n";          print $logfile "\nUnable to write metadata ".$copyfile.':'.$!."\n";
         $r->print(          $r->print(
             "<font color=\"red\">".&mt('Failed to write metadata copy').", $!, ".&mt('FAIL')."</font>");              "<span class=\"LC_error\">".&mt('Failed to write metadata copy').", $!, ".&mt('FAIL')."</span>");
  return 0;   return 0;
     }      }
     $r->rflush;      $r->rflush;
Line 1881  sub defaultmetapublish { Line 1881  sub defaultmetapublish {
     if (copy($fn,$copyfile)) {      if (copy($fn,$copyfile)) {
         $r->print('<p>'.&mt('Copied source file').'</p>');          $r->print('<p>'.&mt('Copied source file').'</p>');
     } else {      } else {
         return "<font color=\"red\">".          return "<span class=\"LC_error\">".
     &mt('Failed to copy source').", $!, ".&mt('FAIL')."</font>";      &mt('Failed to copy source').", $!, ".&mt('FAIL')."</span>";
     }      }
   
 # --------------------------------------------------- Send update notifications  # --------------------------------------------------- Send update notifications

Removed from v.1.225  
changed lines
  Added in v.1.226


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