--- loncom/interface/lonmsgdisplay.pm 2006/04/22 17:10:07 1.4
+++ loncom/interface/lonmsgdisplay.pm 2006/04/25 20:02:30 1.14
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines for messaging display
#
-# $Id: lonmsgdisplay.pm,v 1.4 2006/04/22 17:10:07 albertel Exp $
+# $Id: lonmsgdisplay.pm,v 1.14 2006/04/25 20:02:30 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -184,8 +184,9 @@ sub statuschange {
&Apache::lonnet::put('email_status'.$suffix,{$msgid => $newstatus});
}
if ($newstatus eq 'deleted') {
- &movemsg(&Apache::lonnet::unescape($msgid),$folder,'trash');
- }
+ return &movemsg($msgid,$folder,'trash');
+ }
+ return ;
}
# ============================================================= Make new folder
@@ -206,19 +207,53 @@ sub movemsg {
if ($srcfolder eq 'new') { $srcfolder=''; }
my $srcsuffix=&Apache::lonmsg::foldersuffix($srcfolder);
my $trgsuffix=&Apache::lonmsg::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
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
unless ($trgfolder eq 'trash') {
- my %status=&Apache::lonnet::get('email_status'.$srcsuffix,[$msgid]);
- &Apache::lonnet::put('email_status'.$trgsuffix,{$msgid => $status{$msgid}});
+ my %status=&Apache::lonnet::get('email_status'.$srcsuffix,[$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
- &Apache::lonnet::del('nohist_email'.$srcsuffix,[$msgid]);
- &Apache::lonnet::del('email_status'.$srcsuffix,[$msgid]);
+ my $result_del_msg =
+ &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
@@ -303,7 +338,7 @@ ENDDISHEADER
if (! defined($fullname) || $fullname eq '') { $fullname = $sname; }
$r->print('
'.$sname.'@'.$sdom.'
'.$section.
+ $fullname.'
'.$sname.':'.$sdom.'
'.$section.
'
');
}
$r->print('');
@@ -313,7 +348,7 @@ ENDDISHEADER
sub discrit {
my $r=shift;
- my $header = '