--- loncom/interface/loncommunicate.pm 2004/09/10 06:38:24 1.23 +++ loncom/interface/loncommunicate.pm 2007/01/31 16:02:49 1.41 @@ -1,7 +1,7 @@ # The LearningOnline Network # Communicate # -# $Id: loncommunicate.pm,v 1.23 2004/09/10 06:38:24 www Exp $ +# $Id: loncommunicate.pm,v 1.41 2007/01/31 16:02:49 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -31,133 +31,95 @@ package Apache::loncommunicate; use strict; use Apache::Constants qw(:common); -use Apache::lonmsg(); +use Apache::lonmsgdisplay(); use Apache::loncommon; use Apache::lonlocal; +use Apache::lonnet; sub menu { my $r=shift; + my $crstype = 'Course'; + my $usertype = 'Student'; + if (defined($env{'course.'.$env{'request.course.id'}.'.type'})) { + $crstype = $env{'course.'.$env{'request.course.id'}.'.type'}; + if ($crstype eq 'Group') { + $usertype = 'Member'; + } + } my %lt=&Apache::lonlocal::texthash( -'mnf' => 'Make New Folder', 'vcm' => 'View Critical Messages', 'smu' => 'Send Message to User(s)', -'bmc' => 'Broadcast Message to Course', -'dmu' => 'Distribute Messages from Uploaded File to Course', +'bmc' => "Broadcast Message to $crstype", +'dmu' => "Distribute Messages from Uploaded File to $crstype", 'unr' => 'User Notes, Records of Face-to-Face Discussions, and Critical Messages', -'nm' => 'New Messages', -'su' => 'Subject', -'da' => 'Date', -'us' => 'Username', -'op' => 'Open', -'do' => 'Domain', -'cbs' => 'Configure blocking of student communication during exams' +'cbs' => "Configure Blocking of $usertype Communication during Exams", ); my %help=(); foreach ('Course_Face_To_Face_Records,Course_Critical_Message', 'Course_Broadcast_Message') { $help{$_}=&Apache::loncommon::help_open_topic($_); } - my $folderlist=&Apache::lonmsg::folderlist(); # ------------------------------------------------------------------------ Menu - $r->print(< - - - + my ($can_srm,$can_dcm,$can_dff); + if ($env{'request.course.id'}) { + if ((&Apache::lonnet::allowed('srm',$env{'request.course.id'})) || + (&Apache::lonnet::allowed('srm',$env{'request.course.id'}.'/'. + $env{'request.course.sec'}))) { + $can_srm = 1; + } + if ((&Apache::lonnet::allowed('dcm',$env{'request.course.id'})) || + (&Apache::lonnet::allowed('dcm',$env{'request.course.id'}.'/'. + $env{'request.course.sec'}))) { + $can_dcm = 1; + } + if ((&Apache::lonnet::allowed('dff',$env{'request.course.id'})) || + (&Apache::lonnet::allowed('dff',$env{'request.course.id'}.'/'. + $env{'request.course.sec'}))) { + $can_dff = 1; + } + } + $r->print(< - + + $lt{'smu'} - + + + END - if (($ENV{'request.course.id'}) && - (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) { + if ($can_srm) { $r->print(< + + $lt{'bmc'}$help{'Course_Broadcast_Message'} - - + + $lt{'dmu'} - +END + } + if ($can_dcm || $can_dff) { + $r->print(''); + } + if ($can_dff) { + $r->print(< $lt{'unr'}$help{'Course_Face_To_Face_Records,Course_Critical_Message'} - - - $lt{'cbs'} - + END } - $r->print(''); - my @msgids = sort split(/\&/,&Apache::lonnet::reply - ('keys:'.$ENV{'user.domain'}.':'. - $ENV{'user.name'}.':nohist_email', - $ENV{'user.home'})); - my @newmsgs; - my %setters = (); - my $startblock = 0; - my $endblock = 0; - my %blocked = (); - my $numblocked = 0; - # Check for blocking of display because of scheduled online exams. - &Apache::lonmsg::blockcheck(\%setters,\$startblock,\$endblock); - foreach (@msgids) { - my ($sendtime,$shortsubj,$fromname,$fromdom,$status)= - &Apache::lonmsg::unpackmsgid($_); - if (defined($sendtime) && $sendtime!~/error/) { - my $numsendtime = $sendtime; - $sendtime = &Apache::lonlocal::locallocaltime($sendtime); - if ($status eq 'new') { - if ($numsendtime >= $startblock && ($numsendtime <= $endblock && $endblock > 0) ) { - $blocked{$_} = 'ON'; - $numblocked ++; - } else { - push @newmsgs, { - msgid => $_, - sendtime => $sendtime, - shortsub => &Apache::lonnet::unescape($shortsubj), - from => $fromname, - fromdom => $fromdom - } - } - } - } + if ($can_dcm) { + $r->print(' + + '.$lt{'cbs'}.' +'); } - if ($#newmsgs >= 0) { - $r->print(<$lt{'nm'} - - -TABLEHEAD - foreach my $msg (@newmsgs) { - $r->print(<<"ENDLINK"); - - -ENDLINK - foreach ('sendtime','from','fromdom','shortsub') { - $r->print(""); - } - $r->print(""); - } - $r->print('
 $lt{'da'}$lt{'us'}$lt{'do'}$lt{'su'}
$lt{'op'}$msg->{$_}
'); - } elsif ($numblocked == 0) { - $r->print("

".&mt('You have no unread messages')."

"); - } - if ($numblocked > 0) { - my $beginblock = &Apache::lonlocal::locallocaltime($startblock); - my $finishblock = &Apache::lonlocal::locallocaltime($endblock); - if ($numblocked == 1) { - $r->print("

".&mt('You have').' '.$numblocked.' '.&mt('blocked unread message').".

"); - $r->print(&mt('This message is not viewable because').' '); - } else { - $r->print("

".&mt('You have').' '.$numblocked.' '.&mt('blocked unread messages').".

"); - $r->print(&mt('These').' '.$numblocked.' '.&mt('messages are not viewable because ')); - } - $r->print( -&mt('display of LON-CAPA messages sent to you by other students between').' '.$beginblock.' '.&mt('and').' '.$finishblock.' '.&mt('is currently being blocked because of online exams').'.'); - &Apache::lonmsg::build_block_table($r,$startblock,$endblock,\%setters); + if ($can_dff || $can_dcm) { + $r->print(''); } + $r->print(''); } sub handler { @@ -168,12 +130,6 @@ sub handler { # # Start document # - $r->print(< - -The LearningOnline Network with CAPA - -END # ----------------------------------------------------------------- Breadcrumbs &Apache::lonhtmlcommon::clear_breadcrumbs(); @@ -183,8 +139,10 @@ END faq=>12,bug=>'Communication Tools',}); # ---------------------------------------------------------------------- Header - &Apache::lonmsg::header($r); + &Apache::lonmsgdisplay::header($r); &menu($r); + &Apache::lonmsgdisplay::disall($r); + $r->print(&Apache::loncommon::end_page()); return OK; }