Attachment: '.$fname.'.'.$ft.'';
}
@@ -212,14 +199,15 @@ sub unpackmsgid {
sub sendemail {
my ($to,$subject,$body)=@_;
$body=
- "*** This is an automatic message generated by the LON-CAPA system.\n".
- "*** Please do not reply to this address.\n\n".$body;
+ "*** ".&mt('This is an automatic message generated by the LON-CAPA system.')."\n".
+ "*** ".&mt('Please do not reply to this address.')."\n\n".$body;
my $msg = new Mail::Send;
$msg->to($to);
$msg->subject('[LON-CAPA] '.$subject);
- my $fh = $msg->open('smtp',Server => 'localhost');
- print $fh $body;
- $fh->close;
+ if (my $fh = $msg->open('smtp',Server => 'localhost')) {
+ print $fh $body;
+ $fh->close;
+ }
}
# ==================================================== Send notification emails
@@ -282,6 +270,53 @@ sub author_res_msg {
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.='
';
+ }
+ }
+ 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 {
@@ -362,10 +397,10 @@ sub user_crit_received {
my %contents=&unpackagemsg($message{$msgid},1);
my $status='rec: '.($contents{'sendback'}?
&user_normal_msg($contents{'sendername'},$contents{'senderdomain'},
- 'Receipt: '.$ENV{'user.name'}.' at '.$ENV{'user.domain'},
- 'User '.$ENV{'user.name'}.' at '.$ENV{'user.domain'}.
+ &mt('Receipt').': '.$ENV{'user.name'}.' '.&mt('at').' '.$ENV{'user.domain'}.', '.$contents{'subject'},
+ &mt('User').' '.$ENV{'user.name'}.' '.&mt('at').' '.$ENV{'user.domain'}.
' acknowledged receipt of message'."\n".' "'.
- $contents{'subject'}.'"'."\n".'dated '.
+ $contents{'subject'}.'"'."\n".&mt('dated').' '.
$contents{'time'}.".\n"
):'no msg req');
$status.=' trans: '.
@@ -469,8 +504,11 @@ sub discourse {
$ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
$ENV{'course.'.$ENV{'request.course.id'}.'.num'});
my $now=time;
+ my %lt=&Apache::lonlocal::texthash('cfa' => 'Check for All',
+ 'cfs' => 'Check for Section/Group',
+ 'cfn' => 'Check for None');
$r->print(<
+
-
-
-
-
+
+
+
+
ENDDISHEADER
my %coursepersonnel=
@@ -545,7 +583,7 @@ ENDDISHEADER
sub discrit {
my $r=shift;
- my $header = '
Critical Messages
'.
+ my $header = '
'.&mt('Critical Messages').'
'.
'');
}
-# =============================================================== Compose reply
-
-sub comprep {
- my ($r,$msgid)=@_;
- my %message=&Apache::lonnet::get('nohist_email',[$msgid]);
- my %content=&unpackagemsg($message{$msgid},1);
- my $quotemsg='> '.$content{'message'};
- $quotemsg=~s/\r/\n/g;
- $quotemsg=~s/\f/\n/g;
- $quotemsg=~s/\n+/\n\> /g;
- my $torepl=&Apache::loncommon::aboutmewrapper(
- &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),$content{'sendername'},$content{'senderdomain'}).' ('.
-$content{'sendername'}.'@'.
- $content{'senderdomain'}.')';
- my $subject='Re: '.$content{'subject'};
- my $dispcrit='';
- if (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) {
- my $crithelp = Apache::loncommon::help_open_topic("Course_Critical_Message");
- $dispcrit=
- ' Send as critical message ' . $crithelp .
- ' '.
- ' Send as critical message ' .
- ' and return receipt' . $crithelp . '
';
- }
- $r->print(<<"ENDREPLY");
-
-ENDREPLY
-}
-
sub sortedmessages {
my @messages = &Apache::lonnet::getkeys('nohist_email');
#unpack the varibles and repack into temp for sorting
@@ -688,37 +690,37 @@ sub disall {
}
ENDDISHEADER
- $r->print('