[LON-CAPA-cvs] cvs: loncom / lond /auth lonlogin.pm lonroles.pm roles.tab rolesplain.tab /interface lonannounce.pm /lonnet/perl lonnet.pm

www lon-capa-cvs@mail.lon-capa.org
Tue, 12 Aug 2003 19:46:05 -0000


This is a MIME encoded message

--www1060717565
Content-Type: text/plain

www		Tue Aug 12 15:46:05 2003 EDT

  Modified files:              
    /loncom	lond 
    /loncom/auth	lonlogin.pm lonroles.pm roles.tab rolesplain.tab 
    /loncom/interface	lonannounce.pm 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  Bug #815: Frontpage announcements can now be entered by 
  Superusers and Domain Coordinators
  on a per-machine-base from "CLDR (Calendar/Announce)".
  
  
--www1060717565
Content-Type: text/plain
Content-Disposition: attachment; filename="www-20030812154605.txt"

Index: loncom/lond
diff -u loncom/lond:1.135 loncom/lond:1.136
--- loncom/lond:1.135	Tue Aug 12 05:39:23 2003
+++ loncom/lond	Tue Aug 12 15:46:04 2003
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # lond "LON Daemon" Server (port "LOND" 5663)
 #
-# $Id: lond,v 1.135 2003/08/12 09:39:23 foxr Exp $
+# $Id: lond,v 1.136 2003/08/12 19:46:04 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -81,7 +81,7 @@
 my $status='';
 my $lastlog='';
 
-my $VERSION='$Revision: 1.135 $'; #' stupid emacs
+my $VERSION='$Revision: 1.136 $'; #' stupid emacs
 my $remoteVERSION;
 my $currenthostid;
 my $currentdomainid;
@@ -1733,6 +1733,19 @@
                        }
                        if ($ulsout eq '') { $ulsout='empty'; }
                        print $client "$ulsout\n";
+# ----------------------------------------------------------------- setannounce
+                   } elsif ($userinput =~ /^setannounce/) {
+		       my ($cmd,$announcement)=split(/:/,$userinput);
+		       chomp($announcement);
+		       $announcement=&unescape($announcement);
+                       if (my $store=IO::File->new('>'.$perlvar{'lonDocRoot'}.
+						'/announcement.txt')) {
+			   print $store $announcement;
+                           close $store;
+			   print $client "ok\n";
+		       } else {
+			   print $client "error: ".($!+0)."\n";
+		       }
 # ------------------------------------------------------------------ Hanging up
                    } elsif (($userinput =~ /^exit/) ||
                             ($userinput =~ /^init/)) {
Index: loncom/auth/lonlogin.pm
diff -u loncom/auth/lonlogin.pm:1.44 loncom/auth/lonlogin.pm:1.45
--- loncom/auth/lonlogin.pm:1.44	Tue Aug  5 08:52:23 2003
+++ loncom/auth/lonlogin.pm	Tue Aug 12 15:46:04 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Login Screen
 #
-# $Id: lonlogin.pm,v 1.44 2003/08/05 12:52:23 www Exp $
+# $Id: lonlogin.pm,v 1.45 2003/08/12 19:46:04 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -108,6 +108,8 @@
         $otherserver=Apache::lonnet::spareserver($loadpercent,$userloadpercent);
     }
 
+# ----------------------------------------------------------- Get announcements
+    my $announcements=&Apache::lonnet::getannounce();
 # -------------------------------------------------------- Set login parameters
 
     my @hexstr=('0','1','2','3','4','5','6','7',
@@ -307,7 +309,7 @@
 
    <!-- The right main column holding the large LON-CAPA logo-->
    <!-- Rows 3-4 Column 3 -->
-   <td align="center" valign="top" width="100%" height="100%" rowspan=2 bgcolor="$mainbg">
+   <td align="center" valign="top" width="100%" height="100%" bgcolor="$mainbg">
     <center>
      <img src="$logo" alt="" />
     </center>
@@ -323,7 +325,7 @@
    <td align="center" valign="middle" bgcolor="$sidebg">
 ENDTOP
 } else {
-    $r->print('<h1>The Learning<i>Online</i> Network with CAPA</h1><h2>Text-based Interface Login</h2>');
+    $r->print('<h1>The Learning<i>Online</i> Network with CAPA</h1><h2>Text-based Interface Login</h2>'.$announcements);
 }
     $r->print('<form name="client" onsubmit="return(send())">');
     unless ($fullgraph) {
@@ -385,6 +387,9 @@
 
    <!-- Row 4 Column 2 -->
    <td width=27 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>
+
+   <!-- Row 4 Column 3 -->
+<td bgcolor="$mainbg">$announcements</td>
 
    <!-- Row 4 Column 4 -->
    <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.65 loncom/auth/lonroles.pm:1.66
--- loncom/auth/lonroles.pm:1.65	Tue Aug  5 08:52:23 2003
+++ loncom/auth/lonroles.pm	Tue Aug 12 15:46:04 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # User Roles Screen
 #
-# $Id: lonroles.pm,v 1.65 2003/08/05 12:52:23 www Exp $
+# $Id: lonroles.pm,v 1.66 2003/08/12 19:46:04 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -570,6 +570,7 @@
 	    }
 	}
     }
+    $r->print(&Apache::lonnet::getannounce());
     if ($advanced) {
 	$r->print('<p><small><i>This is LON-CAPA '.
 		  $r->dir_config('lonVersion').'</i></small></p>');
Index: loncom/auth/roles.tab
diff -u loncom/auth/roles.tab:1.21 loncom/auth/roles.tab:1.22
--- loncom/auth/roles.tab:1.21	Thu Jul 24 13:53:59 2003
+++ loncom/auth/roles.tab	Tue Aug 12 15:46:04 2003
@@ -1,6 +1,6 @@
-su:s csu&U:sma:mau:cdc&U:dro
+su:s csu&U:sma:mau:cdc&U:dro:psa
 dc:s bre:sma
-dc:d cli&UIK:cau&U:cdg&UIK:mau:ccc&U:cin&UIK:cta&UIK:cep&UIK:ccr&UIK:cst&UIK:cad&UIK:dro:mky
+dc:d cli&UIK:cau&U:cdg&UIK:mau:ccc&U:cin&UIK:cta&UIK:cep&UIK:ccr&UIK:cst&UIK:cad&UIK:dro:mky:psa
 cc:s bre:sma:mcr
 cc:c cin&IK:cta&IK:cep&IK:ccr&IK:cst&IK:are:cre:ere:vgr:gan:srm:opa:mgr:rin:pch:plc
 in:s sma
Index: loncom/auth/rolesplain.tab
diff -u loncom/auth/rolesplain.tab:1.8 loncom/auth/rolesplain.tab:1.9
--- loncom/auth/rolesplain.tab:1.8	Thu Jul 24 13:53:59 2003
+++ loncom/auth/rolesplain.tab	Tue Aug 12 15:46:04 2003
@@ -60,3 +60,4 @@
 las:Lock and unlock assessments
 opa:Set assessment parameters
 ain:Assume a student's identity
+psa:Post system frontpage announcements
Index: loncom/interface/lonannounce.pm
diff -u loncom/interface/lonannounce.pm:1.16 loncom/interface/lonannounce.pm:1.17
--- loncom/interface/lonannounce.pm:1.16	Thu Jul 10 06:27:04 2003
+++ loncom/interface/lonannounce.pm	Tue Aug 12 15:46:04 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Announce
 #
-# $Id: lonannounce.pm,v 1.16 2003/07/10 10:27:04 www Exp $
+# $Id: lonannounce.pm,v 1.17 2003/08/12 19:46:04 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -225,7 +225,45 @@
     if ($ENV{'request.course.id'}) {
        $allowed=&Apache::lonnet::allowed('srm',$ENV{'request.course.id'});
     }
-
+# does this user have privileges to post to servers?
+    my $serverpost=0;
+    if ($ENV{'request.role.domain'}) {
+	$serverpost=&Apache::lonnet::allowed('psa',
+					     $ENV{'request.role.domain'});
+    } else {
+	$serverpost=&Apache::lonnet::allowed('psa','/');
+    }
+# ------------------------------------------------------------ Process commands
+    if ($serverpost) {
+	if ($ENV{'form.serveraction'}) {
+	    foreach (keys %ENV) {
+		if ($_=~/^form\.postto\_(\w+)/) {
+		    $r->print( 
+			'<br />Posting '.$1.': '.&Apache::lonnet::postannounce
+			($1,$ENV{'form.serverannnounce'}));
+		}
+	    }
+	}
+	$r->print(<<SERVERANNOUNCE);
+<form name="serveranno" method="post">
+<h3>Post Server Announcements</h3>
+Post announcements to the system login and roles screen<br />
+<i>(leave blank to delete announcement)</i><br />
+<textarea name="serverannnounce" cols="60" rows="5"></textarea><br />
+Check machines:<br />
+SERVERANNOUNCE
+# list servers
+    foreach (sort keys %Apache::lonnet::hostname) {
+	if (&Apache::lonnet::allowed('psa',$Apache::lonnet::hostdom{$_})) {
+	    $r->print ('<br /><input type="checkbox" name="postto_'.$_.'" /> '.
+		       $_.' <tt>'.$Apache::lonnet::hostname{$_}.'</tt> '.
+		       '<a href="http://'.$Apache::lonnet::hostname{$_}.
+		       '/announcement.txt" target="annowin">current</a>');
+	}
+    }
+    $r->print(
+  '<br /><input type="submit" name="serveraction" value="Post"></form><hr />');
+    }
     if ($allowed) {
         my $coursenum=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
         my $coursedom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.398 loncom/lonnet/perl/lonnet.pm:1.399
--- loncom/lonnet/perl/lonnet.pm:1.398	Wed Aug  6 13:00:30 2003
+++ loncom/lonnet/perl/lonnet.pm	Tue Aug 12 15:46:04 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.398 2003/08/06 17:00:30 albertel Exp $
+# $Id: lonnet.pm,v 1.399 2003/08/12 19:46:04 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1282,6 +1282,34 @@
         }
      }
     return %returnhash;
+}
+
+# ----------------------------------------------------- Frontpage Announcements
+#
+#
+
+sub postannounce {
+    my ($server,$text)=@_;
+    unless (&allowed('psa',$hostdom{$server})) { return 'refused'; }
+    unless ($text=~/\w/) { $text=''; }
+    return &reply('setannounce:'.&escape($text),$server);
+}
+
+sub getannounce {
+    if (my $fh=Apache::File->new($perlvar{'lonDocRoot'}.'/announcement.txt')) {
+	my $announcement='';
+	while (<$fh>) { $announcement .=$_; }
+	$fh->close();
+	if ($announcement=~/\w/) { 
+	    return 
+   '<table bgcolor="#FF5555" cellpadding="5" cellspacing="3">'.
+   '<tr><td bgcolor="#FFFFFF"><pre>'.$announcement.'</pre></td></tr></table>'; 
+	} else {
+	    return '';
+	}
+    } else {
+	return '';
+    }
 }
 
 # ---------------------------------------------------------- Course ID routines

--www1060717565--