--- loncom/interface/lonmsgdisplay.pm 2006/04/22 17:03:43 1.3 +++ loncom/interface/lonmsgdisplay.pm 2006/04/26 14:10:58 1.18 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines for messaging display # -# $Id: lonmsgdisplay.pm,v 1.3 2006/04/22 17:03:43 albertel Exp $ +# $Id: lonmsgdisplay.pm,v 1.18 2006/04/26 14:10:58 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 @@ -232,7 +267,7 @@ sub discourse { 'cfn' => 'Uncheck All'); $r->print(< -