[LON-CAPA-cvs] cvs: rat / lonratedt.pm

www lon-capa-cvs@mail.lon-capa.org
Wed, 22 May 2002 13:31:22 -0000


www		Wed May 22 09:31:22 2002 EDT

  Modified files:              
    /rat	lonratedt.pm 
  Log:
  Can now call groupimport
  
  
Index: rat/lonratedt.pm
diff -u rat/lonratedt.pm:1.25 rat/lonratedt.pm:1.26
--- rat/lonratedt.pm:1.25	Tue May 21 14:18:07 2002
+++ rat/lonratedt.pm	Wed May 22 09:31:22 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Edit Handler for RAT Maps
 #
-# $Id: lonratedt.pm,v 1.25 2002/05/21 18:18:07 www Exp $
+# $Id: lonratedt.pm,v 1.26 2002/05/22 13:31:22 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -263,6 +263,7 @@
 # ---------------------------------------------------------------- Make buttons
 
 sub buttons {
+    if ($ENV{'form.forceselect'}) { return ''; }
     my $adv=shift;
     my $output='<form method=post>';     
     if ($adv==1) {
@@ -764,23 +765,73 @@
 
 sub viewmap {
     my ($r,$url,$adv,$errtext)=@_;
-    $r->print('<html><body bgcolor="#FFFFFF">'.&buttons($adv));
+    $r->print('<html>');
+    if ($ENV{'form.forceselect'}) { $r->print(<<ENDSCRIPT);
+<script>
+
+function select_group() {
+    window.location="/adm/groupsort?catalogmode=groupimport&mode=rat&acts="+document.forms.fileattr.acts.value;
+}
+
+function queue(val) {
+    if (eval("document.forms."+val+".filelink.checked")) {
+	var l=val.length;
+	var v=val.substring(4,l);
+	document.forms.fileattr.acts.value+='1a'+v+'b';
+    }
+    else {
+	var l=val.length;
+	var v=val.substring(4,l);
+	document.forms.fileattr.acts.value+='0a'+v+'b';
+    }
+}
+
+
+
+</script>
+ENDSCRIPT
+    }
+    $r->print('<body bgcolor="#FFFFFF">'.&buttons($adv));
+    if ($ENV{'form.forceselect'}) { $r->print(<<ENDSELECT);
+<form name=fileattr><input type=hidden name=acts value=''>
+<input type="button" name="close" value='CLOSE' onClick="self.close()">
+<input type="button" name="groupimport" value='GROUP IMPORT'
+onClick="javascript:select_group()">
+</form>   
+ENDSELECT
+    }
     if ($errtext) {
 	$r->print($errtext.'<hr>');
     }
+    my $idx=0;
     foreach (&attemptread(&Apache::lonnet::filelocation('',$url))) {
 	if (defined($_)) {
+            $idx++;
+            if ($ENV{'form.forceselect'}) { 
+		$r->print('<form name="form'.$idx.'">');
+            }
 	    my ($title,$url)=split(/\:/,$_);
             $title=~s/\&colon\;/\:/g;
             $url=~s/\&colon\;/\:/g;
             unless ($title) { $title=(split(/\//,$url))[-1] };
             unless ($title) { $title='<i>Empty</i>'; }
             if ($url) {
+		if ($ENV{'form.forceselect'}) {
+		    $r->print(<<ENDCHECKBOX);
+<input type='checkbox' name='filelink' 
+value='$url' onClick='javascript:queue("form$idx")' >
+<input type='hidden' name='title' value='$title'>
+ENDCHECKBOX
+                }
 		$r->print('<a href="'.&Apache::lonratsrv::qtescape($url).'">');
             }
             $r->print(&Apache::lonratsrv::qtescape($title));
             if ($url) { $r->print('</a>'); }
-            $r->print('<br>');
+            if ($ENV{'form.forceselect'}) {
+		$r->print('</form>');
+            } else {
+		$r->print('<br>');
+            }
         }
     }
     $r->print('</body></html>');
@@ -794,6 +845,9 @@
   $r->send_http_header;
 
   return OK if $r->header_only;
+ 
+  &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+                                          ['forceselect']);
 
   my $url=$r->uri;
   my $fn=&Apache::lonnet::filelocation('',$url);