[LON-CAPA-cvs] cvs: rat / lonratedt.pm loncom/interface londocs.pm mydesk.tab

www lon-capa-cvs@mail.lon-capa.org
Tue, 20 Aug 2002 13:02:41 -0000


This is a MIME encoded message

--www1029848561
Content-Type: text/plain

www		Tue Aug 20 09:02:41 2002 EDT

  Modified files:              
    /loncom/interface	londocs.pm mydesk.tab 
    /rat	lonratedt.pm 
  Log:
  Unstable: interface to upload course documents.
  
  
--www1029848561
Content-Type: text/plain
Content-Disposition: attachment; filename="www-20020820090241.txt"

Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.7 loncom/interface/londocs.pm:1.8
--- loncom/interface/londocs.pm:1.7	Mon Aug 19 17:15:08 2002
+++ loncom/interface/londocs.pm	Tue Aug 20 09:02:41 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.7 2002/08/19 21:15:08 www Exp $
+# $Id: londocs.pm,v 1.8 2002/08/20 13:02:41 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -35,6 +35,7 @@
 use Apache::lonratedt;
 use Apache::lonratsrv;
 
+my $iconpath;
 
 # Mapread read maps into lonratedt::global arrays 
 # @links and @resources, determines status
@@ -65,11 +66,46 @@
     } else {
 # ------------------------------------------------------------ Process commands
 	if ($allowed) {
+	    if ($ENV{'form.cmd'}) {
+
+            }
 	}
 # ---------------------------------------------------------------- Print screen
     }
 }
 
+# --------------------------------------------------------------- An entry line
+
+sub entryline {
+    my ($index,$title,$url,$folder,$allowed)=@_;
+    my $line='<tr>';
+# Edit commands
+    if ($allowed) {
+       $line.=(<<END);
+<td><table border='0' cellspacing='0' cellpadding='0'>
+<tr><td><a href='/adm/coursedocs?folder=$folder&cmd=up_$index'>
+<img src="${iconpath}move_up.gif" alt='UP' border='0' /></a></td></tr>
+<tr><td><a href='/adm/coursedocs?folder=$folder&cmd=down_$index'>
+<img src="${iconpath}move_down.gif" alt='DOWN' border='0' /></a></td></tr>
+</table></td><td>
+<a href='/adm/coursedocs?folder=$folder&cmd=del_$index'>Remove</td>
+END
+    }
+# URL
+    $line.='<td><a href="'.$url.'">View</a></td>';
+# Title
+    $title=&Apache::lonnet::unescape($title);
+    if ($title=~
+ /^(\d+)\_\_\_\&\&\&\_\_\_(\w+)\_\_\_\&\&\&\_\_\_(\w+)\_\_\_\&\&\&\_\_\_(.*)$/
+	) { $title='<i>'.localtime($1).'</i> '.$2.' at '.$3.': <br>'.
+		&Apache::lontexconvert::msgtexconverted($4);
+	}
+    $line.='<td>$title</td>';
+    $line.='</tr>';
+    return $line;
+}
+
+# ================================================================ Main Handler
 sub handler {
     my $r = shift;
     $r->content_type('text/html');
@@ -85,48 +121,36 @@
 
 # does this user have privileges to post, etc?
     my $allowed=&Apache::lonnet::allowed('srm',$ENV{'request.course.id'});
-
+    my $script='';
     if ($allowed) { 
-       &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
-                                                         ['remove']); 
+       &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
+       $script=&Apache::lonratedt::editscript('docs'); 
     }
 
 # get course data
     my $coursenum=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
     my $coursedom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
 
+# graphics settings
 
-# upload a file
+    $iconpath = $r->dir_config('lonIconsURL') . "/";
+
+# upload a file, if present
     if (($ENV{'form.uploaddoc.filename'}) && ($allowed)) {
-        my $id=time.'_'.$ENV{'user.name'}.'_'.$ENV{'user.domain'};
 # this is for a course, not a user, so set coursedoc flag
 # probably the only place in the system where this should be "1"
 	my $url=&Apache::lonnet::userfileupload('uploaddoc',1);
-        if ($url=~/^error\:/) {
-        } else {
-	    my $comment=$ENV{'form.comment'};
-           $comment=~s/\</\&lt\;/g;
-           $comment=~s/\>/\&gt\;/g;
-           &Apache::lonnet::put('coursedocs',
-				{ $id.'.url' => $url,
-                                  $id.'.comment' => $comment },
-                                $coursedom,$coursenum);
-        }        
+	my $comment=$ENV{'form.comment'};
+        $comment=~s/\</\&lt\;/g;
+        $comment=~s/\>/\&gt\;/g;        
     }
 
-# delete a file
-    if ($ENV{'form.remove'}=~/$ENV{'user.name'}\_$ENV{'user.domain'}$/) {
-       my $id=$ENV{'form.remove'};
-       &Apache::lonnet::del('coursedocs',
-			    [$id.'.url',$id.'.comment'],
-                            $coursedom,$coursenum);
-   }
-
 # print screen
     $r->print(<<ENDDOCUMENT);
 <html>
 <head>
 <title>The LearningOnline Network with CAPA</title>
+<script>$script</script>
 </head>
 <body bgcolor="#FFFFFF">
 <h1>Course Documents</h1>
@@ -137,6 +161,17 @@
        my $folder=$ENV{'form.folder'};
        unless ($folder) { $folder='default'; }
        &editor($r,$coursenum,$coursedom,$folder,$allowed);
+       $r->print(<<ENDFORM);
+<h3>Post a new main course document</h3>
+<form method="post" enctype="multipart/form-data">
+<input type="file" name="uploaddoc" size="50">
+<br />
+Title: <input type="text" size="50" name="comment">
+<input type="hidden" name="folder" value="$folder">
+<input type="hidden" name="cmd" value="upload_main">
+<input type="submit" value="Upload Document">
+</form>
+ENDFORM
        $r->print('<hr />');
     }
 # ----------------------------------------------------- Supplemental documents
@@ -145,41 +180,20 @@
        my $folder=$ENV{'form.folder'};
        unless ($folder) { $folder='supplemental'; }
        &editor($r,$coursenum,$coursedom,$folder,$allowed);
-    }
-# ------------------------------------------------------- Print headers to docs
-   my %currentdocs=&Apache::lonnet::dump('coursedocs',$coursedom,$coursenum);
-   foreach (sort keys (%currentdocs)) {
-       if ($_=~/(\d+)\_(\w+)\_(\w+)\.url/) {
-	   $r->print('<hr>'.localtime($1).' '.$2.' '.$3.'<blockquote>'.
-		     &Apache::lontexconvert::msgtexconverted(
-                                 $currentdocs{$1.'_'.$2.'_'.$3.'.comment'}
-                     ).
-                     '</blockquote><a href="'.
-               &Apache::lonnet::tokenwrapper($currentdocs{$_}).'">View</a>');
-	   if (($2 eq $ENV{'user.name'}) && ($3 eq $ENV{'user.domain'})
-               && ($allowed)) {
-              $r->print(' <a href="/adm/coursedocs?remove='.
-                        $1.'_'.$2.'_'.$3.'">Remove</a>');
-	   }
-       }
-   }
-# ----------------------------------------------------------------- Upload form
-   if ($allowed) {
-       $r->print(<<ENDFORM);
-<hr />
-<h3>Post a new course document</h3>
+       if ($allowed) {
+          $r->print(<<ENDSUPFORM);
+<h3>Post a new supplemental course document</h3>
 <form method="post" enctype="multipart/form-data">
 <input type="file" name="uploaddoc" size="50">
 <br />Comment:<br />
 <textarea cols=50 rows=4 name='comment'>
 </textarea>
+<input type="hidden" name="folder" value="$folder">
+<input type="hidden" name="cmd" value="upload_suppl">
 <input type="submit" value="Upload Document">
 </form>
-ENDFORM
-    }
-
-    foreach (@Apache::lonratedt::resources) {
-	$r->print($_.'<br>');
+ENDSUPFORM
+       }
     }
 
     $r->print('</body></html>');
Index: loncom/interface/mydesk.tab
diff -u loncom/interface/mydesk.tab:1.27 loncom/interface/mydesk.tab:1.28
--- loncom/interface/mydesk.tab:1.27	Mon Aug 19 17:14:08 2002
+++ loncom/interface/mydesk.tab	Tue Aug 20 09:02:41 2002
@@ -49,7 +49,7 @@
 10:1:clear
 10:1:any:any:anno.gif:calendar:announce:go('/adm/announcements');:Announcements and Calendar
 10:2:clear
-#10:2:course:any:docs.gif:course:docs:go('/adm/coursedocs');:Course Documents
+10:2:course:any:docs.gif:course:docs:go('/adm/coursedocs');:Course Documents
 10:3:clear
 10:3:course:any:bchat.gif:course:chat:go('/res/adm/pages/chatroom.html');:Chat
 11:1:adv:any:src.gif:search:library:go('/adm/searchcat');:Search Published Resources
Index: rat/lonratedt.pm
diff -u rat/lonratedt.pm:1.31 rat/lonratedt.pm:1.32
--- rat/lonratedt.pm:1.31	Mon Jun 24 10:12:04 2002
+++ rat/lonratedt.pm	Tue Aug 20 09:02:41 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Edit Handler for RAT Maps
 #
-# $Id: lonratedt.pm,v 1.31 2002/06/24 14:12:04 www Exp $
+# $Id: lonratedt.pm,v 1.32 2002/08/20 13:02:41 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -347,6 +347,113 @@
      &Apache::lonratsrv::loadmap($fn,&Apache::lonratsrv::savemap($fn,''));
 }
 
+sub editscript {
+    my $mode=shift;
+    return(<<ENDSCRIPT);
+var srch;
+var srchflag=-1; // 1 means currently open
+                 // 0 means closed (but has been open)
+                 // -1 means never yet opened/defined
+var srchmode='';
+
+var idx;
+var idxflag=-1; // 1 means currently open
+                 // 0 means closed (but has been open)
+                 // -1 means never yet opened/defined
+var idxmode='';
+
+// ------------------------------------------------------ Clears indexer window
+function idxclear() {
+  idx.document.clear();
+}
+
+// ------------------------------------------------------- Clears search window
+function srchclear() {
+  srch.document.clear();
+}
+
+// ------------------------------------------------------ Closes indexer window
+function idxclose() {
+  if (idx && !idx.closed) {
+    idxflag=0;
+    idx.close();
+  }
+}
+
+// ------------------------------------------------------- Closes search window
+function srchclose() {
+  if (srch && !srch.closed) {
+    srchflag=0;
+    srch.close();
+  }
+}
+
+// -------------------------------------------------------- Open indexer window
+function idxopen(mode) {
+   var options="scrollbars=1,resizable=1,menubar=0";
+   idxmode=mode;
+   idxflag=1;
+   idx=open("/res/?launch=1&mode=$mode&catalogmode="+mode,"idxout",options);
+   idx.focus();
+}
+
+// --------------------------------------------------------- Open search window
+function srchopen(mode) {
+   var options="scrollbars=1,resizable=1,menubar=0";
+   srchmode=mode;
+   srchflag=1;
+   srch=open("/adm/searchcat?launch=1&mode=$mode&catalogmode="+mode,"srchout",options);
+   srch.focus();
+}
+// ----------------------------------------------------- launch indexer browser
+function groupsearch() {
+   srchcheck('groupsearch');
+}
+
+function groupimport() {
+   idxcheck('groupimport');
+}
+// ------------------------------------------------------- Do srch status check
+function srchcheck(mode) {
+   if (!srch || srch.closed || srchmode!=mode) {
+      srchopen(mode);
+   }
+   srch.focus();
+}
+
+// -------------------------------------------------------- Do idx status check
+function idxcheck(mode) {
+   if (!idx || idx.closed || idxmode!=mode) {
+      idxopen(mode);
+   }
+   idx.focus();
+}
+
+
+    var editbrowser;
+    function openbrowser(formname,elementname,only,omit) {
+        var url = '/res/?';
+        if (editbrowser == null) {
+            url += 'launch=1&';
+        }
+        url += 'catalogmode=interactive&';
+        url += 'mode=edit&';
+        url += 'form=' + formname + '&';
+        if (only != null) {
+            url += 'only=' + only + '&';
+        } 
+        if (omit != null) {
+            url += 'omit=' + omit + '&';
+        }
+        url += 'element=' + elementname + '';
+        var title = 'Browser';
+        var options = 'scrollbars=1,resizable=1,menubar=0';
+        options += ',width=700,height=600';
+        editbrowser = open(url,title,options,'1');
+        editbrowser.focus();
+    }
+ENDSCRIPT
+}
 # ------------------------------------------------------- Simple edit processor
 
 sub smpedt {
@@ -571,112 +678,13 @@
    } @order);
 
 # ----------------------------------------------------- Start simple RAT screen
+   my $editscript=&editscript('simple');
    $r->print(<<ENDSMPHEAD);
 <html>
 <head>
 <script>
-var srch;
-var srchflag=-1; // 1 means currently open
-                 // 0 means closed (but has been open)
-                 // -1 means never yet opened/defined
-var srchmode='';
-
-var idx;
-var idxflag=-1; // 1 means currently open
-                 // 0 means closed (but has been open)
-                 // -1 means never yet opened/defined
-var idxmode='';
-
-// ------------------------------------------------------ Clears indexer window
-function idxclear() {
-  idx.document.clear();
-}
-
-// ------------------------------------------------------- Clears search window
-function srchclear() {
-  srch.document.clear();
-}
-
-// ------------------------------------------------------ Closes indexer window
-function idxclose() {
-  if (idx && !idx.closed) {
-    idxflag=0;
-    idx.close();
-  }
-}
-
-// ------------------------------------------------------- Closes search window
-function srchclose() {
-  if (srch && !srch.closed) {
-    srchflag=0;
-    srch.close();
-  }
-}
-
-// -------------------------------------------------------- Open indexer window
-function idxopen(mode) {
-   var options="scrollbars=1,resizable=1,menubar=0";
-   idxmode=mode;
-   idxflag=1;
-   idx=open("/res/?launch=1&mode=simple&catalogmode="+mode,"idxout",options);
-   idx.focus();
-}
-
-// --------------------------------------------------------- Open search window
-function srchopen(mode) {
-   var options="scrollbars=1,resizable=1,menubar=0";
-   srchmode=mode;
-   srchflag=1;
-   srch=open("/adm/searchcat?launch=1&mode=simple&catalogmode="+mode,"srchout",options);
-   srch.focus();
-}
-// ----------------------------------------------------- launch indexer browser
-function groupsearch() {
-   srchcheck('groupsearch');
-}
-
-function groupimport() {
-   idxcheck('groupimport');
-}
-// ------------------------------------------------------- Do srch status check
-function srchcheck(mode) {
-   if (!srch || srch.closed || srchmode!=mode) {
-      srchopen(mode);
-   }
-   srch.focus();
-}
-
-// -------------------------------------------------------- Do idx status check
-function idxcheck(mode) {
-   if (!idx || idx.closed || idxmode!=mode) {
-      idxopen(mode);
-   }
-   idx.focus();
-}
 
-
-    var editbrowser;
-    function openbrowser(formname,elementname,only,omit) {
-        var url = '/res/?';
-        if (editbrowser == null) {
-            url += 'launch=1&';
-        }
-        url += 'catalogmode=interactive&';
-        url += 'mode=edit&';
-        url += 'form=' + formname + '&';
-        if (only != null) {
-            url += 'only=' + only + '&';
-        } 
-        if (omit != null) {
-            url += 'omit=' + omit + '&';
-        }
-        url += 'element=' + elementname + '';
-        var title = 'Browser';
-        var options = 'scrollbars=1,resizable=1,menubar=0';
-        options += ',width=700,height=600';
-        editbrowser = open(url,title,options,'1');
-        editbrowser.focus();
-    }
+   $editscript
 
    function openview(entry) {
        var url=unescape((entry.split('='))[1]);

--www1029848561--