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

www lon-capa-cvs@mail.lon-capa.org
Thu, 11 May 2006 15:27:49 -0000


www		Thu May 11 11:27:49 2006 EDT

  Modified files:              
    /loncom/interface	lonrss.pm 
  Log:
  Hide feeds
  
  
Index: loncom/interface/lonrss.pm
diff -u loncom/interface/lonrss.pm:1.19 loncom/interface/lonrss.pm:1.20
--- loncom/interface/lonrss.pm:1.19	Wed May 10 22:08:48 2006
+++ loncom/interface/lonrss.pm	Thu May 11 11:27:49 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # RSS Feeder
 #
-# $Id: lonrss.pm,v 1.19 2006/05/11 02:08:48 www Exp $
+# $Id: lonrss.pm,v 1.20 2006/05/11 15:27:49 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -54,8 +54,8 @@
     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}; }
+    my %stored=&Apache::lonnet::get('nohist_all_rss_feeds',[$filterfilename,'feed_display_option_'.$filterfilename],$udom,$uname);
+    if ($stored{$filterfilename}) { return ($stored{$filterfilename},$stored{'feed_display_option_'.$filterfilename}); }
 # no, construct a name
     my $name=$filterfilename; 
     if ($name=~/^CourseBlog/) {
@@ -66,7 +66,7 @@
     } else {
 	$name=~s/\_/ /g;
     }
-    return $name;
+    return ($name,$stored{'feed_display_option_'.$filterfilename});
 }
 
 sub namefeed {
@@ -76,6 +76,13 @@
 				$udom,$uname);
 }
 
+sub changefeeddisplay {
+    my ($rawname,$uname,$udom,$newstatus)=@_;
+    return &Apache::lonnet::put('nohist_all_rss_feeds',
+				{ 'feed_display_option_'.&filterfeedname($rawname) => $newstatus },
+				$udom,$uname);
+}
+
 sub advertisefeeds {
     my ($uname,$udom,$edit)=@_;
     my $feeds='';
@@ -85,12 +92,18 @@
 	$mode='adm';
     }
     foreach my $feed (sort(keys(%feednames))) {
-	if ($feed!~/^error\:/) {
+	if (($feed!~/^error\:/) && ($feed!~/^feed\_display\_option\_/)) {
 	    my $feedurl='http://'.$ENV{'HTTP_HOST'}.'/public/'.$udom.'/'.$uname.'/'.$feed.'.rss';
 	    my $htmlurl='http://'.$ENV{'HTTP_HOST'}.'/'.$mode.'/'.$udom.'/'.$uname.'/'.$feed.'_rss.html';
-	    $feeds.='<li>'.$feednames{$feed}.
-		'<br />'.($edit?&mt('Edit'):'HTML').': <a href="'.$htmlurl.'"><tt>'.$htmlurl.'</tt></a>'.
-		'<br />RSS: <a href="'.$feedurl.'"><tt>'.$feedurl.'</tt></a></li>';
+	    if ($feednames{'feed_display_option_'.$feed} eq 'hidden') {
+		if ($edit) {
+		    $feeds.='<li><i>'.$feednames{$feed}.'</i><br />'.&mt('Hidden').': <a href="'.$htmlurl.'"><tt>'.$htmlurl.'</tt></a></li>';
+		}
+	    } else {
+		$feeds.='<li><b>'.$feednames{$feed}.
+		    '</b><br />'.($edit?&mt('Edit'):'HTML').': <a href="'.$htmlurl.'"><tt>'.$htmlurl.'</tt></a>'.
+		    '<br />RSS: <a href="'.$feedurl.'"><tt>'.$feedurl.'</tt></a></li>';
+	    }
 	}
     }
     if ($feeds) {
@@ -192,9 +205,9 @@
 
     my $filterfeedname=&filterfeedname($filename);
     my $feedname=&feedname($filename);
-    my $displayfeedname=&displayfeedname($filename,$uname,$udom);
+    my ($displayfeedname,$displayoption)=&displayfeedname($filename,$uname,$udom);
     if ($html) {
-	$r->print(&Apache::loncommon::start_page($displayfeedname,undef,
+	$r->print(&Apache::loncommon::start_page(($displayfeedname?$displayfeedname:&mt("Available RSS Feeds and Blogs")),undef,
 						 {'domain'         => $udom,
 						  'force_register' =>
 						      $env{'form.register'}}).
@@ -214,6 +227,16 @@
     if ($html) {
 # Any new feeds or renaming of feeds?
 	if ($edit) {
+# Hide a feed?
+	    if ($env{'form.hidethisblog'}) {
+		&changefeeddisplay($feedname,$uname,$udom,'hidden');
+		($displayfeedname,$displayoption)=&displayfeedname($filename,$uname,$udom);
+	    }
+# Advertise a feed?
+	    if ($env{'form.advertisethisblog'}) {
+		&changefeeddisplay($feedname,$uname,$udom,'public');
+		($displayfeedname,$displayoption)=&displayfeedname($filename,$uname,$udom);
+	    }
 # New feed?
 	    if ($env{'form.namenewblog'}=~/\w/) {
 		&namefeed($env{'form.namenewblog'},$uname,$udom,$env{'form.namenewblog'});
@@ -222,7 +245,7 @@
 	    if (($displayfeedname) && ($env{'form.newblogname'}=~/\w/)) {
 		if ($env{'form.newblogname'} ne $displayfeedname) {
 		    &namefeed($feedname,$uname,$udom,$env{'form.newblogname'});
-		    $displayfeedname=&displayfeedname($filename,$uname,$udom);
+		    ($displayfeedname,$displayoption)=&displayfeedname($filename,$uname,$udom);
 		}
 	    }
 	}
@@ -267,6 +290,7 @@
 	    $r->print("\n".
 		      ($html?'<hr /><h3>':'<title>').
 		      &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').
 				      ': <input type="text" size="50" name="newblogname" value="'.
@@ -345,7 +369,9 @@
 	    if ($html) {
 		$r->print('</ul>');
 		if ($edit) {
-		    $r->print('<input type="hidden" name="newid" value="'.$newid.'"/><input type="submit" value="'.&mt('Store Marked Changes').'" />');
+		    $r->print('<input type="hidden" name="newid" value="'.$newid.'"/><input type="submit" value="'.&mt('Store Marked Changes').'" />'.
+			      ($displayoption eq 'hidden'?'<input type="submit" name="advertisethisblog" value="'.&mt('Advertise this Feed').'" />':
+			       '<input type="submit" name="hidethisblog" value="'.&mt('Hide this Feed').'" />'));
 		}
 	    }
 	} # was a real display feedname