Diff for /loncom/interface/londocs.pm between versions 1.149 and 1.156

version 1.149, 2004/11/11 22:47:55 version 1.156, 2004/12/14 21:10:58
Line 1034  sub entryline { Line 1034  sub entryline {
  $folderpath=&Apache::lonnet::escape($ENV{'form.folderpath'});   $folderpath=&Apache::lonnet::escape($ENV{'form.folderpath'});
  # $htmlfoldername=&HTML::Entities::encode($ENV{'form.foldername'},'<>&"');   # $htmlfoldername=&HTML::Entities::encode($ENV{'form.foldername'},'<>&"');
     }      }
     my $pagepath;      my ($pagepath,$pagesymb);
     if ($ENV{'form.pagepath'}) {      if ($ENV{'form.pagepath'}) {
         $container = 'page';          $container = 'page';
         $pagepath=&Apache::lonnet::escape($ENV{'form.pagepath'});          $pagepath=&Apache::lonnet::escape($ENV{'form.pagepath'});
           $pagesymb=&Apache::lonnet::escape($ENV{'form.pagesymb'});
     }      }
     if ($allowed) {      if ($allowed) {
  my $incindex=$index+1;   my $incindex=$index+1;
Line 1064  sub entryline { Line 1065  sub entryline {
             $line.=(<<END);              $line.=(<<END);
 <form name="entry_$index" action="/adm/coursedocs" method="post">  <form name="entry_$index" action="/adm/coursedocs" method="post">
 <input type="hidden" name="pagepath" value="$ENV{'form.pagepath'}" />  <input type="hidden" name="pagepath" value="$ENV{'form.pagepath'}" />
   <input type="hidden" name="pagesymb" value="$ENV{'form.pagesymb'}" />
 <input type="hidden" name="setparms" value="$orderidx" />  <input type="hidden" name="setparms" value="$orderidx" />
 <td><table border='0' cellspacing='2' cellpadding='0'>  <td><table border='0' cellspacing='2' cellpadding='0'>
 <tr><td bgcolor="#DDDDDD">  <tr><td bgcolor="#DDDDDD">
 <a href='/adm/coursedocs?cmd=up_$index&pagepath=$pagepath'>  <a href='/adm/coursedocs?cmd=up_$index&pagepath=$pagepath&pagesymb=$pagesymb'>
 <img src="${iconpath}move_up.gif" alt='$lt{'up'}' border='0' /></a></td></tr>  <img src="${iconpath}move_up.gif" alt='$lt{'up'}' border='0' /></a></td></tr>
 <tr><td bgcolor="#DDDDDD">  <tr><td bgcolor="#DDDDDD">
 <a href='/adm/coursedocs?cmd=down_$index&pagepath=$pagepath'>  <a href='/adm/coursedocs?cmd=down_$index&pagepath=$pagepath&pagesymb=$pagesymb'>
 <img src="${iconpath}move_down.gif" alt='$lt{'dw'}' border='0' /></a></td></tr>  <img src="${iconpath}move_down.gif" alt='$lt{'dw'}' border='0' /></a></td></tr>
 </table></td>  </table></td>
 <td>$selectbox  <td>$selectbox
 </td><td bgcolor="#DDDDDD">  </td><td bgcolor="#DDDDDD">
 <a href='javascript:removeres("$pagepath","$index","$renametitle","page");'>  <a href='javascript:removeres("$pagepath","$index","$renametitle","page","$pagesymb");'>
 <font size="-2" color="#990000">$lt{'rm'}</font></a>  <font size="-2" color="#990000">$lt{'rm'}</font></a>
 <a href='javascript:changename("$pagepath","$index","$renametitle","page");'>  <a href='javascript:changename("$pagepath","$index","$renametitle","page","$pagesymb");'>
 <font size="-2" color="#009900">$lt{'rn'}</font></a></td>  <font size="-2" color="#009900">$lt{'rn'}</font></a></td>
 END  END
         } else {          } else {
Line 1152  END Line 1154  END
  } elsif ($url=~m|^/ext/|) {    } elsif ($url=~m|^/ext/|) { 
     $url='/adm/wrapper'.$url;      $url='/adm/wrapper'.$url;
  }   }
         unless ($container eq 'page') {   $url.=(($url=~/\?/)?'&':'?').'symb='.&Apache::lonnet::escape($symb);
    if ($container eq 'page') {
       my $symb=$ENV{'form.pagesymb'};
           
       $url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]);
     $url.=(($url=~/\?/)?'&':'?').'symb='.&Apache::lonnet::escape($symb);      $url.=(($url=~/\?/)?'&':'?').'symb='.&Apache::lonnet::escape($symb);
         }   }
     }      }
     my $parameterset='&nbsp;';      my $parameterset='&nbsp;';
     if ($isfolder) {      if ($isfolder) {
Line 1176  END Line 1182  END
         my $folderpath=$ENV{'form.folderpath'};          my $folderpath=$ENV{'form.folderpath'};
         if ($folderpath) { $pagepath = $folderpath.'&' };          if ($folderpath) { $pagepath = $folderpath.'&' };
         $pagepath.=$pagearg.'&'.$pagename;          $pagepath.=$pagearg.'&'.$pagename;
         $url.='pagepath='.&Apache::lonnet::escape($pagepath);   my $symb=$ENV{'form.pagesymb'};
    if (!$symb) {
       my $path='uploaded/'.
    $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}.'/'.
    $ENV{'course.'.$ENV{'request.course.id'}.'.num'}.'/';
       $symb=&Apache::lonnet::encode_symb($path.$folder.'.sequence',
          $residx,
          $path.$pagearg.'.page');
    }
    $url.='pagepath='.&Apache::lonnet::escape($pagepath).
       '&pagesymb='.&Apache::lonnet::escape($symb);
     }      }
     $line.='<td bgcolor="#FFFFBB"><a href="'.$url.'"><img src="'.$icon.      $line.='<td bgcolor="#FFFFBB"><a href="'.$url.'"><img src="'.$icon.
  '" border="0"></a></td>'.   '" border="0"></a></td>'.
Line 1210  ENDPARMS Line 1226  ENDPARMS
 sub tiehash {  sub tiehash {
     my ($mode)=@_;      my ($mode)=@_;
     $hashtied=0;      $hashtied=0;
     &Apache::lonnet::logthis(" tiehash1 -- $hashtied ");  
     if ($ENV{'request.course.fn'}) {      if ($ENV{'request.course.fn'}) {
  &Apache::lonnet::logthis(" tiehash2 -- $hashtied ");  
  if ($mode eq 'write') {   if ($mode eq 'write') {
     &Apache::lonnet::logthis(" tiehash3 -- $hashtied ");  
     if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db",      if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db",
     &GDBM_WRCREAT(),0640)) {      &GDBM_WRCREAT(),0640)) {
                 $hashtied=2;                  $hashtied=2;
  &Apache::lonnet::logthis(" tiehash4 -- $hashtied ");  
     }      }
  } else {   } else {
     &Apache::lonnet::logthis(" tiehash5 -- $hashtied ");  
     if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db",      if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db",
     &GDBM_READER(),0640)) {      &GDBM_READER(),0640)) {
                 $hashtied=1;                  $hashtied=1;
  &Apache::lonnet::logthis(" tiehash6 -- $hashtied ");  
     }      }
  }   }
     }          }    
     &Apache::lonnet::logthis(" tiehash7 -- $hashtied ");  
 }  }
   
 sub untiehash {  sub untiehash {
     &Apache::lonnet::logthis(" untiehash1 -- $hashtied ");  
     if ($hashtied) { untie %hash; }      if ($hashtied) { untie %hash; }
     $hashtied=0;      $hashtied=0;
     &Apache::lonnet::logthis(" untiehash2 -- $hashtied ");  
 }  }
   
 # --------------------------------------------------------------- check on this  # --------------------------------------------------------------- check on this
Line 1592  ENDHEADERS Line 1599  ENDHEADERS
   
 sub mark_hash_old {  sub mark_hash_old {
     my $retie_hash=0;      my $retie_hash=0;
     &Apache::lonnet::logthis(" markold1 -- $hashtied $retie_hash ");  
     if ($hashtied) {      if ($hashtied) {
  $retie_hash=1;   $retie_hash=1;
  &Apache::lonnet::logthis(" markold2 -- $hashtied $retie_hash ");  
  &untiehash();   &untiehash();
  &Apache::lonnet::logthis(" markold3 -- $hashtied $retie_hash ");  
     }      }
     &tiehash('write');      &tiehash('write');
     &Apache::lonnet::logthis(" markold4 -- $hashtied $retie_hash ");  
     $hash{'old'}=1;      $hash{'old'}=1;
     &Apache::lonnet::logthis(" markold5 -- $hashtied $retie_hash ");      
     &untiehash();      &untiehash();
     &Apache::lonnet::logthis(" markold6 -- $hashtied $retie_hash ");  
     if ($retie_hash) { &tiehash(); }      if ($retie_hash) { &tiehash(); }
     &Apache::lonnet::logthis(" markold7 -- $hashtied $retie_hash ");  
 }  }
   
 sub is_hash_old {  sub is_hash_old {
Line 1623  sub is_hash_old { Line 1623  sub is_hash_old {
 sub changewarning {  sub changewarning {
     my ($r,$postexec)=@_;      my ($r,$postexec)=@_;
     if (!&is_hash_old()) { return; }      if (!&is_hash_old()) { return; }
       my $pathvar='folderpath';
       my $path=&Apache::lonnet::escape($ENV{'form.folderpath'});
       if (defined($ENV{'form.pagepath'})) {
    $pathvar='pagepath';
    $path=&Apache::lonnet::escape($ENV{'form.pagepath'});
    $path.='&amp;symb='.&Apache::lonnet::escape($ENV{'form.pagesymb'});
       }
     $r->print(      $r->print(
 '<script>function reinit(tf) { tf.submit();'.$postexec.' }</script>'.   '<script>function reinit(tf) { tf.submit();'.$postexec.' }</script>'. 
 '<form method="post" action="/adm/roles" target="loncapaclient">'.  '<form method="post" action="/adm/roles" target="loncapaclient">'.
 '<input type="hidden" name="orgurl" value="/adm/coursedocs?folderpath='.  '<input type="hidden" name="orgurl" value="/adm/coursedocs?'.
 &Apache::lonnet::escape($ENV{'form.folderpath'}).  $pathvar.'='.$path.
 '" /><input type="hidden" name="selectrole" value="1" /><h3><font color="red">'.  '" /><input type="hidden" name="selectrole" value="1" /><h3><font color="red">'.
 &mt('Changes will become active for your current session after').  &mt('Changes will become active for your current session after').
 ' <input type="hidden" name="'.  ' <input type="hidden" name="'.
Line 1677  sub handler { Line 1684  sub handler {
 # is this a standard course?  # is this a standard course?
   
     my $standard=($ENV{'request.course.uri'}=~/^\/uploaded\//);      my $standard=($ENV{'request.course.uri'}=~/^\/uploaded\//);
     my $forcestandard;      my $forcestandard = 0;
     my $forcesupplement;      my $forcesupplement;
     my $script='';      my $script='';
     my $allowed;      my $allowed;
Line 1686  sub handler { Line 1693  sub handler {
     my $containertag;      my $containertag;
     my $uploadtag;      my $uploadtag;
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
     ['folderpath','pagepath']);      ['folderpath','pagepath','pagesymb']);
     if ($ENV{'form.folderpath'}) {      if ($ENV{'form.folderpath'}) {
  my (@folderpath)=split('&',$ENV{'form.folderpath'});   my (@folderpath)=split('&',$ENV{'form.folderpath'});
  $ENV{'form.foldername'}=&Apache::lonnet::unescape(pop(@folderpath));   $ENV{'form.foldername'}=&Apache::lonnet::unescape(pop(@folderpath));
Line 1696  sub handler { Line 1703  sub handler {
         my (@pagepath)=split('&',$ENV{'form.pagepath'});          my (@pagepath)=split('&',$ENV{'form.pagepath'});
         $ENV{'form.pagename'}=&Apache::lonnet::unescape(pop(@pagepath));          $ENV{'form.pagename'}=&Apache::lonnet::unescape(pop(@pagepath));
         $ENV{'form.folder'}=pop(@pagepath);          $ENV{'form.folder'}=pop(@pagepath);
         $containertag = '<input type="hidden" name="pagepath" value="" />';          $containertag = '<input type="hidden" name="pagepath" value="" />'.
         $uploadtag = '<input type="hidden" name="pagepath" value="'.$ENV{'form.pagepath'}.'" />';      '<input type="hidden" name="pagesymb" value="" />';
           $uploadtag = '<input type="hidden" name="pagepath" value="'.$ENV{'form.pagepath'}.'" />'.
       '<input type="hidden" name="pagesymb" value="'.$ENV{'form.pagesymb'}.'" />';
     }      }
     if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {      if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
        $showdoc='/'.$1;         $showdoc='/'.$1;
     }      }
     unless ($showdoc) { # got called from remote      unless ($showdoc) { # got called from remote
        $forcestandard=($ENV{'form.folder'}=~/^default_/);         if (($ENV{'form.folder'}=~/^default_/) || 
             ($ENV{'form.folder'} =~ m#^\d+/(pages|sequences)/#)) {
              $forcestandard = 1;
          } 
        $forcesupplement=($ENV{'form.folder'}=~/^supplemental_/);         $forcesupplement=($ENV{'form.folder'}=~/^supplemental_/);
   
 # does this user have privileges to post, etc?  # does this user have privileges to post, etc?
Line 1837  function finishpick() { Line 1849  function finishpick() {
     '";this.document.forms.'+form+'.submit();');      '";this.document.forms.'+form+'.submit();');
 }  }
   
 function changename(folderpath,index,oldtitle,container) {  function changename(folderpath,index,oldtitle,container,pagesymb) {
     var title=prompt('New Title',oldtitle);      var title=prompt('New Title',oldtitle);
     if (title) {      if (title) {
  this.document.forms.renameform.title.value=title;   this.document.forms.renameform.title.value=title;
Line 1847  function changename(folderpath,index,old Line 1859  function changename(folderpath,index,old
         }          }
         if (container == 'page') {          if (container == 'page') {
             this.document.forms.renameform.pagepath.value=folderpath;              this.document.forms.renameform.pagepath.value=folderpath;
               this.document.forms.renameform.pagesymb.value=pagesymb;
         }          }
         this.document.forms.renameform.submit();          this.document.forms.renameform.submit();
     }      }
 }  }
   
 function removeres(folderpath,index,oldtitle,container) {  function removeres(folderpath,index,oldtitle,container,pagesymb) {
     if (confirm('Remove "'+oldtitle+'"?')) {      if (confirm('Remove "'+oldtitle+'"?')) {
  this.document.forms.renameform.cmd.value='del_'+index;   this.document.forms.renameform.cmd.value='del_'+index;
         if (container == 'sequence') {          if (container == 'sequence') {
Line 1860  function removeres(folderpath,index,oldt Line 1873  function removeres(folderpath,index,oldt
         }          }
         if (container == 'page') {          if (container == 'page') {
             this.document.forms.renameform.pagepath.value=folderpath;              this.document.forms.renameform.pagepath.value=folderpath;
               this.document.forms.renameform.pagesymb.value=pagesymb;
         }          }
         this.document.forms.renameform.submit();          this.document.forms.renameform.submit();
     }      }

Removed from v.1.149  
changed lines
  Added in v.1.156


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