--- loncom/interface/lonmsg.pm 2004/09/10 06:38:24 1.106
+++ loncom/interface/lonmsg.pm 2004/10/26 19:50:15 1.111
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines for messaging
#
-# $Id: lonmsg.pm,v 1.106 2004/09/10 06:38:24 www Exp $
+# $Id: lonmsg.pm,v 1.111 2004/10/26 19:50:15 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -117,11 +117,14 @@ use Apache::loncommunicate;
# Querystring component with sorting type
my $sqs;
+my $startdis;
+my $interdis;
# ===================================================================== Package
sub packagemsg {
- my ($subject,$message,$citation,$baseurl,$attachmenturl)=@_;
+ my ($subject,$message,$citation,$baseurl,$attachmenturl,
+ $recuser,$recdomain)=@_;
$message =&HTML::Entities::encode($message,'<>&"');
$citation=&HTML::Entities::encode($citation,'<>&"');
$subject =&HTML::Entities::encode($subject,'<>&"');
@@ -156,6 +159,8 @@ sub packagemsg {
''.$ENV{'request.role'}.''.
''.$ENV{'request.filename'}.''.
''.$msgid.''.
+ ''.$recuser.''.
+ ''.$recdomain.''.
''.$message.'';
if (defined($citation)) {
$result.=''.$citation.'';
@@ -447,13 +452,21 @@ sub user_normal_msg_raw {
my $homeserver=&Apache::lonnet::homeserver($user,$domain);
if ($homeserver ne 'no_host') {
($msgid,$message)=&packagemsg($subject,$message,$citation,$baseurl,
- $attachmenturl);
+ $attachmenturl,$user,$domain);
+# Store in user folder
$status=&Apache::lonnet::critical(
'put:'.$domain.':'.$user.':nohist_email:'.
&Apache::lonnet::escape($msgid).'='.
&Apache::lonnet::escape($message),$homeserver);
+# Save new message received time
&Apache::lonnet::put
('email_status',{'recnewemail'=>time},$domain,$user);
+# Into sent-mail folder
+ $status.=' '.&Apache::lonnet::critical(
+ 'put:'.$ENV{'user.domain'}.':'.$ENV{'user.name'}.
+ ':nohist_email_sent:'.
+ &Apache::lonnet::escape($msgid).'='.
+ &Apache::lonnet::escape($message),$ENV{'user.home'});
} else {
$status='no_host';
}
@@ -507,15 +520,25 @@ sub folderlist {
my @allfolders=&Apache::lonnet::getkeys('email_folders');
if ($allfolders[0]=~/^error:/) { @allfolders=(); }
return '
';
+ '';
}
+
# =============================================================== Folder suffix
sub foldersuffix {
@@ -552,27 +575,32 @@ sub makefolder {
sub movemsg {
my ($msgid,$srcfolder,$trgfolder)=@_;
+ my $unmsgid=&Apache::lonnet::unescape($msgid);
my $srcsuffix=&foldersuffix($srcfolder);
my $trgsuffix=&foldersuffix($trgfolder);
- my $srcstatus=&Apache::lonnet::get('email_status'.$srcsuffix,[$msgid]);
- my $trgstatus=$srcstatus;
- if ($trgstatus eq 'deleted') { $trgstatus='read'; }
- &Apache::lonnet::put(
- 'nohist_email'.$trgsuffix,{$msgid =>
- &Apache::lonnet::get('nohist_email'.$srcsuffix,[$msgid])});
- &statuschange($msgid,$trgstatus,$trgfolder);
+
+# Copy message
+ my %message=&Apache::lonnet::get('nohist_email'.$srcsuffix,[$msgid]);
+ &Apache::lonnet::put('nohist_email'.$trgsuffix,{$msgid => $message{$msgid}});
+
+# Copy status
+ my %status=&Apache::lonnet::get('email_status'.$srcsuffix,[$unmsgid]);
+ &Apache::lonnet::put('email_status'.$trgsuffix,{$unmsgid => $status{$unmsgid}});
+# See if was deleted -> becomes "read" in trash
+ my $currentstatus=(&unpackmsgid($status{$unmsgid}),$srcfolder);
+ if ($currentstatus eq 'deleted') {
+ &statuschange($msgid,'read',$trgfolder);
+ }
+# Delete orginals
&Apache::lonnet::del('nohist_email'.$srcsuffix,[$msgid]);
- &Apache::lonnet::del('email_status'.$srcsuffix,[$msgid]);
+ &Apache::lonnet::del('email_status'.$srcsuffix,[$unmsgid]);
}
# ======================================================= Display a course list
sub discourse {
my $r=shift;
- my %courselist=&Apache::lonnet::dump(
- 'classlist',
- $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
- $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+ my $classlist = &Apache::loncoursedata::get_classlist();
my $now=time;
my %lt=&Apache::lonlocal::texthash('cfa' => 'Check for All',
'cfs' => 'Check for Section/Group',
@@ -614,39 +642,36 @@ sub discourse {
ENDDISHEADER
- my %coursepersonnel=
- &Apache::lonnet::get_course_adv_roles();
+ 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(
- '
'.
- &Apache::loncommon::plainname($puname,
- $pudom).' ('.$_.'), '.$role.'');
- }
+ foreach (split(/\,/,$coursepersonnel{$role})) {
+ my ($puname,$pudom)=split(/\:/,$_);
+ $r->print(' | '.
+ '('.$_.'), | '.$role.' |
');
+ }
}
-
- foreach (sort keys %courselist) {
- my ($end,$start)=split(/\:/,$courselist{$_});
- my $active=1;
- if (($end) && ($now>$end)) { $active=0; }
- if ($active) {
- my ($sname,$sdom)=split(/\:/,$_);
- my %reply=&Apache::lonnet::get('environment',
- ['firstname','middlename','lastname','generation'],
- $sdom,$sname);
- my $section=&Apache::lonnet::usection
- ($sdom,$sname,$ENV{'request.course.id'});
- $r->print(
- '
'.
- $reply{'firstname'}.' '.
- $reply{'middlename'}.' '.
- $reply{'lastname'}.' '.
- $reply{'generation'}.
- ' ('.$_.') '.$section);
- }
+ $r->print('
');
}
# ==================================================== Display Critical Message
@@ -686,7 +711,7 @@ $content{'sendername'}.'@'.
$r->print($header);
}
$r->print($result);
- $r->print('');
+ $r->print('');
}
sub sortedmessages {
@@ -698,7 +723,7 @@ sub sortedmessages {
foreach (@messages) {
my $msgid=&Apache::lonnet::escape($_);
my ($sendtime,$shortsubj,$fromname,$fromdomain,$status)=
- &Apache::lonmsg::unpackmsgid($msgid);
+ &Apache::lonmsg::unpackmsgid($msgid,$folder);
my @temp1 = ($sendtime,$shortsubj,$fromname,$fromdomain,$status,
$msgid);
# Check whether message was sent during blocking period.
@@ -776,43 +801,50 @@ sub disall {
}
ENDDISHEADER
+ my $fsqs='&folder='.$folder;
+ my @temp=sortedmessages(\%blocked,$startblock,$endblock,\$numblocked,$folder);
+ my $totalnumber=$#temp+1;
+ my $number=int($totalnumber/$interdis)+1;
+ my $firstdis=$interdis*$startdis;
+ if ($firstdis>$#temp) { $firstdis=$#temp-$interdis+1; }
+ my $lastdis=$firstdis+$interdis-1;
+ if ($lastdis>$#temp) { $lastdis=$#temp; }
$r->print(''.&mt('Display All Messages').'
'.
&folderlist($folder).
'