--- loncom/interface/lonchat.pm	2006/03/19 22:48:53	1.11
+++ loncom/interface/lonchat.pm	2006/06/28 23:56:09	1.14
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Chat
 #
-# $Id: lonchat.pm,v 1.11 2006/03/19 22:48:53 albertel Exp $
+# $Id: lonchat.pm,v 1.14 2006/06/28 23:56:09 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -38,22 +38,35 @@ sub handler {
     &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;
     return OK if $r->header_only;
-    if (! &Apache::lonnet::allowed('plc',$env{'request.course.id'}.
+    
+    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['group']);
+    my ($group,$group_elem);
+    if (defined($env{'form.group'})) {
+        $group = $env{'form.group'};
+        $group_elem = '<input type="hidden" name="group" value="'.$group.'" />'; 
+        if ((! &Apache::lonnet::allowed('pgc',$env{'request.course.id'}.'/'.
+                                                                    $group))
+            && (! &Apache::lonnet::allowed('vcg',$env{'request.course.id'}))) {
+            return HTTP_NOT_ACCEPTABLE;
+        }
+    } else {
+        if (! &Apache::lonnet::allowed('plc',$env{'request.course.id'}.
               ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')
                                    )) {
-        return HTTP_NOT_ACCEPTABLE;
+            return HTTP_NOT_ACCEPTABLE;
+        }
     }
 
     if ($env{'form.newchat'}) {
-	&Apache::lonnet::chatsend(&Apache::lonfeedback::clear_out_html($env{'form.newchat'}),$env{'form.anonymous'});
+	&Apache::lonnet::chatsend(&Apache::lonfeedback::clear_out_html($env{'form.newchat'}),$env{'form.anonymous'},$group);
     }
 # --------------------------------------------------- Print login screen header
     my $latexHelp = Apache::loncommon::helpLatexCheatsheet();
-    my $loaditems = 'onLoad="this.document.chatentry.newchat.focus();"';
+    my %loaditems = (onload => 'this.document.chatentry.newchat.focus();');
     my $start_page = 
 	&Apache::loncommon::start_page('Chat',undef,
 				       {'only_body'   => 1,
-					'add_entries' => $loaditems,});
+					'add_entries' => \%loaditems,});
     my $end_page = &Apache::loncommon::end_page();
     $r->print(<<ENDDOCUMENT);
 $start_page
@@ -62,6 +75,7 @@ $latexHelp
 <input type="text" size="60" name="newchat">
 <input value="Post Anonymous" name="anonymous" type="submit">
 <input value="Post" name="newentry" type="submit">
+$group_elem
 </form>
 $end_page
 ENDDOCUMENT