--- loncom/interface/lonmsg.pm 2004/03/01 23:06:17 1.71.2.1 +++ loncom/interface/lonmsg.pm 2004/01/28 20:48:35 1.81 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines for messaging # -# $Id: lonmsg.pm,v 1.71.2.1 2004/03/01 23:06:17 albertel Exp $ +# $Id: lonmsg.pm,v 1.81 2004/01/28 20:48:35 albertel 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 @@ -270,26 +255,67 @@ sub author_res_msg { my ($filename,$message)=@_; unless ($message) { return 'empty'; } $filename=&Apache::lonnet::declutter($filename); - my ($domain,$author)=split(/\//,$filename); + my ($domain,$author,@dummy)=split(/\//,$filename); my $homeserver=&Apache::lonnet::homeserver($author,$domain); if ($homeserver ne 'no_host') { my $id=unpack("%32C*",$message); my $msgid; - ($msgid,$message)=&packagemsg("Error: [$filename]",$message); - #FIXME this should be nohist_res_msg, we need to provide an interface - # to this hash BUG#2444 - #return &Apache::lonnet::reply('put:'.$domain.':'.$author. - # ':nohist_res_msg:'. - # &Apache::lonnet::escape($filename.'_'.$id).'='. - # &Apache::lonnet::escape($message),$homeserver); + ($msgid,$message)=&packagemsg($filename,$message); return &Apache::lonnet::reply('put:'.$domain.':'.$author. - ':nohist_email:'. - &Apache::lonnet::escape($msgid).'='. - &Apache::lonnet::escape($message),$homeserver); + ':nohist_res_msgs:'. + &Apache::lonnet::escape($filename.'_'.$id).'='. + &Apache::lonnet::escape($message),$homeserver); } 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 { @@ -839,7 +865,6 @@ ENDCOMP } else { # $broadcast is 'upload' $r->print(< -

Generate messages from a file

Subject: @@ -999,7 +1024,9 @@ sub handler { if (!$ENV{'form.display'}) { $r->print('EMail and Messaging'. &Apache::loncommon::studentbrowser_javascript().''. - &Apache::loncommon::bodytag('EMail and Messages')); + &Apache::loncommon::bodytag('EMail and Messages'). + &Apache::loncommon::help_open_faq(12). + &Apache::loncommon::help_open_bug('Communication Tools')); } if ($ENV{'form.display'}) { my $msgid=$ENV{'form.display'}; @@ -1026,7 +1053,9 @@ sub handler { } $r->print(&Apache::loncommon::studentbrowser_javascript(). ''. - &Apache::loncommon::bodytag('EMail and Messages')); + &Apache::loncommon::bodytag('EMail and Messages'). + &Apache::loncommon::help_open_faq(12). + &Apache::loncommon::help_open_bug('Communication Tools')); $r->print(''.&mt('Subject').': '.$content{'subject'}. '
'.&mt('From').': '. &Apache::loncommon::aboutmewrapper( @@ -1055,7 +1084,7 @@ $content{'sendername'},$content{'senderd '">'.&mt('Next').''); } $r->print('

'.
-             &Apache::lontexconvert::msgtexconverted($content{'message'}).
+             &Apache::lontexconvert::msgtexconverted($content{'message'},1).
              '

'.$content{'citation'}); } elsif ($ENV{'form.replyto'}) { &comprep($r,$ENV{'form.replyto'});