--- loncom/interface/lonmsgdisplay.pm 2006/12/17 15:52:37 1.52
+++ loncom/interface/lonmsgdisplay.pm 2007/05/02 01:33:49 1.72
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines for messaging display
#
-# $Id: lonmsgdisplay.pm,v 1.52 2006/12/17 15:52:37 raeburn Exp $
+# $Id: lonmsgdisplay.pm,v 1.72 2007/05/02 01:33:49 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -33,12 +33,13 @@ package Apache::lonmsgdisplay;
=head1 NAME
-Apache::lonmsg: supports internal messaging
+Apache::lonmsgdisplay: supports internal messaging
=head1 SYNOPSIS
-lonmsg provides routines for sending messages, receiving messages, and
-a handler to allow users to read, send, and delete messages.
+lonmsgdisplay provides a handler to allow users to read, send,
+and delete messages, and to create and delete message folders,
+and to move messages between folders.
=head1 OVERVIEW
@@ -93,25 +94,6 @@ addresses on their B
'.
- &mt('Showing messages [_1] through [_2] of [_3]',$first,$finish,$total).'';
+ &mt('[_1] messages: showing messages [_2] through [_3] of [_4].',$status,$first,$finish,$total).'';
}
# =============================================================== Status Change
@@ -355,18 +364,18 @@ sub deletefolder {
my ($folder)=@_;
my %permfolders = &get_permanent_folders();
if (defined($permfolders{$folder})) {
- return &mt('The folder [_1] may not be deleted',$folder);
+ return &mt('The folder "[_1]" may not be deleted',$folder);
}
my %userfolders = &Apache::lonmsg::get_user_folders();
if (!defined($userfolders{$folder})) {
- return &mt('The folder [_1] does not exist so deletion is not required.',
+ return &mt('The folder "[_1]" does not exist so deletion is not required.',
$folder);
}
# check folder is empty;
my $suffix=&Apache::lonmsg::foldersuffix($folder);
my @messages = &Apache::lonnet::getkeys('nohist_email'.$suffix);
if (@messages > 0) {
- return &mt('The folder [_1] contains messages so it may not be deleted.').
+ return &mt('The folder "[_1]" contains messages so it may not be deleted.',$folder).
'
'.
&mt('Delete or move the messages to a different folder first.');
}
@@ -745,10 +754,9 @@ $content{'sendername'}.':'.
}
sub sortedmessages {
- my ($blocked,$startblock,$endblock,$numblocked,$folder) = @_;
+ my ($blocked,$startblock,$endblock,$numblocked,$folder,$msgstatus) = @_;
my $suffix=&Apache::lonmsg::foldersuffix($folder);
my @messages = &Apache::lonnet::getkeys('nohist_email'.$suffix);
-
#unpack the varibles and repack into temp for sorting
my @temp;
my %descriptions;
@@ -763,9 +771,10 @@ sub sortedmessages {
foreach my $msgid (@messages) {
my $esc_msgid=&escape($msgid);
- my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$fromcid)=
+ my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$fromcid,$processid,$symb,$error) =
&Apache::lonmsg::unpackmsgid($esc_msgid,$folder,undef,
\%status_cache);
+ next if ($msgstatus ne '' && $msgstatus ne $status);
my $description = &get_course_desc($fromcid,\%descriptions);
my @temp1 = ($sendtime,$shortsubj,$fromname,$fromdomain,$status,
$esc_msgid,$description);
@@ -861,148 +870,119 @@ sub get_course_desc {
}
}
-# ======================================================== Display new messages
-
-
-sub disnew {
- my $r=shift;
- my %lt=&Apache::lonlocal::texthash(
- 'nm' => 'New Messages',
- 'su' => 'Subject',
- 'co' => 'Course',
- 'da' => 'Date',
- 'us' => 'Username',
- 'op' => 'Open',
- 'do' => 'Domain'
- );
- my @msgids = sort(&Apache::lonnet::getkeys('nohist_email'));
- my @newmsgs;
- my %setters = ();
- my %blocked = ();
- my $numblocked = 0;
- # Check for blocking of display because of scheduled online exams.
- my ($startblock,$endblock) = &Apache::loncommon::blockcheck(\%setters,'com');
- my %status_cache =
- &Apache::lonnet::get('email_status',\@msgids);
- my %descriptions;
- 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/) {
- my $description = &get_course_desc($fromcid,\%descriptions);
- my $numsendtime = $sendtime;
- $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
- if ($status eq 'new') {
- if ($numsendtime >= $startblock && ($numsendtime <= $endblock && $endblock > 0) ) {
- $blocked{$id} = 'ON';
- $numblocked ++;
- } else {
- push(@newmsgs, {
- msgid => $msgid,
- sendtime => $sendtime,
- shortsub => $shortsubj,
- from => $fromname,
- fromdom => $fromdom,
- course => $description,
- });
- }
- }
- }
- }
- if ($#newmsgs >= 0) {
- $r->print(<
');
- } elsif ($numblocked == 0) {
- $r->print("
-TABLEHEAD
- foreach my $msg (@newmsgs) {
- $r->print(<<"ENDLINK");
-
-$lt{'da'} $lt{'us'} $lt{'do'} $lt{'su'} $lt{'co'}
- ");
- }
- $r->print('$lt{'op'}
-ENDLINK
- foreach my $item ('sendtime','from','fromdom','shortsub','course') {
- $r->print("$msg->{$item} ");
- }
- $r->print("".&mt('You have no unread messages')."
");
- }
- if ($numblocked > 0) {
- my $beginblock = &Apache::lonlocal::locallocaltime($startblock);
- my $finishblock = &Apache::lonlocal::locallocaltime($endblock);
- $r->print(''.&mt('You have [quant,_1,blocked unread message,blocked unread messages].',$numblocked).'
'."\n".
- &mt('[quant,_1,message is,messages are] not viewable because display of LON-CAPA messages sent to you by other students between [_2] and [_3] is currently being blocked because of online exams.',$numblocked,$beginblock,$finishblock).'
'."\n".
- &Apache::loncommon::build_block_table($startblock,$endblock,
- \%setters));
- }
-}
-
-
# ======================================================== Display all messages
sub disall {
- my ($r,$folder)=@_;
- $r->print(&folderlist($folder));
- if ($folder eq 'new') {
- &disnew($r);
- } elsif ($folder eq 'critical') {
+ my ($r,$folder,$msgstatus)=@_;
+ my %saveable = ('folder' => 'scalar',
+ 'msgstatus' => 'scalar',
+ 'sortedby' => 'scalar',
+ 'interdis' => 'scalar',
+ );
+ &Apache::loncommon::store_settings('user','mail',\%saveable);
+ &Apache::loncommon::restore_settings('user','mail',\%saveable);
+ $folder ||= $env{'form.folder'};
+ $msgstatus ||= $env{'form.msgstatus'};
+ $env{'form.interdis'} ||= 20;
+
+ $r->print(&folderlist($folder,$msgstatus));
+ if ($folder eq 'critical') {
&discrit($r);
} else {
- &disfolder($r,$folder);
+ &disfolder($r,$folder,$msgstatus);
}
}
# ============================================================ Display a folder
sub disfolder {
- my ($r,$folder)=@_;
+ my ($r,$folder,$msgstatus)=@_;
+ my %statushash = &get_msgstatus_types();
my %blocked = ();
my %setters = ();
my $numblocked = 0;
my ($startblock,$endblock) = &Apache::loncommon::blockcheck(\%setters,'com');
+ my %lt = &Apache::lonlocal::texthash(
+ sede => 'Select a destination folder to which the messages will be moved.',
+ nome => 'No messages have been selected to apply ths action to.',
+ chec => 'Check the checkbox for at least one message.',
+ );
+ my $jscript = &Apache::loncommon::check_uncheck_jscript();
$r->print(<'.&mt('Empty Folder').'
');
+ if ($totalnumber < 1) {
+ if ($msgstatus eq '') {
+ $r->print(''.&mt('Empty Folder').'
');
+ } elsif ($msgstatus eq 'replied') {
+ $r->print(''.&mt('You have not replied to any messages in this folder.').'
');
+ } else {
+ $r->print(''.&mt('There are no '.lc($statushash{$msgstatus}).' messages in this folder.').'
');
+ }
+ if ($numblocked > 0) {
+ $r->print(&blocked_in_folder($numblocked,$startblock,$endblock,
+ \%setters));
+ }
return;
}
- unless ($interdis) {
- $interdis=20;
- }
+ my $interdis = $env{'form.interdis'};
my $number=int($totalnumber/$interdis);
+ if ($totalnumber%$interdis == 0) {
+ $number--;
+ }
+
if (($startdis<0) || ($startdis>$number)) { $startdis=$number; }
my $firstdis=$interdis*$startdis;
if ($firstdis>$#temp) { $firstdis=$#temp-$interdis+1; }
my $lastdis=$firstdis+$interdis-1;
if ($lastdis>$#temp) { $lastdis=$#temp; }
- $r->print(&scrollbuttons($startdis,$number,$firstdis,$lastdis,$totalnumber));
+ $r->print(&scrollbuttons($startdis,$number,$firstdis,$lastdis,$totalnumber,$msgstatus));
$r->print('');
+ $r->print('');
if ($numblocked > 0) {
- my $beginblock = &Apache::lonlocal::locallocaltime($startblock);
- my $finishblock = &Apache::lonlocal::locallocaltime($endblock);
- $r->print('
'.
- &mt('[quant,_1,message is, messages are] not viewable because display of LON-CAPA messages sent to you by other students between [_2] and [_3] is currently being blocked because of online exams.',$numblocked,$beginblock,$finishblock));
- $r->print(&Apache::loncommon::build_block_table($startblock,$endblock,
- \%setters));
+ $r->print(&blocked_in_folder($numblocked,$startblock,$endblock,
+ \%setters));
}
}
+sub blocked_in_folder {
+ my ($numblocked,$startblock,$endblock,$setters) = @_;
+ my $beginblock = &Apache::lonlocal::locallocaltime($startblock);
+ my $finishblock = &Apache::lonlocal::locallocaltime($endblock);
+ my $output = '
'.
+ &mt('[quant,_1,message is, messages are] not viewable because display of LON-CAPA messages sent to you by other students between [_2] and [_3] is currently being blocked because of online exams.',$numblocked,$beginblock,$finishblock);
+ $output .= &Apache::loncommon::build_block_table($startblock,$endblock,
+ $setters);
+ return $output;
+}
+
# ============================================================== Compose output
sub compout {
- my ($r,$forwarding,$replying,$broadcast,$replycrit,$folder,$dismode)=@_;
+ my ($r,$forwarding,$replying,$broadcast,$replycrit,$folder,$dismode,
+ $multiforward)=@_;
my $suffix=&Apache::lonmsg::foldersuffix($folder);
my ($cdom,$cnum,$group,$refarg);
if (exists($env{'form.group'})) {
@@ -1146,6 +1180,19 @@ sub compout {
} elsif ($replycrit) {
$r->print(''.&mt('Replying to a Critical Message').'
');
$replying=$replycrit;
+ } elsif ($multiforward) {
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>"/adm/email?folder=".&escape($folder),
+ text=>"Display All Messages"});
+ &printheader($r,'/adm/email?compose=multiforward',
+ 'Forwarding Multiple Messages');
+ if ($multiforward > 1) {
+ $r->print(&mt('Each of the [quant,_1,message] you checked
+will be forwarded to the recipient(s) you select below.',$multiforward).'
');
+ } else {
+ $r->print(&mt('The message you checked will be forwarded to the recipient(s) you select below.').'
');
+ }
+
} else {
&printheader($r,'/adm/email?compose=upload',
'Distribute from Uploaded File');
@@ -1162,6 +1209,7 @@ sub compout {
'sb' => 'Subject',
'ca' => 'Cancel',
'ma' => 'Mail',
+ 'msg' => 'Messages',
'gen' => 'Generate messages from a file',
'gmt' => 'General message text',
'tff' => 'The file format for the uploaded portion of the message is',
@@ -1180,7 +1228,19 @@ sub compout {
&mt('Send copy to permanent email address (if known)').'