Diff for /loncom/interface/groupsort.pm between versions 1.68.6.9 and 1.72

version 1.68.6.9, 2017/05/30 15:18:48 version 1.72, 2013/01/09 16:30:19
Line 32  package Apache::groupsort; Line 32  package Apache::groupsort;
   
 use strict;  use strict;
   
 use Apache::Constants qw(:common :http);  use Apache::Constants qw(:common);
 use GDBM_File;  use GDBM_File;
 use Apache::loncommon;  use Apache::loncommon;
 use Apache::lonlocal;  use Apache::lonlocal;
Line 59  sub update_actions_hash { Line 59  sub update_actions_hash {
  $ac++;   $ac++;
     }      }
     # sorting through the actions and changing the global database hash      # sorting through the actions and changing the global database hash
     foreach my $key (sort {$achash{$a}<=>$achash{$b}} (keys(%ahash))) {      foreach my $key (sort {$achash{$a}<=>$achash{$b}} (keys %ahash)) {
  if ($ahash{$key} eq '1') {   if ($ahash{$key} eq '1') {
     $hash->{'store_'.$hash->{'pre_'.$key.'_link'}}=      $hash->{'store_'.$hash->{'pre_'.$key.'_link'}}=
  $hash->{'pre_'.$key.'_title'};   $hash->{'pre_'.$key.'_title'};
Line 203  sub handler { Line 203  sub handler {
     $r->send_http_header;      $r->send_http_header;
     return OK if $r->header_only;      return OK if $r->header_only;
   
 # permissions checking  
     my ($allowed,$canedit,$context,$cid);  
     if ($env{'form.readfile'} eq '') {  
         $allowed = 1;  
     } elsif ($env{'form.readfile'} =~ m{^/uploaded/($match_domain)/($match_courseid)/}) {  
         my ($cdom,$cnum) = ($1,$2);  
         $cid = $cdom.'_'.$cnum;  
         $context = 'course';  
         if ((&Apache::lonnet::allowed('mdc',$cid)) ||  
             (&Apache::lonnet::allowed('cev',$cid))) {  
             $allowed = 1;  
         }  
     } elsif ($env{'form.readfile'} =~ m{^/res/}) {  
         $context = 'res';  
         if ((&Apache::lonnet::allowed('bre',$env{'form.readfile'})) ||  
             (&Apache::lonnet::allowed('bro',$env{'form.readfile'}))) {  
             $allowed = 1;  
         }  
     }  
     if ($allowed) {  
         if ($env{'form.mode'} eq 'rat') {  
             if (&Apache::lonnet::allowed('are',$env{'request.role.domain'})) {  
                 $canedit = 1;  
             }  
         } elsif (($env{'form.mode'} eq 'simple') || ($env{'form.mode'} eq '')) {  
             if ($context eq 'course') {  
                 if (&Apache::lonnet::allowed('mdc',$cid)) {  
                     $canedit = 1;  
                 }  
             } elsif (($env{'request.course.id'}) &&  
                      (&Apache::lonnet::allowed('mdc',$env{'request.course.id'}))) {  
                 $canedit = 1;  
             } elsif (&Apache::lonnet::allowed('are',$env{'request.role.domain'})) {  
                 $canedit = 1;  
             }  
         }  
     }  
   
     unless ($allowed) {  
         if ($context eq 'course') {  
             if ($env{'request.course.id'} eq $cid) {  
                 $env{'user.error.msg'}=  
                     "/adm/groupsort::0:1:Course environment gone, reinitialize the course";  
             } else {  
                 $env{'user.error.msg'}=  
                     "/adm/groupsort:bre:0:0:Cannot view folder contents";  
             }  
         } else {  
             $env{'user.error.msg'}=  
                 "/adm/groupsort:bre:0:0:Cannot view map contents";  
         }  
         return HTTP_NOT_ACCEPTABLE;  
     }  
   
 # finish_import looks different for graphical or "simple" RAT  # finish_import looks different for graphical or "simple" RAT
     my $finishimport='';      my $finishimport='';
     my $begincondition='';      my $begincondition='';
     my $endcondition='';      my $endcondition='';
     my $noedit;  
     unless ($canedit) {  
         if ($context eq 'course') {  
             $noedit = &js_escape(&mt('You do not have rights to edit the course.'));  
         } else {  
             $noedit = &js_escape(&mt('You do not have rights to edit map contents.'));  
         }  
     }  
     if (($env{'form.readfile'}))  {      if (($env{'form.readfile'}))  {
         $begincondition='if (eval("document.forms.groupsort.include"+num+".checked")) {';          $begincondition='if (eval("document.forms.groupsort.include"+num+".checked")) {';
  $endcondition='}';   $endcondition='}';
     }      }
     if ($env{'form.mode'} eq 'simple' || $env{'form.mode'} eq '') {      if ($env{'form.mode'} eq 'simple' || $env{'form.mode'} eq '') {
         if ($canedit) {          $finishimport=(<<ENDSMP);
             $finishimport=(<<ENDSMP);  
 function finish_import() {  function finish_import() {
     opener.document.forms.simpleedit.importdetail.value='';      opener.document.forms.simpleedit.importdetail.value='';
     for (var num=0; num<document.forms.groupsort.fnum.value; num++) {      for (var num=0; num<document.forms.groupsort.fnum.value; num++) {
Line 290  function finish_import() { Line 227  function finish_import() {
     self.close();      self.close();
 }  }
 ENDSMP  ENDSMP
         } else {  
             $finishimport=(<<ENDNO);  
 function finish_import() {  
     alert('$noedit');  
 }  
 ENDNO  
         }  
     } else {      } else {
         if ($canedit) {          $finishimport=(<<ENDADV);
             $finishimport=(<<ENDADV);  
 function finish_import() {  function finish_import() {
     var linkflag=false;      var linkflag=false;
     for (var num=0; num<document.forms.groupsort.fnum.value; num++) {      for (var num=0; num<document.forms.groupsort.fnum.value; num++) {
Line 321  function finish_import() { Line 250  function finish_import() {
     self.close();      self.close();
 }  }
 ENDADV  ENDADV
         } else {  
             $finishimport=(<<ENDNONE);  
 function finish_import() {  
     alert('$noedit');  
 }  
 ENDNONE  
         }  
     }      }
   
 # output start of web page  # output start of web page
Line 381  END Line 303  END
     } else {      } else {
         $title = 'Sort Imported Resources';          $title = 'Sort Imported Resources';
     }      }
     my $disabled;  
     unless ($canedit) {  
         $disabled = ' disabled="disabled"';  
     }  
     if (($clen > 1) || ($env{'form.readfile'})) {      if (($clen > 1) || ($env{'form.readfile'})) {
  my %lt=&Apache::lonlocal::texthash(   my %lt=&Apache::lonlocal::texthash(
  'fin'=> 'Finalize order of resources',   'fin'=> 'Finalize order of resources',
Line 421  END Line 339  END
         if ($env{'form.recover'}) {          if ($env{'form.recover'}) {
     $r->print(<<END);      $r->print(<<END);
 <input type="button" name="alter" value="$buttontext"  <input type="button" name="alter" value="$buttontext"
  onclick="finish_import()"$disabled />&nbsp;   onClick="finish_import()" />&nbsp;
 <input type="button" name="alter" value="$lt{'ca'}" onclick="self.close()" />  <input type="button" name="alter" value="$lt{'ca'}" onClick="self.close()" />
 END  END
  } else {   } else {
         # --- Continue Buttons          # --- Continue Buttons
Line 432  END Line 350  END
 <h2>$lt{'fin'}</h2>  <h2>$lt{'fin'}</h2>
 <div>  <div>
 <input type="button" name="alter" value="$lt{'ci'}"  <input type="button" name="alter" value="$lt{'ci'}"
  onclick="window.location='$resurl?inhibitmenu=yes&amp;catalogmode=import'" />&nbsp;   onClick="window.location='$resurl?inhibitmenu=yes&amp;catalogmode=import'" />&nbsp;
 <input type="button" name="altersearch" value="$lt{'cs'}"  <input type="button" name="altersearch" value="$lt{'cs'}"
  onclick="window.location='/adm/searchcat?inhibitmenu=yes&amp;catalogmode=import'" />&nbsp;   onClick="window.location='/adm/searchcat?inhibitmenu=yes&amp;catalogmode=import'" />&nbsp;
 <input type="button" name="alter" value="$lt{'fi'}"  <input type="button" name="alter" value="$lt{'fi'}"
  onclick="finish_import()"$disabled />&nbsp;   onClick="finish_import()" />&nbsp;
 <input type="button" name="alter" value="$lt{'ca'}" onclick="self.close()" />  <input type="button" name="alter" value="$lt{'ca'}" onClick="self.close()" />
 </div>  </div>
 <br />  <br />
 END  END
Line 486  END Line 404  END
     $r->print(&Apache::loncommon::start_data_table_row()      $r->print(&Apache::loncommon::start_data_table_row()
                      ."<td>");                       ."<td>");
             if (($env{'form.readfile'})) {              if (($env{'form.readfile'})) {
  $r->print(&checkbox($ctr-1,$disabled));   $r->print(&checkbox($ctr-1));
     } else {      } else {
  $r->print(&movers($clen,$ctr));   $r->print(&movers($clen,$ctr));
     }      }
Line 497  END Line 415  END
     $r->print("</td>");      $r->print("</td>");
             unless (($env{'form.readfile'})) {              unless (($env{'form.readfile'})) {
  $r->print("<td>".   $r->print("<td>".
   &select_box($clen,$ctr,$disabled).    &select_box($clen,$ctr).
   "</td>");    "</td>");
     }      }
     $r->print("<td>");      $r->print("<td>");
Line 567  END Line 485  END
   
 # ------------------------------------------ Select box (returns scalar string)  # ------------------------------------------ Select box (returns scalar string)
 sub select_box {  sub select_box {
     my ($total,$sel,$disabled) = @_;      my ($total,$sel) = @_;
     my $string;      my $string;
     $string = '<select name="alt'.$sel.'"';      $string = '<select name="alt'.$sel.'"';
     $string .= " onchange='selectchange($sel)'.$disabled.'>";      $string .= " onChange='selectchange($sel)'>";
     $string .= "<option name='o0' value='0'>".&mt('discard')."</option>";      $string .= "<option name='o0' value='0'>".&mt('discard')."</option>";
     for my $cur (1..$total) {      for my $cur (1..$total) {
  $string .= "<option name='o$cur' value='$cur'";   $string .= "<option name='o$cur' value='$cur'";
Line 586  sub select_box { Line 504  sub select_box {
 # ------------------------------------------------------------------- Checkbox  # ------------------------------------------------------------------- Checkbox
   
 sub checkbox {  sub checkbox {
     my ($sel,$disabled) = @_;      my $sel=shift;
     return "<label><input type='checkbox' name='include$sel'".      return "<label><input type='checkbox' name='include$sel'".
        ($env{"form.include$sel"}?' checked="checked"':'').         ($env{"form.include$sel"}?' checked="checked"':'').
        $disabled.' />'.&mt('Include').'</label>';         ' />'.&mt('Include').'</label>';
 }  }
   
 1;  1;

Removed from v.1.68.6.9  
changed lines
  Added in v.1.72


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