Diff for /loncom/interface/londocs.pm between versions 1.630 and 1.633

version 1.630, 2017/05/10 23:34:15 version 1.633, 2017/07/10 12:48:41
Line 1672  sub do_paste_from_buffer { Line 1672  sub do_paste_from_buffer {
             $srcdom{$suffix} = $srcd;              $srcdom{$suffix} = $srcd;
             $srcnum{$suffix} = $srcn;              $srcnum{$suffix} = $srcn;
         } elsif (($url =~ m{^/res/lib/templates/\w+\.problem$}) ||          } elsif (($url =~ m{^/res/lib/templates/\w+\.problem$}) ||
                  ($url =~ m{^/adm/$match_domain/$match_username/\d+/(bulletinboard|smppg|ext\.tool)$})) {                   ($url =~ m{^/adm/$match_domain/$match_username/\d+/(bulletinboard|smppg)$}) ||
             my $srctype= $1;                   ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$})) {
             my ($srcd,$srcn) = split(/_/,$cid);              my ($srcd,$srcn) = split(/_/,$cid);
 # When paste buffer was populated using an active role in a different course  # When paste buffer was populated using an active role in a different course
 # check for mdc privilege in the course from which the resource was pasted  # check for mdc privilege in the course from which the resource was pasted
Line 1683  sub do_paste_from_buffer { Line 1683  sub do_paste_from_buffer {
                     next;                      next;
                 }                  }
             }              }
             if (($srctype eq 'ext.tool') && ($srcd ne $coursedom)) {  # When buffer was populated using an active role in a different course
   # disallow pasting of External Tool if course is in a different domain.
               if (($url =~ m{/ext\.tool$}) && ($srcd ne $coursedom)) {
                 $notindom{$suffix} = 1;                  $notindom{$suffix} = 1;
                 next;                  next;
             }              }
Line 2164  sub dbcopy { Line 2166  sub dbcopy {
                 if (!$suffix) {                  if (!$suffix) {
                     if ($prefix eq 'smppg') {                      if ($prefix eq 'smppg') {
                         $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a simple page [_1].',$url);                          $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a simple page [_1].',$url);
                       } elsif ($prefix eq 'exttool') {
                           $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying an external tool [_1].',$url);
                     } else {                      } else {
                         $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a discussion board [_1].',$url);                          $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a discussion board [_1].',$url);
                     }                      }
Line 3014  sub update_parameter { Line 3018  sub update_parameter {
   
 sub handle_edit_cmd {  sub handle_edit_cmd {
     my ($coursenum,$coursedom) =@_;      my ($coursenum,$coursedom) =@_;
       my $haschanges = 0;
     if ($env{'form.cmd'} eq '') {      if ($env{'form.cmd'} eq '') {
         return 0;          return $haschanges; 
     }      }
     my ($cmd,$idx)=split('_',$env{'form.cmd'});      my ($cmd,$idx)=split('_',$env{'form.cmd'});
   
Line 3030  sub handle_edit_cmd { Line 3035  sub handle_edit_cmd {
     &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);      &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
  }   }
  splice(@LONCAPA::map::order, $idx, 1);   splice(@LONCAPA::map::order, $idx, 1);
           $haschanges = 1;
     } elsif ($cmd eq 'cut') {      } elsif ($cmd eq 'cut') {
  &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);   &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
  splice(@LONCAPA::map::order, $idx, 1);   splice(@LONCAPA::map::order, $idx, 1);
           $haschanges = 1;
     } elsif ($cmd eq 'up'      } elsif ($cmd eq 'up'
      && ($idx) && (defined($LONCAPA::map::order[$idx-1]))) {       && ($idx) && (defined($LONCAPA::map::order[$idx-1]))) {
  @LONCAPA::map::order[$idx-1,$idx] = @LONCAPA::map::order[$idx,$idx-1];   @LONCAPA::map::order[$idx-1,$idx] = @LONCAPA::map::order[$idx,$idx-1];
           $haschanges = 1;
     } elsif ($cmd eq 'down'      } elsif ($cmd eq 'down'
      && defined($LONCAPA::map::order[$idx+1])) {       && defined($LONCAPA::map::order[$idx+1])) {
  @LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1];   @LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1];
           $haschanges = 1;
     } elsif ($cmd eq 'rename') {      } elsif ($cmd eq 'rename') {
  my $comment = &LONCAPA::map::qtunescape($env{'form.title'});   my $comment = &LONCAPA::map::qtunescape($env{'form.title'});
  if ($comment=~/\S/) {   if ($comment=~/\S/) {
Line 3052  sub handle_edit_cmd { Line 3057  sub handle_edit_cmd {
 # Devalidate title cache  # Devalidate title cache
  my $renamed_url=&LONCAPA::map::qtescape($url);   my $renamed_url=&LONCAPA::map::qtescape($url);
  &Apache::lonnet::devalidate_title_cache($renamed_url);   &Apache::lonnet::devalidate_title_cache($renamed_url);
           $haschanges = 1;
     } else {      } elsif ($cmd eq 'setalias') {
  return 0;          my $newvalue = $env{'form.alias'};
           if ($newvalue ne '') {
               unless (Apache::lonnet::get_symb_from_alias($newvalue)) {
                   &LONCAPA::map::storeparameter($idx,'parameter_0_mapalias',$newvalue,
                                                 'string');
                   &remember_parms($idx,'mapalias','set',$newvalue);
                   $haschanges = 1;
               }
           }
       } elsif ($cmd eq 'delalias') {
           my $current = (&LONCAPA::map::getparameter($idx,'parameter_0_mapalias'))[0];  
           if ($current ne '') {
               &LONCAPA::map::delparameter($idx,'parameter_0_mapalias');
               &remember_parms($idx,'mapalias','del');
               $haschanges = 1;
           }
     }      }
     return 1;      return $haschanges;
 }  }
   
 sub editor {  sub editor {
Line 3180  sub editor { Line 3200  sub editor {
 # Rename, cut, copy or remove a single resource  # Rename, cut, copy or remove a single resource
  if (&handle_edit_cmd($coursenum,$coursedom)) {   if (&handle_edit_cmd($coursenum,$coursedom)) {
             my $contentchg;              my $contentchg;
             if ($env{'form.cmd'} =~ m{^(remove|cut)_}) {              if ($env{'form.cmd'} =~ m{^(remove|cut|setalias|delalias)_}) {
                 $contentchg = 1;                  $contentchg = 1;
             }              }
     ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,$contentchg);      ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,$contentchg);
Line 3420  sub editor { Line 3440  sub editor {
                           .&Apache::loncommon::start_data_table(undef,'contentlist')                            .&Apache::loncommon::start_data_table(undef,'contentlist')
                           .&Apache::loncommon::start_data_table_header_row()                            .&Apache::loncommon::start_data_table_header_row()
                           .'<th colspan="2">'.&mt('Move').'</th>'                            .'<th colspan="2">'.&mt('Move').'</th>'
                           .'<th colspan="2">'.&mt('Actions').'</th>'                            .'<th colspan="3">'.&mt('Actions').'</th>'
                           .'<th>'.&mt('Document').'</th>';                            .'<th>'.&mt('Document').'</th>';
                 if ($folder !~ /^supplemental/) {                  if ($folder !~ /^supplemental/) {
                     $to_show .= '<th colspan="4">'.&mt('Settings').'</th>';                      $to_show .= '<th colspan="2">'.&mt('Settings').'</th>';
                 }                  }
                 $to_show .= &Apache::loncommon::end_data_table_header_row();                  $to_show .= &Apache::loncommon::end_data_table_header_row();
                 if ($folder !~ /^supplemental/) {                  if ($folder !~ /^supplemental/) {
Line 3451  sub editor { Line 3471  sub editor {
                                 '<td>'.                                  '<td>'.
                                 &multiple_check_form('actions',\%lists,$canedit).                                  &multiple_check_form('actions',\%lists,$canedit).
                                 '</td>'.                                  '</td>'.
                                 '<td>&nbsp;</td>'.                                  '<td colspan="3">&nbsp;</td>'.
                                 '<td>&nbsp;</td>'.                                  '<td colspan="2">'.
                                 '<td colspan="4">'.  
                                 &multiple_check_form('settings',\%lists,$canedit).                                  &multiple_check_form('settings',\%lists,$canedit).
                                 '</td>'.                                  '</td>'.
                                 &Apache::loncommon::end_data_table_row();                                  &Apache::loncommon::end_data_table_row();
Line 3801  sub entryline { Line 3820  sub entryline {
     my $line=&Apache::loncommon::start_data_table_row();      my $line=&Apache::loncommon::start_data_table_row();
     my ($form_start,$form_end,$form_common,$form_param);      my ($form_start,$form_end,$form_common,$form_param);
 # Edit commands  # Edit commands
     my ($esc_path, $path, $symb);      my ($esc_path, $path, $symb, $curralias);
     if ($env{'form.folderpath'}) {      if ($env{'form.folderpath'}) {
  $esc_path=&escape($env{'form.folderpath'});   $esc_path=&escape($env{'form.folderpath'});
  $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');   $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
Line 3870  END Line 3889  END
                 'ct' => 'Cut',                  'ct' => 'Cut',
  'rn' => 'Rename',   'rn' => 'Rename',
  'cp' => 'Copy',   'cp' => 'Copy',
                   'da' => 'Unset alias', 
                   'sa' => 'Set alias',
                 'ex' => 'External Resource',                  'ex' => 'External Resource',
                 'et' => 'External Tool',                  'et' => 'External Tool',
                 'ed' => 'Edit',                  'ed' => 'Edit',
Line 3900  END Line 3921  END
             ($url!~/$LONCAPA::assess_page_seq_re/)) {              ($url!~/$LONCAPA::assess_page_seq_re/)) {
             $confirm_removal = 1;              $confirm_removal = 1;
         }          }
           if ($url =~ /$LONCAPA::assess_re/) {
               $curralias = (&LONCAPA::map::getparameter($orderidx,'parameter_0_mapalias'))[0];
           }
   
  if ($denied{'copy'}) {   if ($denied{'copy'}) {
             $copylink=(<<ENDCOPY)              $copylink=(<<ENDCOPY)
Line 4287  $form_end; Line 4311  $form_end;
         $reinit = &mt('(re-initialize course to access)');          $reinit = &mt('(re-initialize course to access)');
     }      }
     $line.='<td class="LC_docs_entry_commands"'.$tdalign.'><span class="LC_nobreak">'.$editlink.$renamelink;      $line.='<td class="LC_docs_entry_commands"'.$tdalign.'><span class="LC_nobreak">'.$editlink.$renamelink;
       if ($url =~ /$LONCAPA::assess_re/) {
           $line.= '<br />';
           if ($curralias ne '') {
               $line.='<span class="LC_nobreak"><a href="javascript:delalias('."'$esc_path','$orderidx'".');" class="LC_docs_alias">'.
                      $lt{'da'}.'</a></span>';
           } else {
               $line.='<span class="LC_nobreak"><a href="javascript:setalias('."'$esc_path','$orderidx'".');" class="LC_docs_alias">'.
                      $lt{'sa'}.'</a></span>';
           }
       }
       $line.='</td><td>';
     my $link;      my $link;
     if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {      if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
        $line.='<a href="'.$url.'"><img src="'.$icon.'" alt="" class="LC_icon" /></a>';         $line.='<a href="'.$url.'"><img src="'.$icon.'" alt="" class="LC_icon" /></a>';
Line 4326  $form_end; Line 4361  $form_end;
            $line.=&Apache::loncommon::modal_link($link,$title,600,500);             $line.=&Apache::loncommon::modal_link($link,$title,600,500);
        }         }
     } elsif (($hiddenfolder) || ($hiddenres)) {      } elsif (($hiddenfolder) || ($hiddenres)) {
        $line.=$title.' <span class="LC_warning LC_docs_reinit_warn">'.&mt('(Hidden)').'</span>';         $line.=$title.' <span class="LC_warning LC_docs_reinit_warn">('.&mt('Hidden').')</span>';
     } else {      } else {
        $line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';         $line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';
     }      }
     $line.="$extresform</td>";      if (($allowed) && ($curralias ne '')) {
           $line .= '<br /><span class="LC_docs_alias_name">('.$curralias.')</span>';
       } else {
           $line .= $extresform;
       }
       $line .= '</td>';
     $rand_pick_text = '&nbsp;' if ($rand_pick_text eq '');      $rand_pick_text = '&nbsp;' if ($rand_pick_text eq '');
     $rand_order_text = '&nbsp;' if ($rand_order_text eq '');      $rand_order_text = '&nbsp;' if ($rand_order_text eq '');
     if (($allowed) && ($folder!~/^supplemental/)) {      if (($allowed) && ($folder!~/^supplemental/)) {
Line 5832  CRSFORM Line 5872  CRSFORM
    <input type="hidden" name="copyfolder" />     <input type="hidden" name="copyfolder" />
    $containertag     $containertag
  </form>   </form>
    <form name="aliasform" method="post" action="/adm/coursedocs">
      <input type="hidden" name="alias" />
      <input type="hidden" name="cmd" />
      $containertag
    </form>
   
 HIDDENFORM  HIDDENFORM
         $r->print(&makesimpleeditform($pathitem)."\n".          $r->print(&makesimpleeditform($pathitem)."\n".
Line 6052  NWEBFORM Line 6097  NWEBFORM
                 $numauthor ++;                  $numauthor ++;
             }              }
         }          }
         my ($pickdir,$showtitle);;          my ($pickdir,$showtitle);
         if ($numauthor) {          if ($numauthor) {
             my @order;              my @order;
             my $defrole;              my $defrole;
Line 6899  sub editing_js { Line 6944  sub editing_js {
                                           p_ctr2b => '?',                                            p_ctr2b => '?',
                                           p_ctr3a => 'Cut those',                                            p_ctr3a => 'Cut those',
                                           p_ctr3b => 'items?',                                            p_ctr3b => 'items?',
                                             setal   => 'Enter a (unique) alias',
                                             delal   => 'Are you sure you want to eliminate the alias?',
                                           rpck    => 'Enter number to pick (e.g., 3)',                                            rpck    => 'Enter number to pick (e.g., 3)',
                                           imsfile => 'You must choose an IMS package for import',                                            imsfile => 'You must choose an IMS package for import',
                                           imscms  => 'You must select which Course Management System was the source of the IMS package',                                            imscms  => 'You must select which Course Management System was the source of the IMS package',
Line 7101  function changename(folderpath,index,old Line 7148  function changename(folderpath,index,old
     }      }
 }  }
   
   function setalias(folderpath,index) {
       var alias = prompt('$js_lt{"setal"}');
       if ((alias != null) && (alias != '')) {
           this.document.forms.aliasform.alias.value=alias;
           this.document.forms.aliasform.cmd.value='setalias_'+index;
           this.document.forms.aliasform.folderpath.value=folderpath;
           this.document.forms.aliasform.submit();
       }
   }
   
   function delalias(folderpath,index) {
       if (confirm('$js_lt{"delal"}')) {
           this.document.forms.aliasform.cmd.value='delalias_'+index;
           this.document.forms.aliasform.folderpath.value=folderpath;
           this.document.forms.aliasform.submit();
       }
   }
   
 ENDNEWSCRIPT  ENDNEWSCRIPT
     } else {      } else {
         $jsmakefunctions = <<ENDNEWSCRIPT;          $jsmakefunctions = <<ENDNEWSCRIPT;
Line 7145  function changename() { Line 7210  function changename() {
     alert("$js_lt{'edri'}");      alert("$js_lt{'edri'}");
 }  }
   
   function setalias() {
       alert("$js_lt{'edri'}");
   }
   
   function delalias() {
       alert("$js_lt{'edri'}");
   }
   
 function makenew() {  function makenew() {
     alert("$js_lt{'edri'}");      alert("$js_lt{'edri'}");
 }  }

Removed from v.1.630  
changed lines
  Added in v.1.633


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