Diff for /loncom/interface/londocs.pm between versions 1.258 and 1.266

version 1.258, 2006/11/28 15:03:19 version 1.266, 2007/01/05 17:55:41
Line 42  use HTML::Entities; Line 42  use HTML::Entities;
 use GDBM_File;  use GDBM_File;
 use Apache::lonlocal;  use Apache::lonlocal;
 use Cwd;  use Cwd;
 use LONCAPA;  use LONCAPA qw(:DEFAULT :match);
   
 my $iconpath;  my $iconpath;
   
Line 99  sub authorhosts { Line 99  sub authorhosts {
  $ca=$env{'user.name'};   $ca=$env{'user.name'};
  $cd=$env{'user.domain'};   $cd=$env{'user.domain'};
     } else {      } else {
  ($cd,$ca)=($realm=~/^\/(\w+)\/(\w+)$/);   ($cd,$ca)=($realm=~/^\/($match_domain)\/($match_username)$/);
     }      }
     my $allowed=0;      my $allowed=0;
     my $myhome=&Apache::lonnet::homeserver($ca,$cd);      my $myhome=&Apache::lonnet::homeserver($ca,$cd);
Line 366  sub exportcourse { Line 366  sub exportcourse {
             if (ref($curRes)) {              if (ref($curRes)) {
                 my $symb = $curRes->symb();                  my $symb = $curRes->symb();
                 my $ressymb = $symb;                  my $ressymb = $symb;
                 if ($ressymb =~ m|adm/(\w+)/(\w+)/(\d+)/bulletinboard$|) {                  if ($ressymb =~ m|adm/($match_domain)/($match_username)/(\d+)/bulletinboard$|) {
                     unless ($ressymb =~ m|adm/wrapper/adm|) {                      unless ($ressymb =~ m|adm/wrapper/adm|) {
                         $ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard';                          $ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard';
                     }                      }
Line 613  sub build_package { Line 613  sub build_package {
                         if (grep/^$count$/,@$discussions) {                          if (grep/^$count$/,@$discussions) {
                             my $ressymb = $symb;                              my $ressymb = $symb;
                             my $mode;                              my $mode;
                             if ($ressymb =~ m|adm/(\w+)/(\w+)/(\d+)/bulletinboard$|) {                              if ($ressymb =~ m|adm/($match_domain)/($match_username)/(\d+)/bulletinboard$|) {
                                 unless ($ressymb =~ m|adm/wrapper/adm|) {                                  unless ($ressymb =~ m|adm/wrapper/adm|) {
                                     $ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard';                                      $ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard';
                                 }                                  }
Line 698  sub process_content { Line 698  sub process_content {
         }          }
     } elsif ($symb =~ m-lib/templates/examupload\.problem$-) {      } elsif ($symb =~ m-lib/templates/examupload\.problem$-) {
         $content_type = 'examupload';          $content_type = 'examupload';
     } elsif ($symb =~ m-adm/(\w+)/(\w+)/(\d+)/bulletinboard$-) {      } elsif ($symb =~ m-adm/($match_domain)/($match_username)/(\d+)/bulletinboard$-) {
         $content_type = 'bulletinboard';          $content_type = 'bulletinboard';
         my $contents =  &Apache::imsexport::templatedpage($content_type,$3,$count,\@uploads,$1,$2);          my $contents =  &Apache::imsexport::templatedpage($content_type,$3,$count,\@uploads,$1,$2);
         if ($contents) {          if ($contents) {
Line 913  sub group_import { Line 913  sub group_import {
     while (@_) {      while (@_) {
  my $name = shift;   my $name = shift;
  my $url = shift;   my $url = shift;
         if (($url =~ m#^/uploaded/$coursedom/$coursenum/(default_\d+\.)(page|sequence)$#) && ($caller eq 'londocs')) {          if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) && ($caller eq 'londocs')) {
             my $errtext = '';              my $errtext = '';
             my $fatal = 0;              my $fatal = 0;
             my $newmapstr = '<map>'."\n".              my $newmapstr = '<map>'."\n".
Line 936  sub group_import { Line 936  sub group_import {
     my $idx = &LONCAPA::map::getresidx($url);      my $idx = &LONCAPA::map::getresidx($url);
     $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx;      $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx;
     my $ext = 'false';      my $ext = 'false';
     if ($url=~/^http:\/\//) { $ext = 'true'; }      if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }
     $url =~ s/:/\&colon;/g;      $url =~ s/:/\&colon;/g;
     $name =~ s/:/\&colon;/g;      $name =~ s/:/\&colon;/g;
     $LONCAPA::map::resources[$idx] =       $LONCAPA::map::resources[$idx] = 
Line 988  sub breadcrumbs { Line 988  sub breadcrumbs {
       {'href'=>$url.$cpinfo,        {'href'=>$url.$cpinfo,
        'title'=>$name,         'title'=>$name,
        'text'=>'<font size="+1">'.         'text'=>'<font size="+1">'.
    $name.'</font>'     $name.'</font>',
          'no_mt'=>1,
        });         });
  $plain.=$name.' &gt; ';   $plain.=$name.' &gt; ';
     }      }
Line 1028  sub log_docs { Line 1029  sub log_docs {
   
     sub log_differences {      sub log_differences {
         my ($plain)=@_;          my ($plain)=@_;
         my %storehash=('folder' => $plain);          my %storehash=('folder' => $plain,
                          'currentfolder' => $env{'form.folder'});
         if ($parmidx) {          if ($parmidx) {
            $storehash{'parameter_res'}=$oldresources[$parmidx];             $storehash{'parameter_res'}=$oldresources[$parmidx];
            foreach my $parm (keys %parmaction) {             foreach my $parm (keys %parmaction) {
Line 1063  sub log_docs { Line 1065  sub log_docs {
 #  #
 sub docs_change_log {  sub docs_change_log {
     my ($r)=@_;      my ($r)=@_;
       my $folder=$env{'form.folder'};
     $r->print(&Apache::loncommon::start_page('Course Document Change Log'));      $r->print(&Apache::loncommon::start_page('Course Document Change Log'));
     $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Document Change Log'));      $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Document Change Log'));
   
     my %docslog=&Apache::lonnet::dump('nohist_docslog',      my %docslog=&Apache::lonnet::dump('nohist_docslog',
                                       $env{'course.'.$env{'request.course.id'}.'.domain'},                                        $env{'course.'.$env{'request.course.id'}.'.domain'},
                                       $env{'course.'.$env{'request.course.id'}.'.num'});                                        $env{'course.'.$env{'request.course.id'}.'.num'});
Line 1086  sub docs_change_log { Line 1088  sub docs_change_log {
     'randompick'     => 'Randomly pick',      'randompick'     => 'Randomly pick',
     'set'            => 'set to',      'set'            => 'set to',
     'del'            => 'deleted');      'del'            => 'deleted');
       $r->print(&Apache::loncommon::display_filter().
     my $countselect =                '<input type="hidden" name="folder" value="'.$folder.'" />'.
         &Apache::lonmeta::selectbox('show',$env{'form.show'},undef,  
                                     (&mt('all'),10,20,50,100,1000,10000));  
   
     $r->print('<nobr>'.&mt('[_1] Records',$countselect).'</nobr>'.  
               '<input type="submit" value="'.&mt('Display').'" /></form>');                '<input type="submit" value="'.&mt('Display').'" /></form>');
     $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().      $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
               '<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Folder').'</th><th>'.&mt('Before').'</th><th>'.                '<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Folder').'</th><th>'.&mt('Before').'</th><th>'.
Line 1099  sub docs_change_log { Line 1097  sub docs_change_log {
               &Apache::loncommon::end_data_table_header_row());                &Apache::loncommon::end_data_table_header_row());
     my $shown=0;      my $shown=0;
     foreach my $id (sort { $docslog{$b}{'exe_time'}<=>$docslog{$a}{'exe_time'} } (keys(%docslog))) {      foreach my $id (sort { $docslog{$b}{'exe_time'}<=>$docslog{$a}{'exe_time'} } (keys(%docslog))) {
    if ($env{'form.displayfilter'} eq 'currentfolder') {
       if ($docslog{$id}{'logentry'}{'currentfolder'} ne $folder) { next; }
    }
         my @changes=keys(%{$docslog{$id}{'logentry'}});          my @changes=keys(%{$docslog{$id}{'logentry'}});
           if ($env{'form.displayfilter'} eq 'containing') {
       my $wholeentry=$docslog{$id}{'exe_uname'}.':'.$docslog{$id}{'exe_udom'}.':'.
    &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},$docslog{$id}{'exe_udom'});
       foreach my $key (@changes) {
    $wholeentry.=':'.$docslog{$id}{'logentry'}{$key};
       }
       if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }         
    }
         my $count = 0;          my $count = 0;
         my $time =          my $time =
             &Apache::lonlocal::locallocaltime($docslog{$id}{'exe_time'});              &Apache::lonlocal::locallocaltime($docslog{$id}{'exe_time'});
Line 1301  sub editor { Line 1310  sub editor {
     $url=~/^(.+)\.(\w+)$/;      $url=~/^(.+)\.(\w+)$/;
     my $newurl=$1.$newid.'.'.$2;      my $newurl=$1.$newid.'.'.$2;
     my $storefn=$newurl;      my $storefn=$newurl;
                     $storefn=~s/^\/\w+\/\w+\/\w+\///;                      $storefn=~s{^/\w+/$match_domain/$match_username/}{};
     &Apache::lonclonecourse::writefile      &Apache::lonclonecourse::writefile
  ($env{'request.course.id'},$storefn,   ($env{'request.course.id'},$storefn,
  &Apache::lonnet::getfile($url));   &Apache::lonnet::getfile($url));
Line 1609  sub process_secondary_uploads { Line 1618  sub process_secondary_uploads {
     $destination .= $newidx;      $destination .= $newidx;
     my ($url,$filename);      my ($url,$filename);
     $url=&Apache::lonnet::userfileupload($formname.$num,1,$destination);      $url=&Apache::lonnet::userfileupload($formname.$num,1,$destination);
     ($filename) = ($url =~ m-^/uploaded/$coursedom/$coursenum/$destination/(.+)$-);      ($filename) = ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/\Q$destination\E/(.+)$});
     return $filename;      return $filename;
 }  }
   
Line 1624  sub entryline { Line 1633  sub entryline {
     my $foldertitle=$title;      my $foldertitle=$title;
     my $pagetitle=$title;      my $pagetitle=$title;
     my $orderidx=$LONCAPA::map::order[$index];      my $orderidx=$LONCAPA::map::order[$index];
     if ($title=~ /^(\d+)___&amp;&amp;&amp;___(\w+)___&amp;&amp;&amp;___(\w+)___&amp;&amp;&amp;___(.*)$/ ) {       if ($title=~ /^(\d+)___&amp;&amp;&amp;___($match_username)___&amp;&amp;&amp;___($match_domain)___&amp;&amp;&amp;___(.*)$/ ) { 
  $foldertitle=&Apache::lontexconvert::msgtexconverted($4);   $foldertitle=&Apache::lontexconvert::msgtexconverted($4);
  $renametitle=$4;   $renametitle=$4;
  $title='<i>'.&Apache::lonlocal::locallocaltime($1).'</i> '.   $title='<i>'.&Apache::lonlocal::locallocaltime($1).'</i> '.
Line 1775  END Line 1784  END
     if ($uploaded) {      if ($uploaded) {
  if ($extension eq 'sequence') {   if ($extension eq 'sequence') {
     $icon=$iconpath.'/folder_closed.gif';      $icon=$iconpath.'/folder_closed.gif';
     $url=~/$coursenum\/([\/\w]+)\.sequence$/;      $url=~/\Q$coursenum\E\/([\/\w]+)\.sequence$/;
     $url='/adm/coursedocs?';      $url='/adm/coursedocs?';
     $folderarg=$1;      $folderarg=$1;
     $isfolder=1;      $isfolder=1;
         } elsif ($extension eq 'page') {          } elsif ($extension eq 'page') {
             $icon=$iconpath.'/page.gif';              $icon=$iconpath.'/page.gif';
             $url=~/$coursenum\/([\/\w]+)\.page$/;              $url=~/\Q$coursenum\E\/([\/\w]+)\.page$/;
             $pagearg=$1;              $pagearg=$1;
             $url='/adm/coursedocs?';              $url='/adm/coursedocs?';
             $ispage=1;              $ispage=1;
Line 2482  sub handler { Line 2491  sub handler {
   my %codebase = ();    my %codebase = ();
   my ($upload_result,$upload_output);    my ($upload_result,$upload_output);
   if ($allowed) {    if ($allowed) {
       if (($env{'form.uploaddoc.filename'}) &&                                               ($env{'form.cmd'}=~/^upload_(\w+)/)) {        if (($env{'form.uploaddoc.filename'}) &&
     ($env{'form.cmd'}=~/^upload_(\w+)/)) {
 # Process file upload - phase one - upload and parse primary file.    # Process file upload - phase one - upload and parse primary file.  
           $upload_result = &process_file_upload(\$upload_output,$coursenum,            $upload_result = &process_file_upload(\$upload_output,$coursenum,
  $coursedom,\%allfiles,   $coursedom,\%allfiles,
Line 2641  $exportbut Line 2651  $exportbut
 </td><td bgcolor="#DDDDCC">  </td><td bgcolor="#DDDDCC">
     <input type="submit" name="listsymbs" value="$lt{'ls'}" />      <input type="submit" name="listsymbs" value="$lt{'ls'}" />
 </td><td bgcolor="#DDDDCC">  </td><td bgcolor="#DDDDCC">
       <input type="hidden" name="folder" value="$env{'form.folder'}" />
     <input type="submit" name="docslog" value="$lt{'sl'}" />      <input type="submit" name="docslog" value="$lt{'sl'}" />
 </td></tr></table>  </td></tr></table>
 </form>  </form>

Removed from v.1.258  
changed lines
  Added in v.1.266


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