'Open',
'do' => 'Domain'
);
- my @msgids = sort split(/\&/,&Apache::lonnet::reply
- ('keys:'.$env{'user.domain'}.':'.
- $env{'user.name'}.':nohist_email',
- $env{'user.home'}));
+ my @msgids = sort(&Apache::lonnet::getkeys('nohist_email'));
my @newmsgs;
my %setters = ();
my $startblock = 0;
@@ -951,11 +987,15 @@ sub disnew {
my $numblocked = 0;
# Check for blocking of display because of scheduled online exams.
&blockcheck(\%setters,\$startblock,\$endblock);
+ my %status_cache =
+ &Apache::lonnet::get('email_status',\@msgids);
+ my %descriptions;
foreach (@msgids) {
+ my $msgid=&Apache::lonnet::escape($_);
my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=
- &Apache::lonmsg::unpackmsgid($_);
+ &Apache::lonmsg::unpackmsgid($msgid,undef,undef,\%status_cache);
if (defined($sendtime) && $sendtime!~/error/) {
- my $description = &get_course_desc($fromcid);
+ my $description = &get_course_desc($fromcid,\%descriptions);
my $numsendtime = $sendtime;
$sendtime = &Apache::lonlocal::locallocaltime($sendtime);
if ($status eq 'new') {
@@ -964,7 +1004,7 @@ sub disnew {
$numblocked ++;
} else {
push @newmsgs, {
- msgid => $_,
+ msgid => $msgid,
sendtime => $sendtime,
shortsub => &Apache::lonnet::unescape($shortsubj),
from => $fromname,
@@ -1208,7 +1248,9 @@ sub compout {
'ca' => 'Cancel',
'ma' => 'Mail');
- if (&Apache::lonnet::allowed('srm',$env{'request.course.id'})) {
+ if (&Apache::lonnet::allowed('srm',$env{'request.course.id'})
+ || &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
+ '/'.$env{'request.course.sec'})) {
my $crithelp = Apache::loncommon::help_open_topic("Course_Critical_Message");
$dispcrit=
' ' . $crithelp .
@@ -1217,8 +1259,9 @@ sub compout {
&mt('and return receipt') . '' . $crithelp .
'
'.
-''; }
+'';
+ }
my %message;
my %content;
my $defdom=$env{'user.domain'};
@@ -1334,7 +1377,7 @@ $dispcrit
ENDUPLOAD
}
if ($broadcast eq 'group') {
- &discourse;
+ &discourse($r);
}
$r->print(''.
&Apache::lonfeedback::generate_preview_button('compemail','message').
@@ -1347,7 +1390,9 @@ sub retrieve_instructor_comments {
my ($user,$domain)=@_;
my $target=$env{'form.grade_target'};
if (! $env{'request.course.id'}) { return; }
- if (! &Apache::lonnet::allowed('srm',$env{'request.course.id'})) {
+ if (! &Apache::lonnet::allowed('srm',$env{'request.course.id'})
+ && ! &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
+ '/'.$env{'request.course.sec'})) {
return;
}
my %records=&Apache::lonnet::dump('nohist_email',
@@ -1372,7 +1417,10 @@ sub disfacetoface {
my ($r,$user,$domain)=@_;
my $target=$env{'form.grade_target'};
unless ($env{'request.course.id'}) { return; }
- unless (&Apache::lonnet::allowed('srm',$env{'request.course.id'})) {
+ if (!&Apache::lonnet::allowed('srm',$env{'request.course.id'})
+ && ! &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
+ '/'.$env{'request.course.sec'})) {
+ $r->print('Not allowed');
return;
}
my %records=&Apache::lonnet::dump('nohist_email',
@@ -1389,17 +1437,29 @@ sub disfacetoface {
} elsif ($content{'subject'}=~/^Broadcast/) {
$result .=''.&mt('Broadcast Message').'
';
if ($content{'subject'}=~/^Broadcast\./) {
- %content=&unpackagemsg($content{'message'});
- $content{'message'}=
+ if (defined($content{'coursemsgid'})) {
+ my $crsmsgid = &Apache::lonnet::escape($content{'coursemsgid'});
+ my $broadcast_message = &general_message($crsmsgid);
+ $content{'message'} = ''.&mt('Subject').': '.$content{'message'}.'
'.$broadcast_message;
+ } else {
+ %content=&unpackagemsg($content{'message'});
+ $content{'message'} =
''.&mt('Subject').': '.$content{'subject'}.'
'.
$content{'message'};
+ }
}
} else {
$result.=''.&mt('Critical Message').'
';
- %content=&unpackagemsg($content{'message'});
- $content{'message'}=
+ if (defined($content{'coursemsgid'})) {
+ my $crsmsgid=&Apache::lonnet::escape($content{'coursemsgid'});
+ my $critical_message = &general_message($crsmsgid);
+ $content{'message'} = ''.&mt('Subject').': '.$content{'message'}.'
'.$critical_message;
+ } else {
+ %content=&unpackagemsg($content{'message'});
+ $content{'message'}=
''.&mt('Subject').': '.$content{'subject'}.'
'.
$content{'message'};
+ }
}
$result.=&mt('By').': '.
&Apache::loncommon::aboutmewrapper(
@@ -1422,11 +1482,26 @@ $content{'sendername'}.'@'.
}
}
+sub general_message {
+ my ($crsmsgid) = @_;
+ my %general_content;
+ if ($crsmsgid) {
+ my %course_content = &Apache::lonnet::get('nohist_email',[$crsmsgid],
+ $env{'course.'.$env{'request.course.id'}.'.domain'},
+ $env{'course.'.$env{'request.course.id'}.'.num'});
+ %general_content = &unpackagemsg($course_content{$crsmsgid});
+ }
+ return $general_content{'message'};
+}
+
# ---------------------------------------------------------------- Face to face
sub facetoface {
my ($r,$stage)=@_;
- unless (&Apache::lonnet::allowed('srm',$env{'request.course.id'})) {
+ if (!&Apache::lonnet::allowed('srm',$env{'request.course.id'})
+ && ! &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
+ '/'.$env{'request.course.sec'})) {
+ $r->print('Not allowed');
return;
}
&printheader($r,
@@ -1501,7 +1576,12 @@ ENDBFORM
sub examblock {
my ($r,$action) = @_;
unless ($env{'request.course.id'}) { return;}
- unless (&Apache::lonnet::allowed('srm',$env{'request.course.id'})) { $r->print('Not allowed'); }
+ if (!&Apache::lonnet::allowed('srm',$env{'request.course.id'})
+ && ! &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
+ '/'.$env{'request.course.sec'})) {
+ $r->print('Not allowed');
+ return;
+ }
my %lt=&Apache::lonlocal::texthash(
'comb' => 'Communication Blocking',
'cbds' => 'Communication blocking during scheduled exams',
@@ -1992,9 +2072,10 @@ sub displayresource {
$content{'sendername'},
$content{'senderdomain'},
$content{'courseid'});
- } else {
+ } elsif ($env{'user.adv'}) {
return $content{'citation'};
}
+ return '';
}
# ================================================================== The Header
@@ -2116,8 +2197,12 @@ sub sendoffmail {
my $savemsg;
my $msgtype;
my %sentmessage;
+ my $msgsubj=&Apache::lonfeedback::clear_out_html($env{'form.subject'});
if ((($env{'form.critmsg'}) || ($env{'form.sendbck'})) &&
- (&Apache::lonnet::allowed('srm',$env{'request.course.id'}))) {
+ (&Apache::lonnet::allowed('srm',$env{'request.course.id'})
+ || &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
+ '/'.$env{'request.course.sec'})
+ )) {
$savemsg=&Apache::lonfeedback::clear_out_html($env{'form.message'},1);
$msgtype = 'critical';
} else {
@@ -2130,17 +2215,16 @@ sub sendoffmail {
if ($toaddr{$_}) { $msgtxt.='
'.$toaddr{$_}; }
my $thismsg;
if ((($env{'form.critmsg'}) || ($env{'form.sendbck'})) &&
- (&Apache::lonnet::allowed('srm',$env{'request.course.id'}))) {
+ (&Apache::lonnet::allowed('srm',$env{'request.course.id'})
+ || &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
+ '/'.$env{'request.course.sec'}))) {
$r->print(&mt('Sending critical message').' '.$recuname.'@'.$recdomain.': ');
- $thismsg=&user_crit_msg($recuname,$recdomain,
- &Apache::lonfeedback::clear_out_html($env{'form.subject'}),
- $msgtxt,
- $env{'form.sendbck'},$env{'form.permanent'},\$sentmessage{$_});
+ $thismsg=&user_crit_msg($recuname,$recdomain,$msgsubj,$msgtxt,
+ $env{'form.sendbck'},$env{'form.permanent'},
+ \$sentmessage{$_});
} else {
$r->print(&mt('Sending').' '.$recuname.'@'.$recdomain.': ');
- $thismsg=&user_normal_msg($recuname,$recdomain,
- &Apache::lonfeedback::clear_out_html($env{'form.subject'}),
- $msgtxt,
+ $thismsg=&user_normal_msg($recuname,$recdomain,$msgsubj,$msgtxt,
$content{'citation'},undef,undef,$env{'form.permanent'},\$sentmessage{$_});
}
if (($env{'request.course.id'}) && (($msgtype eq 'critical') ||
@@ -2176,7 +2260,7 @@ sub sendoffmail {
my $record_sent;
my @recusers = ();
my @recudoms = ();
- my ($stamp,$msgsubj,$msgname,$msgdom,$msgcount,$context,$pid) =
+ my ($stamp,$crssubj,$msgname,$msgdom,$msgcount,$context,$pid) =
split(/\:/,&Apache::lonnet::unescape($specialmsgid));
foreach my $recipient (sort(keys(%toaddr))) {
if ($specialmsg_status{$recipient} eq 'ok') {
@@ -2184,8 +2268,8 @@ sub sendoffmail {
my $usermsgid = &buildmsgid($stamp,$usersubj,$msgname,
$msgdom,$msgcount,$context,$pid);
&user_normal_msg_raw($cnum,$cdom,$subj_prefix.
- ' ['.$recipient.']',$sentmessage{$recipient},
- undef,undef,undef,undef,$usermsgid);
+ ' ['.$recipient.']',$msgsubj,undef,
+ undef,undef,undef,$usermsgid,undef,undef,$specialmsgid);
my ($uname,$udom) = split/:/,$recipient;
push(@recusers,$uname);
push(@recudoms,$udom);
@@ -2194,14 +2278,12 @@ sub sendoffmail {
if (@recusers) {
my $specialmessage;
my $sentsubj = $subj_prefix.' ('.$numspecial.' sent) '.
- &Apache::lonfeedback::clear_out_html($env{'form.subject'});
+ $msgsubj;
$sentsubj = &HTML::Entities::encode($sentsubj,'<>&"');
my $sentmsgid = &buildmsgid($stamp,$sentsubj,$msgname,
$msgdom,$msgcount,$context,$pid);
- ($specialmsgid,$specialmessage) =
- &packagemsg(&Apache::lonfeedback::clear_out_html(
- $env{'form.subject'}),$savemsg,undef,undef,undef,
- \@recusers,\@recudoms,$sentmsgid);
+ ($specialmsgid,$specialmessage) = &packagemsg($msgsubj,$savemsg,
+ undef,undef,undef,\@recusers,\@recudoms,$sentmsgid);
$record_sent = &store_sent_mail($specialmsgid,$specialmessage);
}
} else {