version 1.159, 2005/11/29 22:41:30
|
version 1.169, 2006/01/05 20:10:54
|
Line 97 Right now, this document will cover just
|
Line 97 Right now, this document will cover just
|
it is likely you will not need to programmatically read messages, |
it is likely you will not need to programmatically read messages, |
since lonmsg already implements that functionality. |
since lonmsg already implements that functionality. |
|
|
|
The routines used to package messages and unpackage messages are not |
|
only used by lonmsg when creating/extracting messages for LON-CAPA's |
|
internal messaging system, but also by lonnotify.pm which is available |
|
for use by Domain Coordinators to broadcast standard e-mail to specified |
|
users in their domain. The XML packaging used in the two cases is very |
|
similar. The differences are the use of <recuser>$uname</recuser> and |
|
<recdomain>$udom</recdomain> in stored internal messages, compared |
|
with <recipient username="$uname:$udom">$email</recipient> in stored |
|
Domain Coordinator e-mail for the storage of information about |
|
recipients of the message/e-mail. |
|
|
=head1 FUNCTIONS |
=head1 FUNCTIONS |
|
|
=over 4 |
=over 4 |
Line 126 my $interdis;
|
Line 137 my $interdis;
|
|
|
sub packagemsg { |
sub packagemsg { |
my ($subject,$message,$citation,$baseurl,$attachmenturl, |
my ($subject,$message,$citation,$baseurl,$attachmenturl, |
$recuser,$recdomain,$msgid)=@_; |
$recuser,$recdomain,$msgid,$type)=@_; |
$message =&HTML::Entities::encode($message,'<>&"'); |
$message =&HTML::Entities::encode($message,'<>&"'); |
$citation=&HTML::Entities::encode($citation,'<>&"'); |
$citation=&HTML::Entities::encode($citation,'<>&"'); |
$subject =&HTML::Entities::encode($subject,'<>&"'); |
$subject =&HTML::Entities::encode($subject,'<>&"'); |
Line 142 sub packagemsg {
|
Line 153 sub packagemsg {
|
split(/\:/,&Apache::lonnet::unescape($env{'form.replyid'})); |
split(/\:/,&Apache::lonnet::unescape($env{'form.replyid'})); |
$course_context = $origcid; |
$course_context = $origcid; |
} |
} |
|
foreach my $key (keys(%env)) { |
|
if ($key=~/^form\.(rep)?rec\_(.*)$/) { |
|
my ($sendtime,$shortsubj,$fromname,$fromdomain,$count,$origcid) = |
|
split(/\:/,&Apache::lonnet::unescape($2)); |
|
$course_context = $origcid; |
|
last; |
|
} |
|
} |
unless(defined($course_context)) { |
unless(defined($course_context)) { |
$course_context = $env{'request.course.id'}; |
$course_context = $env{'request.course.id'}; |
} |
} |
Line 170 sub packagemsg {
|
Line 189 sub packagemsg {
|
'<msgid>'.$msgid.'</msgid>'; |
'<msgid>'.$msgid.'</msgid>'; |
if (ref($recuser) eq 'ARRAY') { |
if (ref($recuser) eq 'ARRAY') { |
for (my $i=0; $i<@{$recuser}; $i++) { |
for (my $i=0; $i<@{$recuser}; $i++) { |
$result .= '<recuser>'.$$recuser[$i].'</recuser>'. |
if ($type eq 'dcmail') { |
'<recdomain>'.$$recdomain[$i].'</recdomain>'; |
my ($username,$email) = split(/:/,$$recuser[$i]); |
|
$username = &Apache::lonnet::unescape($username); |
|
$email = &Apache::lonnet::unescape($email); |
|
$username = &HTML::Entities::encode($username,'<>&"'); |
|
$email = &HTML::Entities::encode($email,'<>&"'); |
|
$result .= '<recipient username="'.$username.'">'. |
|
$email.'</recipient>'; |
|
} else { |
|
$result .= '<recuser>'.$$recuser[$i].'</recuser>'. |
|
'<recdomain>'.$$recdomain[$i].'</recdomain>'; |
|
} |
} |
} |
} else { |
} else { |
$result .= '<recuser>'.$recuser.'</recuser>'. |
$result .= '<recuser>'.$recuser.'</recuser>'. |
Line 203 sub unpackagemsg {
|
Line 232 sub unpackagemsg {
|
my $value=$parser->get_text('/'.$entry); |
my $value=$parser->get_text('/'.$entry); |
if (($entry eq 'recuser') || ($entry eq 'recdomain')) { |
if (($entry eq 'recuser') || ($entry eq 'recdomain')) { |
push(@{$content{$entry}},$value); |
push(@{$content{$entry}},$value); |
|
} elsif ($entry eq 'recipient') { |
|
my $username = $token->[2]{'username'}; |
|
$username = &HTML::Entities::decode($username,'<>&"'); |
|
$content{$entry}{$username} = $value; |
} else { |
} else { |
$content{$entry}=$value; |
$content{$entry}=$value; |
} |
} |
} |
} |
} |
} |
|
if (!exists($content{'recuser'})) { $content{'recuser'} = []; } |
if ($content{'attachmenturl'}) { |
if ($content{'attachmenturl'}) { |
my ($fname)=($content{'attachmenturl'}=~m|/([^/]+)$|); |
my ($fname)=($content{'attachmenturl'}=~m|/([^/]+)$|); |
if ($notoken) { |
if ($notoken) { |
Line 233 sub buildmsgid {
|
Line 267 sub buildmsgid {
|
} |
} |
|
|
sub unpackmsgid { |
sub unpackmsgid { |
my ($msgid,$folder)=@_; |
my ($msgid,$folder,$skipstatus,$status_cache)=@_; |
$msgid=&Apache::lonnet::unescape($msgid); |
$msgid=&Apache::lonnet::unescape($msgid); |
my $suffix=&foldersuffix($folder); |
my ($sendtime,$shortsubj,$fromname,$fromdomain,$count,$fromcid, |
my ($sendtime,$shortsubj,$fromname,$fromdomain,$count,$fromcid)=split(/\:/, |
$processid)=split(/\:/,&Apache::lonnet::unescape($msgid)); |
&Apache::lonnet::unescape($msgid)); |
if (!defined($processid)) { $fromcid = ''; } |
my %status=&Apache::lonnet::get('email_status'.$suffix,[$msgid]); |
my %status=(); |
if ($status{$msgid}=~/^error\:/) { $status{$msgid}=''; } |
unless ($skipstatus) { |
unless ($status{$msgid}) { $status{$msgid}='new'; } |
if (ref($status_cache)) { |
|
$status{$msgid} = $status_cache->{$msgid}; |
|
} else { |
|
my $suffix=&foldersuffix($folder); |
|
%status=&Apache::lonnet::get('email_status'.$suffix,[$msgid]); |
|
} |
|
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); |
} |
} |
|
|
Line 820 sub sortedmessages {
|
Line 862 sub sortedmessages {
|
my @messages = &Apache::lonnet::getkeys('nohist_email'.$suffix); |
my @messages = &Apache::lonnet::getkeys('nohist_email'.$suffix); |
#unpack the varibles and repack into temp for sorting |
#unpack the varibles and repack into temp for sorting |
my @temp; |
my @temp; |
|
my %descriptions; |
|
my %status_cache = |
|
&Apache::lonnet::get('email_status'.&foldersuffix($folder),\@messages); |
foreach (@messages) { |
foreach (@messages) { |
my $msgid=&Apache::lonnet::escape($_); |
my $msgid=&Apache::lonnet::escape($_); |
my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$fromcid)= |
my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$fromcid)= |
&Apache::lonmsg::unpackmsgid($msgid,$folder); |
&Apache::lonmsg::unpackmsgid($msgid,$folder,undef, |
my $description = &get_course_desc($fromcid); |
\%status_cache); |
|
my $description = &get_course_desc($fromcid,\%descriptions); |
my @temp1 = ($sendtime,$shortsubj,$fromname,$fromdomain,$status, |
my @temp1 = ($sendtime,$shortsubj,$fromname,$fromdomain,$status, |
$msgid,$description); |
$msgid,$description); |
# Check whether message was sent during blocking period. |
# Check whether message was sent during blocking period. |
Line 878 sub sortedmessages {
|
Line 924 sub sortedmessages {
|
} |
} |
|
|
sub get_course_desc { |
sub get_course_desc { |
my ($fromcid) = @_; |
my ($fromcid,$descriptions) = @_; |
my $description; |
my $description; |
if (defined($env{'course.'.$fromcid.'.description'})) { |
if (!$fromcid) { |
$description = $env{'course.'.$fromcid.'.description'}; |
return $description; |
} else { |
} else { |
my %courseinfo=&Apache::lonnet::coursedescription($fromcid); |
if (defined($$descriptions{$fromcid})) { |
$description = $courseinfo{'description'}; |
$description = $$descriptions{$fromcid}; |
|
} else { |
|
if (defined($env{'course.'.$fromcid.'.description'})) { |
|
$description = $env{'course.'.$fromcid.'.description'}; |
|
} else { |
|
my %courseinfo=&Apache::lonnet::coursedescription($fromcid); $description = $courseinfo{'description'}; |
|
$description = $courseinfo{'description'}; |
|
} |
|
$$descriptions{$fromcid} = $description; |
|
} |
|
return $description; |
} |
} |
return $description; |
|
} |
} |
|
|
# ======================================================== Display new messages |
# ======================================================== Display new messages |
Line 903 sub disnew {
|
Line 958 sub disnew {
|
'op' => 'Open', |
'op' => 'Open', |
'do' => 'Domain' |
'do' => 'Domain' |
); |
); |
my @msgids = sort split(/\&/,&Apache::lonnet::reply |
my @msgids = sort(&Apache::lonnet::getkeys('nohist_email')); |
('keys:'.$env{'user.domain'}.':'. |
|
$env{'user.name'}.':nohist_email', |
|
$env{'user.home'})); |
|
my @newmsgs; |
my @newmsgs; |
my %setters = (); |
my %setters = (); |
my $startblock = 0; |
my $startblock = 0; |
Line 915 sub disnew {
|
Line 967 sub disnew {
|
my $numblocked = 0; |
my $numblocked = 0; |
# Check for blocking of display because of scheduled online exams. |
# Check for blocking of display because of scheduled online exams. |
&blockcheck(\%setters,\$startblock,\$endblock); |
&blockcheck(\%setters,\$startblock,\$endblock); |
|
my %status_cache = |
|
&Apache::lonnet::get('email_status',\@msgids); |
|
my %descriptions; |
foreach (@msgids) { |
foreach (@msgids) { |
|
my $msgid=&Apache::lonnet::escape($_); |
my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)= |
my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)= |
&Apache::lonmsg::unpackmsgid($_); |
&Apache::lonmsg::unpackmsgid($msgid,undef,undef,\%status_cache); |
if (defined($sendtime) && $sendtime!~/error/) { |
if (defined($sendtime) && $sendtime!~/error/) { |
my $description = &get_course_desc($fromcid); |
my $description = &get_course_desc($fromcid,\%descriptions); |
my $numsendtime = $sendtime; |
my $numsendtime = $sendtime; |
$sendtime = &Apache::lonlocal::locallocaltime($sendtime); |
$sendtime = &Apache::lonlocal::locallocaltime($sendtime); |
if ($status eq 'new') { |
if ($status eq 'new') { |
Line 928 sub disnew {
|
Line 984 sub disnew {
|
$numblocked ++; |
$numblocked ++; |
} else { |
} else { |
push @newmsgs, { |
push @newmsgs, { |
msgid => $_, |
msgid => $msgid, |
sendtime => $sendtime, |
sendtime => $sendtime, |
shortsub => &Apache::lonnet::unescape($shortsubj), |
shortsub => &Apache::lonnet::unescape($shortsubj), |
from => $fromname, |
from => $fromname, |
Line 1181 sub compout {
|
Line 1237 sub compout {
|
&mt('and return receipt') . '</label>' . $crithelp . |
&mt('and return receipt') . '</label>' . $crithelp . |
'</p><p><label><input type="checkbox" name="permanent" /> '. |
'</p><p><label><input type="checkbox" name="permanent" /> '. |
&mt('Send copy to permanent email address (if known)').'</label></p>'. |
&mt('Send copy to permanent email address (if known)').'</label></p>'. |
'<p><label><input type="checkbox" name="rsspost" /> '. |
'<!-- <p><label><input type="checkbox" name="rsspost" /> '. |
&mt('Include in course RSS newsfeed').'</label></p>'; } |
&mt('Include in course RSS newsfeed').'</label></p>-->'; } |
my %message; |
my %message; |
my %content; |
my %content; |
my $defdom=$env{'user.domain'}; |
my $defdom=$env{'user.domain'}; |