--- loncom/interface/lonmsg.pm 2003/10/15 21:10:24 1.69 +++ loncom/interface/lonmsg.pm 2003/12/31 02:33:27 1.77 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines for messaging # -# $Id: lonmsg.pm,v 1.69 2003/10/15 21:10:24 www Exp $ +# $Id: lonmsg.pm,v 1.77 2003/12/31 02:33:27 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -25,23 +25,8 @@ # # http://www.lon-capa.org/ # -# -# (Routines to control the menu -# -# (TeX Conversion Module -# -# 05/29/00,05/30 Gerd Kortemeyer) -# -# 10/05 Gerd Kortemeyer) -# -# 10/19,10/20,10/30, -# 02/06/01 Gerd Kortemeyer -# 07/27 Guy Albertelli -# 07/27,07/28,07/30,08/03,08/06,08/08,08/09,08/10,8/13,8/15, -# 10/1,11/5 Gerd Kortemeyer -# YEAR=2002 -# 1/1,3/18 Gerd Kortemeyer -# + + package Apache::lonmsg; =pod @@ -284,6 +269,53 @@ sub author_res_msg { return 'no_host'; } +# =========================================== Retrieve author resource messages + +sub retrieve_author_res_msg { + my $url=shift; + $url=&Apache::lonnet::declutter($url); + my ($domain,$author)=($url=~/^(\w+)\/(\w+)\//); + my %errormsgs=&Apache::lonnet::dump('nohist_res_msgs',$domain,$author); + my $msgs=''; + foreach (keys %errormsgs) { + if ($_=~/^\Q$url\E\_\d+$/) { + my %content=&unpackagemsg($errormsgs{$_}); + $msgs.='

'. + $content{'time'}.': '.$content{'message'}. + '

'; + } + } + return $msgs; +} + + +# =============================== Delete all author messages related to one URL + +sub del_url_author_res_msg { + my $url=shift; + $url=&Apache::lonnet::declutter($url); + my ($domain,$author)=($url=~/^(\w+)\/(\w+)\//); + my @delmsgs=(); + foreach (&Apache::lonnet::getkeys('nohist_res_msgs',$domain,$author)) { + if ($_=~/^\Q$url\E\_\d+$/) { + push (@delmsgs,$_); + } + } + return &Apache::lonnet::del('nohist_res_msgs',\@delmsgs,$domain,$author); +} + +# ================= Return hash with URLs for which there is a resource message + +sub all_url_author_res_msg { + my ($author,$domain)=@_; + my %returnhash=(); + foreach (&Apache::lonnet::getkeys('nohist_res_msgs',$domain,$author)) { + $_=~/^(.+)\_\d+/; + $returnhash{$1}=1; + } + return %returnhash; +} + # ================================================== Critical message to a user sub user_crit_msg_raw { @@ -1060,7 +1092,7 @@ $content{'sendername'},$content{'senderd &statuschange($msgid,'replied'); if ((($ENV{'form.critmsg'}) || ($ENV{'form.sendbck'})) && (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) { - $r->print(&mt('Sending critical').': '. + $r->print(&mt('Sending critical message').': '. &user_crit_msg($content{'sendername'}, $content{'senderdomain'}, &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}), @@ -1118,6 +1150,7 @@ $content{'sendername'},$content{'senderd } elsif ($ENV{'form.recordftf'}) { &facetoface($r,$ENV{'form.recordftf'}); } elsif ($ENV{'form.sendmail'}) { + my $sendstatus=''; if ($ENV{'form.send'}) { my %content=(); undef %content; @@ -1160,24 +1193,32 @@ $content{'sendername'},$content{'senderd if ($toaddr{$_}) { $msgtxt.='
'.$toaddr{$_}; } if ((($ENV{'form.critmsg'}) || ($ENV{'form.sendbck'})) && (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) { - $r->print('Sending critical: '. - &user_crit_msg($recuname,$recdomain, + $r->print(&mt('Sending critical message').' ...'); + $sendstatus.=' '.&user_crit_msg($recuname,$recdomain, &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}), $msgtxt, - $ENV{'form.sendbck'})); + $ENV{'form.sendbck'}); } else { - $r->print('Sending: '.&user_normal_msg($recuname,$recdomain, - &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}), + $r->print(&mt('Sending').' ...'); + $sendstatus.=' '.&user_normal_msg($recuname,$recdomain, + &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}), $msgtxt, - $content{'citation'})); + $content{'citation'}); } $r->print('
'); } } - if ($ENV{'form.displayedcrit'}) { - &discrit($r); + if ($sendstatus=~/^(\s*(?:ok|con_delayed)\s*)*$/) { + if ($ENV{'form.displayedcrit'}) { + &discrit($r); + } else { + &disall($r); + } } else { - &disall($r); + $r->print( + '

'.&mt('Could not deliver message').'

'. + &mt('Please use the browser "Back" button and correct the recipient addresses') + ); } } else { &disall($r);