[LON-CAPA-cvs] cvs: loncom /interface lonaboutme.pm lonannounce.pm lonfeedback.pm lonmsg.pm lonrss.pm lonsyllabus.pm

www lon-capa-cvs@mail.lon-capa.org
Fri, 18 Nov 2005 13:35:32 -0000


This is a MIME encoded message

--www1132320932
Content-Type: text/plain

www		Fri Nov 18 08:35:32 2005 EDT

  Modified files:              
    /loncom/interface	lonaboutme.pm lonannounce.pm lonfeedback.pm 
                     	lonmsg.pm lonrss.pm lonsyllabus.pm 
  Log:
  Implementing Course Journals
  
  
--www1132320932
Content-Type: text/plain
Content-Disposition: attachment; filename="www-20051118083532.txt"

Index: loncom/interface/lonaboutme.pm
diff -u loncom/interface/lonaboutme.pm:1.38 loncom/interface/lonaboutme.pm:1.39
--- loncom/interface/lonaboutme.pm:1.38	Sun Jun  5 22:29:46 2005
+++ loncom/interface/lonaboutme.pm	Fri Nov 18 08:35:30 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # "About Me" Personal Information
 #
-# $Id: lonaboutme.pm,v 1.38 2005/06/06 02:29:46 albertel Exp $
+# $Id: lonaboutme.pm,v 1.39 2005/11/18 13:35:30 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -34,6 +34,7 @@
 use Apache::lonnet;
 use Apache::lontexconvert;
 use Apache::lonfeedback;
+use Apache::lonrss();
 use Apache::lonlocal;
 
 sub handler {
@@ -97,7 +98,7 @@
     }
     if ($target ne 'tex') {
 	$r->print('<h3>'.$Apache::lonnet::domaindescription{$cdom}.'</h3>'.
-		  '<p>'.&Apache::loncommon::messagewrapper('Send me a message',$cnum,$cdom).'</p>');
+		  '<p>'.&Apache::loncommon::messagewrapper('Send me a message',$cnum,$cdom).'</p>'.&Apache::lonrss::advertisefeeds($cnum,$cdom));
     } else {
 	$r->print('\textbf{'.$Apache::lonnet::domaindescription{$cdom}.'}\\\\');
     }
Index: loncom/interface/lonannounce.pm
diff -u loncom/interface/lonannounce.pm:1.36 loncom/interface/lonannounce.pm:1.37
--- loncom/interface/lonannounce.pm:1.36	Thu Nov 17 16:33:40 2005
+++ loncom/interface/lonannounce.pm	Fri Nov 18 08:35:30 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Announce
 #
-# $Id: lonannounce.pm,v 1.36 2005/11/17 21:33:40 www Exp $
+# $Id: lonannounce.pm,v 1.37 2005/11/18 13:35:30 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -53,7 +53,7 @@
     my %lt=&Apache::lonlocal::texthash('post' => 'Post Announcement',
 				       'start' => 'Starting date',
 				       'end' => 'Ending date',
-				       'incrss' => 'Include in course newsfeed');
+				       'incrss' => 'Include in course RSS newsfeed');
 
     $r->print(<<ENDFORM);
 $help
Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.174 loncom/interface/lonfeedback.pm:1.175
--- loncom/interface/lonfeedback.pm:1.174	Tue Nov 15 15:33:20 2005
+++ loncom/interface/lonfeedback.pm	Fri Nov 18 08:35:30 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Feedback
 #
-# $Id: lonfeedback.pm,v 1.174 2005/11/15 20:33:20 albertel Exp $
+# $Id: lonfeedback.pm,v 1.175 2005/11/18 13:35:30 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -39,6 +39,7 @@
 use Apache::lonhtmlcommon();
 use Apache::lonnavmaps;
 use Apache::lonenc();
+use Apache::lonrss();
 use HTML::LCParser();
 use Apache::lonspeller();
 use Cwd;
@@ -1300,7 +1301,7 @@
 sub mail_screen {
   my ($r,$feedurl,$options) = @_;
   if (exists($env{'form.origpage'})) {
-      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['subject','comment','currnewattach','addnewattach','deloldattach','delnewattach','timestamp','idx','anondiscuss','discuss']);
+      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['subject','comment','currnewattach','addnewattach','deloldattach','delnewattach','timestamp','idx','anondiscuss','discuss','blog']);
   }
   my $bodytag=&Apache::loncommon::bodytag('Resource Feedback and Discussion',
                                           '','onLoad="window.focus();setposttype();"');
@@ -1484,6 +1485,11 @@
              rec=1;
           } 
         }
+        if (typeof(document.mailform.elements.blog)!="undefined") {
+          if (document.mailform.elements.blog.checked) {
+             rec=1;
+          } 
+        }
 
         if (rec) {
             if (typeof(document.mailform.onsubmit)=='function') {
@@ -2140,7 +2146,7 @@
 }
 
 sub redirect_back {
-  my ($r,$feedurl,$typestyle,$sendsomething,$sendposts,$status,$previous,$sort,$rolefilter,$statusfilter,$sectionpick,$numpicks) = @_;
+  my ($r,$feedurl,$typestyle,$sendsomething,$sendposts,$blog,$status,$previous,$sort,$rolefilter,$statusfilter,$sectionpick,$numpicks) = @_;
   my $sorttag = '';
   my $roletag = '';
   my $statustag = '';
@@ -2222,6 +2228,7 @@
 <img align="right" src="$logo" />
 $typestyle
 <b>Sent $sendsomething message(s), and $sendposts post(s).</b>
+$blog
 <font color="red">$status</font>
 <form name="reldt" action="$feedurl" target="loncapaclient">
 $prevtag
@@ -2307,6 +2314,8 @@
 		' <i>('.&mt('name only visible to course faculty').')</i></label> '.
 		'<a href="/adm/preferences?action=changescreenname">'.&mt('Change Screenname').'</a>';
         }
+        $discussoptions.='<br /><label><input type="checkbox" name="blog" /> '.
+	    &mt('Add to my course blog').'</label>';
     }
     if ($msgoptions) { $msgoptions='<h2><img src="'.&Apache::loncommon::lonhttpdurl('/adm/lonMisc/feedback.gif').'" />'.&mt('Sending Messages').'</h2>'.$msgoptions; }
     if ($discussoptions) { 
@@ -2736,6 +2745,7 @@
 <input type="hidden" name="numoldver" value="$env{'form.numoldver'}" />
 <input type="hidden" name="origpage" value="$env{'form.origpage'}" />
 <input type="hidden" name="anondiscuss" value="$env{'form.anondiscuss'}" />
+<input type="hidden" name="blog" value="$env{'form.blog'}" />
 <input type="hidden" name="discuss" value="$env{'form.discuss'}" />
 END
     foreach (@{$currnewattach}) {
@@ -2800,6 +2810,7 @@
 <input type="hidden" name="timestamp" value="$now" />
 <input type="hidden" name="subject" />
 <input type="hidden" name="comment" />
+<input type="hidden" name="blog" value = "0" />
 <input type="hidden" name="anondiscuss" value = "0" />
 <input type="hidden" name="discuss" value = "0" />
 <input type="hidden" name="numoldver" value="$numoldver" />
@@ -3005,7 +3016,7 @@
 			  \%readinghash,$env{'user.domain'},$env{'user.name'});
       }
       &redirect_back($r,$feedurl,&mt('Marked postings read/unread').'<br />',
-		     '0','0','',$env{'form.previous'},'','','',);
+		     '0','0','','',$env{'form.previous'},'','','',);
       return OK;
   }
   if ($env{'form.allversions'}) {
@@ -3057,14 +3068,14 @@
       $discinfo{$symb.'_userpick'} = join('&',@posters);
       &Apache::lonnet::put('nohist_'.$env{'request.course.id'}.'_discuss',
 			   \%discinfo,$env{'user.domain'},$env{'user.name'});
-      &redirect_back($r,$feedurl,&mt('Changed sort/filter').'<br />','0','0',
+      &redirect_back($r,$feedurl,&mt('Changed sort/filter').'<br />','0','0','',
 		     '',$env{'form.previous'},$env{'form.sortposts'},'','','',
 		     $numpicks);
       return OK;
   }
   if ($env{'form.applysort'}) {
       my ($symb,$feedurl)=&get_feedurl_and_clean_symb($env{'form.applysort'});
-      &redirect_back($r,$feedurl,&mt('Changed sort/filter').'<br />','0','0',
+      &redirect_back($r,$feedurl,&mt('Changed sort/filter').'<br />','0','0','',
 		     '',$env{'form.previous'},$env{'form.sortposts'},
 		     $env{'form.rolefilter'},$env{'form.statusfilter'},
 		     $env{'form.sectionpick'});
@@ -3168,7 +3179,7 @@
       my $previous=$env{'form.previous'};
       if ($env{'form.markondisp'}) { $previous=undef; }
       &redirect_back($r,$feedurl,&mt('Changed display status').'<br />',
-		     '0','0','',$previous);
+		     '0','0','','',$previous);
       return OK;
   } elsif (($env{'form.hide'}) || ($env{'form.unhide'})) {
 # ----------------------------------------------------------------- Hide/unhide
@@ -3208,7 +3219,7 @@
 			   $env{'course.'.$env{'request.course.id'}.'.num'});
 
       &redirect_back($r,$feedurl,&mt('Changed discussion status').'<br />',
-		     '0','0','',$env{'form.previous'});
+		     '0','0','','',$env{'form.previous'});
       return OK;
   } elsif ($env{'form.cmd'}=~/^(threadedoff|threadedon)$/) {
       my ($symb,$feedurl)=&get_feedurl_and_clean_symb($env{'form.symb'});
@@ -3220,7 +3231,7 @@
 	  &Apache::lonnet::delenv('environment\.threadeddiscussion');
       }
       &redirect_back($r,$feedurl,&mt('Changed discussion view mode').'<br />',
-		     '0','0','',$env{'form.previous'});
+		     '0','0','','',$env{'form.previous'});
       return OK;
   } elsif ($env{'form.deldisc'}) {
 # --------------------------------------------------------------- Hide for good
@@ -3234,7 +3245,7 @@
 			   $env{'course.'.$env{'request.course.id'}.'.domain'},
 			   $env{'course.'.$env{'request.course.id'}.'.num'});
       &redirect_back($r,$feedurl,&mt('Changed discussion status').'<br />',
-		     '0','0','',$env{'form.previous'});
+		     '0','0','','',$env{'form.previous'});
       return OK;
   } elsif ($env{'form.preview'}) {
 # -------------------------------------------------------- User wants a preview
@@ -3244,7 +3255,7 @@
 # -------------------------------------------------------- Work on attachments
       &Apache::loncommon::content_type($r,'text/html');
       $r->send_http_header;
-      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['subject','comment','addnewattach','delnewattach','timestamp','numoldver','idx','anondiscuss','discuss']);
+      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['subject','comment','addnewattach','delnewattach','timestamp','numoldver','idx','anondiscuss','discuss','blog']);
       my (@currnewattach,@currdelold,@keepold);
       &process_attachments(\@currnewattach,\@currdelold,\@keepold);
       if (exists($env{'form.addnewattach.filename'})) {
@@ -3412,9 +3423,21 @@
 				  $subject);
 	  $numpost++;
       }
+
+# Add to blog?
+
+      my $blog='';
+      if ($env{'form.blog'}) {
+	  my $subject = &clear_out_html($env{'form.subject'});
+	  $status.=&Apache::lonrss::addentry($env{'user.name'},
+				    $env{'user.domain'},
+				    'CourseBlog_'.$env{'request.course.id'},
+				    $subject,$message,$feedurl,'public');
+	  $blog='<br />'.&mt('Added to my course blog').'<br />';
+      }
 	  
 # Receipt screen and redirect back to where came from
-      &redirect_back($r,$feedurl,$typestyle,$numsent,$numpost,$status,$env{'form.previous'});
+      &redirect_back($r,$feedurl,$typestyle,$numsent,$numpost,$blog,$status,$env{'form.previous'});
   }
   return OK;
 } 
Index: loncom/interface/lonmsg.pm
diff -u loncom/interface/lonmsg.pm:1.154 loncom/interface/lonmsg.pm:1.155
--- loncom/interface/lonmsg.pm:1.154	Thu Nov 17 16:33:40 2005
+++ loncom/interface/lonmsg.pm	Fri Nov 18 08:35:30 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines for messaging
 #
-# $Id: lonmsg.pm,v 1.154 2005/11/17 21:33:40 www Exp $
+# $Id: lonmsg.pm,v 1.155 2005/11/18 13:35:30 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1117,7 +1117,7 @@
  '</p><p><label><input type="checkbox" name="permanent" /> '.
 &mt('Send copy to permanent email address (if known)').'</label></p>'.
 '<p><label><input type="checkbox" name="rsspost" /> '.
-		  &mt('Include in course newsfeed').'</label></p>';      }
+		  &mt('Include in course RSS newsfeed').'</label></p>';      }
     my %message;
     my %content;
     my $defdom=$env{'user.domain'};
Index: loncom/interface/lonrss.pm
diff -u loncom/interface/lonrss.pm:1.1 loncom/interface/lonrss.pm:1.2
--- loncom/interface/lonrss.pm:1.1	Thu Nov 17 16:40:52 2005
+++ loncom/interface/lonrss.pm	Fri Nov 18 08:35:30 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # RSS Feeder
 #
-# $Id: lonrss.pm,v 1.1 2005/11/17 21:40:52 www Exp $
+# $Id: lonrss.pm,v 1.2 2005/11/18 13:35:30 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -33,11 +33,8 @@
 use Apache::loncommon;
 use Apache::lonnet;
 use Apache::lontexconvert;
-use Apache::lonfeedback;
-use Apache::lonannounce;
 use Apache::lonlocal;
 use Apache::lonhtmlcommon;
-use Apache::lonspeller();
 
 my $feedcounter=0;
 
@@ -53,16 +50,61 @@
 }
 
 sub displayfeedname {
-    my $filename=&filterfeedname(shift);
-    $filename=~s/\_/ /g;
-    return $filename;
+    my ($rawname,$uname,$udom)=@_;
+    my $filterfilename=&filterfeedname($rawname);
+# do we have a stored name?
+    my %stored=&Apache::lonnet::get('nohist_all_rss_feeds',[$filterfilename],$udom,$uname);
+    if ($stored{$filterfilename}) { return $stored{$filterfilename}; }
+# no, construct a name
+    my $name=$filterfilename; 
+    if ($name=~/^CourseBlog/) {
+        $name=&mt('Course Blog');
+	if ($env{'course.'.$env{'request.course.id'}.'.description'}) {
+	    $name.=' '.$env{'course.'.$env{'request.course.id'}.'.description'};
+	}
+    } else {
+	$name=~s/\_/ /g;
+    }
+    return $name;
+}
+
+sub renamefeed {
+    my ($rawname,$uname,$udom,$newname)=@_;
+    return &Apache::lonnet::put('nohist_all_rss_feeds',
+				{ &filterfeedname($rawname) => $newname },
+				$udom,$uname);
+}
+
+sub advertisefeeds {
+    my ($uname,$udom)=@_;
+    my $feeds='';
+    my %feednames=&Apache::lonnet::dump('nohist_all_rss_feeds',$udom,$uname);
+    foreach (sort keys %feednames) {
+	if ($_!~/^error\:/) {
+	    my $url='feed://'.$ENV{'HTTP_HOST'}.'/public/'.$udom.'/'.$uname.'/'.$_.'.rss';
+	    $feeds.='<li><a href="'.$url.'">'.
+		$feednames{$_}.'</a><br /><tt>'.$url.'</tt></li>';
+	}
+    }
+    if ($feeds) {
+	return '<h4>'.&mt('Available RSS Feeds and Blogs').'</h4><ul>'.$feeds.'</ul>';
+    } else {
+        return '';
+    }
 }
 
 sub addentry {
-    my ($uname,$udom,$filename,$title,$description,$url,$status,$encurl,$enclength,$enctype)=@_;
-    my $feedname=&feedname($filename);
     $feedcounter++;
     my $id=time.'00000'.$$.'00000'.$feedcounter;
+    return &editentry($id,@_);
+}
+
+sub editentry {
+    my ($id,$uname,$udom,$filename,$title,$description,$url,$status,$encurl,$enclength,$enctype)=@_;
+    my $feedname=&feedname($filename);
+    &Apache::lonnet::put('nohist_all_rss_feeds',
+			 { &filterfeedname($filename) => &displayfeedname($filename,$uname,$udom) },
+			 $udom,$uname);
     return &Apache::lonnet::put($feedname,{
 	$id.'_title' => $title,
 	$id.'_description' => $description,
@@ -73,6 +115,22 @@
 	$id.'_status' => $status},$udom,$uname);
 }
 
+sub changestatus {
+    my ($id,$uname,$udom,$filename,$status)=@_;
+    my $feedname=&feedname($filename);
+    if ($status eq 'deleted') {
+	return &Apache::lonnet::del($feedname,[$id.'_title',
+					       $id.'_description',
+					       $id.'_link',
+					       $id.'_enclosureurl',
+					       $id.'_enclosurelength',
+					       $id.'_enclosuretype',
+					       $id.'_status'],$udom,$uname);
+    } else {
+	return &Apache::lonnet::put($feedname,{$id.'_status' => $status},$udom,$uname);
+    }
+}
+
 sub handler {
     my $r = shift;
     &Apache::loncommon::content_type($r,'text/xml');
@@ -82,7 +140,7 @@
     my (undef,undef,$udom,$uname,$filename)=split(/\//,$r->uri);
     my $filterfeedname=&filterfeedname($filename);
     my $feedname=&feedname($filename);
-    my $displayfeedname=&displayfeedname($filename);
+    my $displayfeedname=&displayfeedname($filename,$uname,$udom);
     $r->print("<rss version='2.0' xmlns:dc='http://purl.org/dc/elements/1.1'>\n<channel>".
 	      "\n<link>http://".$ENV{'HTTP_HOST'}.'/</link>'.
 	      "\n<description>".&mt('An RSS Feed provided by the LON-CAPA Learning Content Management System').'</description>');
@@ -111,6 +169,7 @@
 	    if ($_=~/^(\d+)\_status$/) {
 		my $id=$1;
 		if (($newsfeed{$id.'_status'} ne 'public') && ($viewpubliconly)) { next; }
+		if ($newsfeed{$id.'_status'} eq 'hidden') { next; }
 		$r->print("\n<item>\n<title>".$newsfeed{$id.'_title'}."</title>\n<description>".
 			  $newsfeed{$id.'_description'}."</description>\n<link>".
 			  $newsfeed{$id.'_link'}."</link>\n");
Index: loncom/interface/lonsyllabus.pm
diff -u loncom/interface/lonsyllabus.pm:1.43 loncom/interface/lonsyllabus.pm:1.44
--- loncom/interface/lonsyllabus.pm:1.43	Thu Nov 17 17:36:37 2005
+++ loncom/interface/lonsyllabus.pm	Fri Nov 18 08:35:30 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Syllabus
 #
-# $Id: lonsyllabus.pm,v 1.43 2005/11/17 22:36:37 www Exp $
+# $Id: lonsyllabus.pm,v 1.44 2005/11/18 13:35:30 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -116,9 +116,8 @@
 # -------------------------------------------------------------- Announcements?
     if ($target ne 'tex') {
 	$r->print(&Apache::lonannounce::showday(time,2,
-                         &Apache::lonannounce::readcalendar($cdom.'_'.$cnum)).
-		  '<p>'.&mt('Course Announcement RSS Feed').': '.
-		  '<a href="'.$feedurl.'"><tt>'.$feedurl.'</tt></a></p>');
+		       &Apache::lonannounce::readcalendar($cdom.'_'.$cnum)).
+                       &Apache::lonrss::advertisefeeds($cnum,$cdom));
     } else {
 	$r->print(&Apache::lonxml::xmlparse($r,'tex',
 		       &Apache::lonannounce::showday(time,2,

--www1132320932--