version 1.185, 2006/06/12 22:55:23
|
version 1.189, 2006/12/06 23:44:33
|
Line 33 use Apache::lonnet;
|
Line 33 use Apache::lonnet;
|
use HTML::TokeParser(); |
use HTML::TokeParser(); |
use Apache::lonlocal; |
use Apache::lonlocal; |
use Mail::Send; |
use Mail::Send; |
use lib '/home/httpd/lib/perl/'; |
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA; |
|
|
|
{ |
{ |
my $uniq; |
my $uniq; |
Line 210 sub unpackmsgid {
|
Line 209 sub unpackmsgid {
|
|
|
sub sendemail { |
sub sendemail { |
my ($to,$subject,$body)=@_; |
my ($to,$subject,$body)=@_; |
|
my %senderemails=&Apache::loncommon::getemails(); |
|
my $senderaddress=''; |
|
foreach my $type ('notification','permanentemail','critnotification') { |
|
if ($senderemails{$type}) { |
|
$senderaddress=$senderemails{$type}; |
|
} |
|
} |
$body= |
$body= |
"*** ".&mt('This is an automatic message generated by the LON-CAPA system.')."\n". |
"*** ".&mt('This is an automatic message generated by the LON-CAPA system.')."\n". |
"*** ".&mt('Please do not reply to this address.')."\n\n".$body; |
"*** ".($senderaddress?&mt('You can reply to this message'):&mt('Please do not reply to this address.')."\n*** ". |
|
&mt('A reply will not be received by the recipient!'))."\n\n".$body; |
my $msg = new Mail::Send; |
my $msg = new Mail::Send; |
$msg->to($to); |
$msg->to($to); |
$msg->subject('[LON-CAPA] '.$subject); |
$msg->subject('[LON-CAPA] '.$subject); |
|
if ($senderaddress) { $msg->add('Reply-to',$senderaddress); $msg->add('From',$senderaddress); } |
if (my $fh = $msg->open()) { |
if (my $fh = $msg->open()) { |
print $fh $body; |
print $fh $body; |
$fh->close; |
$fh->close; |
Line 299 sub author_res_msg {
|
Line 307 sub author_res_msg {
|
sub retrieve_author_res_msg { |
sub retrieve_author_res_msg { |
my $url=shift; |
my $url=shift; |
$url=&Apache::lonnet::declutter($url); |
$url=&Apache::lonnet::declutter($url); |
my ($domain,$author)=($url=~/^(\w+)\/(\w+)\//); |
my ($domain,$author)=($url=~/^($match_domain)\/($match_username)\//); |
my %errormsgs=&Apache::lonnet::dump('nohist_res_msgs',$domain,$author); |
my %errormsgs=&Apache::lonnet::dump('nohist_res_msgs',$domain,$author); |
my $msgs=''; |
my $msgs=''; |
foreach (keys %errormsgs) { |
foreach (keys %errormsgs) { |
Line 319 sub retrieve_author_res_msg {
|
Line 327 sub retrieve_author_res_msg {
|
sub del_url_author_res_msg { |
sub del_url_author_res_msg { |
my $url=shift; |
my $url=shift; |
$url=&Apache::lonnet::declutter($url); |
$url=&Apache::lonnet::declutter($url); |
my ($domain,$author)=($url=~/^(\w+)\/(\w+)\//); |
my ($domain,$author)=($url=~/^($match_domain)\/($match_username)\//); |
my @delmsgs=(); |
my @delmsgs=(); |
foreach (&Apache::lonnet::getkeys('nohist_res_msgs',$domain,$author)) { |
foreach (&Apache::lonnet::getkeys('nohist_res_msgs',$domain,$author)) { |
if ($_=~/^\Q$url\E\_\d+$/) { |
if ($_=~/^\Q$url\E\_\d+$/) { |
Line 333 sub del_url_author_res_msg {
|
Line 341 sub del_url_author_res_msg {
|
sub clear_author_res_msg { |
sub clear_author_res_msg { |
my $url=shift; |
my $url=shift; |
$url=&Apache::lonnet::declutter($url); |
$url=&Apache::lonnet::declutter($url); |
my ($domain,$author)=($url=~/^(\w+)\/(\w+)\//); |
my ($domain,$author)=($url=~/^($match_domain)\/($match_username)\//); |
my @delmsgs=(); |
my @delmsgs=(); |
foreach (&Apache::lonnet::getkeys('nohist_res_msgs',$domain,$author)) { |
foreach (&Apache::lonnet::getkeys('nohist_res_msgs',$domain,$author)) { |
if ($_=~/^\Q$url\E/) { |
if ($_=~/^\Q$url\E/) { |
Line 390 sub user_crit_msg_raw {
|
Line 398 sub user_crit_msg_raw {
|
$status='no_host'; |
$status='no_host'; |
} |
} |
# Notifications |
# Notifications |
my %userenv = &Apache::lonnet::get('environment',['critnotification', |
my %userenv = &Apache::loncommon::getemails($user,$domain); |
'permanentemail'], |
|
$domain,$user); |
|
if ($userenv{'critnotification'}) { |
if ($userenv{'critnotification'}) { |
&sendnotification($userenv{'critnotification'},$user,$domain,$subject,1, |
&sendnotification($userenv{'critnotification'},$user,$domain,$subject,1, |
$text); |
$text); |
Line 595 sub store_sent_mail {
|
Line 601 sub store_sent_mail {
|
sub foldersuffix { |
sub foldersuffix { |
my $folder=shift; |
my $folder=shift; |
unless ($folder) { return ''; } |
unless ($folder) { return ''; } |
return '_'.&escape($folder); |
my $suffix; |
|
my %folderhash = &get_user_folders($folder); |
|
if (ref($folderhash{$folder}) eq 'HASH') { |
|
$suffix = '_'.&escape($folderhash{$folder}{'id'}); |
|
} else { |
|
$suffix = '_'.&escape($folder); |
|
} |
|
return $suffix; |
|
} |
|
|
|
# ========================================================= User-defined folders |
|
|
|
sub get_user_folders { |
|
my ($folder) = @_; |
|
my %userfolders = |
|
&Apache::lonnet::dump('email_folders',undef,undef,$folder); |
|
my $lock = "\0".'lock_counter'; # locks db while counter incremented |
|
my $counter = "\0".'idcount'; # used in suffix for email db files |
|
if (defined($userfolders{$lock})) { |
|
delete($userfolders{$lock}); |
|
} |
|
if (defined($userfolders{$counter})) { |
|
delete($userfolders{$counter}); |
|
} |
|
return %userfolders; |
} |
} |
|
|
1; |
1; |