--- loncom/interface/lonmsgdisplay.pm 2006/04/25 19:50:09 1.13
+++ loncom/interface/lonmsgdisplay.pm 2006/11/29 07:46:39 1.44
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines for messaging display
#
-# $Id: lonmsgdisplay.pm,v 1.13 2006/04/25 19:50:09 albertel Exp $
+# $Id: lonmsgdisplay.pm,v 1.44 2006/11/29 07:46:39 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -125,6 +125,9 @@ use Apache::lonlocal;
use Apache::loncommunicate;
use Apache::lonfeedback;
use Apache::lonrss();
+use Apache::lonselstudent();
+use lib '/home/httpd/lib/perl/';
+use LONCAPA;
# Querystring component with sorting type
my $sqs;
@@ -214,7 +217,7 @@ sub movemsg {
# Copy message
my %message=&Apache::lonnet::get('nohist_email'.$srcsuffix,[$msgid]);
if (!exists($message{$msgid}) || $message{$msgid} eq '') {
- if (&Apache::slotrequest::network_error(%message)) {
+ if (&Apache::lonnet::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.'));
@@ -223,7 +226,7 @@ sub movemsg {
my $result =&Apache::lonnet::put('nohist_email'.$trgsuffix,
{$msgid => $message{$msgid}});
- if (&Apache::slotrequest::network_error($result)) {
+ if (&Apache::lonnet::error($result)) {
return (0,&mt('Message not moved, A network error occurred.'));
}
@@ -231,12 +234,12 @@ sub movemsg {
unless ($trgfolder eq 'trash') {
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)) {
+ if (&Apache::lonnet::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)) {
+ if (&Apache::lonnet::error($result)) {
return (0,&mt('Message copied to new folder but status was not, A network error occurred.'));
}
}
@@ -246,10 +249,10 @@ sub movemsg {
&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)) {
+ if (&Apache::lonnet::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)) {
+ if (&Apache::lonnet::error($result_del_stat)) {
return (0,&mt('Message copied, but unable to delete the original status from the source folder.'));
}
@@ -259,89 +262,219 @@ sub movemsg {
# ======================================================= Display a course list
sub discourse {
- my $r=shift;
- my $classlist = &Apache::loncoursedata::get_classlist();
- my $now=time;
- my %lt=&Apache::lonlocal::texthash('cfa' => 'Check All',
- 'cfs' => 'Check Section/Group',
- 'cfn' => 'Uncheck All');
- $r->print(<
-
-
-
-
-
-
-ENDDISHEADER
- my %coursepersonnel=&Apache::lonnet::get_course_adv_roles();
- $r->print('
');
- foreach my $role (sort keys %coursepersonnel) {
- foreach (split(/\,/,$coursepersonnel{$role})) {
- my ($puname,$pudom)=split(/\:/,$_);
- $r->print('
'.
- '
('.$_.'),
'.$role.'
');
- }
- }
- $r->print('
');
- my $sort = sub {
- my $aname=lc($classlist->{$a}[&Apache::loncoursedata::CL_FULLNAME()]);
- if (!$aname) { $aname=$a; }
- my $bname=lc($classlist->{$b}[&Apache::loncoursedata::CL_FULLNAME()]);
- if (!$bname) { $bname=$b; }
- return $aname cmp $bname;
- };
- foreach my $student (sort $sort (keys(%{$classlist}))) {
- my $info=$classlist->{$student};
- my ($sname,$sdom,$status,$fullname,$section) =
- (@{$info}[&Apache::loncoursedata::CL_SNAME(),
- &Apache::loncoursedata::CL_SDOM(),
- &Apache::loncoursedata::CL_STATUS(),
- &Apache::loncoursedata::CL_FULLNAME(),
- &Apache::loncoursedata::CL_SECTION()]);
- next if ($status ne 'Active');
- next if ($env{'request.course.sec'} &&
- $section ne $env{'request.course.sec'});
- my $key = 'send_to_&&&'.$section.'&&&_'.$student;
- if (! defined($fullname) || $fullname eq '') { $fullname = $sname; }
- $r->print('
'.
&mt('You have to confirm that you received this message. After confirmation, this message will be moved to your regular inbox').
' '.
- ''.
- ''.
+ '';
}
# Check to see if there were any messages.
@@ -400,7 +533,7 @@ sub sortedmessages {
}
foreach my $msgid (@messages) {
- my $esc_msgid=&Apache::lonnet::escape($msgid);
+ my $esc_msgid=&escape($msgid);
my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$fromcid)=
&Apache::lonmsg::unpackmsgid($esc_msgid,$folder,undef,
\%status_cache);
@@ -507,7 +640,7 @@ sub disnew {
my %lt=&Apache::lonlocal::texthash(
'nm' => 'New Messages',
'su' => 'Subject',
- 'co' => 'Course',
+ 'co' => 'Course/Group',
'da' => 'Date',
'us' => 'Username',
'op' => 'Open',
@@ -516,17 +649,15 @@ sub disnew {
my @msgids = sort(&Apache::lonnet::getkeys('nohist_email'));
my @newmsgs;
my %setters = ();
- my $startblock = 0;
- my $endblock = 0;
my %blocked = ();
my $numblocked = 0;
# Check for blocking of display because of scheduled online exams.
- &blockcheck(\%setters,\$startblock,\$endblock);
+ my ($startblock,$endblock) = &Apache::loncommon::blockcheck(\%setters,'com');
my %status_cache =
&Apache::lonnet::get('email_status',\@msgids);
my %descriptions;
- foreach (@msgids) {
- my $msgid=&Apache::lonnet::escape($_);
+ foreach my $id (@msgids) {
+ my $msgid=&escape($id);
my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=
&Apache::lonmsg::unpackmsgid($msgid,undef,undef,\%status_cache);
if (defined($sendtime) && $sendtime!~/error/) {
@@ -535,7 +666,7 @@ sub disnew {
$sendtime = &Apache::lonlocal::locallocaltime($sendtime);
if ($status eq 'new') {
if ($numsendtime >= $startblock && ($numsendtime <= $endblock && $endblock > 0) ) {
- $blocked{$_} = 'ON';
+ $blocked{$id} = 'ON';
$numblocked ++;
} else {
push @newmsgs, {
@@ -561,8 +692,8 @@ TABLEHEAD
");
+ foreach my $item ('sendtime','from','fromdom','shortsub','course') {
+ $r->print("
$msg->{$item}
");
}
$r->print("
");
}
@@ -582,7 +713,8 @@ ENDLINK
}
$r->print(
&mt('display of LON-CAPA messages sent to you by other students between').' '.$beginblock.' '.&mt('and').' '.$finishblock.' '.&mt('is currently being blocked because of online exams').'.');
- &build_block_table($r,$startblock,$endblock,\%setters);
+ $r->print(&Apache::loncommon::build_block_table($startblock,$endblock,
+ \%setters));
}
}
@@ -607,12 +739,10 @@ sub disfolder {
my ($r,$folder)=@_;
my %blocked = ();
my %setters = ();
- my $startblock;
- my $endblock;
my $numblocked = 0;
- &blockcheck(\%setters,\$startblock,\$endblock);
+ my ($startblock,$endblock) = &Apache::loncommon::blockcheck(\%setters,'com');
$r->print(<
+
ENDDISHEADER
my $fsqs='&folder='.$folder;
- my @temp=sortedmessages(\%blocked,$startblock,$endblock,\$numblocked,$folder);
+ my @temp=&sortedmessages(\%blocked,$startblock,$endblock,\$numblocked,$folder);
my $totalnumber=$#temp+1;
unless ($totalnumber>0) {
$r->print('