--- loncom/interface/lonmsgdisplay.pm 2006/04/26 14:10:58 1.18 +++ loncom/interface/lonmsgdisplay.pm 2006/10/04 20:26:48 1.41 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines for messaging display # -# $Id: lonmsgdisplay.pm,v 1.18 2006/04/26 14:10:58 albertel Exp $ +# $Id: lonmsgdisplay.pm,v 1.41 2006/10/04 20:26:48 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -125,6 +125,9 @@ use Apache::lonlocal; use Apache::loncommunicate; use Apache::lonfeedback; use Apache::lonrss(); +use Apache::lonselstudent(); +use lib '/home/httpd/lib/perl/'; +use LONCAPA; # Querystring component with sorting type my $sqs; @@ -214,7 +217,7 @@ sub movemsg { # Copy message my %message=&Apache::lonnet::get('nohist_email'.$srcsuffix,[$msgid]); if (!exists($message{$msgid}) || $message{$msgid} eq '') { - if (&Apache::slotrequest::network_error(%message)) { + if (&Apache::lonnet::error(%message)) { return (0,&mt('Message not moved, A network error occurred.')); } else { return (0,&mt('Message not moved as the message is no longer in the source folder.')); @@ -223,7 +226,7 @@ sub movemsg { my $result =&Apache::lonnet::put('nohist_email'.$trgsuffix, {$msgid => $message{$msgid}}); - if (&Apache::slotrequest::network_error($result)) { + if (&Apache::lonnet::error($result)) { return (0,&mt('Message not moved, A network error occurred.')); } @@ -231,12 +234,12 @@ sub movemsg { unless ($trgfolder eq 'trash') { my %status=&Apache::lonnet::get('email_status'.$srcsuffix,[$msgid]); # a non-existant status is the mark of an unread msg - if (&Apache::slotrequest::network_error(%status)) { + if (&Apache::lonnet::error(%status)) { return (0,&mt('Message copied to new folder but status was not, A network error occurred.')); } my $result=&Apache::lonnet::put('email_status'.$trgsuffix, {$msgid => $status{$msgid}}); - if (&Apache::slotrequest::network_error($result)) { + if (&Apache::lonnet::error($result)) { return (0,&mt('Message copied to new folder but status was not, A network error occurred.')); } } @@ -246,10 +249,10 @@ sub movemsg { &Apache::lonnet::del('nohist_email'.$srcsuffix,[$msgid]); my $result_del_stat = &Apache::lonnet::del('email_status'.$srcsuffix,[$msgid]); - if (&Apache::slotrequest::network_error($result_del_msg)) { + if (&Apache::lonnet::error($result_del_msg)) { return (0,&mt('Message copied, but unable to delete the original from the source folder.')); } - if (&Apache::slotrequest::network_error($result_del_stat)) { + if (&Apache::lonnet::error($result_del_stat)) { return (0,&mt('Message copied, but unable to delete the original status from the source folder.')); } @@ -259,89 +262,219 @@ sub movemsg { # ======================================================= Display a course list sub discourse { - my $r=shift; - my $classlist = &Apache::loncoursedata::get_classlist(); - my $now=time; - my %lt=&Apache::lonlocal::texthash('cfa' => 'Check All', - 'cfs' => 'Check Section/Group', - 'cfn' => 'Uncheck All'); - $r->print(< - -  - -  - -

-ENDDISHEADER - my %coursepersonnel=&Apache::lonnet::get_course_adv_roles(); - $r->print(''); - foreach my $role (sort keys %coursepersonnel) { - foreach (split(/\,/,$coursepersonnel{$role})) { - my ($puname,$pudom)=split(/\:/,$_); - $r->print(''. - ''); - } - } - $r->print('
('.$_.'),'.$role.'
'); - my $sort = sub { - my $aname=lc($classlist->{$a}[&Apache::loncoursedata::CL_FULLNAME()]); - if (!$aname) { $aname=$a; } - my $bname=lc($classlist->{$b}[&Apache::loncoursedata::CL_FULLNAME()]); - if (!$bname) { $bname=$b; } - return $aname cmp $bname; - }; - foreach my $student (sort $sort (keys(%{$classlist}))) { - my $info=$classlist->{$student}; - my ($sname,$sdom,$status,$fullname,$section) = - (@{$info}[&Apache::loncoursedata::CL_SNAME(), - &Apache::loncoursedata::CL_SDOM(), - &Apache::loncoursedata::CL_STATUS(), - &Apache::loncoursedata::CL_FULLNAME(), - &Apache::loncoursedata::CL_SECTION()]); - next if ($status ne 'Active'); - next if ($env{'request.course.sec'} && - $section ne $env{'request.course.sec'}); - my $key = 'send_to_&&&'.$section.'&&&_'.$student; - if (! defined($fullname) || $fullname eq '') { $fullname = $sname; } - $r->print(''); + |; +} + +sub groupmail_header { + my ($action,$group,$cdom,$cnum) = @_; + my ($description,$refarg); + if (!$cdom || !$cnum) { + $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + } + if (exists($env{'form.ref'})) { + $refarg = 'ref='.$env{'form.ref'}; + } + if (!$group) { + $group = $env{'form.group'}; + } + if ($group eq '') { + return ''; + } else { + my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum,$group); + if (defined($curr_groups{$group})) { + my %groupinfo = + &Apache::longroup::get_group_settings($curr_groups{$group}); + $description = &unescape($groupinfo{'description'}); + } } - $r->print('
'.$sname.':'.$sdom.''.$section. - '
'); + &Apache::lonhtmlcommon::clear_breadcrumbs(); + if ($refarg) { + &Apache::lonhtmlcommon::add_breadcrumb + ({href=>"/adm/coursegroups", + text=>"Groups", + title=>"View course groups"}); + } + &Apache::lonhtmlcommon::add_breadcrumb + ({href=>"/adm/$cdom/$cnum/$group/smppg?$refarg", + text=>"Group: $description", + title=>"Go to group's home page"}, + {href=>"/adm/email?compose=group&group=". + "$env{'form.group'}&$refarg", + text=>"Send a Message in a Group", + title=>"Compose Group Email Message"},); + if ($action eq 'sending') { + &Apache::lonhtmlcommon::add_breadcrumb + ({text=>"Messages being sent.", + title=>"Messages sent"},); + } + my $groupheader = &Apache::loncommon::start_page('Group Email'); + $groupheader .= &Apache::lonhtmlcommon::breadcrumbs + ('Group - '.$env{'form.group'}.' Email'); + return $groupheader; +} + +sub groupmail_sent { + my ($group,$cdom,$cnum) = @_; + my $refarg; + if (exists($env{'form.ref'})) { + $refarg = 'ref='.$env{'form.ref'}; + } + my $output .= '

'. + &mt('Send another group email').''.'   '. + ''. &mt('Return to group page').''; + return $output; } # ==================================================== Display Critical Message @@ -400,7 +533,7 @@ sub sortedmessages { } foreach my $msgid (@messages) { - my $esc_msgid=&Apache::lonnet::escape($msgid); + my $esc_msgid=&escape($msgid); my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$fromcid)= &Apache::lonmsg::unpackmsgid($esc_msgid,$folder,undef, \%status_cache); @@ -507,7 +640,7 @@ sub disnew { my %lt=&Apache::lonlocal::texthash( 'nm' => 'New Messages', 'su' => 'Subject', - 'co' => 'Course', + 'co' => 'Course/Group', 'da' => 'Date', 'us' => 'Username', 'op' => 'Open', @@ -526,7 +659,7 @@ sub disnew { &Apache::lonnet::get('email_status',\@msgids); my %descriptions; foreach (@msgids) { - my $msgid=&Apache::lonnet::escape($_); + my $msgid=&escape($_); my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)= &Apache::lonmsg::unpackmsgid($msgid,undef,undef,\%status_cache); if (defined($sendtime) && $sendtime!~/error/) { @@ -625,7 +758,7 @@ sub disfolder { function uncheckall() { for (i=0; iprint(''); if ($env{'form.sortedby'} eq "revcourse") { - $r->print(''.&mt('Course').''); + $r->print(''.&mt('Course/Group').''); } else { - $r->print(''.&mt('Course').''); + $r->print(''.&mt('Course/Group').''); } $r->print(''); if ($env{'form.sortedby'} eq "revstatus") { @@ -709,7 +842,7 @@ ENDDISHEADER $dis_name = join('
',@{$recv_name}); $dis_domain = join('
',@{$recv_domain}); } else { - my $msg_id = &Apache::lonnet::unescape($origID); + my $msg_id = &unescape($origID); my %message = &Apache::lonnet::get('nohist_email'.$suffix, [$msg_id]); my %content = &Apache::lonmsg::unpackagemsg($message{$msg_id}); @@ -728,7 +861,7 @@ ENDDISHEADER } elsif ($status eq 'deleted') { # purge my ($result,$msg) = - &movemsg(&Apache::lonnet::unescape($origID),$folder,'trash'); + &movemsg(&unescape($origID),$folder,'trash'); } } @@ -763,8 +896,14 @@ ENDDISHEADER sub compout { my ($r,$forwarding,$replying,$broadcast,$replycrit,$folder,$dismode)=@_; my $suffix=&Apache::lonmsg::foldersuffix($folder); - - if ($broadcast eq 'individual') { + my ($cdom,$cnum,$group,$refarg); + if (exists($env{'form.group'})) { + $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + $group = $env{'form.group'}; + my $action = 'composing'; + $r->print(&groupmail_header($action,$group,$cdom,$cnum)); + } elsif ($broadcast eq 'individual') { &printheader($r,'/adm/email?compose=individual', 'Send a Message'); } elsif ($broadcast) { @@ -772,15 +911,15 @@ sub compout { 'Broadcast Message'); } elsif ($forwarding) { &Apache::lonhtmlcommon::add_breadcrumb - ({href=>"/adm/email?display=".&Apache::lonnet::escape($forwarding), + ({href=>"/adm/email?display=".&escape($forwarding), text=>"Display Message"}); - &printheader($r,'/adm/email?forward='.&Apache::lonnet::escape($forwarding), + &printheader($r,'/adm/email?forward='.&escape($forwarding), 'Forwarding a Message'); } elsif ($replying) { &Apache::lonhtmlcommon::add_breadcrumb - ({href=>"/adm/email?display=".&Apache::lonnet::escape($replying), + ({href=>"/adm/email?display=".&escape($replying), text=>"Display Message"}); - &printheader($r,'/adm/email?replyto='.&Apache::lonnet::escape($replying), + &printheader($r,'/adm/email?replyto='.&escape($replying), 'Replying to a Message'); } elsif ($replycrit) { $r->print('

'.&mt('Replying to a Critical Message').'

'); @@ -830,7 +969,7 @@ sub compout { $dismsg=&mt('Forwarded message from').' '. $content{'sendername'}.' '.&mt('at').' '.$content{'senderdomain'}; if ($content{'baseurl'}) { - $disbase=''; + $disbase=''; } } if ($replying) { @@ -846,23 +985,44 @@ sub compout { $dismsg=~s/\f/\n/g; $dismsg=~s/\n+/\n\> /g; if ($content{'baseurl'}) { - $disbase=''; + $disbase=''; if ($env{'user.adv'}) { $disbase.=' '. + &escape($content{'baseurl'}).'" target="comments">'. &mt('Show re-usable messages').'
'; } } } my $citation=&displayresource(%content); + my ($can_grp_broadcast,$viewgrps,$editgrps); if ($env{'form.recdom'}) { $defdom=$env{'form.recdom'}; } - $r->print( + if ($env{'form.text'}) { $dismsg=$env{'form.text'}; } + if ($env{'form.subject'}) { $dissub=$env{'form.subject'}; } + $r->print( '
'."\n". - ''."\n". - ''); - unless (($broadcast eq 'group') || ($broadcast eq 'upload')) { + ''."\n"); + if ($broadcast eq 'group' && $env{'form.group'} ne '') { + $can_grp_broadcast = + &Apache::lonnet::allowed('sgb',$env{'request.course.id'}.'/'. + $group); + $viewgrps = + &Apache::lonnet::allowed('vcg',$env{'request.course.id'}. + ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')); + $editgrps = + &Apache::lonnet::allowed('mdg',$env{'request.course.id'}. + ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')); + if ($viewgrps || $editgrps || $can_grp_broadcast) { + $r->print(&disgroup($cdom,$cnum,$group,$viewgrps,$editgrps)); + } + } + $r->print('
'); + if (($broadcast eq 'group') && ($group ne '') && + (!$can_grp_broadcast && !$viewgrps && !$editgrps)) { + $r->print(&recipient_input_row($cdom,%lt)); + } + if (($broadcast ne 'group') && ($broadcast ne 'upload')) { if ($replying) { $r->print(''); } else { - my $domform = &Apache::loncommon::select_dom_form($defdom,'recdomain'); - my $selectlink=&Apache::loncommon::selectstudent_link - ('compemail','recuname','recdomain'); - $r->print(<<"ENDREC"); - - - -ENDREC + $r->print(&recipient_input_row($defdom,%lt)); } } my $latexHelp = Apache::loncommon::helpLatexCheatsheet(); @@ -902,6 +1055,14 @@ $disbase
$citation ENDCOMP + if (exists($env{'form.ref'})) { + $r->print(''); + } + if (exists($env{'form.group'})) { + $r->print(''); + } } else { # $broadcast is 'upload' $r->print(< @@ -931,7 +1092,13 @@ $dispcrit ENDUPLOAD } if ($broadcast eq 'group') { - &discourse($r); + if ($group eq '') { + my $studentsel = &discourse(); + $r->print($studentsel); + } + } + if ($env{'form.displayedcrit'}) { + $r->print(''); } $r->print(''. &Apache::lonfeedback::generate_preview_button('compemail','message'). @@ -940,6 +1107,20 @@ ENDUPLOAD # ---------------------------------------------------- Display all face to face +sub recipient_input_row { + my ($dom,%lt) = @_; + my $domform = &Apache::loncommon::select_dom_form($dom,'recdomain'); + my $selectlink= + &Apache::loncommon::selectstudent_link('compemail','recuname', + 'recdomain'); + my $output = <<"ENDREC"; + + + +ENDREC + return $output; +} + sub retrieve_instructor_comments { my ($user,$domain)=@_; my $target=$env{'form.grade_target'}; @@ -992,7 +1173,7 @@ sub disfacetoface { $result .='

'.&mt('Broadcast Message').'

'; if ($content{'subject'}=~/^Broadcast\./) { if (defined($content{'coursemsgid'})) { - my $crsmsgid = &Apache::lonnet::escape($content{'coursemsgid'}); + my $crsmsgid = &escape($content{'coursemsgid'}); my $broadcast_message = &general_message($crsmsgid); $content{'message'} = ''.&mt('Subject').': '.$content{'message'}.'
'.$broadcast_message; } else { @@ -1005,7 +1186,7 @@ sub disfacetoface { } else { $result.='

'.&mt('Critical Message').'

'; if (defined($content{'coursemsgid'})) { - my $crsmsgid=&Apache::lonnet::escape($content{'coursemsgid'}); + my $crsmsgid=&escape($content{'coursemsgid'}); my $critical_message = &general_message($crsmsgid); $content{'message'} = ''.&mt('Subject').': '.$content{'message'}.'
'.$critical_message; } else { @@ -1026,10 +1207,11 @@ $content{'sendername'}.':'. } # Check to see if there were any messages. if ($result eq '') { + my $lctype = lc(&Apache::loncommon::course_type()); if ($target ne 'tex') { - $r->print("

".&mt("No notes, face-to-face discussion records, critical messages, or broadcast messages in this course.")."

"); + $r->print("

".&mt('No notes, face-to-face discussion records, critical messages, or broadcast messages in this [_1].',$lctype)."

"); } else { - $r->print('\textbf{'.&mt("No notes, face-to-face discussion records, critical messages or broadcast messages in this course.").'}\\\\'); + $r->print('\textbf{'.&mt('No notes, face-to-face discussion records, critical messages or broadcast messages in this [_1].',$lctype).'}\\\\'); } } else { $r->print($result); @@ -1058,6 +1240,9 @@ sub facetoface { $r->print('Not allowed'); return; } + my $crstype = &Apache::loncommon::course_type(); + my $leaders = ($crstype eq 'Group') ? 'coordinators and leaders' + : 'faculty and staff'; &printheader($r, '/adm/email?recordftf=query', "User Notes, Face-to-Face, Critical Messages, Broadcast Messages"); @@ -1075,9 +1260,9 @@ sub facetoface { ('stdselect','recuname','recdomain'); my %lt=&Apache::lonlocal::texthash('user' => 'Username', 'dom' => 'Domain', - 'head' => 'User Notes, Records of Face-To-Face Discussions, Critical Messages, and Broadcast Messages in Course', + 'head' => "User Notes, Records of Face-To-Face Discussions, Critical Messages, and Broadcast Messages in $crstype", 'subm' => 'Retrieve discussion and message records', - 'newr' => 'New Record (record is visible to course faculty and staff)', + 'newr' => 'New Record (record is visible to '.lc($crstype).' '.$leaders.')', 'post' => 'Post this Record'); $r->print(<<"ENDTREC");

$lt{'head'}

@@ -1098,13 +1283,9 @@ ENDTREC ($env{'form.recdomain'}) && ($env{'form.recuname'})) { chomp($env{'form.newrecord'}); if ($env{'form.newrecord'}) { - my $recordtxt = $env{'form.newrecord'}; - &Apache::lonmsg::user_normal_msg_raw( - $env{'course.'.$env{'request.course.id'}.'.num'}, - $env{'course.'.$env{'request.course.id'}.'.domain'}, - &mt('Record'). - ' ['.$env{'form.recuname'}.':'.$env{'form.recdomain'}.']', - $recordtxt); + &Apache::lonmsg::store_instructor_comment($env{'form.newrecord'}, + $env{'form.recuname'}, + $env{'form.recdomain'}); } $r->print('

'.&Apache::loncommon::plainname($env{'form.recuname'}, $env{'form.recdomain'}).'

'); @@ -1136,10 +1317,12 @@ sub examblock { $r->print('Not allowed'); return; } + my $usertype = (&Apache::loncommon::course_type() eq 'Group') ? 'members' + : 'students'; my %lt=&Apache::lonlocal::texthash( 'comb' => 'Communication Blocking', 'cbds' => 'Communication blocking during scheduled exams', - 'desc' => 'You can use communication blocking to prevent students enrolled in this course from displaying LON-CAPA messages sent by other students during an online exam. As blocking of communication could potentially interrupt legitimate communication between students who are also both enrolled in a different LON-CAPA course, please be careful that you select the correct start and end times for your scheduled exam when setting or modifying these parameters.', + 'desc' => "You can use communication blocking to prevent $usertype enrolled in this course from displaying LON-CAPA messages sent by other $usertype during an online exam. As blocking of communication could potentially interrupt legitimate communication between $usertype who are also both enrolled in a different LON-CAPA course, please be careful that you select the correct start and end times for your scheduled exam when setting or modifying these parameters.", 'mecb' => 'Modify existing communication blocking periods', 'ncbc' => 'No communication blocks currently stored' ); @@ -1310,7 +1493,7 @@ END my ($setuname,$setudom,$title) = &parse_block_record($$records{$record}); - $title = &HTML::Entities::encode($title,'"<>'); + $title = &HTML::Entities::encode($title,'"<>&'); my $settername = &Apache::loncommon::plainname($setuname,$setudom); $r->print(&Apache::loncommon::start_data_table_row()); $r->print(<<"END"); @@ -1393,12 +1576,9 @@ sub blockcheck { # for students. return if (!%live_courses); - &Apache::lonnet::logthis("hmm"); - &Apache::lonnet::logthis(join(" ",%live_courses)); - &Apache::lonnet::logthis(join(" ",%staff_of)); - foreach my $course (keys(%live_courses)) { - my ($cdom,$cnum) = split(/_/,$course); + my $cdom = $env{'course.'.$course.'.domain'}; + my $cnum = $env{'course.'.$course.'.num'}; # if they are a staff member and are currently not playing student next if ( $staff_of{$course} @@ -1430,7 +1610,7 @@ sub build_block_table { my ($r,$startblock,$endblock,$setters) = @_; my %lt = &Apache::lonlocal::texthash( 'cacb' => 'Currently active communication blocks', - 'cour' => 'Course', + 'cour' => 'Course/Group', 'dura' => 'Duration', 'blse' => 'Block set by' ); @@ -1474,6 +1654,8 @@ sub displaymessage { my $startblock = 0; my $endblock = 0; my $numblocked = 0; + my $crstype = &Apache::loncommon::course_type(); + # info to generate "next" and "previous" buttons and check if message is blocked &blockcheck(\%setters,\$startblock,\$endblock); my @messages=&sortedmessages(\%blocked,$startblock,$endblock,\$numblocked,$folder); @@ -1489,7 +1671,7 @@ sub displaymessage { my $counter=0; $r->print('
');
-    my $escmsgid=&Apache::lonnet::escape($msgid);
+    my $escmsgid=&escape($msgid);
     foreach (@messages) {
 	if ($_->[5] eq $escmsgid){
 	    last;
@@ -1499,17 +1681,17 @@ sub displaymessage {
     $r->print('
'); my $number_of_messages = scalar(@messages); #subtract 1 for last index # start output - &printheader($r,'/adm/email?display='.&Apache::lonnet::escape($msgid),'Display a Message','',$content{'baseurl'}); + &printheader($r,'/adm/email?display='.&escape($msgid),'Display a Message','',$content{'baseurl'}); my %courseinfo=&Apache::lonnet::coursedescription($content{'courseid'}); # Functions $r->print('
'.&mt('Replying to').' '. &Apache::loncommon::aboutmewrapper( @@ -873,14 +1033,7 @@ sub compout { ''. '
$lt{'us'}:$selectlink
$lt{'do'}:$domform
$lt{'us'}:$selectlink
$lt{'do'}:$domform
'. - ''. - ''. - ''. - ''. '
'.&mt('Functions').':'.&mt('Reply').''.&mt('Forward').''.&mt('Mark Unread').''.&mt('Delete').''. $content{'baseurl'}.' ('.&Apache::lonnet::gettitle($content{'baseurl'}).')':''). @@ -1608,13 +1790,12 @@ sub header { my $extra = &Apache::loncommon::studentbrowser_javascript(); if ($baseurl) { - $extra .= ""; + $extra .= ""; } $r->print(&Apache::loncommon::start_page('Communication and Messages', - $extra)); + $extra)); $r->print(&Apache::lonhtmlcommon::breadcrumbs - (undef,($title?$title:'Communication and Messages'))); - + (($title?$title:'Communication and Messages'))); } # ---------------------------------------------------------------- Print header @@ -1638,14 +1819,14 @@ sub storecomment { $cleanmsgtxt.=$_."\n"; } } - my $key=&Apache::lonnet::escape($env{'form.baseurl'}).'___'.time; + my $key=&escape($env{'form.baseurl'}).'___'.time; &Apache::lonnet::put('nohist_stored_comments',{ $key => $cleanmsgtxt }); } sub storedcommentlisting { my ($r)=@_; my %msgs=&Apache::lonnet::dump('nohist_stored_comments',undef,undef, - '^'.&Apache::lonnet::escape(&Apache::lonnet::escape($env{'form.showcommentbaseurl'}))); + '^'.&escape(&escape($env{'form.showcommentbaseurl'}))); $r->print(&Apache::loncommon::start_page('Stored Comment Listing',undef, {'onlybody' => 1})); if ((keys %msgs)[0]=~/^error\:/) { @@ -1670,8 +1851,20 @@ sub sendoffmail { my $sendstatus=''; my %specialmsg_status; my $numspecial = 0; + my ($cdom,$cnum,$group); + if (exists($env{'form.group'})) { + $group = $env{'form.group'}; + } + if (exists($env{'request.course.id'})) { + $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + } if ($env{'form.send'}) { - &printheader($r,'','Messages being sent.'); + if ($group eq '') { + &printheader($r,'','Messages being sent.'); + } else { + $r->print(&groupmail_header('sending',$group)); + } $r->rflush(); my %content=(); undef %content; @@ -1690,13 +1883,27 @@ sub sendoffmail { &statuschange($msgid,'replied',$folder); } + my @to = + &Apache::loncommon::get_env_multiple('form.selectedusers_forminput'); + my $mode = $env{'form.sendmode'}; + my %toaddr; - if ($env{'form.sendmode'} eq 'group') { - foreach my $address (keys(%env)) { - if ($address=~/^form\.send\_to\_\&\&\&[^\&]*\&\&\&\_(.+)$/) { - $toaddr{$1}=''; + if (@to) { + foreach my $dest (@to) { + my ($user,$domain) = split(/:/, $dest); + if (($user ne '') && ($domain ne '')) { + my $address = $user.":".$domain; # How the code below expects it. + $toaddr{$address} = ''; } } + } + + if ($env{'form.sendmode'} eq 'group') { + foreach my $address (keys(%env)) { + if ($address=~/^form\.send\_to\_\&\&\&[^\&]*\&\&\&\_(.+)$/) { + $toaddr{$1}=''; + } + } } elsif ($env{'form.sendmode'} eq 'upload') { foreach my $line (split(/[\n\r\f]+/,$env{'form.upfile'})) { my ($rec,$txt)=split(/\s*\:\s*/,$line); @@ -1706,12 +1913,16 @@ sub sendoffmail { } } } else { - $toaddr{$env{'form.recuname'}.':'.$env{'form.recdomain'}}=''; + if (($env{'form.recuname'} ne '') && ($env{'form.recdomain'} ne '')) { + $toaddr{$env{'form.recuname'}.':'.$env{'form.recdomain'}}=''; + } } if ($env{'form.additionalrec'}) { foreach (split(/\,/,$env{'form.additionalrec'})) { my ($auname,$audom)=split(/\@/,$_); - $toaddr{$auname.':'.$audom}=''; + if (($auname ne "") && ($audom ne "")) { + $toaddr{$auname.':'.$audom}=''; + } } } @@ -1778,22 +1989,20 @@ sub sendoffmail { $subj_prefix = 'Broadcast.'; } my ($specialmsgid,$specialresult); - my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; - my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - my $course_str = &Apache::lonnet::escape('['.$cnum.':'.$cdom.']'); + my $course_str = &escape('['.$cnum.':'.$cdom.']'); if ($numspecial) { $specialresult = &Apache::lonmsg::user_normal_msg_raw($cnum,$cdom,$subj_prefix. ' '.$course_str,$savemsg,undef,undef,undef, undef,undef,\$specialmsgid); - $specialmsgid = &Apache::lonnet::unescape($specialmsgid); + $specialmsgid = &unescape($specialmsgid); } if ($specialresult eq 'ok') { my $record_sent; my @recusers; my @recudoms; my ($stamp,$crssubj,$msgname,$msgdom,$msgcount,$context,$pid) = - split(/\:/,&Apache::lonnet::unescape($specialmsgid)); + split(/\:/,&unescape($specialmsgid)); foreach my $recipient (sort(keys(%toaddr))) { if ($specialmsg_status{$recipient} eq 'ok') { @@ -1835,12 +2044,15 @@ sub sendoffmail { $r->print('
'.&mt('Completed.').''); if ($env{'form.displayedcrit'}) { &discrit($r); + } + if ($group ne '') { + $r->print(&groupmail_sent($group,$cdom,$cnum)); } else { &Apache::loncommunicate::menu($r); } } else { $r->print('

'.&mt('Could not deliver message').' '. - &mt('Please use the browser "Back" button and correct the recipient addresses').'

'); + &mt('Please use the browser "Back" button and correct the recipient addresses '."($sendstatus)").'

'); } } @@ -1861,7 +2073,7 @@ sub handler { ['display','replyto','forward','markread','markdel','markunread', 'sendreply','compose','sendmail','critical','recname','recdom', 'recordftf','sortedby','block','folder','startdis','interdis', - 'showcommentbaseurl','dismode']); + 'showcommentbaseurl','dismode','group','subject','text','ref']); $sqs='&sortedby='.$env{'form.sortedby'}; # ------------------------------------------------------ They checked for email @@ -1883,7 +2095,7 @@ sub handler { unless ($folder) { $folder=''; } else { - $sqs.='&folder='.&Apache::lonnet::escape($folder); + $sqs.='&folder='.&escape($folder); } # ------------------------------------------------------------ Get Display Mode @@ -1891,7 +2103,7 @@ sub handler { unless ($dismode) { $dismode=''; } else { - $sqs.='&dismode='.&Apache::lonnet::escape($dismode); + $sqs.='&dismode='.&escape($dismode); } # --------------------------------------------------------------------- Display @@ -1927,6 +2139,7 @@ sub handler { &compout($r,'',$env{'form.replyto'},undef,undef,$folder,$dismode); } elsif ($env{'form.confirm'}) { &printheader($r,'','Confirmed Receipt'); + my $replying = 0; foreach (keys %env) { if ($_=~/^form\.rec\_(.*)$/) { $r->print(''.&mt('Confirming Receipt').': '. @@ -1937,9 +2150,12 @@ sub handler { $r->print(''.&mt('Confirming Receipt').': '. &Apache::lonmsg::user_crit_received($msgid).'
'); &compout($r,'','','',$msgid); + $replying = 1; } } - &discrit($r); + if (!$replying) { + &discrit($r); + } } elsif ($env{'form.critical'}) { &printheader($r,'','Displaying Critical Messages'); &discrit($r); @@ -1961,7 +2177,7 @@ sub handler { foreach my $key (keys(%env)) { if ($key=~/^form\.delmark_(.*)$/) { my ($result,$msg) = - &movemsg(&Apache::lonnet::unescape($1),$folder, + &movemsg(&unescape($1),$folder, $env{'form.movetofolder'}); if ($result) { $total++; @@ -1988,7 +2204,7 @@ sub handler { foreach my $key (keys(%env)) { if ($key=~/^form\.delmark_(.*)$/) { my ($result,$msg) = - &statuschange(&Apache::lonnet::unescape($1),'deleted', + &statuschange(&unescape($1),'deleted', $folder); if ($result) { $total++; @@ -2025,15 +2241,17 @@ sub handler { &sendoffmail($r,$folder); if ($env{'form.storebasecomment'}) { &storecomment($r); - } + } if (($env{'form.rsspost'}) && ($env{'request.course.id'})) { - &Apache::lonrss::addentry($env{'course.'.$env{'request.course.id'}.'.num'}, + &Apache::lonrss::addentry($env{'course.'.$env{'request.course.id'}.'.num'}, $env{'course.'.$env{'request.course.id'}.'.domain'}, 'Course_Announcements', $env{'form.subject'}, $env{'form.message'},'/adm/communicate','public'); } - &disall($r,($folder?$folder:$dismode)); + if ((!exists($env{'form.group'})) && (!$env{'form.displayedcrit'})) { + &disall($r,($folder?$folder:$dismode)); + } } elsif ($env{'form.newfolder'}) { &printheader($r,'','New Folder'); &makefolder($env{'form.newfolder'}); @@ -2061,9 +2279,3 @@ sub handler { __END__ - - - - - -