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

www lon-capa-cvs@mail.lon-capa.org
Thu, 11 May 2006 17:38:45 -0000


www		Thu May 11 13:38:45 2006 EDT

  Modified files:              
    /loncom/interface	lonparmset.pm lonrss.pm 
  Log:
  Saving my work: direct posting to feeds
  
  
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.302 loncom/interface/lonparmset.pm:1.303
--- loncom/interface/lonparmset.pm:1.302	Wed May 10 18:27:29 2006
+++ loncom/interface/lonparmset.pm	Thu May 11 13:38:44 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.302 2006/05/10 22:27:29 albertel Exp $
+# $Id: lonparmset.pm,v 1.303 2006/05/11 17:38:44 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -63,6 +63,7 @@
 use Apache::lonxml;
 use Apache::lonlocal;
 use Apache::lonnavmaps;
+use Apache::lonrss;
 
 # --- Caches local to lonparmset
 
@@ -3412,7 +3413,10 @@
 		if (($uname) && ($udom)) {
 		    $r->print('<td>Notify Link</td>');
 		} else {
-		    $r->print('<td>Blog Link</td>');
+		    $r->print('<td>'.
+			      &Apache::lonrss::course_blog_link
+			      ($id,
+			       'New Parameter','Set new parameter').'</td>');
 		}
 	    } else {
 		$r->print('<td>&nbsp;</td>');
Index: loncom/interface/lonrss.pm
diff -u loncom/interface/lonrss.pm:1.20 loncom/interface/lonrss.pm:1.21
--- loncom/interface/lonrss.pm:1.20	Thu May 11 11:27:49 2006
+++ loncom/interface/lonrss.pm	Thu May 11 13:38:44 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # RSS Feeder
 #
-# $Id: lonrss.pm,v 1.20 2006/05/11 15:27:49 www Exp $
+# $Id: lonrss.pm,v 1.21 2006/05/11 17:38:44 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -180,6 +180,34 @@
     return &Apache::loncommon::filemimetype($ending);
 }
 
+sub course_blog_link {
+    my ($id,$title,$description,$url,$encurl,$enctype)=@_;
+    if ($env{'request.course.id'}) {
+	return &add_blog_entry_link($id,
+				    $env{'course.'.$env{'request.course.id'}.'.num'},
+				    $env{'course.'.$env{'request.course.id'}.'.domain'},
+				    'Course_Announcements',
+				    $title,$description,$url,'public',$encurl,$enctype,
+				    &mt('Add to Course Announcements'));
+    } else {
+	return '';
+    }
+}
+
+sub add_blog_entry_link {
+    my ($id,$uname,$udom,$filename,$title,$description,$url,$status,$encurl,$enctype,$linktext)=@_;
+    return "<a href='/adm/$udom/$uname/".&filterfeedname($filename).'_rss.html?queryid='.
+	&Apache::lonnet::escape($id).
+	'&title='.&Apache::lonnet::escape($title).
+	'&description='.&Apache::lonnet::escape($description).
+	'&url='.&Apache::lonnet::escape($url).
+	'&status='.&Apache::lonnet::escape($status).
+	'&encurl='.&Apache::lonnet::escape($encurl).
+	'&enctype='.&Apache::lonnet::escape($enctype).
+	"'>".$linktext.'</a>';
+
+}
+
 sub handler {
     my ($r) = @_;
 
@@ -190,6 +218,10 @@
 	$edit=1;
 	$html=1;
     }
+    if  (($mode eq 'adm') && (&Apache::lonnet::allowed('mdc',$env{'request.course.id'}))) {
+	$edit=1;
+	$html=1;
+    }
     if ($filename=~/\.html$/) {
 	$html=1;
     }
@@ -220,7 +252,7 @@
 		  &mt('An RSS Feed provided by the LON-CAPA Learning Content Management System').
 		  '</description>');
     }
-# Do we have stuff to store?
+# This will be the entry id for new additions to the blog
     my $newid = &get_new_feed_id();
 # Is this user for real?
     my $homeserver=&Apache::lonnet::homeserver($uname,$udom);
@@ -265,13 +297,36 @@
 # Add a new feed
         if (($html) && ($edit)) {
 	    $r->print('<form method="post">');
-            $r->print(&mt('Name for New Blog').": <input type='text' size='40' name='namenewblog' />");
-	    $r->print('<input type="submit" value="'.&mt('Start a New Blog').'" />');
+            $r->print(&mt('Name for New Feed').": <input type='text' size='40' name='namenewblog' />");
+	    $r->print('<input type="submit" value="'.&mt('Start a New Feed').'" />');
 	    $r->print('</form>');
 	}
         if ($displayfeedname) { # this is an existing feed
 # Anything to store?
 	    if ($edit) {
+# check if this was called with a query string
+		&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['queryid']);
+		if ($env{'form.queryid'}) {
+# yes, collect the remainder
+		    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+							    ['title',
+							     'description',
+							     'url',
+							     'status',
+							     'enclosureurl',
+							     'enclosuretype']);
+#    my ($id,$uname,$udom,$filename,$title,$description,$url,$status,$encurl,$enctype)=@_;
+
+		    &editentry($env{'form.queryid'},
+			       $uname,$udom,$filename,
+			       $env{'form.title'},
+			       $env{'form.description'},
+			       $env{'form.url'},
+			       $env{'form.status'},
+			       $env{'form.encurl'},
+			       $env{'form.enctype'}
+			       );
+		}
 		my %newsfeed=&Apache::lonnet::dump($feedname,$udom,$uname);
 		foreach my $entry (sort(keys(%newsfeed)),$env{'form.newid'}.'_status') {
 		    if ($entry=~/^(\d+)\_status$/) {
@@ -281,7 +336,10 @@
 				       $env{'form.'.$id.'_title'},
 				       $env{'form.'.$id.'_description'},
 				       $env{'form.'.$id.'_url'},
-				       $env{'form.'.$id.'_status'});
+				       $env{'form.'.$id.'_status'},
+				       $env{'form.'.$id.'_enclosureurl'},
+				       $env{'form.'.$id.'_enclosuretype'},
+				       );
 			}
 		    }
 		}
@@ -292,7 +350,7 @@
 		      &mt('LON-CAPA Feed "[_1]" for [_2]',$displayfeedname,$name).
 		      ($displayoption eq 'hidden'?' ('.&mt('Hidden').')':'').
 		      ($html?'</h3>'.($edit?'<form method="post"><br />'.
-				      &mt('Name of blog/journal').
+				      &mt('Name of this Feed').
 				      ': <input type="text" size="50" name="newblogname" value="'.
 				      $displayfeedname.'" />':'').'<ul>':'</title>'));
 # Render private items?