--- loncom/interface/groupsort.pm 2017/05/30 15:18:48 1.68.6.9 +++ loncom/interface/groupsort.pm 2012/06/30 23:02:20 1.69 @@ -2,7 +2,7 @@ # The LON-CAPA group sort handler # Allows for sorting prior to import into RAT. # -# $Id: groupsort.pm,v 1.68.6.9 2017/05/30 15:18:48 raeburn Exp $ +# $Id: groupsort.pm,v 1.69 2012/06/30 23:02:20 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -32,7 +32,7 @@ package Apache::groupsort; use strict; -use Apache::Constants qw(:common :http); +use Apache::Constants qw(:common); use GDBM_File; use Apache::loncommon; use Apache::lonlocal; @@ -59,7 +59,7 @@ sub update_actions_hash { $ac++; } # 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') { $hash->{'store_'.$hash->{'pre_'.$key.'_link'}}= $hash->{'pre_'.$key.'_title'}; @@ -152,23 +152,12 @@ sub readfromfile { &Apache::lonnet::filelocation('',$env{'form.readfile'})); } else { my $parser = HTML::TokeParser->new(\$cont); - my ($token,$donechk,$allmaps); - $allmaps = {}; + my $token; while ($token = $parser->get_token) { if ($token->[0] eq 'S') { if ($token->[1] eq 'resource') { if ($env{'form.recover'}) { if ($token->[2]->{'type'} ne 'zombie') { next; } - if ($token->[2]->{'src'} =~ /\.(page|sequence)$/) { - if (($env{'request.course.id'}) && - ($env{'form.readfile'} =~ m{/default(|_\d+)\.(page|sequence)$})) { - unless ($donechk) { - $allmaps = &Apache::loncommon::allmaps_incourse(); - $donechk = 1; - } - } - if ($allmaps->{$token->[2]->{'src'}}) { next; } - } } else { if ($token->[2]->{'type'} eq 'zombie') { next; } } @@ -192,6 +181,7 @@ sub readfromfile { } } + # ---------------------------------------------------------------- Main Handler sub handler { my $r = shift; @@ -203,79 +193,16 @@ sub handler { $r->send_http_header; 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 my $finishimport=''; my $begincondition=''; 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'})) { $begincondition='if (eval("document.forms.groupsort.include"+num+".checked")) {'; $endcondition='}'; } if ($env{'form.mode'} eq 'simple' || $env{'form.mode'} eq '') { - if ($canedit) { - $finishimport=(< 1) || ($env{'form.readfile'})) { my %lt=&Apache::lonlocal::texthash( 'fin'=> 'Finalize order of resources', @@ -421,8 +329,8 @@ END if ($env{'form.recover'}) { $r->print(<  - + onClick="finish_import()" />  + END } else { # --- Continue Buttons @@ -432,12 +340,12 @@ END

$lt{'fin'}

  + onClick="window.location='$resurl?inhibitmenu=yes&catalogmode=import'" />    + onClick="window.location='/adm/searchcat?inhibitmenu=yes&catalogmode=import'" />    - + onClick="finish_import()" />  +

END @@ -486,7 +394,7 @@ END $r->print(&Apache::loncommon::start_data_table_row() .""); if (($env{'form.readfile'})) { - $r->print(&checkbox($ctr-1,$disabled)); + $r->print(&checkbox($ctr-1)); } else { $r->print(&movers($clen,$ctr)); } @@ -497,18 +405,18 @@ END $r->print(""); unless (($env{'form.readfile'})) { $r->print("". - &select_box($clen,$ctr,$disabled). + &select_box($clen,$ctr). ""); } $r->print(""); $r->print(""); $r->print(""); - if (($env{'form.recover'}) && + if (($env{'form.recover'}) && ($resource->{'url'} =~ m{/uploaded/$match_domain/$match_courseid/supplemental/})) { - my $title = &Apache::loncommon::parse_supplemental_title($resource->{'title'}); + my $title = &Apache::loncommon::parse_supplemental_title($resource->{'title'}); $r->print($title); } else { - $r->print($resource->{'title'}); + $r->print($resource->{'title'}); } $r->print($resource->{'notes'}."\n"); $r->print($resource->{'url'}."" @@ -567,10 +475,10 @@ END # ------------------------------------------ Select box (returns scalar string) sub select_box { - my ($total,$sel,$disabled) = @_; + my ($total,$sel) = @_; my $string; $string = ''.&mt('Include').''; + ' />'.&mt('Include').''; } 1;