[LON-CAPA-cvs] cvs: loncom /interface londocs.pm

www lon-capa-cvs@mail.lon-capa.org
Thu, 06 May 2004 20:34:06 -0000


www		Thu May  6 16:34:06 2004 EDT

  Modified files:              
    /loncom/interface	londocs.pm 
  Log:
  Bug #1869: moving resources up and down by pulldown menus.
  
  
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.124 loncom/interface/londocs.pm:1.125
--- loncom/interface/londocs.pm:1.124	Thu May  6 14:28:16 2004
+++ loncom/interface/londocs.pm	Thu May  6 16:34:06 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.124 2004/05/06 18:28:16 www Exp $
+# $Id: londocs.pm,v 1.125 2004/05/06 20:34:06 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -326,7 +326,34 @@
 
 		    my $newpos=$ENV{'form.newpos'}-1;
 		    my $currentpos=$ENV{'form.currentpos'}-1;
-		    $r->print('Sorting '.$idx.': '.$currentpos.' -> '.$newpos);
+		    my $i;
+		    my @neworder=();
+		    if ($newpos>$currentpos) {
+# moving stuff up
+			for ($i=0;$i<$currentpos;$i++) {
+			    $neworder[$i]=$Apache::lonratedt::order[$i];
+			}
+			for ($i=$currentpos;$i<$newpos;$i++) {
+			    $neworder[$i]=$Apache::lonratedt::order[$i+1];
+			}
+                        $neworder[$newpos]=$Apache::lonratedt::order[$currentpos];
+			for ($i=$newpos+1;$i<=$#Apache::lonratedt::order;$i++) {
+			    $neworder[$i]=$Apache::lonratedt::order[$i];
+			}
+		    } else {
+# moving stuff down
+			for ($i=0;$i<$newpos;$i++) {
+			    $neworder[$i]=$Apache::lonratedt::order[$i];
+			}
+			$neworder[$newpos]=$Apache::lonratedt::order[$currentpos];
+			for ($i=$newpos+1;$i<$currentpos+1;$i++) {
+			    $neworder[$i]=$Apache::lonratedt::order[$i-1];
+			}
+			for ($i=$currentpos+1;$i<=$#Apache::lonratedt::order;$i++) {
+			    $neworder[$i]=$Apache::lonratedt::order[$i];
+			}
+		    }
+		    @Apache::lonratedt::order=@neworder;
 		}
 # store the changed version