version 1.157, 2005/11/28 18:32:39
|
version 1.173.2.2, 2006/06/19 09:36:14
|
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 136 sub packagemsg {
|
Line 147 sub packagemsg {
|
#remove machine specification |
#remove machine specification |
$attachmenturl =~ s|^http://[^/]+/|/|; |
$attachmenturl =~ s|^http://[^/]+/|/|; |
$attachmenturl =&HTML::Entities::encode($attachmenturl,'<>&"'); |
$attachmenturl =&HTML::Entities::encode($attachmenturl,'<>&"'); |
|
my $course_context; |
|
if (defined($env{'form.replyid'})) { |
|
my ($sendtime,$shortsubj,$fromname,$fromdomain,$count,$origcid)= |
|
split(/\:/,&Apache::lonnet::unescape($env{'form.replyid'})); |
|
$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)) { |
|
$course_context = $env{'request.course.id'}; |
|
} |
my $now=time; |
my $now=time; |
$msgcount++; |
$msgcount++; |
my $partsubj=$subject; |
|
$partsubj=&Apache::lonnet::escape($partsubj); |
|
unless(defined($msgid)) { |
unless(defined($msgid)) { |
$msgid=&Apache::lonnet::escape( |
$msgid = &buildmsgid($now,$subject,$env{'user.name'},$env{'user.domain'}, |
$now.':'.$partsubj.':'.$env{'user.name'}.':'. |
$msgcount,$course_context,$$); |
$env{'user.domain'}.':'.$msgcount.':'. |
|
$env{'request.course.id'}.':'.$$); |
|
} |
} |
my $result='<sendername>'.$env{'user.name'}.'</sendername>'. |
my $result='<sendername>'.$env{'user.name'}.'</sendername>'. |
'<senderdomain>'.$env{'user.domain'}.'</senderdomain>'. |
'<senderdomain>'.$env{'user.domain'}.'</senderdomain>'. |
Line 159 sub packagemsg {
|
Line 182 sub packagemsg {
|
'<browserversion>'.$env{'browser.version'}.'</browserversion>'. |
'<browserversion>'.$env{'browser.version'}.'</browserversion>'. |
'<browsermathml>'.$env{'browser.mathml'}.'</browsermathml>'. |
'<browsermathml>'.$env{'browser.mathml'}.'</browsermathml>'. |
'<browserraw>'.$ENV{'HTTP_USER_AGENT'}.'</browserraw>'. |
'<browserraw>'.$ENV{'HTTP_USER_AGENT'}.'</browserraw>'. |
'<courseid>'.$env{'request.course.id'}.'</courseid>'. |
'<courseid>'.$course_context.'</courseid>'. |
'<coursesec>'.$env{'request.course.sec'}.'</coursesec>'. |
'<coursesec>'.$env{'request.course.sec'}.'</coursesec>'. |
'<role>'.$env{'request.role'}.'</role>'. |
'<role>'.$env{'request.role'}.'</role>'. |
'<resource>'.$env{'request.filename'}.'</resource>'. |
'<resource>'.$env{'request.filename'}.'</resource>'. |
'<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 199 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 221 sub unpackagemsg {
|
Line 259 sub unpackagemsg {
|
|
|
# ======================================================= Get info out of msgid |
# ======================================================= Get info out of msgid |
|
|
|
sub buildmsgid { |
|
my ($now,$subject,$uname,$udom,$msgcount,$course_context,$pid) = @_; |
|
$subject=&Apache::lonnet::escape($subject); |
|
return(&Apache::lonnet::escape($now.':'.$subject.':'.$uname.':'. |
|
$udom.':'.$msgcount.':'.$course_context.':'.$pid)); |
|
} |
|
|
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 378 sub all_url_author_res_msg {
|
Line 431 sub all_url_author_res_msg {
|
return %returnhash; |
return %returnhash; |
} |
} |
|
|
|
# ====================================== Add a comment to the User Notes screen |
|
|
|
sub store_instructor_comment { |
|
my ($msg,$uname,$udom) = @_; |
|
my $cid = $env{'request.course.id'}; |
|
my $cnum = $env{'course.'.$cid.'.num'}; |
|
my $cdom = $env{'course.'.$cid.'.domain'}; |
|
my $subject= &mt('Record').' ['.$uname.':'.$udom.']'; |
|
my $result = &user_normal_msg_raw($cnum,$cdom,$subject,$msg); |
|
return $result; |
|
} |
|
|
# ================================================== Critical message to a user |
# ================================================== Critical message to a user |
|
|
sub user_crit_msg_raw { |
sub user_crit_msg_raw { |
my ($user,$domain,$subject,$message,$sendback,$toperm)=@_; |
my ($user,$domain,$subject,$message,$sendback,$toperm,$sentmessage)=@_; |
# Check if allowed missing |
# Check if allowed missing |
my $status=''; |
my $status=''; |
my $msgid='undefined'; |
my $msgid='undefined'; |
Line 395 sub user_crit_msg_raw {
|
Line 460 sub user_crit_msg_raw {
|
'put:'.$domain.':'.$user.':critical:'. |
'put:'.$domain.':'.$user.':critical:'. |
&Apache::lonnet::escape($msgid).'='. |
&Apache::lonnet::escape($msgid).'='. |
&Apache::lonnet::escape($message),$homeserver); |
&Apache::lonnet::escape($message),$homeserver); |
if ($env{'request.course.id'}) { |
if (defined($sentmessage)) { |
&user_normal_msg_raw( |
$$sentmessage = $message; |
$env{'course.'.$env{'request.course.id'}.'.num'}, |
} |
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
|
'Critical ['.$user.':'.$domain.']', |
|
$message); |
|
} |
|
} else { |
} else { |
$status='no_host'; |
$status='no_host'; |
} |
} |
Line 439 sub user_crit_msg_raw {
|
Line 500 sub user_crit_msg_raw {
|
=cut |
=cut |
|
|
sub user_crit_msg { |
sub user_crit_msg { |
my ($user,$domain,$subject,$message,$sendback,$toperm)=@_; |
my ($user,$domain,$subject,$message,$sendback,$toperm,$sentmessage)=@_; |
my $status=''; |
my $status=''; |
my %userenv = &Apache::lonnet::get('environment',['msgforward'], |
my %userenv = &Apache::lonnet::get('environment',['msgforward'], |
$domain,$user); |
$domain,$user); |
Line 449 sub user_crit_msg {
|
Line 510 sub user_crit_msg {
|
my ($forwuser,$forwdomain)=split(/\:/,$_); |
my ($forwuser,$forwdomain)=split(/\:/,$_); |
$status.= |
$status.= |
&user_crit_msg_raw($forwuser,$forwdomain,$subject,$message, |
&user_crit_msg_raw($forwuser,$forwdomain,$subject,$message, |
$sendback,$toperm).' '; |
$sendback,$toperm,$sentmessage).' '; |
} |
} |
} else { |
} else { |
$status=&user_crit_msg_raw($user,$domain,$subject,$message,$sendback,$toperm); |
$status=&user_crit_msg_raw($user,$domain,$subject,$message,$sendback,$toperm,$sentmessage); |
} |
} |
return $status; |
return $status; |
} |
} |
Line 487 sub user_crit_received {
|
Line 548 sub user_crit_received {
|
|
|
sub user_normal_msg_raw { |
sub user_normal_msg_raw { |
my ($user,$domain,$subject,$message,$citation,$baseurl,$attachmenturl, |
my ($user,$domain,$subject,$message,$citation,$baseurl,$attachmenturl, |
$toperm,$newid)=@_; |
$toperm,$currid,$newid,$sentmessage)=@_; |
# Check if allowed missing |
# Check if allowed missing |
my $status=''; |
my ($status,$packed_message); |
my $msgid='undefined'; |
my $msgid='undefined'; |
my $text=$message; |
my $text=$message; |
unless (($message)&&($user)&&($domain)) { $status='empty'; }; |
unless (($message)&&($user)&&($domain)) { $status='empty'; }; |
my $homeserver=&Apache::lonnet::homeserver($user,$domain); |
my $homeserver=&Apache::lonnet::homeserver($user,$domain); |
if ($homeserver ne 'no_host') { |
if ($homeserver ne 'no_host') { |
($msgid,$message)=&packagemsg($subject,$message,$citation,$baseurl, |
($msgid,$packed_message)= |
$attachmenturl,$user,$domain); |
&packagemsg($subject,$message,$citation,$baseurl, |
|
$attachmenturl,$user,$domain,$currid); |
|
(undef, my $packed_message_no_citation)= |
|
&packagemsg($subject,$message,undef ,$baseurl, |
|
$attachmenturl,$user,$domain,$currid); |
# Store in user folder |
# Store in user folder |
$status=&Apache::lonnet::critical( |
$status=&Apache::lonnet::critical( |
'put:'.$domain.':'.$user.':nohist_email:'. |
'put:'.$domain.':'.$user.':nohist_email:'. |
&Apache::lonnet::escape($msgid).'='. |
&Apache::lonnet::escape($msgid).'='. |
&Apache::lonnet::escape($message),$homeserver); |
&Apache::lonnet::escape($packed_message),$homeserver); |
# Save new message received time |
# Save new message received time |
&Apache::lonnet::put |
&Apache::lonnet::put |
('email_status',{'recnewemail'=>time},$domain,$user); |
('email_status',{'recnewemail'=>time},$domain,$user); |
# Into sent-mail folder unless a broadcast message |
# Into sent-mail folder unless a broadcast message or critical message |
unless (($env{'request.course.id'}) && ($env{'form.sendmode'} eq 'group')) { |
unless (($env{'request.course.id'}) && |
$status .= &store_sent_mail($msgid,$message); |
(($env{'form.sendmode'} eq 'group') || |
|
(($env{'form.critmsg'}) || ($env{'form.sendbck'})) && |
|
(&Apache::lonnet::allowed('srm',$env{'request.course.id'}) |
|
|| &Apache::lonnet::allowed('srm',$env{'request.course.id'}. |
|
'/'.$env{'request.course.sec'})))) { |
|
$status .= &store_sent_mail($msgid,$packed_message_no_citation); |
} |
} |
} else { |
} else { |
$status='no_host'; |
$status='no_host'; |
Line 515 sub user_normal_msg_raw {
|
Line 585 sub user_normal_msg_raw {
|
if (defined($newid)) { |
if (defined($newid)) { |
$$newid = $msgid; |
$$newid = $msgid; |
} |
} |
|
if (defined($sentmessage)) { |
|
$$sentmessage = $packed_message; |
|
} |
|
|
# Notifications |
# Notifications |
my %userenv = &Apache::lonnet::get('environment',['notification', |
my %userenv = &Apache::lonnet::get('environment',['notification', |
'permanentemail'], |
'permanentemail'], |
Line 545 sub user_normal_msg_raw {
|
Line 619 sub user_normal_msg_raw {
|
|
|
sub user_normal_msg { |
sub user_normal_msg { |
my ($user,$domain,$subject,$message,$citation,$baseurl,$attachmenturl, |
my ($user,$domain,$subject,$message,$citation,$baseurl,$attachmenturl, |
$toperm)=@_; |
$toperm,$sentmessage)=@_; |
my $status=''; |
my $status=''; |
my %userenv = &Apache::lonnet::get('environment',['msgforward'], |
my %userenv = &Apache::lonnet::get('environment',['msgforward'], |
$domain,$user); |
$domain,$user); |
my $msgforward=$userenv{'msgforward'}; |
my $msgforward=$userenv{'msgforward'}; |
if ($msgforward) { |
if ($msgforward) { |
foreach (split(/\,/,$msgforward)) { |
foreach (split(/\,/,$msgforward)) { |
my ($forwuser,$forwdomain)=split(/\:/,$_); |
my ($forwuser,$forwdomain)=split(/\:/,$_); |
$status.= |
$status.= |
&user_normal_msg_raw($forwuser,$forwdomain,$subject,$message, |
&user_normal_msg_raw($forwuser,$forwdomain,$subject,$message, |
$citation,$baseurl,$attachmenturl,$toperm).' '; |
$citation,$baseurl,$attachmenturl,$toperm, |
} |
undef,undef,$sentmessage).' '; |
|
} |
} else { |
} else { |
$status=&user_normal_msg_raw($user,$domain,$subject,$message, |
$status=&user_normal_msg_raw($user,$domain,$subject,$message, |
$citation,$baseurl,$attachmenturl,$toperm); |
$citation,$baseurl,$attachmenturl,$toperm, |
|
undef,undef,$sentmessage); |
} |
} |
return $status; |
return $status; |
} |
} |
|
|
sub store_sent_mail { |
sub store_sent_mail { |
my ($msgid,$message) = @_; |
my ($msgid,$message) = @_; |
my $status =' '.&Apache::lonnet::critical( |
my $status =' '.&Apache::lonnet::critical( |
'put:'.$env{'user.domain'}.':'.$env{'user.name'}. |
'put:'.$env{'user.domain'}.':'.$env{'user.name'}. |
':nohist_email_sent:'. |
':nohist_email_sent:'. |
&Apache::lonnet::escape($msgid).'='. |
&Apache::lonnet::escape($msgid).'='. |
&Apache::lonnet::escape($message),$env{'user.home'}); |
&Apache::lonnet::escape($message),$env{'user.home'}); |
return $status; |
return $status; |
} |
} |
|
|
Line 636 sub statuschange {
|
Line 712 sub statuschange {
|
&Apache::lonnet::put('email_status'.$suffix,{$msgid => $newstatus}); |
&Apache::lonnet::put('email_status'.$suffix,{$msgid => $newstatus}); |
} |
} |
if ($newstatus eq 'deleted') { |
if ($newstatus eq 'deleted') { |
&movemsg(&Apache::lonnet::unescape($msgid),$folder,'trash'); |
return &movemsg($msgid,$folder,'trash'); |
} |
} |
|
return ; |
} |
} |
|
|
# ============================================================= Make new folder |
# ============================================================= Make new folder |
Line 658 sub movemsg {
|
Line 735 sub movemsg {
|
if ($srcfolder eq 'new') { $srcfolder=''; } |
if ($srcfolder eq 'new') { $srcfolder=''; } |
my $srcsuffix=&foldersuffix($srcfolder); |
my $srcsuffix=&foldersuffix($srcfolder); |
my $trgsuffix=&foldersuffix($trgfolder); |
my $trgsuffix=&foldersuffix($trgfolder); |
|
if ($srcsuffix eq $trgsuffix) { |
|
return (0,&mt('Message not moved, Attempted to move message to the same folder as it already is in.')); |
|
} |
|
|
# Copy message |
# Copy message |
my %message=&Apache::lonnet::get('nohist_email'.$srcsuffix,[$msgid]); |
my %message=&Apache::lonnet::get('nohist_email'.$srcsuffix,[$msgid]); |
&Apache::lonnet::put('nohist_email'.$trgsuffix,{$msgid => $message{$msgid}}); |
if (!exists($message{$msgid}) || $message{$msgid} eq '') { |
|
if (&Apache::slotrequest::network_error(%message)) { |
|
return (0,&mt('Message not moved, A network error occurred.')); |
|
} else { |
|
return (0,&mt('Message not moved as the message is no longer in the source folder.')); |
|
} |
|
} |
|
|
|
my $result =&Apache::lonnet::put('nohist_email'.$trgsuffix, |
|
{$msgid => $message{$msgid}}); |
|
if (&Apache::slotrequest::network_error($result)) { |
|
return (0,&mt('Message not moved, A network error occurred.')); |
|
} |
|
|
# Copy status |
# Copy status |
unless ($trgfolder eq 'trash') { |
unless ($trgfolder eq 'trash') { |
my %status=&Apache::lonnet::get('email_status'.$srcsuffix,[$msgid]); |
my %status=&Apache::lonnet::get('email_status'.$srcsuffix,[$msgid]); |
&Apache::lonnet::put('email_status'.$trgsuffix,{$msgid => $status{$msgid}}); |
# a non-existant status is the mark of an unread msg |
|
if (&Apache::slotrequest::network_error(%status)) { |
|
return (0,&mt('Message copied to new folder but status was not, A network error occurred.')); |
|
} |
|
my $result=&Apache::lonnet::put('email_status'.$trgsuffix, |
|
{$msgid => $status{$msgid}}); |
|
if (&Apache::slotrequest::network_error($result)) { |
|
return (0,&mt('Message copied to new folder but status was not, A network error occurred.')); |
|
} |
} |
} |
|
|
# Delete orginals |
# Delete orginals |
&Apache::lonnet::del('nohist_email'.$srcsuffix,[$msgid]); |
my $result_del_msg = |
&Apache::lonnet::del('email_status'.$srcsuffix,[$msgid]); |
&Apache::lonnet::del('nohist_email'.$srcsuffix,[$msgid]); |
|
my $result_del_stat = |
|
&Apache::lonnet::del('email_status'.$srcsuffix,[$msgid]); |
|
if (&Apache::slotrequest::network_error($result_del_msg)) { |
|
return (0,&mt('Message copied, but unable to delete the original from the source folder.')); |
|
} |
|
if (&Apache::slotrequest::network_error($result_del_stat)) { |
|
return (0,&mt('Message copied, but unable to delete the original status from the source folder.')); |
|
} |
|
|
|
return (1); |
} |
} |
|
|
# ======================================================= Display a course list |
# ======================================================= Display a course list |
Line 806 sub sortedmessages {
|
Line 917 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 864 sub sortedmessages {
|
Line 979 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 889 sub disnew {
|
Line 1013 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 901 sub disnew {
|
Line 1022 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 914 sub disnew {
|
Line 1039 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 1085 ENDDISHEADER
|
Line 1210 ENDDISHEADER
|
$description.'</td><td>'.$status.'</td></tr>'."\n"); |
$description.'</td><td>'.$status.'</td></tr>'."\n"); |
} elsif ($status eq 'deleted') { |
} elsif ($status eq 'deleted') { |
# purge |
# purge |
&movemsg(&Apache::lonnet::unescape($origID),$folder,'trash'); |
my ($result,$msg) = |
|
&movemsg(&Apache::lonnet::unescape($origID),$folder,'trash'); |
|
|
} |
} |
} |
} |
$r->print("</table>\n<p>". |
$r->print("</table>\n<p>". |
Line 1158 sub compout {
|
Line 1285 sub compout {
|
'ca' => 'Cancel', |
'ca' => 'Cancel', |
'ma' => 'Mail'); |
'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"); |
my $crithelp = Apache::loncommon::help_open_topic("Course_Critical_Message"); |
$dispcrit= |
$dispcrit= |
'<p><label><input type="checkbox" name="critmsg" /> '.&mt('Send as critical message').'</label> ' . $crithelp . |
'<p><label><input type="checkbox" name="critmsg" /> '.&mt('Send as critical message').'</label> ' . $crithelp . |
Line 1167 sub compout {
|
Line 1296 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'}; |
Line 1284 $dispcrit
|
Line 1413 $dispcrit
|
ENDUPLOAD |
ENDUPLOAD |
} |
} |
if ($broadcast eq 'group') { |
if ($broadcast eq 'group') { |
&discourse; |
&discourse($r); |
} |
} |
$r->print('</form>'. |
$r->print('</form>'. |
&Apache::lonfeedback::generate_preview_button('compemail','message'). |
&Apache::lonfeedback::generate_preview_button('compemail','message'). |
Line 1297 sub retrieve_instructor_comments {
|
Line 1426 sub retrieve_instructor_comments {
|
my ($user,$domain)=@_; |
my ($user,$domain)=@_; |
my $target=$env{'form.grade_target'}; |
my $target=$env{'form.grade_target'}; |
if (! $env{'request.course.id'}) { return; } |
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; |
return; |
} |
} |
my %records=&Apache::lonnet::dump('nohist_email', |
my %records=&Apache::lonnet::dump('nohist_email', |
Line 1322 sub disfacetoface {
|
Line 1453 sub disfacetoface {
|
my ($r,$user,$domain)=@_; |
my ($r,$user,$domain)=@_; |
my $target=$env{'form.grade_target'}; |
my $target=$env{'form.grade_target'}; |
unless ($env{'request.course.id'}) { return; } |
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; |
return; |
} |
} |
my %records=&Apache::lonnet::dump('nohist_email', |
my %records=&Apache::lonnet::dump('nohist_email', |
Line 1338 sub disfacetoface {
|
Line 1472 sub disfacetoface {
|
$result.='<h3>'.&mt('Record').'</h3>'; |
$result.='<h3>'.&mt('Record').'</h3>'; |
} elsif ($content{'subject'}=~/^Broadcast/) { |
} elsif ($content{'subject'}=~/^Broadcast/) { |
$result .='<h3>'.&mt('Broadcast Message').'</h3>'; |
$result .='<h3>'.&mt('Broadcast Message').'</h3>'; |
|
if ($content{'subject'}=~/^Broadcast\./) { |
|
%content=&unpackagemsg($content{'message'}); |
|
$content{'message'}= |
|
'<b>'.&mt('Subject').': '.$content{'subject'}.'</b><br />'. |
|
$content{'message'}; |
|
} |
} else { |
} else { |
$result.='<h3>'.&mt('Critical Message').'</h3>'; |
$result.='<h3>'.&mt('Critical Message').'</h3>'; |
%content=&unpackagemsg($content{'message'}); |
%content=&unpackagemsg($content{'message'}); |
Line 1370 $content{'sendername'}.'@'.
|
Line 1510 $content{'sendername'}.'@'.
|
|
|
sub facetoface { |
sub facetoface { |
my ($r,$stage)=@_; |
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; |
return; |
} |
} |
&printheader($r, |
&printheader($r, |
Line 1413 ENDTREC
|
Line 1556 ENDTREC
|
($env{'form.recdomain'}) && ($env{'form.recuname'})) { |
($env{'form.recdomain'}) && ($env{'form.recuname'})) { |
chomp($env{'form.newrecord'}); |
chomp($env{'form.newrecord'}); |
if ($env{'form.newrecord'}) { |
if ($env{'form.newrecord'}) { |
&user_normal_msg_raw( |
&Apache::lonmsg::store_instructor_comment($env{'form.newrecord'}, |
$env{'course.'.$env{'request.course.id'}.'.num'}, |
$env{'form.recuname'}, |
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
$env{'form.recdomain'}); |
&mt('Record'). |
|
' ['.$env{'form.recuname'}.':'.$env{'form.recdomain'}.']', |
|
$env{'form.newrecord'}); |
|
} |
} |
$r->print('<h3>'.&Apache::loncommon::plainname($env{'form.recuname'}, |
$r->print('<h3>'.&Apache::loncommon::plainname($env{'form.recuname'}, |
$env{'form.recdomain'}).'</h3>'); |
$env{'form.recdomain'}).'</h3>'); |
Line 1444 ENDBFORM
|
Line 1584 ENDBFORM
|
sub examblock { |
sub examblock { |
my ($r,$action) = @_; |
my ($r,$action) = @_; |
unless ($env{'request.course.id'}) { return;} |
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( |
my %lt=&Apache::lonlocal::texthash( |
'comb' => 'Communication Blocking', |
'comb' => 'Communication Blocking', |
'cbds' => 'Communication blocking during scheduled exams', |
'cbds' => 'Communication blocking during scheduled exams', |
Line 1935 sub displayresource {
|
Line 2080 sub displayresource {
|
$content{'sendername'}, |
$content{'sendername'}, |
$content{'senderdomain'}, |
$content{'senderdomain'}, |
$content{'courseid'}); |
$content{'courseid'}); |
} else { |
} elsif ($env{'user.adv'}) { |
return $content{'citation'}; |
return $content{'citation'}; |
} |
} |
|
return ''; |
} |
} |
|
|
# ================================================================== The Header |
# ================================================================== The Header |
Line 2009 sub sendoffmail {
|
Line 2155 sub sendoffmail {
|
my ($r,$folder)=@_; |
my ($r,$folder)=@_; |
my $suffix=&foldersuffix($folder); |
my $suffix=&foldersuffix($folder); |
my $sendstatus=''; |
my $sendstatus=''; |
my %broadcast_status; |
my %specialmsg_status; |
my $numbroadcast = 0; |
my $numspecial = 0; |
if ($env{'form.send'}) { |
if ($env{'form.send'}) { |
&printheader($r,'','Messages being sent.'); |
&printheader($r,'','Messages being sent.'); |
$r->rflush(); |
$r->rflush(); |
Line 2056 sub sendoffmail {
|
Line 2202 sub sendoffmail {
|
} |
} |
} |
} |
|
|
my $basicmsg; |
my $savemsg; |
my $msgtype; |
my $msgtype; |
|
my %sentmessage; |
if ((($env{'form.critmsg'}) || ($env{'form.sendbck'})) && |
if ((($env{'form.critmsg'}) || ($env{'form.sendbck'})) && |
(&Apache::lonnet::allowed('srm',$env{'request.course.id'}))) { |
(&Apache::lonnet::allowed('srm',$env{'request.course.id'}) |
$basicmsg=&Apache::lonfeedback::clear_out_html($env{'form.message'},1); |
|| &Apache::lonnet::allowed('srm',$env{'request.course.id'}. |
$msgtype = '(critical)'; |
'/'.$env{'request.course.sec'}) |
|
)) { |
|
$savemsg=&Apache::lonfeedback::clear_out_html($env{'form.message'},1); |
|
$msgtype = 'critical'; |
} else { |
} else { |
$basicmsg=&Apache::lonfeedback::clear_out_html($env{'form.message'}); |
$savemsg=&Apache::lonfeedback::clear_out_html($env{'form.message'}); |
} |
} |
|
|
foreach (keys %toaddr) { |
foreach (keys %toaddr) { |
my ($recuname,$recdomain)=split(/\:/,$_); |
my ($recuname,$recdomain)=split(/\:/,$_); |
my $msgtxt = $basicmsg; |
my $msgtxt = $savemsg; |
if ($toaddr{$_}) { $msgtxt.='<hr />'.$toaddr{$_}; } |
if ($toaddr{$_}) { $msgtxt.='<hr />'.$toaddr{$_}; } |
my $thismsg; |
my $thismsg; |
if ((($env{'form.critmsg'}) || ($env{'form.sendbck'})) && |
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.': '); |
$r->print(&mt('Sending critical message').' '.$recuname.'@'.$recdomain.': '); |
$thismsg=&user_crit_msg($recuname,$recdomain, |
$thismsg=&user_crit_msg($recuname,$recdomain, |
&Apache::lonfeedback::clear_out_html($env{'form.subject'}), |
&Apache::lonfeedback::clear_out_html($env{'form.subject'}), |
$msgtxt, |
$msgtxt, |
$env{'form.sendbck'},$env{'form.permanent'}); |
$env{'form.sendbck'},$env{'form.permanent'},\$sentmessage{$_}); |
} else { |
} else { |
$r->print(&mt('Sending').' '.$recuname.'@'.$recdomain.': '); |
$r->print(&mt('Sending').' '.$recuname.'@'.$recdomain.': '); |
$thismsg=&user_normal_msg($recuname,$recdomain, |
$thismsg=&user_normal_msg($recuname,$recdomain, |
&Apache::lonfeedback::clear_out_html($env{'form.subject'}), |
&Apache::lonfeedback::clear_out_html($env{'form.subject'}), |
$msgtxt, |
$msgtxt, |
$content{'citation'},undef,undef,$env{'form.permanent'}); |
$content{'citation'},undef,undef,$env{'form.permanent'},\$sentmessage{$_}); |
} |
} |
if (($env{'request.course.id'}) && |
if (($env{'request.course.id'}) && (($msgtype eq 'critical') || |
($env{'form.sendmode'} eq 'group')) { |
($env{'form.sendmode'} eq 'group'))) { |
$broadcast_status{$recuname.':'.$recdomain} = $thismsg; |
$specialmsg_status{$recuname.':'.$recdomain} = $thismsg; |
if ($thismsg eq 'ok') { |
if ($thismsg eq 'ok') { |
$numbroadcast ++; |
$numspecial ++; |
} |
} |
} |
} |
$r->print($thismsg.'<br />'); |
$r->print($thismsg.'<br />'); |
$sendstatus.=' '.$thismsg; |
$sendstatus.=' '.$thismsg; |
} |
} |
if (($env{'request.course.id'}) && ($env{'form.sendmode'} eq 'group')) { |
if (($env{'request.course.id'}) && (($env{'form.sendmode'} eq 'group') |
|
|| ($msgtype eq 'critical'))) { |
my $subj_prefix; |
my $subj_prefix; |
if ($msgtype eq 'critical') { |
if ($msgtype eq 'critical') { |
$subj_prefix = 'Critical broadcast'; |
$subj_prefix = 'Critical.'; |
} else { |
} else { |
$subj_prefix = 'Broadcast'; |
$subj_prefix = 'Broadcast.'; |
} |
} |
my ($broadmsgid,$broadresult); |
my ($specialmsgid,$specialresult); |
if ($numbroadcast) { |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
$broadresult = &user_normal_msg_raw( |
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
$env{'course.'.$env{'request.course.id'}.'.num'}, |
my $course_str = &Apache::lonnet::escape('['.$cnum.':'.$cdom.']'); |
$env{'course.'.$env{'request.course.id'}.'.domain'}, $subj_prefix.' to: '.$env{'course.'.$env{'request.course.id'}.'.description'}. |
|
' ('.$numbroadcast.' sent)',$basicmsg,undef,undef,undef, |
if ($numspecial) { |
undef,\$broadmsgid); |
$specialresult = &user_normal_msg_raw($cnum,$cdom,$subj_prefix. |
|
' '.$course_str,$savemsg,undef,undef,undef, |
|
undef,undef,\$specialmsgid); |
|
$specialmsgid = &Apache::lonnet::unescape($specialmsgid); |
} |
} |
if ($broadresult eq 'ok') { |
if ($specialresult eq 'ok') { |
my $record_sent; |
my $record_sent; |
my @recusers = (); |
my @recusers = (); |
my @recudoms = (); |
my @recudoms = (); |
|
my ($stamp,$msgsubj,$msgname,$msgdom,$msgcount,$context,$pid) = |
|
split(/\:/,&Apache::lonnet::unescape($specialmsgid)); |
foreach my $recipient (sort(keys(%toaddr))) { |
foreach my $recipient (sort(keys(%toaddr))) { |
if ($broadcast_status{$recipient} eq 'ok') { |
if ($specialmsg_status{$recipient} eq 'ok') { |
|
my $usersubj = $subj_prefix.'['.$recipient.']'; |
|
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); |
my ($uname,$udom) = split/:/,$recipient; |
my ($uname,$udom) = split/:/,$recipient; |
push(@recusers,$uname); |
push(@recusers,$uname); |
push(@recudoms,$udom); |
push(@recudoms,$udom); |
} |
} |
} |
} |
if (@recusers) { |
if (@recusers) { |
my $broadmessage; |
my $specialmessage; |
($broadmsgid,$broadmessage)=&packagemsg(&Apache::lonfeedback::clear_out_html($env{'form.subject'}),$basicmsg,undef,undef,undef,\@recusers,\@recudoms,$broadmsgid); |
my $sentsubj = $subj_prefix.' ('.$numspecial.' sent) '. |
$record_sent = &store_sent_mail($broadmsgid,$broadmessage); |
&Apache::lonfeedback::clear_out_html($env{'form.subject'}); |
|
$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); |
|
$record_sent = &store_sent_mail($specialmsgid,$specialmessage); |
} |
} |
} else { |
} else { |
&Apache::lonnet::logthis('Failed to create record of broadcast in '.$env{'course.'.$env{'request.course.id'}.'.num'}.' at '.$env{'course.'.$env{'request.course.id'}.'.domain'}.' - no msgid generated'); |
&Apache::lonnet::logthis('Failed to create record of critical message or broadcast in '.$env{'course.'.$env{'request.course.id'}.'.num'}.' at '.$env{'course.'.$env{'request.course.id'}.'.domain'}.' - no msgid generated'); |
} |
} |
} |
} |
} else { |
} else { |
Line 2251 sub handler {
|
Line 2423 sub handler {
|
&compout($r,$env{'form.forward'},undef,undef,undef,$folder); |
&compout($r,$env{'form.forward'},undef,undef,undef,$folder); |
} elsif ($env{'form.markdel'}) { |
} elsif ($env{'form.markdel'}) { |
&printheader($r,'','Deleted Message'); |
&printheader($r,'','Deleted Message'); |
&statuschange($env{'form.markdel'},'deleted',$folder); |
my ($result,$msg) = |
|
&statuschange($env{'form.markdel'},'deleted',$folder); |
|
if (!$result) { |
|
$r->print('<p style="color: red">Failed to delete the message.</p>'. |
|
'<p style="color: red">'.$msg."</p>\n"); |
|
} |
&Apache::loncommunicate::menu($r); |
&Apache::loncommunicate::menu($r); |
&disall($r,($folder?$folder:$dismode)); |
&disall($r,($folder?$folder:$dismode)); |
} elsif ($env{'form.markedmove'}) { |
} elsif ($env{'form.markedmove'}) { |
my $total=0; |
my ($total,$failed,@failed_msg)=(0,0); |
foreach (keys %env) { |
foreach my $key (keys(%env)) { |
if ($_=~/^form\.delmark_(.*)$/) { |
if ($key=~/^form\.delmark_(.*)$/) { |
&movemsg(&Apache::lonnet::unescape($1),$folder, |
my ($result,$msg) = |
$env{'form.movetofolder'}); |
&movemsg(&Apache::lonnet::unescape($1),$folder, |
$total++; |
$env{'form.movetofolder'}); |
|
if ($result) { |
|
$total++; |
|
} else { |
|
$failed++; |
|
push(@failed_msg,$msg); |
|
} |
} |
} |
} |
} |
&printheader($r,'','Moved Messages'); |
&printheader($r,'','Moved Messages'); |
|
if ($failed) { |
|
$r->print('<p style="color: red;"> |
|
Failed to move '.$failed.' message(s)</p>'); |
|
$r->print('<p style="color: red;">'. |
|
join("</p>\n<p style=\"color: red;\">",@failed_msg). |
|
"</p>\n"); |
|
} |
$r->print('Moved '.$total.' message(s)<p>'); |
$r->print('Moved '.$total.' message(s)<p>'); |
&Apache::loncommunicate::menu($r); |
&Apache::loncommunicate::menu($r); |
&disall($r,($folder?$folder:$dismode)); |
&disall($r,($folder?$folder:$dismode)); |
} elsif ($env{'form.markeddel'}) { |
} elsif ($env{'form.markeddel'}) { |
my $total=0; |
my ($total,$failed,@failed_msg)=(0,0); |
foreach (keys %env) { |
foreach my $key (keys(%env)) { |
if ($_=~/^form\.delmark_(.*)$/) { |
if ($key=~/^form\.delmark_(.*)$/) { |
&statuschange(&Apache::lonnet::unescape($1),'deleted',$folder); |
my ($result,$msg) = |
$total++; |
&statuschange(&Apache::lonnet::unescape($1),'deleted', |
|
$folder); |
|
if ($result) { |
|
$total++; |
|
} else { |
|
$failed++; |
|
push(@failed_msg,$msg); |
|
} |
} |
} |
} |
} |
&printheader($r,'','Deleted Messages'); |
&printheader($r,'','Deleted Messages'); |
|
if ($failed) { |
|
$r->print('<p style="color: red;"> |
|
Failed to delete '.$failed.' message(s)</p>'); |
|
$r->print('<p style="color: red;">'. |
|
join("</p>\n<p style=\"color: red;\">",@failed_msg). |
|
"</p>\n"); |
|
} |
$r->print('Deleted '.$total.' message(s)<p>'); |
$r->print('Deleted '.$total.' message(s)<p>'); |
&Apache::loncommunicate::menu($r); |
&Apache::loncommunicate::menu($r); |
&disall($r,($folder?$folder:$dismode)); |
&disall($r,($folder?$folder:$dismode)); |