--- loncom/interface/lonmsg.pm 2004/03/01 01:06:10 1.86
+++ loncom/interface/lonmsg.pm 2004/09/28 14:12:40 1.109
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines for messaging
#
-# $Id: lonmsg.pm,v 1.86 2004/03/01 01:06:10 www Exp $
+# $Id: lonmsg.pm,v 1.109 2004/09/28 14:12:40 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -74,6 +74,18 @@ email program, so they have full access
interface, or other features they may wish to use in response to the
student's query.
+=item * B '.&mt('Attachment').': '.$fname.'.'.$ft.'';
+ $content{'message'}.=' '.&mt('Attachment').': '.$fname.'';
} else {
- $content{'message'}.=' '.&mt('Attachment').': '.$fname.'.'.$ft.'';
+ &Apache::lonnet::allowuploaded('/adm/msg',
+ $content{'attachmenturl'});
+ $content{'message'}.=' '.&mt('Attachment').
+ ': '.
+ $fname.'';
}
}
return %content;
@@ -186,10 +206,12 @@ sub unpackagemsg {
# ======================================================= Get info out of msgid
sub unpackmsgid {
- my $msgid=&Apache::lonnet::unescape(shift);
+ my ($msgid,$folder)=@_;
+ $msgid=&Apache::lonnet::unescape($msgid);
+ my $suffix=&foldersuffix($folder);
my ($sendtime,$shortsubj,$fromname,$fromdomain)=split(/\:/,
&Apache::lonnet::unescape($msgid));
- my %status=&Apache::lonnet::get('email_status',[$msgid]);
+ my %status=&Apache::lonnet::get('email_status'.$suffix,[$msgid]);
if ($status{$msgid}=~/^error\:/) { $status{$msgid}=''; }
unless ($status{$msgid}) { $status{$msgid}='new'; }
return ($sendtime,$shortsubj,$fromname,$fromdomain,$status{$msgid});
@@ -204,10 +226,14 @@ sub sendemail {
my $msg = new Mail::Send;
$msg->to($to);
$msg->subject('[LON-CAPA] '.$subject);
- if (my $fh = $msg->open('smtp',Server => 'localhost')) {
+ my %oldENV=%ENV;
+ undef(%ENV);
+ if (my $fh = $msg->open()) {
print $fh $body;
$fh->close;
}
+ %ENV=%oldENV;
+ undef(%oldENV);
}
# ==================================================== Send notification emails
@@ -426,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';
}
@@ -479,36 +513,100 @@ sub user_normal_msg {
}
+# ============================================================ List all folders
+
+sub folderlist {
+ my $folder=shift;
+ my @allfolders=&Apache::lonnet::getkeys('email_folders');
+ if ($allfolders[0]=~/^error:/) { @allfolders=(); }
+ return '
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(' ');
+ }
}
-
- 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(
- ''.
+ ' ('.$_.'), '.$role.'
'.
- $reply{'firstname'}.' '.
- $reply{'middlename'}.' '.
- $reply{'lastname'}.' '.
- $reply{'generation'}.
- ' ('.$_.') '.$section);
- }
+ $r->print('');
+ while (my ($student,$info) = each(%$classlist)) {
+ 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');
+ my $key = 'send_to_&&&'.$section.'&&&'.$student;
+ if (! defined($fullname) || $fullname eq '') { $fullname = $sname; }
+ $r->print('
');
}
+ $r->print(''.$sname.'@'.$sdom.' '.$section.
+ '
'. + '
'.&mt('Subject').': '.$content{'subject'}. + ''. &Apache::lontexconvert::msgtexconverted($content{'message'}). ''. &mt('You have to confirm that you received this message. After confirmation, this message will be moved to your regular inbox'). @@ -610,70 +705,35 @@ $content{'sendername'}.'@'. # Check to see if there were any messages. if ($result eq '') { $result = "".&mt('You have no critical messages.')."
". - ''.&mt('Select a course').''; + ''.&mt('Select a course').'
'. + ''.&mt('Communicate').''; } else { $r->print($header); } $r->print($result); - $r->print(''); -} - -# =============================================================== Compose reply - -sub comprep { - my ($r,$msgid)=@_; - my %message=&Apache::lonnet::get('nohist_email',[$msgid]); - my %content=&unpackagemsg($message{$msgid},1); - my $quotemsg='> '.$content{'message'}; - $quotemsg=~s/\r/\n/g; - $quotemsg=~s/\f/\n/g; - $quotemsg=~s/\n+/\n\> /g; - my $torepl=&Apache::loncommon::aboutmewrapper( - &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),$content{'sendername'},$content{'senderdomain'}).' ('. -$content{'sendername'}.'@'. - $content{'senderdomain'}.')'; - my $subject=&mt('Re').': '.$content{'subject'}; - my $dispcrit=''; - if (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) { - my $crithelp = Apache::loncommon::help_open_topic("Course_Critical_Message"); - $dispcrit= - ' '.&mt('Send as critical message').' ' . $crithelp . - '
'. - ' '.&mt('Send as critical message').' ' . - &mt('and return receipt') . $crithelp . ''; - } - my %lt=&Apache::lonlocal::texthash( - 'to' => 'To', - 'sb' => 'Subject', - 'sr' => 'Send Reply', - 'ca' => 'Cancel' - ); - $r->print(<<"ENDREPLY"); -
-ENDREPLY + $r->print(''); } sub sortedmessages { - my @messages = &Apache::lonnet::getkeys('nohist_email'); + my ($blocked,$startblock,$endblock,$numblocked,$folder) = @_; + my $suffix=&foldersuffix($folder); + my @messages = &Apache::lonnet::getkeys('nohist_email'.$suffix); #unpack the varibles and repack into temp for sorting my @temp; 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); - push @temp ,\@temp1; + # Check whether message was sent during blocking period. + if ($sendtime >= $startblock && ($sendtime <= $endblock && $endblock > 0) ) { + my $escid = &Apache::lonnet::unescape($msgid); + $$blocked{$escid} = 'ON'; + $$numblocked ++; + } else { + push @temp ,\@temp1; + } } #default sort @temp = sort {$a->[0] <=> $b->[0]} @temp; @@ -713,8 +773,14 @@ sub sortedmessages { # ======================================================== Display all messages sub disall { - my $r=shift; - $r->print(<print(< function checkall() { for (i=0; i ENDDISHEADER - $r->print(' '.&mt('Display All Messages').'