--- loncom/interface/lonmsg.pm 2006/12/13 01:45:15 1.190 +++ loncom/interface/lonmsg.pm 2006/12/24 22:13:19 1.191 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines for messaging # -# $Id: lonmsg.pm,v 1.190 2006/12/13 01:45:15 raeburn Exp $ +# $Id: lonmsg.pm,v 1.191 2006/12/24 22:13:19 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -47,7 +47,7 @@ use LONCAPA qw(:DEFAULT :match); sub packagemsg { my ($subject,$message,$citation,$baseurl,$attachmenturl, - $recuser,$recdomain,$msgid,$type,$crsmsgid)=@_; + $recuser,$recdomain,$msgid,$type,$crsmsgid,$symb,$error)=@_; $message =&HTML::Entities::encode($message,'<>&"'); $citation=&HTML::Entities::encode($citation,'<>&"'); $subject =&HTML::Entities::encode($subject,'<>&"'); @@ -78,7 +78,7 @@ sub packagemsg { my $msgcount = &get_uniq(); unless(defined($msgid)) { $msgid = &buildmsgid($now,$subject,$env{'user.name'},$env{'user.domain'}, - $msgcount,$course_context,$$); + $msgcount,$course_context,$symb,$error,$$); } my $result = ''.$env{'user.name'}.''. ''.$env{'user.domain'}.''. @@ -134,7 +134,18 @@ sub packagemsg { if (defined($attachmenturl)) { $result.= ''.$attachmenturl.''; } - return $msgid,$result; + if (defined($symb)) { + $result.= ''.$symb.''; + if (defined($course_context)) { + if ($course_context eq $env{'request.course.id'}) { + my $resource_title = &Apache::lonnet::gettitle($symb); + if (defined($resource_title)) { + $result .= ''.$resource_title.''; + } + } + } + } + return ($msgid,$result); } # ================================================== Unpack message into a hash @@ -178,17 +189,17 @@ sub unpackagemsg { # ======================================================= Get info out of msgid sub buildmsgid { - my ($now,$subject,$uname,$udom,$msgcount,$course_context,$pid) = @_; + my ($now,$subject,$uname,$udom,$msgcount,$course_context,$symb,$error,$pid) = @_; $subject=&escape($subject); return(&escape($now.':'.$subject.':'.$uname.':'. - $udom.':'.$msgcount.':'.$course_context.':'.$pid)); + $udom.':'.$msgcount.':'.$course_context.':'.$pid.':'.$symb.':'.$error)); } sub unpackmsgid { my ($msgid,$folder,$skipstatus,$status_cache)=@_; $msgid=&unescape($msgid); my ($sendtime,$shortsubj,$fromname,$fromdomain,$count,$fromcid, - $processid)=split(/\:/,&unescape($msgid)); + $processid,$symb,$error) = split(/\:/,&unescape($msgid)); $shortsubj = &unescape($shortsubj); $shortsubj = &HTML::Entities::decode($shortsubj); if (!defined($processid)) { $fromcid = ''; } @@ -203,7 +214,7 @@ sub unpackmsgid { if ($status{$msgid}=~/^error\:/) { $status{$msgid}=''; } unless ($status{$msgid}) { $status{$msgid}='new'; } } - return ($sendtime,$shortsubj,$fromname,$fromdomain,$status{$msgid},$fromcid); + return ($sendtime,$shortsubj,$fromname,$fromdomain,$status{$msgid},$fromcid,$symb,$error); } @@ -495,7 +506,8 @@ sub user_crit_received { sub user_normal_msg_raw { my ($user,$domain,$subject,$message,$citation,$baseurl,$attachmenturl, - $toperm,$currid,$newid,$sentmessage,$crsmsgid)=@_; + $toperm,$currid,$newid,$sentmessage,$crsmsgid,$symb,$restitle, + $error)=@_; # Check if allowed missing my ($status,$packed_message); my $msgid='undefined'; @@ -506,7 +518,7 @@ sub user_normal_msg_raw { ($msgid,$packed_message)= &packagemsg($subject,$message,$citation,$baseurl, $attachmenturl,$user,$domain,$currid, - undef,$crsmsgid); + undef,$crsmsgid,$symb,$error); # Store in user folder $status=&Apache::lonnet::critical( @@ -525,7 +537,7 @@ sub user_normal_msg_raw { '/'.$env{'request.course.sec'})))) { (undef,my $packed_message_no_citation) = &packagemsg($subject,$message,undef,$baseurl,$attachmenturl, - $user,$domain,$currid,undef,$crsmsgid); + $user,$domain,$currid,undef,$crsmsgid,$symb,$error); $status .= &store_sent_mail($msgid,$packed_message_no_citation); } } else { @@ -560,15 +572,15 @@ sub user_normal_msg_raw { =pod -=item * B: Sends a message to the - $user at $domain, with subject $subject and message $message. +=item * B: + Sends a message to the $user at $domain, with subject $subject and message $message. =cut sub user_normal_msg { my ($user,$domain,$subject,$message,$citation,$baseurl,$attachmenturl, - $toperm,$sentmessage)=@_; + $toperm,$sentmessage,$symb,$restitle,$error)=@_; my $status=''; my %userenv = &Apache::lonnet::get('environment',['msgforward'], $domain,$user); @@ -579,12 +591,12 @@ sub user_normal_msg { $status.= &user_normal_msg_raw($forwuser,$forwdomain,$subject,$message, $citation,$baseurl,$attachmenturl,$toperm, - undef,undef,$sentmessage).' '; + undef,undef,$sentmessage,undef,$symb,$restitle,$error).' '; } - } else { + } else { $status=&user_normal_msg_raw($user,$domain,$subject,$message, $citation,$baseurl,$attachmenturl,$toperm, - undef,undef,$sentmessage); + undef,undef,$sentmessage,undef,$symb,$restitle,$error); } return $status; }