--- loncom/interface/groupsort.pm 2009/03/13 15:39:43 1.65 +++ loncom/interface/groupsort.pm 2012/05/02 19:10:13 1.68.6.1 @@ -2,7 +2,7 @@ # The LON-CAPA group sort handler # Allows for sorting prior to import into RAT. # -# $Id: groupsort.pm,v 1.65 2009/03/13 15:39:43 bisitz Exp $ +# $Id: groupsort.pm,v 1.68.6.1 2012/05/02 19:10:13 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -86,8 +86,8 @@ sub update_actions_hash { sub readfromdb { my ($r,$resources)=@_; - my $diropendb = - "/home/httpd/perl/tmp/$env{'user.domain'}_$env{'user.name'}_sel_res.db"; + my $diropendb = LONCAPA::tempdir() . + "$env{'user.domain'}_$env{'user.name'}_sel_res.db"; # ----------------------------- diropendb is now the filename of the db to open if (tie(%hash,'GDBM_File',$diropendb,&GDBM_WRCREAT(),0640)) { @@ -191,12 +191,12 @@ sub readfrombookmarks { my @bookmarks=($bookmarks{'bookmarks'}=~/\((?:\'([^\']+)\'\,\'([^\']+)\'|\"([^\"]+)\"\,\"([^\"]+)\")\)\;/g); for (my $index=0;$index<($#bookmarks+1)/2;$index++) { if ($bookmarks[$index*2+1]) { - my $url = $bookmarks[$index*2+1]; - my $name = $bookmarks[$index*2]; - $name =~ s/^LON\-CAPA\s+//; + my $url = $bookmarks[$index*2+1]; + my $name = $bookmarks[$index*2]; + $name =~ s/^LON\-CAPA\s+//; - push(@{$resources},{'url' => $url, 'title' => $name}); - } + push(@{$resources},{'url' => $url, 'title' => $name}); + } } } @@ -300,13 +300,22 @@ END if ($env{'form.readfile'}) { &readfromfile($r,\@resources); } elsif ($env{'form.bookmarks'}) { - &readfrombookmarks($r,\@resources); + &readfrombookmarks($r,\@resources); } else { &readfromdb($r,\@resources); } my $ctr = 0; my $clen = scalar(@resources); + my $title = ''; + if ($env{'form.recover'}) { + $title = 'Recover Removed Resources'; + } else { + $title = 'Sort Imported Resources'; + } + if ($env{'form.bookmarks'}) { + $title = 'Import Resources from Bookmarks'; + } if (($clen > 1) || ($env{'form.readfile'}) || ($env{'form.bookmarks'})) { my %lt=&Apache::lonlocal::texthash( 'fin'=> 'Finalize order of resources', @@ -321,17 +330,9 @@ END 'pa' => 'Path', 'in' => 'Include' ); - my $title = ''; - if ($env{'form.recover'}) { - $title = 'Recover Removed Resources'; - } else { - $title = 'Sort Imported Resources'; - } - if ($env{'form.bookmarks'}) { - $title = 'Import Resources from Bookmarks'; - } $r->print(&Apache::loncommon::start_page($title, $js)); + $r->print('

'.&mt($title).'

'); $r->print(< 0) { $r->print(&Apache::loncommon::start_data_table() .&Apache::loncommon::start_data_table_header_row()); - if (($env{'form.readfile'}) || ($env{'form.bookmarks'})) { + if (($env{'form.readfile'})) { $r->print("$lt{'in'}\n"); } else { $r->print(''.$lt{'co'}.''."\n"); @@ -390,15 +391,21 @@ END $r->print("$lt{'pa'}"); $r->print(&Apache::loncommon::end_data_table_header_row()."\n"); } else { - $r->print('

'); + my $errtxt = ''; + if ($env{'form.recover'}) { + $errtxt = 'There are no resources to recover.'; + } else { + $errtxt = 'There are no resources to import.'; + } if ($env{'form.bookmarks'}) { - $r->print(&mt('There are no resources in your bookmarks to import.')); + $errtxt = 'There are no resources in your bookmarks to import.'; } - $r->print('

'); + $r->print('

'.&mt($errtxt).'

'); } } else { $r->print(&Apache::loncommon::start_page(undef,$js, {'only_body' => 1})); +# $r->print('

'.&mt($title).'

'); $r->print(< @@ -413,7 +420,7 @@ END foreach my $resource (@resources) { $ctr++; my $iconname=&Apache::loncommon::icon($resource->{'url'}); - if (($clen > 1) || ($env{'form.readfile'}) || ($env{'form.bookmarks'})) { + if (($clen > 1) || ($env{'form.readfile'}) || ($env{'form.bookmarks'})) { $r->print(&Apache::loncommon::start_data_table_row() .""); if (($env{'form.readfile'}) || ($env{'form.bookmarks'})) {