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

raeburn raeburn at source.lon-capa.org
Mon May 6 12:16:04 EDT 2013


raeburn		Mon May  6 16:16:04 2013 EDT

  Modified files:              
    /loncom/interface	lonrss.pm lonsyllabus.pm 
    /loncom/auth	lonroles.pm 
  Log:
  - lonrss::advertisefeeds() takes two additional, optional args:
    $count, $hidden (refs to scalars to accumulate counts of visible feeds
  - Set additional item in %env for a course:
    $env{'course.<courseid>.feeds'} contains number of visible course RSS feeds.
  - Added information in Syllabus template about availability of RSS Feeds and 
    Blogs item (editing mode).
  
  
Index: loncom/interface/lonrss.pm
diff -u loncom/interface/lonrss.pm:1.50 loncom/interface/lonrss.pm:1.51
--- loncom/interface/lonrss.pm:1.50	Tue Jul  3 15:18:54 2012
+++ loncom/interface/lonrss.pm	Mon May  6 16:15:59 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # RSS Feeder
 #
-# $Id: lonrss.pm,v 1.50 2012/07/03 15:18:54 raeburn Exp $
+# $Id: lonrss.pm,v 1.51 2013/05/06 16:15:59 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -88,7 +88,7 @@
 }
 
 sub advertisefeeds {
-    my ($uname,$udom,$edit)=@_;
+    my ($uname,$udom,$edit,$count,$hidden)=@_;
     my $feeds='';
     my %feednames=&Apache::lonnet::dump('nohist_all_rss_feeds',$udom,$uname);
     my $mode='public';
@@ -100,7 +100,20 @@
 	next if ($feed =~/^\s*$/    ||
 		 $feed =~ /^error:/ ||
 		 $feed =~ /^feed_display_option_/);
-
+        if ($feednames{'feed_display_option_'.$feed} eq 'hidden') {
+            if (ref($hidden)) {
+                $$hidden ++;
+            }
+            if (ref($count)) {
+                unless ($edit) {
+                    next;
+                }
+            }
+        } else {
+            if (ref($count)) {
+                $$count ++;
+            }
+        }
 	my $feedurl= $server.'/public/'.$udom.'/'.$uname.'/'.$feed.'.rss';
 	my $htmlurl= $server.'/'.$mode.'/'.$udom.'/'.$uname.'/'.$feed.'_rss.html';
 	if ($feednames{'feed_display_option_'.$feed} eq 'hidden') {
Index: loncom/interface/lonsyllabus.pm
diff -u loncom/interface/lonsyllabus.pm:1.119 loncom/interface/lonsyllabus.pm:1.120
--- loncom/interface/lonsyllabus.pm:1.119	Sun May  5 02:21:20 2013
+++ loncom/interface/lonsyllabus.pm	Mon May  6 16:15:59 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Syllabus
 #
-# $Id: lonsyllabus.pm,v 1.119 2013/05/05 02:21:20 raeburn Exp $
+# $Id: lonsyllabus.pm,v 1.120 2013/05/06 16:15:59 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -143,6 +143,8 @@
         }
     }
 
+    my $crstype = &Apache::loncommon::course_type();
+
 # ------------------------------ The buck stops here: internal syllabus display
 # --------------------------------------------------------- The syllabus fields
     my %syllabusfields=&Apache::lonlocal::texthash(
@@ -292,7 +294,6 @@
                    text=>"Course syllabus"});
             $args->{'bread_crumbs'} = $brcrum;
         } elsif ($env{'form.folderpath'} =~ /^supplemental/) {
-            my $crstype = &Apache::loncommon::course_type();
             my $title = $env{'form.title'};
             if ($title eq '') {
                 $title = &mt('Syllabus');
@@ -646,15 +647,39 @@
             }
             &Apache::lontemplate::print_start_template($r,&mt('RSS Feeds and Blogs'),'LC_Box',
                                                        'box_000_showrssfeeds',$display);
-            $r->print(&Apache::lonrss::advertisefeeds($cnum,$cdom,$forceedit));
+            my ($numfeeds,$hiddenfeeds,$rsslinktext);
+            my $feeds=&Apache::lonrss::advertisefeeds($cnum,$cdom,$forceedit,\$numfeeds,\$hiddenfeeds);
+            if ($numfeeds) {
+                $r->print($feeds);
+                $rsslinktext = &mt('New RSS Feed or Blog');
+            } else {
+                my $msg = '<br />'.
+                          &mt("RSS Feeds and Blogs item is not included in a student's view of the syllabus.");
+                if ($hiddenfeeds) {
+                    $r->print('<p class="LC_info">'.
+                              &mt('All feeds currently hidden').
+                              $msg.
+                              '</p>');
+                } else {
+                    $r->print('<p class="LC_info">'.
+                              &mt('No current feeds').
+                              $msg.
+                              '</p>');
+                }
+                $rsslinktext = &mt('Manage Course RSS Feeds/Blogs');
+                if ($crstype eq 'Community') {
+                    $rsslinktext = &mt('Manage Communiity RSS Feeds/Blogs');
+                }
+            }
             my $editurl= &Apache::lonnet::absolute_url().'/adm/'.$cdom.'/'.$cnum.'/_rss.html';
-            $r->print( '<a href="'.$editurl.'">'.&mt('New RSS Feed or Blog').'</a>');
+            $r->print( '<a href="'.$editurl.'">'.$rsslinktext.'</a>');
             &Apache::lontemplate::print_end_template($r);
         } else {
             unless ($syllabus{'000_showrssfeeds'} eq 'no') {
-                if (&Apache::lonrss::advertisefeeds($cnum,$cdom) ne '') {
+                my $feeds = &Apache::lonrss::advertisefeeds($cnum,$cdom,$forceedit);
+                if ($feeds ne '') {
                     &Apache::lontemplate::print_start_template($r,&mt('RSS Feeds and Blogs'),'LC_Box');
-                    $r->print(&Apache::lonrss::advertisefeeds($cnum,$cdom,$forceedit));
+                    $r->print($feeds);
                     &Apache::lontemplate::print_end_template($r);
                 }
             }
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.282 loncom/auth/lonroles.pm:1.283
--- loncom/auth/lonroles.pm:1.282	Wed Apr  3 20:46:55 2013
+++ loncom/auth/lonroles.pm	Mon May  6 16:16:03 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # User Roles Screen
 #
-# $Id: lonroles.pm,v 1.282 2013/04/03 20:46:55 raeburn Exp $
+# $Id: lonroles.pm,v 1.283 2013/05/06 16:16:03 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -139,6 +139,7 @@
 use Apache::lonnavdisplay();
 use Apache::loncoursequeueadmin;
 use Apache::longroup;
+use Apache::lonrss;
 use GDBM_File;
 use LONCAPA qw(:DEFAULT :match);
 use HTML::Entities;
@@ -523,6 +524,11 @@
                             &Apache::lonnet::put('nohist_crslastlogin',
                                 {$env{'user.name'}.':'.$env{'user.domain'}.
                                 ':'.$csec.':'.$role => $now},$cdom,$cnum);
+                            my $feeds;
+                            &Apache::lonrss::advertisefeeds($cnum,$cdom,undef,\$feeds);
+                            &Apache::lonnet::appenv(
+                                                   {'course.'.$cdom.'_'.$cnum.'.feeds' => $feeds}
+                                                    );
                         }
 			if (($env{'form.orgurl'}) && 
 			    ($env{'form.orgurl'}!~/^\/adm\/flip/)) {




More information about the LON-CAPA-cvs mailing list