Diff for /loncom/interface/groupsort.pm between versions 1.62 and 1.68.6.1

version 1.62, 2008/09/15 13:22:48 version 1.68.6.1, 2012/05/02 19:10:13
Line 86  sub update_actions_hash { Line 86  sub update_actions_hash {
 sub readfromdb {  sub readfromdb {
     my ($r,$resources)=@_;      my ($r,$resources)=@_;
   
     my $diropendb =       my $diropendb = LONCAPA::tempdir() .
        "/home/httpd/perl/tmp/$env{'user.domain'}_$env{'user.name'}_sel_res.db";         "$env{'user.domain'}_$env{'user.name'}_sel_res.db";
   
 # ----------------------------- diropendb is now the filename of the db to open  # ----------------------------- diropendb is now the filename of the db to open
     if (tie(%hash,'GDBM_File',$diropendb,&GDBM_WRCREAT(),0640)) {      if (tie(%hash,'GDBM_File',$diropendb,&GDBM_WRCREAT(),0640)) {
Line 191  sub readfrombookmarks { Line 191  sub readfrombookmarks {
     my @bookmarks=($bookmarks{'bookmarks'}=~/\((?:\'([^\']+)\'\,\'([^\']+)\'|\"([^\"]+)\"\,\"([^\"]+)\")\)\;/g);      my @bookmarks=($bookmarks{'bookmarks'}=~/\((?:\'([^\']+)\'\,\'([^\']+)\'|\"([^\"]+)\"\,\"([^\"]+)\")\)\;/g);
     for (my $index=0;$index<($#bookmarks+1)/2;$index++) {      for (my $index=0;$index<($#bookmarks+1)/2;$index++) {
         if ($bookmarks[$index*2+1]) {          if ($bookmarks[$index*2+1]) {
     my $url  = $bookmarks[$index*2+1];              my $url  = $bookmarks[$index*2+1];
     my $name = $bookmarks[$index*2];              my $name = $bookmarks[$index*2];
     $name =~ s/^LON\-CAPA\s+//;              $name =~ s/^LON\-CAPA\s+//;
   
     push(@{$resources},{'url' => $url, 'title' => $name});              push(@{$resources},{'url' => $url, 'title' => $name});
  }          }
     }      }
 }  }
   
Line 300  END Line 300  END
     if ($env{'form.readfile'}) {      if ($env{'form.readfile'}) {
  &readfromfile($r,\@resources);   &readfromfile($r,\@resources);
     } elsif ($env{'form.bookmarks'}) {      } elsif ($env{'form.bookmarks'}) {
  &readfrombookmarks($r,\@resources);          &readfrombookmarks($r,\@resources);
     } else {      } else {
  &readfromdb($r,\@resources);   &readfromdb($r,\@resources);
     }      }
   
     my $ctr = 0;      my $ctr = 0;
     my $clen = scalar(@resources);      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'})) {      if (($clen > 1) || ($env{'form.readfile'}) || ($env{'form.bookmarks'})) {
  my %lt=&Apache::lonlocal::texthash(   my %lt=&Apache::lonlocal::texthash(
  'fin'=> 'Finalize order of resources',   'fin'=> 'Finalize order of resources',
Line 314  END Line 323  END
  'cs' => 'Continue Search',   'cs' => 'Continue Search',
  'fi' => 'Finish Import',   'fi' => 'Finish Import',
  're' => 'Recover Checked',   're' => 'Recover Checked',
    'ip' => 'Import Checked',
  'ca' => 'Cancel',   'ca' => 'Cancel',
  'co' => 'Change Order',   'co' => 'Change Order',
  'ti' => 'Title',   'ti' => 'Title',
  'pa' => 'Path',   'pa' => 'Path',
                 'in' => 'Include'                  'in' => 'Include'
  );   );
  my $title = ($env{'form.recover'}) ? 'Recover Removed Resources'  
                                            : 'Sort Imported Resources';  
  $r->print(&Apache::loncommon::start_page($title, $js));   $r->print(&Apache::loncommon::start_page($title, $js));
    $r->print('<h1>'.&mt($title).'</h1>');
   
  $r->print(<<END);   $r->print(<<END);
 <form method='post' action='/adm/groupsort' name='groupsort'  <form method='post' action='/adm/groupsort' name='groupsort'
Line 338  END Line 348  END
   
         $r->print(&Apache::loncommon::inhibit_menu_check('input'));          $r->print(&Apache::loncommon::inhibit_menu_check('input'));
         # ---          # ---
       
         if ($env{'form.recover'}) {          my $buttontext = $lt{'re'};
           if ($env{'form.bookmarks'}) {
               $buttontext = $lt{'ip'}
           }
           if ($env{'form.recover'} || $env{'form.bookmarks'}) {
     $r->print(<<END);      $r->print(<<END);
 <input type="button" name="alter" value="$lt{'re'}"  <input type="button" name="alter" value="$buttontext"
  onClick="finish_import()" />&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
Line 363  END Line 377  END
 <br />  <br />
 END  END
         }          }
         $r->print(&Apache::loncommon::start_data_table()  
                  .&Apache::loncommon::start_data_table_header_row());          # Only display header if content exists
  if (($env{'form.readfile'}) || ($env{'form.bookmarks'})) {           if ($clen > 0) {
     $r->print("<th>$lt{'in'}</th>\n");              $r->print(&Apache::loncommon::start_data_table()
  } else {                        .&Apache::loncommon::start_data_table_header_row());
     $r->print("<th colspan='2'>$lt{'co'}</th>\n");               if (($env{'form.readfile'})) { 
  }                  $r->print("<th>$lt{'in'}</th>\n");
  $r->print("<th colspan='2'>$lt{'ti'}</th>\n");              } else { 
  $r->print("<th>$lt{'pa'}</th>");                  $r->print('<th colspan="2">'.$lt{'co'}.'</th>'."\n"); 
         $r->print(&Apache::loncommon::end_data_table_header_row()              }
                  ."\n");              $r->print('<th colspan="2">'.$lt{'ti'}.'</th>'."\n");
               $r->print("<th>$lt{'pa'}</th>");
               $r->print(&Apache::loncommon::end_data_table_header_row()."\n");
           } else {
               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'}) {
                   $errtxt = 'There are no resources in your bookmarks to import.';
               }
               $r->print('<p class="LC_info">'.&mt($errtxt).'</p>');
           }
     } else {      } else {
  $r->print(&Apache::loncommon::start_page(undef,$js,   $r->print(&Apache::loncommon::start_page(undef,$js,
  {'only_body' => 1}));   {'only_body' => 1}));
   #       $r->print('<h1>'.&mt($title).'</h1>');
  $r->print(<<END);   $r->print(<<END);
 <form method='post' action='/adm/groupsort' name='groupsort'  <form method='post' action='/adm/groupsort' name='groupsort'
       enctype='application/x-www-form-urlencoded'>        enctype='application/x-www-form-urlencoded'>
Line 391  END Line 420  END
     foreach my $resource (@resources) {      foreach my $resource (@resources) {
  $ctr++;   $ctr++;
  my $iconname=&Apache::loncommon::icon($resource->{'url'});   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()      $r->print(&Apache::loncommon::start_data_table_row()
                      ."<td>");                       ."<td>");
             if (($env{'form.readfile'}) || ($env{'form.bookmarks'})) {              if (($env{'form.readfile'}) || ($env{'form.bookmarks'})) {
Line 419  END Line 448  END
  }    } 
     }      }
     if (($clen > 1) || ($env{'form.readfile'}) || ($env{'form.bookmarks'})) {      if (($clen > 1) || ($env{'form.readfile'}) || ($env{'form.bookmarks'})) {
         $r->print(&Apache::loncommon::end_data_table()          if ($clen > 0) {
                  ."</form>");              $r->print(&Apache::loncommon::end_data_table());
           }
           $r->print('</form>');
     } else {      } else {
  $r->print(<<END);   $r->print(<<END);
 <script type="text/javascript">  <script type="text/javascript">
Line 495  sub checkbox { Line 526  sub checkbox {
 1;  1;
   
 __END__  __END__
   
   =pod
   
   =head1 NAME
   
   Apache::groupsort.pm
   
   =head1 SYNOPSIS
   
   Implements a second phase of importing
   multiple resources into the RAT. Allows for
   reordering the sequence of resources
   
   This is part of the LearningOnline Network with CAPA project
   described at http://www.lon-capa.org.
   
   
   =head1 NOTABLE SUBROUTINES
   
   =over
   
   =item 
   
   =back
   
   =cut
   

Removed from v.1.62  
changed lines
  Added in v.1.68.6.1


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