version 1.9, 2005/12/09 00:08:35
|
version 1.11, 2005/12/10 00:46:34
|
Line 274 $breadcrumbs
|
Line 274 $breadcrumbs
|
ENDONE |
ENDONE |
|
|
foreach my $msgid (keys(%sentmail)) { |
foreach my $msgid (keys(%sentmail)) { |
my %content = &unpackagemail($sentmail{$msgid}); |
my %content = &Apache::lonmsg::unpackagemsg($sentmail{$msgid}); |
$msgcount ++; |
$msgcount ++; |
%{$dcmail{$msgid}} = (); |
%{$dcmail{$msgid}} = (); |
foreach my $item (keys(%content)) { |
foreach my $item (keys(%content)) { |
if ($item eq 'recipients') { |
if ($item eq 'recipient') { |
foreach my $user (keys(%{$content{recipients}})) { |
foreach my $user (keys(%{$content{recipient}})) { |
$dcmail{$msgid}{recipients}{$user} = $content{recipients}{$user}; |
$dcmail{$msgid}{recipient}{$user} = $content{recipient}{$user}; |
} |
} |
} else { |
} else { |
$dcmail{$msgid}{$item} = $content{$item}; |
$dcmail{$msgid}{$item} = $content{$item}; |
Line 306 ENDONE
|
Line 306 ENDONE
|
$rowColor = $rowColor2; |
$rowColor = $rowColor2; |
} |
} |
my $recipients = ''; |
my $recipients = ''; |
my ($date,$subj,$sname,$sdom,$cdom) = split(/:/,$msgid,5); |
my ($date,$subj,$sname,$sdom) = |
|
&Apache::lonmsg::unpackmsgid($msgid,undef,1); |
|
$subj = &Apache::lonnet::escape($subj); |
$date = &Apache::lonlocal::locallocaltime($date); |
$date = &Apache::lonlocal::locallocaltime($date); |
foreach my $user (sort(keys(%{$dcmail{$msgid}{recipients}}))) { |
foreach my $user (sort(keys(%{$dcmail{$msgid}{recipient}}))) { |
$recipients .= $dcmail{$msgid}{recipients}{$user}.', '; |
$recipients .= $dcmail{$msgid}{recipient}{$user}.', '; |
} |
} |
$recipients =~ s/,\s$//; |
$recipients =~ s/,\s$//; |
$output .= '<tr bgcolor="'.$rowColor.'"><td><small>'.$date.'</small></td><td><small>'.&cr_to_br($dcmail{$msgid}{subject}).'</small></td><td><small>'.$sname.':'.$sdom.'</small></td><td><small>'.&cr_to_br($dcmail{$msgid}{message}).'</small></td><td><small>'.$recipients.'</small></td></tr>'."\n"; |
$output .= '<tr bgcolor="'.$rowColor.'"><td><small>'.$date.'</small></td><td><small>'.&cr_to_br($dcmail{$msgid}{subject}).'</small></td><td><small>'.$sname.':'.$sdom.'</small></td><td><small>'.&cr_to_br($dcmail{$msgid}{message}).'</small></td><td><small>'.$recipients.'</small></td></tr>'."\n"; |
Line 317 ENDONE
|
Line 319 ENDONE
|
} |
} |
} else { |
} else { |
foreach my $msgid (sort(keys(%dcmail))) { |
foreach my $msgid (sort(keys(%dcmail))) { |
my ($date,$subj,$sname,$sdom,$cdom) = split(/:/,$msgid,5); |
my ($date,$subj,$sname,$sdom) = |
|
&Apache::lonmsg::unpackmsgid($msgid,undef,1); |
|
$subj = &Apache::lonnet::escape($subj); |
if ($env{'form.sortby'} eq 'subject') { |
if ($env{'form.sortby'} eq 'subject') { |
push @{$Sortby{$dcmail{$msgid}{subject}}},$msgid; |
push @{$Sortby{$dcmail{$msgid}{subject}}},$msgid; |
} elsif ($env{'form.sortby'} eq 'message') { |
} elsif ($env{'form.sortby'} eq 'message') { |
push @{$Sortby{$dcmail{$msgid}{message}}},$msgid; |
push @{$Sortby{$dcmail{$msgid}{message}}},$msgid; |
} elsif ($env{'form.sortby'} eq 'recipients') { |
} elsif ($env{'form.sortby'} eq 'recipients') { |
my $recipients =''; |
my $recipients =''; |
foreach my $user (sort(keys(%{$dcmail{$msgid}{recipients}}))) { |
foreach my $user (sort(keys(%{$dcmail{$msgid}{recipient}}))) { |
$recipients .= $dcmail{$msgid}{recipients}{$user}.', '; |
$recipients .= $dcmail{$msgid}{recipient}{$user}.', '; |
} |
} |
$recipients =~ s/,\s$//; |
$recipients =~ s/,\s$//; |
push @{$Sortby{$recipients}},$msgid; |
push @{$Sortby{$recipients}},$msgid; |
Line 346 ENDONE
|
Line 350 ENDONE
|
if ($env{'form.sortby'} eq 'recipients') { |
if ($env{'form.sortby'} eq 'recipients') { |
$recipients = $key; |
$recipients = $key; |
} else { |
} else { |
foreach my $user (sort(keys(%{$dcmail{$msgid}{recipients}}))) { |
foreach my $user (sort(keys(%{$dcmail{$msgid}{recipient}}))) { |
$recipients .= $dcmail{$msgid}{recipients}{$user}.', '; |
$recipients .= $dcmail{$msgid}{recipient}{$user}.', '; |
} |
} |
$recipients =~ s/,\s$//; |
$recipients =~ s/,\s$//; |
} |
} |
|
my ($date,$subj,$sname,$sdom) = |
my ($date,$subj,$sname,$sdom,$cdom) = split(/:/,$msgid,5); |
&Apache::lonmsg::unpackmsgid($msgid,undef,1); |
|
$subj = &Apache::lonnet::escape($subj); |
$date = &Apache::lonlocal::locallocaltime($date); |
$date = &Apache::lonlocal::locallocaltime($date); |
$output .= '<tr bgcolor="'.$rowColor.'"><td><small>'.$date.'</small></td><td><small>'.&cr_to_br($dcmail{$msgid}{subject}).'</small></td><td><small>'.$sname.':'.$sdom.'</small></td><td><small>'.&cr_to_br($dcmail{$msgid}{message}).'</small></td><td><small>'.$recipients.'</small></td></tr>'."\n"; |
$output .= '<tr bgcolor="'.$rowColor.'"><td><small>'.$date.'</small></td><td><small>'.&cr_to_br($dcmail{$msgid}{subject}).'</small></td><td><small>'.$sname.':'.$sdom.'</small></td><td><small>'.&cr_to_br($dcmail{$msgid}{message}).'</small></td><td><small>'.$recipients.'</small></td></tr>'."\n"; |
$rowNum ++; |
$rowNum ++; |
Line 376 ENDONE
|
Line 381 ENDONE
|
$output .= qq(<input type="hidden" name="sortby" value="$curr_sortby" />\n); |
$output .= qq(<input type="hidden" name="sortby" value="$curr_sortby" />\n); |
$output .= qq( |
$output .= qq( |
</form> |
</form> |
</body> |
</body |
</html>); |
</html>); |
$r->print($output); |
$r->print($output); |
return; |
return; |
Line 758 ENDONE
|
Line 763 ENDONE
|
</table> |
</table> |
</td> |
</td> |
</tr>'; |
</tr>'; |
&store_mail($subject,$message,$dom,\@deliveries); |
|
} else { |
} else { |
$output .= 'No mail sent - no recipients identified'; |
$output .= 'No mail sent - no recipients identified'; |
} |
} |
Line 842 sub form_elements {
|
Line 846 sub form_elements {
|
sub store_mail { |
sub store_mail { |
my ($subject,$message,$domain,$recipients,$attachmenturl,$ltext) = @_; |
my ($subject,$message,$domain,$recipients,$attachmenturl,$ltext) = @_; |
my $msgid; |
my $msgid; |
($msgid,$message) = &packagemail($subject,$message,$domain,$recipients, |
($msgid,$message) = &Apache::lonmsg::packagemsg($subject,$message,undef,undef, |
$attachmenturl); |
$attachmenturl,$recipients,undef,undef,'dcmail'); |
|
|
# Store in dc email db files on primary library server for domain. |
# Store in dc email db files on primary library server for domain. |
my $server = $Apache::lonnet::domain_primary{$domain}; |
my $server = $Apache::lonnet::domain_primary{$domain}; |
if (defined($server)) { |
if (defined($server)) { |
Line 858 sub store_mail {
|
Line 863 sub store_mail {
|
} |
} |
} |
} |
|
|
sub packagemail { |
|
my ($subject,$message,$dom,$recipients,$attachmenturl) = @_; |
|
my %record = (); |
|
my $partsubj=$subject; |
|
$partsubj=&Apache::lonnet::escape($partsubj); |
|
$message =&HTML::Entities::encode($message,'<>&"'); |
|
$subject =&HTML::Entities::encode($subject,'<>&"'); |
|
#remove machine specification |
|
$attachmenturl =~ s|^http://[^/]+/|/|; |
|
$attachmenturl =&HTML::Entities::encode($attachmenturl,'<>&"'); |
|
my $now=time; |
|
my $msgid= &Apache::lonnet::escape($now).':'.$partsubj.':'. |
|
&Apache::lonnet::escape($env{'user.name'}).':'. |
|
&Apache::lonnet::escape($env{'user.domain'}).':'. |
|
&Apache::lonnet::escape($dom).':'.$$; |
|
my $result='<sendername>'.$env{'user.name'}.'</sendername>'. |
|
'<senderdomain>'.$env{'user.domain'}.'</senderdomain>'. |
|
'<time>'.&Apache::lonlocal::locallocaltime($now).'</time>'. |
|
'<servername>'.$ENV{'SERVER_NAME'}.'</servername>'. |
|
'<host>'.$ENV{'HTTP_HOST'}.'</host>'. |
|
'<client>'.$ENV{'REMOTE_ADDR'}.'</client>'. |
|
'<msgid>'.$msgid.'</msgid>'. |
|
'<dcdomain>'.$dom.'</dcdomain>'. |
|
'<subject>'.$subject.'</subject>'. |
|
'<message>'.$message.'</message>'."\n"; |
|
if (defined($attachmenturl)) { |
|
$result.= '<attachmenturl>'.$attachmenturl.'</attachmenturl>'; |
|
} |
|
foreach my $recip (@{$recipients}) { |
|
my ($username,$email) = split(/:/,$recip); |
|
$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>'; |
|
} |
|
return ($msgid,$result); |
|
} |
|
|
|
sub unpackagemail { |
|
my ($message,$notoken,$ltext)=@_; |
|
my $parser=HTML::TokeParser->new(\$message); |
|
my $token; |
|
my %content=(); |
|
%{$content{recipients}} = (); |
|
while ($token=$parser->get_token()) { |
|
if ($token->[0] eq 'S') { |
|
my $entry=$token->[1]; |
|
my $value=$parser->get_text('/'.$entry); |
|
my ($username,$email); |
|
if ($entry eq 'recipient') { |
|
$username = $token->[2]{'username'}; |
|
$username = &HTML::Entities::decode($username,'<>&"'); |
|
$content{recipients}{$username} = |
|
&HTML::Entities::decode($value,'<>&"'); |
|
} elsif ($entry eq 'subject' || $entry eq 'message') { |
|
$content{$entry}=&HTML::Entities::decode($value,'<>&"'); |
|
} else { |
|
$content{$entry}=$value; |
|
} |
|
} |
|
} |
|
if ($content{'attachmenturl'}) { |
|
my ($fname)=($content{'attachmenturl'}=~m|/([^/]+)$|); |
|
if ($notoken) { |
|
$content{'message'}.='<p>'.&mt('Attachment').': <tt>'.$fname.'</tt>'; } else { |
|
&Apache::lonnet::allowuploaded('/adm/notify', |
|
$content{'attachmenturl'}); |
|
$content{'message'}.='<p>'.&mt('Attachment'). |
|
': <a href="'.$content{'attachmenturl'}.'"><tt>'. |
|
$fname.'</tt></a>'; |
|
} |
|
} |
|
return %content; |
|
} |
|
|
|
sub cr_to_br { |
sub cr_to_br { |
my $incoming = shift; |
my $incoming = shift; |
$incoming =~ s/\n/\<br \/\>/g; |
$incoming =~ s/\n/\<br \/\>/g; |